Bug 38461: Refactoring - build_libraries

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:42:34 +01:00 committed by Katrin Fischer
parent a55281fbca
commit f5a7c307da
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 26 additions and 73 deletions

View File

@ -1,5 +1,26 @@
import { mount } from "@cypress/vue";
const RESTdefaultPageSize = "20"; // FIXME Mock this
const baseTotalCount = "42";
function build_libraries() {
return 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,
},
});
});
}
describe("kohaTable (using REST API)", () => {
beforeEach(() => {
cy.login();
@ -11,27 +32,11 @@ describe("kohaTable (using REST API)", () => {
afterEach(() => {});
const RESTdefaultPageSize = "20"; // FIXME Mock this
const baseTotalCount = "42";
describe("Simple tables", () => {
const table_id = "libraries";
it("Input search bar and clear filter ", () => {
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,
},
});
build_libraries().then(() => {
cy.visit("/cgi-bin/koha/admin/branches.pl");
cy.get(`#${table_id}_wrapper .dt-info`).contains(
@ -69,20 +74,7 @@ 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,
},
});
build_libraries().then(() => {
cy.visit("/cgi-bin/koha/admin/branches.pl");
cy.window().then(win => {
@ -98,20 +90,7 @@ describe("kohaTable (using REST API)", () => {
});
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,
},
});
build_libraries().then(() => {
cy.visit("/cgi-bin/koha/admin/branches.pl");
cy.window().then(win => {
@ -134,20 +113,7 @@ describe("kohaTable (using REST API)", () => {
});
it("One column hidden by default then shown by user - Save state OFF", () => {
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,
},
});
build_libraries().then(() => {
cy.visit("/cgi-bin/koha/admin/branches.pl");
cy.window().then(win => {
@ -201,20 +167,7 @@ describe("kohaTable (using REST API)", () => {
});
it("One column hidden by default then shown by user - Save state is ON", () => {
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,
},
});
build_libraries().then(() => {
cy.visit("/cgi-bin/koha/admin/branches.pl");
cy.window().then(win => {