Bug 38461: Columns - All, is_hidden by default, then shown by user

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2024-11-21 16:33:11 +01:00 committed by Katrin Fischer
parent 6438b1e0e2
commit 9544cbf977
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 132 additions and 0 deletions

View File

@ -4,6 +4,9 @@ describe("kohaTable (using REST API)", () => {
beforeEach(() => {
cy.login();
cy.title().should("eq", "Koha staff interface");
cy.window().then(win => {
win.localStorage.clear();
});
});
afterEach(() => {});
@ -64,6 +67,135 @@ describe("kohaTable (using REST API)", () => {
);
});
});
it("All columns displayed", () => {
cy.task("buildSampleObjects", {
object: "library",
count: RESTdefaultPageSize,
values: { library_hours: [] },
}).then(libraries => {
cy.intercept("GET", "/api/v1/libraries*", {
statusCode: 200,
body: libraries,
headers: {
"X-Base-Total-Count": baseTotalCount,
"X-Total-Count": baseTotalCount,
},
});
cy.visit("/cgi-bin/koha/admin/branches.pl");
cy.window().then(win => {
win.table_settings.columns = win.table_settings.columns.map(
c => ({ ...c, is_hidden: 0, cannot_be_toggled: 0 })
);
cy.get(`#${table_id} th`).should(
"have.length",
win.table_settings.columns.length
);
});
});
});
it("One column hidden by default", () => {
cy.task("buildSampleObjects", {
object: "library",
count: RESTdefaultPageSize,
values: { library_hours: [] },
}).then(libraries => {
cy.intercept("GET", "/api/v1/libraries*", {
statusCode: 200,
body: libraries,
headers: {
"X-Base-Total-Count": baseTotalCount,
"X-Total-Count": baseTotalCount,
},
});
cy.visit("/cgi-bin/koha/admin/branches.pl");
cy.window().then(win => {
win.table_settings.columns = win.table_settings.columns.map(
c => ({ ...c, is_hidden: 0, cannot_be_toggled: 0 })
);
win.table_settings.columns.find(
c => c.columnname == "library_code"
).is_hidden = 1;
cy.get(`#${table_id} th`).should(
"have.length",
win.table_settings.columns.length - 1
);
cy.get(`#${table_id} th`).contains("Name");
cy.get(`#${table_id} th`)
.contains("Code")
.should("not.exist");
});
});
});
/* TODO Missing mock, we assume that 'Save state' is ON */
it("One column hidden by default then shown by user", () => {
cy.task("buildSampleObjects", {
object: "library",
count: RESTdefaultPageSize,
values: { library_hours: [] },
}).then(libraries => {
cy.intercept("GET", "/api/v1/libraries*", {
statusCode: 200,
body: libraries,
headers: {
"X-Base-Total-Count": baseTotalCount,
"X-Total-Count": baseTotalCount,
},
});
cy.visit("/cgi-bin/koha/admin/branches.pl");
cy.window().then(win => {
win.table_settings.columns = win.table_settings.columns.map(
c => ({ ...c, is_hidden: 0, cannot_be_toggled: 0 })
);
win.table_settings.columns.find(
c => c.columnname == "library_code"
).is_hidden = 1;
cy.get(`#${table_id} th`).should(
"have.length",
win.table_settings.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();
cy.get(`#${table_id}_wrapper .dt-button-collection`)
.contains("Code")
.click();
cy.get(`#${table_id} th`).should(
"have.length",
win.table_settings.columns.length
);
cy.get(`#${table_id} th`).contains("Name");
cy.get(`#${table_id} th`).contains("Code");
});
cy.visit("/cgi-bin/koha/admin/branches.pl");
cy.window().then(win => {
win.table_settings.columns = win.table_settings.columns.map(
c => ({ ...c, is_hidden: 0, cannot_be_toggled: 0 })
);
win.table_settings.columns.find(
c => c.columnname == "library_code"
).is_hidden = 1;
cy.get(`#${table_id} th`).should(
"have.length",
win.table_settings.columns.length
);
cy.get(`#${table_id} th`).contains("Name");
cy.get(`#${table_id} th`).contains("Code");
});
});
});
});
describe("Patrons search", () => {