From 5aecdd4d160e6bff681b320ea05a873f6a36ab65 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 27 Nov 2024 15:16:37 +0100 Subject: [PATCH] Bug 38461: Shareable link Signed-off-by: Victor Grousset/tuxayo --- t/cypress/integration/KohaTable_spec.ts | 92 +++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/t/cypress/integration/KohaTable_spec.ts b/t/cypress/integration/KohaTable_spec.ts index eef837c0cf..8b1667a61e 100644 --- a/t/cypress/integration/KohaTable_spec.ts +++ b/t/cypress/integration/KohaTable_spec.ts @@ -233,6 +233,98 @@ describe("kohaTable (using REST API)", () => { }); }); }); + + it("Shareable link", { scrollBehavior: false }, () => { + build_libraries().then(() => { + cy.visit("/cgi-bin/koha/admin/branches.pl"); + + mock_table_settings({ + default_save_state: 1, + columns: { library_code: { is_hidden: 1 } }, + }); + + cy.get("@columns").then(columns => { + // Code is not shown + 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"); + cy.get(`#${table_id}_wrapper .buttons-colvis`).click(); + // Show Code + cy.get(`#${table_id}_wrapper .dt-button-collection`) + .contains("Code") + .click(); + cy.get(`#${table_id} th`).should( + "have.length", + columns.length + ); + cy.get(`#${table_id} th`).contains("Name"); + cy.get(`#${table_id} th`).contains("Code"); + + // Close the 'Columns' list + cy.get(".dt-button-background").click(); + cy.get(".dt-button-background").should("not.exist"); + + // Copy the shareable link (Name and Code shown) + cy.get( + `#${table_id}_wrapper .copyConditions_controls` + ).click({ force: true }); + cy.get(".tooltip").contains("Copied!"); + }); + + cy.window().then(win => { + // Retrieve the content of the clipboard + win.navigator.clipboard.readText().then(url => { + expect(url).to.match( + /branches.pl\?DataTables_admin_libraries_libraries_state=/ + ); + + // Remove localStorage + win.localStorage.clear(); + + // Use it + cy.visit(url); + + // Code is shown whereas it is hidden in the config + 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 "Name" + cy.get( + `#${table_id}_wrapper .buttons-colvis` + ).click(); + cy.get(`#${table_id}_wrapper .dt-button-collection`) + .contains("Name") + .click(); + }); + + // Go to the shareable link + // but do not remove localStorage! + cy.visit(url); + + // Name is hidden and Code is shown + 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"); + }); + }); + }); + }); + }); }); describe("Patrons search", () => { -- 2.47.1