From d419b22a526656d2dfca76186cce7686854fb69a Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 13 Oct 2025 14:14:24 +0200 Subject: [PATCH] Bug 40982: Add Cypress tests --- .../integration/KohaTable/KohaTable_spec.ts | 77 +++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/t/cypress/integration/KohaTable/KohaTable_spec.ts b/t/cypress/integration/KohaTable/KohaTable_spec.ts index a53974f2560..a1d6f7b650c 100644 --- a/t/cypress/integration/KohaTable/KohaTable_spec.ts +++ b/t/cypress/integration/KohaTable/KohaTable_spec.ts @@ -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"); -- 2.34.1