Bugzilla – Attachment 174878 Details for
Bug 38461
Table features needs to be covered by e2e tests - Cypress
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38461: Use buildSampleObjects
Bug-38461-Use-buildSampleObjects.patch (text/plain), 8.38 KB, created by
Jonathan Druart
on 2024-11-21 13:50:02 UTC
(
hide
)
Description:
Bug 38461: Use buildSampleObjects
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-11-21 13:50:02 UTC
Size:
8.38 KB
patch
obsolete
>From fb7da9b3499df0a05f961e644d671809f3307271 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 21 Nov 2024 14:00:18 +0100 >Subject: [PATCH] Bug 38461: Use buildSampleObjects > >--- > t/cypress/integration/KohaTable_spec.ts | 165 +++++++++++++++--------- > 1 file changed, 101 insertions(+), 64 deletions(-) > >diff --git a/t/cypress/integration/KohaTable_spec.ts b/t/cypress/integration/KohaTable_spec.ts >index 9d655650e94..1cd60e07ed6 100644 >--- a/t/cypress/integration/KohaTable_spec.ts >+++ b/t/cypress/integration/KohaTable_spec.ts >@@ -8,94 +8,131 @@ describe("kohaTable (using REST API)", () => { > > afterEach(() => {}); > >- const RESTdefaultPageSize = 20; // FIXME Mock this >+ const RESTdefaultPageSize = "20"; // FIXME Mock this >+ const baseTotalCount = "42"; > >- it("Simple tables", () => { >+ describe("Simple tables", () => { > const table_id = "libraries"; > > it("Input search bar and clear filter ", () => { >- cy.visit("/cgi-bin/koha/admin/branches.pl"); >+ 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.query("SELECT COUNT(*) as count FROM branches").then(result => { >- let count = result[0].count; >- let display = Math.min(RESTdefaultPageSize, count); > cy.get(`#${table_id}_wrapper .dt-info`).contains( >- `Showing 1 to ${display} of ${count} entries` >+ `Showing 1 to ${RESTdefaultPageSize} of ${baseTotalCount} entries` > ); >- }); > >- // Should be disabled by default - empty search bar >- cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).should( >- "have.class", >- "disabled" >- ); >+ // Should be disabled by default - empty search bar >+ cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).should( >+ "have.class", >+ "disabled" >+ ); > >- // Type something in the input search bar >- cy.get(`#${table_id}_wrapper input.dt-input`).type("centerville"); >- cy.get(`#${table_id}_wrapper input.dt-input`).should( >- "have.value", >- "centerville" >- ); >+ // Type something in the input search bar >+ cy.get(`#${table_id}_wrapper input.dt-input`).type( >+ "centerville" >+ ); >+ cy.get(`#${table_id}_wrapper input.dt-input`).should( >+ "have.value", >+ "centerville" >+ ); > >- // Should no longer be disabled >- cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).should( >- "not.have.class", >- "disabled" >- ); >+ // Should no longer be disabled >+ cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).should( >+ "not.have.class", >+ "disabled" >+ ); > >- // Click the clear_filter button >- cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).click(); >- cy.get(`#${table_id}_wrapper input.dt-input`).should( >- "have.value", >- "" >- ); >+ // Click the clear_filter button >+ cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).click(); >+ cy.get(`#${table_id}_wrapper input.dt-input`).should( >+ "have.value", >+ "" >+ ); >+ }); > }); > }); > >- it("Patrons search", () => { >+ describe("Patrons search", () => { > const table_id = "memberresultst"; > > it("Input search bar and clear filter ", () => { >- cy.visit("/cgi-bin/koha/members/members-home.pl"); >- >- cy.get("form.patron_search_form input[type='submit']").click(); >+ cy.task("buildSampleObjects", { >+ object: "patron", >+ count: RESTdefaultPageSize, >+ values: {}, >+ }).then(patrons => { >+ // Needs more properties to not explode >+ // account_balace: balance_str.escapeHtml(...).format_price is not a function >+ patrons = patrons.map(p => ({ ...p, account_balance: 0 })); >+ >+ cy.intercept("GET", "/api/v1/patrons*", { >+ statusCode: 200, >+ body: patrons, >+ headers: { >+ "X-Base-Total-Count": baseTotalCount, >+ "X-Total-Count": baseTotalCount, >+ }, >+ }); >+ >+ cy.visit("/cgi-bin/koha/members/members-home.pl"); >+ >+ cy.window().then(win => { >+ win.categories_map = patrons.reduce((map, p) => { >+ map[p.category_id] = p.category_id; >+ return map; >+ }, {}); >+ }); >+ cy.get("form.patron_search_form input[type='submit']").click(); > >- cy.query("SELECT COUNT(*) as count FROM borrowers").then(result => { >- let count = result[0].count; >- let display = Math.min(RESTdefaultPageSize, count); > cy.get(`#${table_id}_wrapper .dt-info`).contains( >- `Showing 1 to ${display} of ${count} entries` >+ `Showing 1 to ${RESTdefaultPageSize} of ${baseTotalCount} entries` > ); >- }); > >- // Should be disabled by default - empty search bar >- cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).should( >- "have.class", >- "disabled" >- ); >+ // Should be disabled by default - empty search bar >+ cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).should( >+ "have.class", >+ "disabled" >+ ); > >- // Type something in the input search bar >- cy.get(`#${table_id}_wrapper input.dt-input`).type( >- "edna", >- { force: true } // Needs to force because of sticky header? It's not clear what's happening, Cypress bug? >- ); >- cy.get(`#${table_id}_wrapper input.dt-input`).should( >- "have.value", >- "edna" >- ); >+ // Type something in the input search bar >+ cy.get(`#${table_id}_wrapper input.dt-input`).type( >+ "edna", >+ { force: true } // Needs to force because of sticky header? It's not clear what's happening, Cypress bug? >+ ); >+ cy.get(`#${table_id}_wrapper input.dt-input`).should( >+ "have.value", >+ "edna" >+ ); > >- // Should no longer be disabled >- cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).should( >- "not.have.class", >- "disabled" >- ); >+ // Should no longer be disabled >+ cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).should( >+ "not.have.class", >+ "disabled" >+ ); > >- // Click the clear_filter button >- cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).click(); >- cy.get(`#${table_id}_wrapper input.dt-input`).should( >- "have.value", >- "" >- ); >+ // Click the clear_filter button >+ cy.get(`#${table_id}_wrapper .dt_button_clear_filter`).click({ >+ force: true, >+ }); // #searchheader is on top of it >+ cy.get(`#${table_id}_wrapper input.dt-input`).should( >+ "have.value", >+ "" >+ ); >+ }); > }); > }); > }); >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38461
:
174877
| 174878