Revert "Bug 41247: Preparation: Cypress XML plugin"

This reverts commit 0387ebfb97.
This commit is contained in:
Martin Renvoize 2026-03-24 12:17:58 +01:00
parent 7077634044
commit aa895e95c5
No known key found for this signature in database
GPG Key ID: 2D86E0EAEC83711B
2 changed files with 0 additions and 56 deletions

View File

@ -26,8 +26,6 @@ const { getBasicAuthHeader } = require("./auth.js");
const { query } = require("./db.js");
const { modifyXmlElement, readXmlElementValue } = require("./xml.js");
const { apiGet, apiPost, apiPut, apiDelete } = require("./api-client.js");
/**
@ -54,7 +52,6 @@ const { apiGet, apiPost, apiPut, apiDelete } = require("./api-client.js");
* - API Access: apiGet, apiPost, apiPut, apiDelete
* - Database Access: query
* - Authentication: getBasicAuthHeader
* - XML files Access: modifyXmlElement, readXmlElementValue
*
* @example
* // Usage in Cypress tests
@ -107,8 +104,6 @@ module.exports = (on, config) => {
},
deleteSampleObjects,
query,
modifyXmlElement,
readXmlElementValue,
apiGet(args) {
return apiGet({ ...args, baseUrl, authHeader });

View File

@ -1,51 +0,0 @@
const fs = require("fs");
const path = require("path");
const { exec } = require("child_process");
const { promisify } = require("util");
const execPromise = promisify(exec);
async function modifyXmlElement({ filePath, element, value }) {
const targetPath = path.resolve(filePath);
let xmlContent;
try {
xmlContent = fs.readFileSync(targetPath, "utf8");
const regex = new RegExp(`<${element}>[^<]*</${element}>`, "i");
const replacement = `<${element}>${value}</${element}>`;
if (!regex.test(xmlContent)) {
throw new Error(`Element <${element}> not found in ${targetPath}`);
}
const newContent = xmlContent.replace(regex, replacement);
fs.writeFileSync(targetPath, newContent, "utf8");
await execPromise("flush_memcached");
await execPromise("koha-plack --restart kohadev");
return null;
} catch (err) {
return err.message;
}
}
async function readXmlElementValue({ filePath, element }) {
const targetPath = path.resolve(filePath);
let xmlContent;
try {
xmlContent = fs.readFileSync(targetPath, "utf8");
const regex = new RegExp(`<${element}>([^<]*)</${element}>`, "i");
const match = xmlContent.match(regex);
if (!match) {
throw new Error(`Element <${element}> not found in ${targetPath}`);
}
// Return the value of the element
return match[1]; // match[1] contains the value between the tags
} catch (err) {
return err.message;
}
}
module.exports = { readXmlElementValue, modifyXmlElement };