Bugzilla – Attachment 149119 Details for
Bug 33370
Cypress tests are failing randomly
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33370: Create a new visit_and_wait command
Bug-33370-Create-a-new-visitandwait-command.patch (text/plain), 12.75 KB, created by
Jonathan Druart
on 2023-04-04 08:09:56 UTC
(
hide
)
Description:
Bug 33370: Create a new visit_and_wait command
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-04-04 08:09:56 UTC
Size:
12.75 KB
patch
obsolete
>From 785aa00277b52c595ffd075bd5890e420b600cee Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 4 Apr 2023 10:07:59 +0200 >Subject: [PATCH] Bug 33370: Create a new visit_and_wait command > >It seems easier and cleaner to have our own visit_and_wait command that >will intercept the 2 queries (for avs and vendors) and then do the wait. > >This is needed for the first hit to erm module. >--- > t/cypress/integration/Agreements_spec.ts | 14 +++++--------- > t/cypress/integration/Dialog_spec.ts | 8 ++++---- > t/cypress/integration/Licenses_spec.ts | 10 +++++----- > t/cypress/integration/Packages_spec.ts | 10 +++++----- > t/cypress/integration/Titles_spec.ts | 12 ++++++------ > t/cypress/support/commands.js | 7 +++++++ > 6 files changed, 32 insertions(+), 29 deletions(-) > >diff --git a/t/cypress/integration/Agreements_spec.ts b/t/cypress/integration/Agreements_spec.ts >index 86387b94629..0e6bbfb3dac 100644 >--- a/t/cypress/integration/Agreements_spec.ts >+++ b/t/cypress/integration/Agreements_spec.ts >@@ -125,9 +125,6 @@ describe("Agreement CRUD operations", () => { > beforeEach(() => { > cy.login(); > cy.title().should("eq", "Koha staff interface"); >- >- cy.intercept("GET", "/api/v1/authorised_value_categories*").as("avs"); >- cy.intercept("GET", "/api/v1/acquisitions/vendors*").as("vendors"); > }); > > after(() => { >@@ -140,7 +137,7 @@ describe("Agreement CRUD operations", () => { > statusCode: 500, > error: "Something went wrong", > }); >- cy.visit("/cgi-bin/koha/erm/erm.pl"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/erm.pl"); > cy.get("#navmenulist").contains("Agreements").click(); > cy.get("main div[class='dialog alert']").contains( > /Something went wrong/ >@@ -180,8 +177,7 @@ describe("Agreement CRUD operations", () => { > }); > > // Click the button in the toolbar >- cy.visit("/cgi-bin/koha/erm/agreements"); >- cy.wait(["@avs", "@vendors"]); >+ cy.visit_and_wait("/cgi-bin/koha/erm/agreements"); > cy.contains("New agreement").click(); > cy.get("#agreements_add h2").contains("New agreement"); > >@@ -379,7 +375,7 @@ describe("Agreement CRUD operations", () => { > "X-Total-Count": "1", > }, > }).as("get-single-agreement-search-result"); >- cy.visit("/cgi-bin/koha/erm/agreements"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/agreements"); > > // Intercept request after edit click > cy.intercept("GET", "/api/v1/erm/agreements/*", agreement).as( >@@ -470,7 +466,7 @@ describe("Agreement CRUD operations", () => { > cy.intercept("GET", "/api/v1/erm/agreements/*", agreement).as( > "get-agreement" > ); >- cy.visit("/cgi-bin/koha/erm/agreements"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/agreements"); > let name_link = cy.get( > "#agreements_list table tbody tr:first td:first a" > ); >@@ -506,7 +502,7 @@ describe("Agreement CRUD operations", () => { > }, > }); > cy.intercept("GET", "/api/v1/erm/agreements/*", agreement); >- cy.visit("/cgi-bin/koha/erm/agreements"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/agreements"); > > cy.get("#agreements_list table tbody tr:first") > .contains("Delete") >diff --git a/t/cypress/integration/Dialog_spec.ts b/t/cypress/integration/Dialog_spec.ts >index 9f39eaa2125..77f5658e39c 100644 >--- a/t/cypress/integration/Dialog_spec.ts >+++ b/t/cypress/integration/Dialog_spec.ts >@@ -46,7 +46,7 @@ describe("Dialog operations", () => { > "X-Total-Count": "0", > }, > }); >- cy.visit("/cgi-bin/koha/erm/eholdings/local/packages"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/eholdings/local/packages"); > cy.get("#packages_list").contains("There are no packages defined"); > }); > >@@ -56,7 +56,7 @@ describe("Dialog operations", () => { > statusCode: 500, > error: "Something went wrong", > }); >- cy.visit("/cgi-bin/koha/erm/erm.pl"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/erm.pl"); > cy.get("#navmenulist").contains("Packages").click(); > cy.get("main div[class='dialog alert']").contains( > /Something went wrong/ >@@ -73,7 +73,7 @@ describe("Dialog operations", () => { > let erm_package = get_package(); > cy.intercept("GET", "/api/v1/erm/agreements*", []); > >- cy.visit("/cgi-bin/koha/erm/eholdings/local/packages/add"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/eholdings/local/packages/add"); > cy.get("#package_name").type(erm_package.name); > cy.get("#package_type .vs__search").type( > erm_package.package_type + "{enter}", >@@ -123,7 +123,7 @@ describe("Dialog operations", () => { > "/api/v1/erm/eholdings/local/packages/*", > erm_package > ); >- cy.visit("/cgi-bin/koha/erm/eholdings/local/packages"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/eholdings/local/packages"); > > cy.get("#packages_list table tbody tr:first").contains("Edit").click(); > cy.get("#packages_add").contains("Submit").click(); >diff --git a/t/cypress/integration/Licenses_spec.ts b/t/cypress/integration/Licenses_spec.ts >index 88791518282..b49069d5ea2 100644 >--- a/t/cypress/integration/Licenses_spec.ts >+++ b/t/cypress/integration/Licenses_spec.ts >@@ -53,7 +53,7 @@ describe("License CRUD operations", () => { > statusCode: 500, > error: "Something went wrong", > }); >- cy.visit("/cgi-bin/koha/erm/erm.pl"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/erm.pl"); > cy.get("#navmenulist").contains("Licenses").click(); > cy.get("main div[class='dialog alert']").contains( > /Something went wrong/ >@@ -83,7 +83,7 @@ describe("License CRUD operations", () => { > > it("Add license", () => { > // Click the button in the toolbar >- cy.visit("/cgi-bin/koha/erm/licenses"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/licenses"); > cy.contains("New license").click(); > cy.get("#licenses_add h2").contains("New license"); > >@@ -160,7 +160,7 @@ describe("License CRUD operations", () => { > cy.intercept("GET", "/api/v1/erm/licenses/*", license).as( > "get-license" > ); >- cy.visit("/cgi-bin/koha/erm/licenses"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/licenses"); > cy.get("#licenses_list table tbody tr:first") > .contains("Edit") > .click(); >@@ -218,7 +218,7 @@ describe("License CRUD operations", () => { > cy.intercept("GET", "/api/v1/erm/licenses/*", license).as( > "get-license" > ); >- cy.visit("/cgi-bin/koha/erm/licenses"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/licenses"); > let name_link = cy.get( > "#licenses_list table tbody tr:first td:first a" > ); >@@ -248,7 +248,7 @@ describe("License CRUD operations", () => { > }, > }); > cy.intercept("GET", "/api/v1/erm/licenses/*", license); >- cy.visit("/cgi-bin/koha/erm/licenses"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/licenses"); > > cy.get("#licenses_list table tbody tr:first") > .contains("Delete") >diff --git a/t/cypress/integration/Packages_spec.ts b/t/cypress/integration/Packages_spec.ts >index f5f6be5c4ed..99e2b9b0b57 100644 >--- a/t/cypress/integration/Packages_spec.ts >+++ b/t/cypress/integration/Packages_spec.ts >@@ -44,7 +44,7 @@ describe("Package CRUD operations", () => { > statusCode: 500, > error: "Something went wrong", > }); >- cy.visit("/cgi-bin/koha/erm/erm.pl"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/erm.pl"); > cy.get("#navmenulist").contains("Packages").click(); > cy.get("main div[class='dialog alert']").contains( > /Something went wrong/ >@@ -88,7 +88,7 @@ describe("Package CRUD operations", () => { > cy.intercept("GET", "/api/v1/erm/agreements*", []); > > // Click the button in the toolbar >- cy.visit("/cgi-bin/koha/erm/eholdings/local/packages"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/eholdings/local/packages"); > cy.contains("New package").click(); > cy.get("#packages_add h2").contains("New package"); > >@@ -164,7 +164,7 @@ describe("Package CRUD operations", () => { > "/api/v1/erm/eholdings/local/packages/*", > erm_package > ).as("get-package"); >- cy.visit("/cgi-bin/koha/erm/eholdings/local/packages"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/eholdings/local/packages"); > // Intercept related agreements request after entering agreement edit > cy.intercept("GET", "/api/v1/erm/agreements*", { > statusCode: 200, >@@ -219,7 +219,7 @@ describe("Package CRUD operations", () => { > "/api/v1/erm/eholdings/local/packages/*", > erm_package > ).as("get-package"); >- cy.visit("/cgi-bin/koha/erm/eholdings/local/packages"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/eholdings/local/packages"); > let name_link = cy.get( > "#packages_list table tbody tr:first td:first a" > ); >@@ -290,7 +290,7 @@ describe("Package CRUD operations", () => { > "/api/v1/erm/eholdings/local/packages/*", > erm_package > ); >- cy.visit("/cgi-bin/koha/erm/eholdings/local/packages"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/eholdings/local/packages"); > > cy.get("#packages_list table tbody tr:first") > .contains("Delete") >diff --git a/t/cypress/integration/Titles_spec.ts b/t/cypress/integration/Titles_spec.ts >index 90061e600db..409f1fa68a0 100644 >--- a/t/cypress/integration/Titles_spec.ts >+++ b/t/cypress/integration/Titles_spec.ts >@@ -47,7 +47,7 @@ describe("Title CRUD operations", () => { > statusCode: 200, > body: [] > }).as("get-empty-packages"); >- cy.visit("/cgi-bin/koha/erm/eholdings/local/titles"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/eholdings/local/titles"); > cy.wait(500); > cy.get("#toolbar a").contains("Import from list").click(); > cy.get("h2").contains("Import from a list"); >@@ -78,7 +78,7 @@ describe("Title CRUD operations", () => { > statusCode: 500, > error: "Something went wrong", > }); >- cy.visit("/cgi-bin/koha/erm/erm.pl"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/erm.pl"); > cy.get("#navmenulist").contains("Titles").click(); > cy.get("main div[class='dialog alert']").contains( > /Something went wrong/ >@@ -124,7 +124,7 @@ describe("Title CRUD operations", () => { > }); > > // Click the button in the toolbar >- cy.visit("/cgi-bin/koha/erm/eholdings/local/titles"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/eholdings/local/titles"); > cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet! > cy.contains("New title").click(); > cy.get("#titles_add h2").contains("New title"); >@@ -219,7 +219,7 @@ describe("Title CRUD operations", () => { > "/api/v1/erm/eholdings/local/titles/*", > erm_title > ).as("get-title"); >- cy.visit("/cgi-bin/koha/erm/eholdings/local/titles"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/eholdings/local/titles"); > // Intercept related packages request after entering title edit > cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", { > statusCode: 200, >@@ -306,7 +306,7 @@ describe("Title CRUD operations", () => { > } > } > ).as("get-title"); >- cy.visit("/cgi-bin/koha/erm/eholdings/local/titles"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/eholdings/local/titles"); > let title_link = cy.get( > "#titles_list table tbody tr:first td:first a" > ); >@@ -369,7 +369,7 @@ describe("Title CRUD operations", () => { > "/api/v1/erm/eholdings/local/titles/*", > erm_title > ); >- cy.visit("/cgi-bin/koha/erm/eholdings/local/titles"); >+ cy.visit_and_wait("/cgi-bin/koha/erm/eholdings/local/titles"); > > cy.get("#titles_list table tbody tr:first") > .contains("Delete") >diff --git a/t/cypress/support/commands.js b/t/cypress/support/commands.js >index bea38fb7c9e..b30b0a5c534 100644 >--- a/t/cypress/support/commands.js >+++ b/t/cypress/support/commands.js >@@ -70,3 +70,10 @@ Cypress.Commands.add('reset_initial_ERM_sys_pref_value', () => { > cy.login(); > cy.set_ERM_sys_pref_value(Cypress.env("initial_ERM_Module_sys_pref_value")); > }) >+ >+Cypress.Commands.add('visit_and_wait', (url) => { >+ cy.intercept("GET", "/api/v1/authorised_value_categories*").as("avs"); >+ cy.intercept("GET", "/api/v1/acquisitions/vendors*").as("vendors"); >+ cy.visit(url); >+ cy.wait(["@avs", "@vendors"]); >+}) >-- >2.25.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 33370
:
149001
| 149119