Bugzilla – Attachment 164713 Details for
Bug 35919
Add record sources CRUD
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35919: Add cypress tests
Bug-35919-Add-cypress-tests.patch (text/plain), 7.52 KB, created by
Martin Renvoize
on 2024-04-11 13:46:33 UTC
(
hide
)
Description:
Bug 35919: Add cypress tests
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2024-04-11 13:46:33 UTC
Size:
7.52 KB
patch
obsolete
>From e2c625942d9114eb286ae9319a7e4a1c23676c67 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Wed, 24 Jan 2024 16:18:55 -0300 >Subject: [PATCH] Bug 35919: Add cypress tests > >This patch adds Cypress tests for the `record sources` CRUD as required >by QA. > >I tried to cover all the UI interactions and behaviours. > >To test: >1. Have all the patches applied >2. Run: > $ ktd --shell > k$ cypress run --spec t/cypress/integration/Admin/RecordSources_spec.ts >=> SUCCESS: Tests pass! >3. Sign off :-D > >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >Signed-off-by: Matt Blenkinsop <matt.blenkinsop@ptfs-europe.com> > >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >--- > .../integration/Admin/RecordSources_spec.ts | 179 ++++++++++++++++++ > 1 file changed, 179 insertions(+) > create mode 100644 t/cypress/integration/Admin/RecordSources_spec.ts > >diff --git a/t/cypress/integration/Admin/RecordSources_spec.ts b/t/cypress/integration/Admin/RecordSources_spec.ts >new file mode 100644 >index 00000000000..0fa77a47b18 >--- /dev/null >+++ b/t/cypress/integration/Admin/RecordSources_spec.ts >@@ -0,0 +1,179 @@ >+import { mount } from "@cypress/vue"; >+const dayjs = require("dayjs"); /* Cannot use our calendar JS code, it's in an include file (!) >+ Also note that moment.js is deprecated */ >+ >+describe("Breadcrumbs tests", () => { >+ beforeEach(() => { >+ cy.login(); >+ cy.title().should("eq", "Koha staff interface"); >+ }); >+ >+ it("Breadcrumbs", () => { >+ cy.visit("/cgi-bin/koha/admin/admin-home.pl"); >+ cy.contains("Record sources").click(); >+ cy.get("#breadcrumbs").contains("Administration"); >+ cy.get(".item-last").contains("Record sources"); >+ // use the 'New' button >+ cy.contains("New record source").click(); >+ cy.get(".current").contains("Add record source"); >+ cy.get("#breadcrumbs") >+ .contains("Record sources") >+ .should("have.attr", "href") >+ .and("equal", "/cgi-bin/koha/admin/record_sources"); >+ }); >+}); >+ >+describe("Record sources CRUD tests", () => { >+ beforeEach(() => { >+ cy.login(); >+ cy.title().should("eq", "Koha staff interface"); >+ }); >+ >+ it("Add", () => { >+ cy.visit("/cgi-bin/koha/admin/admin-home.pl"); >+ cy.contains("Record sources").click(); >+ cy.contains("New record source").click(); >+ cy.get("#name").type("Poop"); >+ >+ // Submit the form, get 201 >+ cy.intercept("POST", "/api/v1/record_sources", { >+ statusCode: 201, >+ body: {}, >+ }); >+ cy.get("#record_source_edit").contains("Submit").click(); >+ >+ cy.get("main div[class='dialog message']").contains( >+ "Record source created!" >+ ); >+ }); >+ >+ it("List", () => { >+ cy.intercept("GET", "/api/v1/record_sources*", { >+ statusCode: 200, >+ body: [], >+ headers: { >+ "X-Base-Total-Count": "0", >+ "X-Total-Count": "0", >+ }, >+ }); >+ cy.visit("/cgi-bin/koha/admin/record_sources"); >+ cy.get("#record_sources_list").contains( >+ "There are no record sources defined" >+ ); >+ >+ cy.intercept("GET", "/api/v1/record_sources*", { >+ statusCode: 200, >+ body: [ >+ { record_source_id: 1, name: "Source 1", can_be_edited: true }, >+ { record_source_id: 2, name: "Source 2", can_be_edited: false }, >+ { record_source_id: 3, name: "Source 3", can_be_edited: true }, >+ ], >+ headers: { >+ "X-Base-Total-Count": "3", >+ "X-Total-Count": "3", >+ }, >+ }); >+ cy.visit("/cgi-bin/koha/admin/record_sources"); >+ cy.get("#record_sources_list").contains("Showing 1 to 3 of 3 entries"); >+ >+ // Test true => "Yes" >+ let row_1 = cy.get(".dataTable > tbody > tr:first-child"); >+ row_1.get("td:nth-child(3n+3)").contains("Yes"); >+ // Test false => "No" >+ let row_2 = cy.get(".dataTable > tbody > tr:nth-child(2n+2)"); >+ row_2.get("td:nth-child(3n+3)").contains("No"); >+ >+ // Action buttons displayed >+ row_1.get("td:last-child").contains("Edit"); >+ row_1.get("td:last-child").contains("Delete"); >+ }); >+ >+ it("Edit", () => { >+ cy.intercept("GET", "/api/v1/record_sources*", { >+ statusCode: 200, >+ body: [ >+ { record_source_id: 1, name: "Source 1", can_be_edited: true }, >+ { record_source_id: 2, name: "Source 2", can_be_edited: false }, >+ { record_source_id: 3, name: "Source 3", can_be_edited: true }, >+ ], >+ headers: { >+ "X-Base-Total-Count": "3", >+ "X-Total-Count": "3", >+ }, >+ }); >+ cy.visit("/cgi-bin/koha/admin/record_sources"); >+ cy.intercept("GET", "/api/v1/record_sources/1", { >+ statusCode: 200, >+ body: { >+ record_source_id: 1, >+ name: "Source 1", >+ can_be_edited: true, >+ }, >+ }); >+ cy.get("#record_sources_list table tbody tr:first") >+ .contains("Edit") >+ .click(); >+ cy.get("#name").should("have.value", "Source 1"); >+ cy.get("#can_be_edited").should("be.checked"); >+ >+ cy.intercept("GET", "/api/v1/record_sources/1", { >+ statusCode: 200, >+ body: { >+ record_source_id: 1, >+ name: "Source 1", >+ can_be_edited: false, >+ }, >+ }); >+ cy.visit("/cgi-bin/koha/admin/record_sources/edit/1"); >+ cy.get("#name").should("have.value", "Source 1"); >+ cy.get("#can_be_edited").should("not.be.checked"); >+ >+ // Submit the form, get 500 >+ cy.intercept("PUT", "/api/v1/record_sources/1", { >+ statusCode: 201, >+ body: { >+ record_source_id: 1, >+ name: "Poop", >+ can_be_edited: false, >+ }, >+ }); >+ cy.get("#record_source_edit").contains("Submit").click(); >+ }); >+ >+ it("Delete", () => { >+ cy.intercept("GET", "/api/v1/record_sources*", { >+ statusCode: 200, >+ body: [ >+ { record_source_id: 1, name: "Source 1", can_be_edited: true }, >+ { record_source_id: 2, name: "Source 2", can_be_edited: false }, >+ { record_source_id: 3, name: "Source 3", can_be_edited: true }, >+ ], >+ headers: { >+ "X-Base-Total-Count": "3", >+ "X-Total-Count": "3", >+ }, >+ }); >+ cy.visit("/cgi-bin/koha/admin/record_sources"); >+ cy.intercept("DELETE", "/api/v1/record_sources/2", { >+ statusCode: 204, >+ body: {}, >+ }); >+ cy.get("#record_sources_list table tbody tr:nth-child(2n+2)") >+ .contains("Delete") >+ .click(); >+ cy.get(".dialog.alert.confirmation h1").contains( >+ "Are you sure you want to remove this record source?" >+ ); >+ cy.contains("Source 2"); >+ cy.contains("No, do not remove").click(); >+ >+ cy.get("#record_sources_list table tbody tr:nth-child(2n+2)") >+ .contains("Delete") >+ .click(); >+ cy.contains("Source 2"); >+ cy.contains("Yes, remove").click(); >+ cy.get("main div[class='dialog message']").contains( >+ "Record source 'Source 2' removed" >+ ); >+ }); >+}); >-- >2.44.0
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 35919
:
161531
|
161532
|
161533
|
161534
|
161535
|
161537
|
161538
|
161577
|
161578
|
161579
|
161580
|
161581
|
161582
|
161583
|
162489
|
162594
|
162595
|
162596
|
162599
|
163348
|
163349
|
163350
|
163351
|
163352
|
163353
|
163354
|
163355
|
163360
|
163369
|
163389
|
163390
|
163391
|
163392
|
163393
|
163394
|
163395
|
163396
|
163397
|
163398
|
163399
|
163400
|
164708
|
164709
|
164710
|
164711
|
164712
| 164713 |
164714
|
164715
|
164716
|
164717
|
165274