Bug 40982: Add Cypress tests

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
(cherry picked from commit a9ffa8b64a)
Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de>
This commit is contained in:
Jonathan Druart 2025-10-13 14:14:24 +02:00 committed by Paul Derscheid
parent b564610152
commit 17fb36122c
No known key found for this signature in database
GPG Key ID: C25F9FD44CED595B
1 changed files with 77 additions and 0 deletions

View File

@ -206,6 +206,83 @@ describe("kohaTable (using REST API)", () => {
});
});
it("Force visibility of one column", () => {
build_libraries().then(() => {
cy.visit("/cgi-bin/koha/admin/branches.pl");
// default settings: show "Code"
cy.mock_table_settings({
default_save_state: 1,
columns: { library_code: { is_hidden: 0 } },
});
cy.get("@columns").then(columns => {
cy.get(`#${table_id} th`).should(
"have.length",
columns.length
);
cy.get(`#${table_id} th`).contains("Name");
cy.get(`#${table_id} th`).contains("Code");
// Hide "Code"
cy.get(`#${table_id}_wrapper .buttons-colvis`).click();
cy.get(`#${table_id}_wrapper .dt-button-collection`)
.contains("Code")
.click();
cy.get(`#${table_id} th`).should(
"have.length",
columns.length - 1
);
cy.get(`#${table_id} th`).contains("Name");
cy.get(`#${table_id} th`)
.contains("Code")
.should("not.exist");
});
// "Code" has been hidden by the user
cy.visit("/cgi-bin/koha/admin/branches.pl");
// But we want to display it
cy.mock_table_settings({
default_save_state: 1,
columns: {
library_code: { is_hidden: 0, force_visibility: 1 },
},
});
cy.get("@columns").then(columns => {
cy.get(`#${table_id} th`).should(
"have.length",
columns.length
);
// Both are shown
cy.get(`#${table_id} th`).contains("Name");
cy.get(`#${table_id} th`).contains("Code");
});
// Now hide it
cy.visit("/cgi-bin/koha/admin/branches.pl");
cy.mock_table_settings({
default_save_state: 1,
columns: {
library_code: { is_hidden: 1, force_visibility: 1 },
},
});
cy.get("@columns").then(columns => {
cy.get(`#${table_id} th`).should(
"have.length",
columns.length - 1
);
cy.get(`#${table_id} th`).contains("Name");
cy.get(`#${table_id} th`)
.contains("Code")
.should("not.exist");
});
});
});
it("Shareable link", { scrollBehavior: false }, () => {
build_libraries().then(() => {
cy.visit("/cgi-bin/koha/admin/branches.pl");