Bugzilla – Attachment 147949 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: Add cypress tests for the dialog box
Bug-32991-Add-cypress-tests-for-the-dialog-box.patch (text/plain), 6.11 KB, created by
Agustín Moyano
on 2023-03-08 14:40:19 UTC
(
hide
)
Description:
Bug 32991: Add cypress tests for the dialog box
Filename:
MIME Type:
Creator:
Agustín Moyano
Created:
2023-03-08 14:40:19 UTC
Size:
6.11 KB
patch
obsolete
>From 2a6c8179a1f052e26a80ec308ea2dc12fa108f42 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 28 Feb 2023 12:21:54 +0100 >Subject: [PATCH] Bug 32991: Add cypress tests for the dialog box >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> > >Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Signed-off-by: AgustÃn Moyano <agustinmoyano@theke.io> >--- > t/cypress/integration/Dialog.spec.ts | 147 +++++++++++++++++++++++++++ > 1 file changed, 147 insertions(+) > create mode 100644 t/cypress/integration/Dialog.spec.ts > >diff --git a/t/cypress/integration/Dialog.spec.ts b/t/cypress/integration/Dialog.spec.ts >new file mode 100644 >index 0000000000..46702188f8 >--- /dev/null >+++ b/t/cypress/integration/Dialog.spec.ts >@@ -0,0 +1,147 @@ >+import { mount } from "@cypress/vue"; >+ >+function get_package() { >+ return { >+ package_id: 1, >+ name: "package 1", >+ package_type: "complete", >+ content_type: "Print", >+ package_agreements: [ >+ { >+ agreement: { >+ agreement_id: 2, >+ description: "agreement description", >+ name: "agreement name", >+ }, >+ agreement_id: 2, >+ package_id: 1, >+ }, >+ ], >+ resources_count: 0, >+ }; >+} >+ >+describe("Dialog operations", () => { >+ before(() => { >+ cy.fetch_initial_ERM_sys_pref_value(); >+ cy.set_ERM_sys_pref_value(true); >+ }); >+ >+ beforeEach(() => { >+ cy.login(); >+ cy.title().should("eq", "Koha staff interface"); >+ }); >+ >+ after(() => { >+ cy.reset_initial_ERM_sys_pref_value(); >+ }); >+ >+ it("There are no ... defined", () => { >+ // GET packages returns empty list >+ cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", { >+ statusCode: 200, >+ body: [], >+ headers: { >+ "X-Base-Total-Count": "0", >+ "X-Total-Count": "0", >+ }, >+ }); >+ cy.visit("/cgi-bin/koha/erm/eholdings/local/packages"); >+ cy.get("#packages_list").contains("There are no packages defined"); >+ }); >+ >+ it("Something went wrong - 500", () => { >+ // GET package returns 500 >+ cy.intercept("GET", "/api/v1/erm/eholdings/local/packages*", { >+ statusCode: 500, >+ error: "Something went wrong", >+ }); >+ cy.visit("/cgi-bin/koha/erm/erm.pl"); >+ cy.get("#navmenulist").contains("Packages").click(); >+ cy.get("main div[class='dialog alert']").contains( >+ /Something went wrong/ >+ ); >+ >+ cy.intercept("GET", "/api/v1/erm/agreements*", []); >+ cy.get("#navmenulist").contains("Agreements").click(); >+ // Info messages should be cleared when view is changed >+ cy.get("main div[class='dialog message']").contains("There are no agreements defined"); >+ cy.get("main div[class='dialog message']").should("have.length", 1); >+ }); >+ >+ it("...created!", () => { >+ let erm_package = get_package(); >+ cy.intercept("GET", "/api/v1/erm/agreements*", []); >+ >+ cy.visit("/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}", >+ { force: true } >+ ); >+ >+ cy.intercept("POST", "/api/v1/erm/eholdings/local/packages", { >+ statusCode: 201, >+ body: erm_package, >+ }); >+ cy.get("#packages_add").contains("Submit").click(); >+ cy.get("main div[class='dialog message']").contains("Package created"); >+ cy.get("main div[class='dialog message']").should("have.length", 1); >+ >+ cy.get("#navmenulist").contains("Agreements").click(); >+ // Info messages should be cleared when view is changed >+ cy.get("main div[class='dialog message']").should("not.exist"); >+ }); >+ >+ it("Confirmation messages", () => { >+ let erm_package = get_package(); >+ let packages = [erm_package]; >+ >+ // Click the 'Delete' button 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("PUT", "/api/v1/erm/eholdings/local/packages/*", { >+ statusCode: 200, >+ body: [erm_package], >+ }); >+ cy.intercept( >+ "GET", >+ "/api/v1/erm/eholdings/local/packages/*", >+ erm_package >+ ); >+ cy.visit("/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(); >+ cy.get("main div[class='dialog message']").contains("Package updated"); >+ cy.get("main div[class='dialog message']").should("have.length", 1); >+ >+ cy.get("#packages_list table tbody tr:first") >+ .contains("Delete") >+ .click(); >+ cy.contains("No, do not delete").click(); >+ cy.get(".dialog.alert.confirmation h1").should("not.exist"); >+ cy.get("main div[class='dialog message']").contains("Package updated"); >+ cy.get("main div[class='dialog message']").should("have.length", 1); >+ >+ 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"); >+ cy.get("main div[class='dialog message']").should("have.length", 1); >+ }); >+}); >-- >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 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