Bugzilla – Attachment 147461 Details for
Bug 32991
Improve our Dialog component and remove routes for deletion
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32991: Fix cypress tests. Added new test for when deleting from show view.
Bug-32991-Fix-cypress-tests-Added-new-test-for-whe.patch (text/plain), 13.57 KB, created by
Pedro Amorim
on 2023-02-27 16:31:20 UTC
(
hide
)
Description:
Bug 32991: Fix cypress tests. Added new test for when deleting from show view.
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2023-02-27 16:31:20 UTC
Size:
13.57 KB
patch
obsolete
>From 2611e745e1d4a0184398580d90c2bf577e780e78 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Fri, 24 Feb 2023 16:06:31 +0000 >Subject: [PATCH] Bug 32991: Fix cypress tests. Added new test for when > deleting from show view. > >--- > t/cypress/integration/Agreements_spec.ts | 53 +++++++++++++++++--- > t/cypress/integration/Licenses_spec.ts | 50 +++++++++++++++--- > t/cypress/integration/Packages_spec.ts | 52 +++++++++++++++++-- > t/cypress/integration/Titles_spec.ts | 64 ++++++++++++++++++++++-- > 4 files changed, 196 insertions(+), 23 deletions(-) > >diff --git a/t/cypress/integration/Agreements_spec.ts b/t/cypress/integration/Agreements_spec.ts >index d6b7ffcb30..b983545954 100644 >--- a/t/cypress/integration/Agreements_spec.ts >+++ b/t/cypress/integration/Agreements_spec.ts >@@ -491,6 +491,7 @@ describe("Agreement CRUD operations", () => { > let agreement = get_agreement(); > let agreements = [agreement]; > >+ // Delete from list > // Click the 'Delete' button from the list > cy.intercept("GET", "/api/v1/erm/agreements*", { > statusCode: 200, >@@ -506,27 +507,65 @@ describe("Agreement CRUD operations", () => { > cy.get("#agreements_list table tbody tr:first") > .contains("Delete") > .click(); >- cy.get("#agreements_confirm_delete h2").contains("Delete agreement"); >- cy.contains("Agreement name: " + agreement.name); >+ cy.get(".dialog.alert.confirmation h1").contains("remove this agreement"); >+ cy.contains(agreement.name); > >- // Submit the form, get 500 >+ // Accept the confirmation dialog, get 500 > cy.intercept("DELETE", "/api/v1/erm/agreements/*", { > statusCode: 500, > error: "Something went wrong", > }); >- cy.contains("Yes, delete").click(); >+ cy.contains("Accept").click(); > cy.get("main div[class='dialog alert']").contains( > "Something went wrong: Error: Internal Server Error" > ); > >- // Submit the form, success! >+ // Accept the confirmation dialog, success! > cy.intercept("DELETE", "/api/v1/erm/agreements/*", { > statusCode: 204, > body: null, > }); >+ cy.get("#agreements_list table tbody tr:first") >+ .contains("Delete") >+ .click(); >+ cy.get(".dialog.alert.confirmation h1").contains("remove this agreement"); > cy.contains("Yes, delete").click(); >- cy.get("main div[class='dialog message']").contains( >- "Agreement deleted" >+ cy.get("main div[class='dialog message']").contains("Agreement").contains("deleted"); >+ >+ // Delete from show >+ // Click the "name" link from the list >+ cy.intercept("GET", "/api/v1/erm/agreements*", { >+ statusCode: 200, >+ body: agreements, >+ headers: { >+ "X-Base-Total-Count": "1", >+ "X-Total-Count": "1", >+ }, >+ }); >+ cy.intercept("GET", "/api/v1/erm/agreements/*", agreement).as( >+ "get-agreement" > ); >+ cy.visit("/cgi-bin/koha/erm/agreements"); >+ let name_link = cy.get( >+ "#agreements_list table tbody tr:first td:first a" >+ ); >+ name_link.should( >+ "have.text", >+ agreement.name + " (#" + agreement.agreement_id + ")" >+ ); >+ name_link.click(); >+ cy.wait("@get-agreement"); >+ cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet! >+ cy.get("#agreements_show h2").contains( >+ "Agreement #" + agreement.agreement_id >+ ); >+ >+ cy.get('#agreements_show .action_links .fa-trash').click(); >+ cy.get(".dialog.alert.confirmation h1").contains("remove this agreement"); >+ cy.contains("Yes, delete").click(); >+ cy.get("main div[class='dialog message']").contains("Agreement").contains("deleted"); >+ >+ //Make sure we return to list after deleting from show >+ cy.get("#agreements_list table tbody tr:first") > }); > }); >diff --git a/t/cypress/integration/Licenses_spec.ts b/t/cypress/integration/Licenses_spec.ts >index f825808138..628417aa18 100644 >--- a/t/cypress/integration/Licenses_spec.ts >+++ b/t/cypress/integration/Licenses_spec.ts >@@ -253,10 +253,10 @@ describe("License CRUD operations", () => { > cy.get("#licenses_list table tbody tr:first") > .contains("Delete") > .click(); >- cy.get("#licenses_confirm_delete h2").contains("Delete license"); >- cy.contains("License name: " + license.name); >+ cy.get(".dialog.alert.confirmation h1").contains("remove this license"); >+ cy.contains(license.name); > >- // Submit the form, get 500 >+ // Accept the confirmation dialog, get 500 > cy.intercept("DELETE", "/api/v1/erm/licenses/*", { > statusCode: 500, > error: "Something went wrong", >@@ -266,14 +266,52 @@ describe("License CRUD operations", () => { > "Something went wrong: Error: Internal Server Error" > ); > >- // Submit the form, success! >+ // Accept the confirmation dialog, success! > cy.intercept("DELETE", "/api/v1/erm/licenses/*", { > statusCode: 204, > body: null, > }); >+ cy.get("#licenses_list table tbody tr:first") >+ .contains("Delete") >+ .click(); >+ cy.get(".dialog.alert.confirmation h1").contains("remove this license"); > cy.contains("Yes, delete").click(); >- cy.get("main div[class='dialog message']").contains( >- "License deleted" >+ cy.get("main div[class='dialog message']").contains("License").contains("deleted"); >+ >+ // Delete from show >+ // Click the "name" link from the list >+ cy.intercept("GET", "/api/v1/erm/licenses*", { >+ statusCode: 200, >+ body: licenses, >+ headers: { >+ "X-Base-Total-Count": "1", >+ "X-Total-Count": "1", >+ }, >+ }); >+ cy.intercept("GET", "/api/v1/erm/licenses/*", license).as( >+ "get-license" > ); >+ cy.visit("/cgi-bin/koha/erm/licenses"); >+ let name_link = cy.get( >+ "#licenses_list table tbody tr:first td:first a" >+ ); >+ name_link.should( >+ "have.text", >+ license.name + " (#" + license.license_id + ")" >+ ); >+ name_link.click(); >+ cy.wait("@get-license"); >+ cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet! >+ cy.get("#licenses_show h2").contains( >+ "License #" + license.license_id >+ ); >+ >+ cy.get('#licenses_show .action_links .fa-trash').click(); >+ cy.get(".dialog.alert.confirmation h1").contains("remove this license"); >+ cy.contains("Yes, delete").click(); >+ cy.get("main div[class='dialog message']").contains("License").contains("deleted"); >+ >+ //Make sure we return to list after deleting from show >+ cy.get("#licenses_list table tbody tr:first") > }); > }); >diff --git a/t/cypress/integration/Packages_spec.ts b/t/cypress/integration/Packages_spec.ts >index 48689e9a0e..2fd7da3511 100644 >--- a/t/cypress/integration/Packages_spec.ts >+++ b/t/cypress/integration/Packages_spec.ts >@@ -295,10 +295,10 @@ describe("Package CRUD operations", () => { > cy.get("#packages_list table tbody tr:first") > .contains("Delete") > .click(); >- cy.get("#packages_confirm_delete h2").contains("Delete package"); >- cy.contains("Package name: " + erm_package.name); >+ cy.get(".dialog.alert.confirmation h1").contains("remove this package"); >+ cy.contains(erm_package.name); > >- // Submit the form, get 500 >+ // Accept the confirmation dialog, get 500 > cy.intercept("DELETE", "/api/v1/erm/eholdings/local/packages/*", { > statusCode: 500, > error: "Something went wrong", >@@ -308,12 +308,54 @@ describe("Package CRUD operations", () => { > "Something went wrong: Error: Internal Server Error" > ); > >- // Submit the form, success! >+ // Accept the confirmation dialog, success! > cy.intercept("DELETE", "/api/v1/erm/eholdings/local/packages/*", { > statusCode: 204, > body: null, > }); >+ cy.get("#packages_list table tbody tr:first") >+ .contains("Delete") >+ .click(); >+ cy.get(".dialog.alert.confirmation h1").contains("remove this package"); >+ cy.contains("Yes, delete").click(); >+ cy.get("main div[class='dialog message']").contains("Local package").contains("deleted"); >+ >+ // Delete from show >+ // Click the "name" link from the list >+ cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", { >+ statusCode: 200, >+ body: packages, >+ headers: { >+ "X-Base-Total-Count": "1", >+ "X-Total-Count": "1", >+ }, >+ }); >+ cy.intercept( >+ "GET", >+ "/api/v1/erm/eholdings/local/packages/*", >+ erm_package >+ ).as("get-package"); >+ cy.visit("/cgi-bin/koha/erm/eholdings/local/packages"); >+ let name_link = cy.get( >+ "#packages_list table tbody tr:first td:first a" >+ ); >+ name_link.should( >+ "have.text", >+ erm_package.name + " (#" + erm_package.package_id + ")" >+ ); >+ name_link.click(); >+ cy.wait("@get-package"); >+ cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet! >+ cy.get("#packages_show h2").contains( >+ "Package #" + erm_package.package_id >+ ); >+ >+ cy.get('#packages_show .action_links .fa-trash').click(); >+ cy.get(".dialog.alert.confirmation h1").contains("remove this package"); > cy.contains("Yes, delete").click(); >- cy.get("main div[class='dialog message']").contains("Package deleted"); >+ cy.get("main div[class='dialog message']").contains("Local package").contains("deleted"); >+ >+ //Make sure we return to list after deleting from show >+ cy.get("#packages_list table tbody tr:first") > }); > }); >diff --git a/t/cypress/integration/Titles_spec.ts b/t/cypress/integration/Titles_spec.ts >index 11fd825b29..c2deebdd44 100644 >--- a/t/cypress/integration/Titles_spec.ts >+++ b/t/cypress/integration/Titles_spec.ts >@@ -428,10 +428,10 @@ describe("Title CRUD operations", () => { > cy.get("#titles_list table tbody tr:first") > .contains("Delete") > .click(); >- cy.get("#eholdings_confirm_delete h2").contains("Delete title"); >- cy.contains("Title: " + erm_title.publication_title); >+ cy.get(".dialog.alert.confirmation h1").contains("remove this title"); >+ cy.contains(erm_title.publication_title); > >- // Submit the form, get 500 >+ // Accept the confirmation dialog, get 500 > cy.intercept("DELETE", "/api/v1/erm/eholdings/local/titles/*", { > statusCode: 500, > error: "Something went wrong", >@@ -441,12 +441,66 @@ describe("Title CRUD operations", () => { > "Something went wrong: Error: Internal Server Error" > ); > >- // Submit the form, success! >+ // Accept the confirmation dialog, success! > cy.intercept("DELETE", "/api/v1/erm/eholdings/local/titles/*", { > statusCode: 204, > body: null, > }); >+ cy.get("#titles_list table tbody tr:first") >+ .contains("Delete") >+ .click(); >+ cy.get(".dialog.alert.confirmation h1").contains("remove this title"); >+ cy.contains("Yes, delete").click(); >+ cy.get("main div[class='dialog message']").contains("Local title").contains("deleted"); >+ >+ // Delete from show >+ // Click the "name" link from the list >+ cy.intercept("GET", "/api/v1/erm/eholdings/local/titles*", { >+ statusCode: 200, >+ body: titles, >+ headers: { >+ "X-Base-Total-Count": "1", >+ "X-Total-Count": "1", >+ }, >+ }); >+ // Title with empty resources. >+ cy.intercept( >+ { >+ method: "GET", >+ url: "/api/v1/erm/eholdings/local/titles/*", >+ times: 1 >+ }, >+ { >+ body: { >+ publication_title: "publication title", >+ resources: [], >+ title_id: 1, >+ } >+ } >+ ).as("get-title"); >+ cy.visit("/cgi-bin/koha/erm/eholdings/local/titles"); >+ let title_link = cy.get( >+ "#titles_list table tbody tr:first td:first a" >+ ); >+ title_link.should( >+ "have.text", >+ erm_title.publication_title + " (#" + erm_title.title_id + ")" >+ ); >+ cy.get( >+ "#titles_list table tbody tr:first td:first a" >+ ).click(); >+ cy.wait("@get-title"); >+ cy.wait(500); // Cypress is too fast! Vue hasn't populated the form yet! >+ cy.get("#eholdings_title_show h2").contains( >+ "Title #" + erm_title.title_id >+ ); >+ >+ cy.get('#eholdings_title_show .action_links .fa-trash').click(); >+ cy.get(".dialog.alert.confirmation h1").contains("remove this title"); > cy.contains("Yes, delete").click(); >- cy.get("main div[class='dialog message']").contains("Title deleted"); >+ cy.get("main div[class='dialog message']").contains("Local title").contains("deleted"); >+ >+ //Make sure we return to list after deleting from show >+ cy.get("#titles_list table tbody tr:first") > }); > }); >-- >2.30.2
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 32991
:
146828
|
146829
|
147051
|
147052
|
147053
|
147054
|
147082
|
147083
|
147281
|
147282
|
147291
|
147305
|
147350
|
147383
|
147384
|
147385
|
147387
|
147388
|
147389
|
147390
|
147391
|
147392
|
147393
|
147394
|
147429
|
147439
|
147445
|
147447
|
147448
|
147449
|
147450
|
147451
|
147452
|
147453
|
147454
|
147455
|
147456
|
147461
|
147483
|
147485
|
147486
|
147487
|
147542
|
147543
|
147544
|
147545
|
147546
|
147547
|
147548
|
147549
|
147550
|
147551
|
147552
|
147553
|
147554
|
147569
|
147573
|
147584
|
147588
|
147589
|
147590
|
147591
|
147592
|
147593
|
147594
|
147595
|
147596
|
147597
|
147598
|
147599
|
147600
|
147601
|
147602
|
147603
|
147604
|
147937
|
147938
|
147939
|
147940
|
147941
|
147942
|
147943
|
147944
|
147945
|
147946
|
147947
|
147948
|
147949
|
147950
|
147951