Lines 43-48
Cypress.Commands.add('login', (username, password) => {
Link Here
|
43 |
Cypress.Commands.add('left_menu_active_item_is', (label) => { |
43 |
Cypress.Commands.add('left_menu_active_item_is', (label) => { |
44 |
cy.get("#navmenulist a.current:not(.disabled)").should('have.length',1).contains(label); |
44 |
cy.get("#navmenulist a.current:not(.disabled)").should('have.length',1).contains(label); |
45 |
}) |
45 |
}) |
|
|
46 |
|
47 |
/** |
48 |
* Builds an object based on the provided class and data. |
49 |
* |
50 |
* @param {string} objectClass - The class of the object to be built. |
51 |
* @param {Object} data - The data used to build the object. If not provided, a default object will be built. |
52 |
* @return {void} This function does not return anything. |
53 |
*/ |
54 |
Cypress.Commands.add('buildObject', (objectClass, data) => { |
55 |
if (!objectClass) return |
56 |
if (!data) { |
57 |
const buildCommand = `perl t/cypress/support/cypress_builder.pl --class ${objectClass}` |
58 |
cy.exec(buildCommand) |
59 |
return |
60 |
} |
61 |
const properties = Object.keys(data) |
62 |
const buildValues = properties.map(prop => ` --data ${prop}=${data[prop]}`) |
63 |
const buildCommand = `perl t/cypress/support/cypress_builder.pl --class ${objectClass}${buildValues.join('')}` |
64 |
cy.exec(buildCommand) |
65 |
}) |
66 |
|
67 |
const tableMappings = { |
68 |
'Koha::Patrons': { tableName: 'borrowers', primaryKey: 'borrowernumber'} |
69 |
} |
70 |
|
71 |
/** |
72 |
* Deletes one or more rows from a database table based on the given className and delete parameters. |
73 |
* |
74 |
* @param {string} className - The name of the class to delete rows from. |
75 |
* @param {Object} deleteParameters - The parameters used to filter the rows to be deleted. |
76 |
* @param {number} numberOfRows - The number of rows to delete. If provided, rows will be deleted in descending order up to the value of numberOfRows. |
77 |
* @return {void} This function does not return anything. |
78 |
*/ |
79 |
Cypress.Commands.add('deleteDbRow', (className, deleteParameters, numberOfRows) => { |
80 |
if(!className) return |
81 |
if(numberOfRows) { |
82 |
const sql = `DELETE from ${tableMappings[className].tableName} ORDER BY ${tableMappings[className].primaryKey} DESC LIMIT ${numberOfRows}` |
83 |
cy.query(sql); |
84 |
return |
85 |
} |
86 |
const properties = Object.keys(deleteParameters) |
87 |
const deleteFilters = properties.map(prop => `${prop}=?`) |
88 |
const deleteValues = properties.map(prop => deleteParameters[prop]) |
89 |
const sql = `DELETE from ${tableMappings[className].tableName} WHERE ${deleteFilters.join(' AND ')}` |
90 |
cy.query(sql, deleteValues); |
91 |
}) |
92 |
|
46 |
const dayjs = require("dayjs") /* Cannot use our calendar JS code, it's in an include file (!) |
93 |
const dayjs = require("dayjs") /* Cannot use our calendar JS code, it's in an include file (!) |
47 |
Also note that moment.js is deprecated */ |
94 |
Also note that moment.js is deprecated */ |
48 |
|
95 |
|
49 |
- |
|
|