Bugzilla – Attachment 189607 Details for
Bug 41247
ILL batches modal does not reset correctly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 41247: Preparation: Cypress XML plugin
Bug-41247-Preparation-Cypress-XML-plugin.patch (text/plain), 3.33 KB, created by
Pedro Amorim
on 2025-11-14 14:17:32 UTC
(
hide
)
Description:
Bug 41247: Preparation: Cypress XML plugin
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2025-11-14 14:17:32 UTC
Size:
3.33 KB
patch
obsolete
>From 9dee6f0a4d6446dfc3b73417d7cb6e77ca1c37aa Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@openfifth.co.uk> >Date: Fri, 14 Nov 2025 13:42:53 +0000 >Subject: [PATCH] Bug 41247: Preparation: Cypress XML plugin > >Add a way to access and manipulate koha-conf.xml (we need to ensure plugins_restricted is 0 for the actual tests) >--- > t/cypress/plugins/index.js | 5 ++++ > t/cypress/plugins/xml.js | 51 ++++++++++++++++++++++++++++++++++++++ > 2 files changed, 56 insertions(+) > create mode 100644 t/cypress/plugins/xml.js > >diff --git a/t/cypress/plugins/index.js b/t/cypress/plugins/index.js >index 5970890dc02..47ab304cb14 100644 >--- a/t/cypress/plugins/index.js >+++ b/t/cypress/plugins/index.js >@@ -26,6 +26,8 @@ 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"); > > /** >@@ -52,6 +54,7 @@ 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 >@@ -104,6 +107,8 @@ module.exports = (on, config) => { > }, > deleteSampleObjects, > query, >+ modifyXmlElement, >+ readXmlElementValue, > > apiGet(args) { > return apiGet({ ...args, baseUrl, authHeader }); >diff --git a/t/cypress/plugins/xml.js b/t/cypress/plugins/xml.js >new file mode 100644 >index 00000000000..b7811ddbe14 >--- /dev/null >+++ b/t/cypress/plugins/xml.js >@@ -0,0 +1,51 @@ >+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 }; >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 41247
:
189572
|
189603
|
189604
|
189607
|
189608
|
189609
|
189618
|
190903
|
190904
|
190905