Skip to content

Commit

Permalink
COMPENF-428-Cypress Tests (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
barrfalk authored Oct 3, 2023
1 parent c81295a commit 6adbb02
Show file tree
Hide file tree
Showing 21 changed files with 212 additions and 131 deletions.
6 changes: 4 additions & 2 deletions frontend/cypress/e2e/allegation-details-edit.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import COMPLAINT_TYPES from "../../src/app/types/app/complaint-types";

/*
Test to verify that the user is able to click the edit button
on the wildlife contacts details page and see all the inputs
Expand All @@ -9,7 +11,7 @@ describe("Complaint Edit Page spec - Edit Allegation View", () => {
});

it("Navigate to the Complaint Edit page & check inputs", () => {
cy.navigateToAllegationEditScreen("23-006888");
cy.navigateToEditScreen(COMPLAINT_TYPES.ERS,"23-006888");


// Note: if the layout of this page changes, these selectors that use classes may break
Expand Down Expand Up @@ -186,7 +188,7 @@ describe("Complaint Edit Page spec - Edit Allegation View", () => {
});

it("it has a map on screen with a marker at the correct location", function () {
cy.navigateToAllegationEditScreen("23-006888");
cy.navigateToEditScreen(COMPLAINT_TYPES.ERS,"23-006888");
cy.verifyMapMarkerExists();
});

Expand Down
11 changes: 6 additions & 5 deletions frontend/cypress/e2e/allegation-details.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import COMPLAINT_TYPES from "../../src/app/types/app/complaint-types";

describe("COMPENF-37 Display ECR Details", () => {

const callDetails = {
Expand Down Expand Up @@ -27,8 +29,7 @@ describe("COMPENF-37 Display ECR Details", () => {
//-- click on Allegation tab
cy.get("#ers-tab").click({ force: true });

cy.get('.comp-loader-overlay').should('exist');
cy.get('.comp-loader-overlay').should('not.exist');
cy.waitForSpinner();

//-- check to make sure there are items in the table
cy.get("#complaint-list")
Expand All @@ -39,14 +40,14 @@ describe("COMPENF-37 Display ECR Details", () => {
});

it("it can select record", () => {
cy.navigateToAllegationDetailsScreen("23-007890");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS,"23-007890");

//-- verify the right complaint identifier is selected and the animal type
cy.get(".comp-box-complaint-id").contains("23-007890")
});

it("it has correct call details", () => {
cy.navigateToAllegationDetailsScreen("23-007890");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS,"23-007890");

//-- verify the call details block
cy.get('p[id="comp-details-description"]').contains(callDetails.description)
Expand All @@ -61,7 +62,7 @@ describe("COMPENF-37 Display ECR Details", () => {
});

it("it has a map on screen with a marker at the correct location", function () {
cy.navigateToAllegationDetailsScreen("23-006888");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS,"23-006888");
cy.verifyMapMarkerExists();
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import COMPLAINT_TYPES from "../../src/app/types/app/complaint-types"

/*
Test to verify that the user is able to change the assignee both the
HWLC and Enforcement details screens
Expand All @@ -13,17 +15,16 @@ describe("Complaint Change Assignee spec - Details View", () => {
Cypress._.times(complaintTypes.length, (index) => {
it("Changes assignee of a complaint", () => {
if ("#hwcr-tab".includes(complaintTypes[index])) {
cy.navigateToHWLCDetailsScreen("23-000076");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR,"23-000076");
} else {
cy.navigateToAllegationDetailsScreen("23-006888");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS,"23-006888");
}

cy.get("#details-screen-assign-button").click({ force: true });

// self assign the complaint
cy.get("#self_assign_button").click({ force: true });
cy.get(".comp-loader-overlay").should("exist");
cy.get(".comp-loader-overlay").should("not.exist");
cy.waitForSpinner();
cy.get("#comp-details-assigned-officer-name-text-id")
.contains("ENV TestAcct")
.should("exist");
Expand Down
6 changes: 2 additions & 4 deletions frontend/cypress/e2e/change-complaint-assignee.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ describe('Complaint Assign Popover spec', { scrollBehavior: false }, () => {
cy.visit("/");
cy.get(complaintTypes[index]).click({ force: true });

cy.get('.comp-loader-overlay').should('exist');
cy.get('.comp-loader-overlay').should('not.exist');
cy.waitForSpinner();

cy.get('.popover').should('not.exist');

cy.get("#comp-zone-filter").click({ force: true }); //clear zone filter so we have some complaint is in the list view

cy.get('.comp-loader-overlay').should('exist');
cy.get('.comp-loader-overlay').should('not.exist');
cy.waitForSpinner();

cy.get('td.comp-ellipsis-cell').first() // finds the buttons cell of that row
.click({force: true});
Expand Down
3 changes: 1 addition & 2 deletions frontend/cypress/e2e/change-complaint-filters-view.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ describe('Complaint Change Status spec - Details View', () => {

it('Verifies filters are available and defaults exist', () => {
cy.visit("/");
cy.get('.comp-loader-overlay').should('exist');
cy.get('.comp-loader-overlay').should('not.exist');
cy.waitForSpinner();

cy.get(complaintTypes[index]).click({ force: true });

Expand Down
12 changes: 6 additions & 6 deletions frontend/cypress/e2e/change-complaint-status-details-view.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import COMPLAINT_TYPES from "../../src/app/types/app/complaint-types";

/*
Test to verify that the user is able to change the status both the
HWLC and Enforcement details screens
Expand All @@ -13,9 +15,9 @@ describe("Complaint Change Status spec - Details View", () => {
Cypress._.times(complaintTypes.length, (index) => {
it("Changes status of complaint to open, closed, and back to open", () => {
if ("#hwcr-tab".includes(complaintTypes[index])) {
cy.navigateToHWLCDetailsScreen("23-000076");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR,"23-000076");
} else {
cy.navigateToAllegationDetailsScreen("23-006888");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS,"23-006888");
}

cy.get("#details-screen-update-status-button").click({ force: true });
Expand All @@ -27,8 +29,7 @@ describe("Complaint Change Status spec - Details View", () => {

cy.get("#update_complaint_status_button").click();

cy.get(".comp-loader-overlay").should("exist");
cy.get(".comp-loader-overlay").should("not.exist");
cy.waitForSpinner();

cy.get("#comp-details-status-text-id").contains("Closed").should("exist");

Expand All @@ -41,8 +42,7 @@ describe("Complaint Change Status spec - Details View", () => {

cy.get("#update_complaint_status_button").click();

cy.get(".comp-loader-overlay").should("exist");
cy.get(".comp-loader-overlay").should("not.exist");
cy.waitForSpinner();

cy.get("#comp-details-status-text-id").contains("Open").should("exist");
});
Expand Down
9 changes: 3 additions & 6 deletions frontend/cypress/e2e/change-complaint-status.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,13 @@ describe('Complaint Assign and Status Popover spec', { scrollBehavior: false },
cy.visit("/");
cy.get(complaintTypes[index]).click({ force: true });

cy.get('.comp-loader-overlay').should('exist');
cy.get('.comp-loader-overlay').should('not.exist');
cy.waitForSpinner();

cy.get('.popover').should('not.exist');

cy.get("#comp-zone-filter").click({ force: true }); //clear zone filter so this complaint is in the list view

cy.get('.comp-loader-overlay').should('exist');
cy.get('.comp-loader-overlay').should('not.exist');
cy.waitForSpinner();

// Find the number of closed complaints
// This number should change if a complaint is changed from closed to open
Expand All @@ -50,8 +48,7 @@ describe('Complaint Assign and Status Popover spec', { scrollBehavior: false },

cy.get('#update_complaint_status_button').click();

cy.get('.comp-loader-overlay').should('exist');
cy.get('.comp-loader-overlay').should('not.exist');
cy.waitForSpinner();

cy.get('table tr').filter(':contains("Closed")').should('have.length.at.least', 1);

Expand Down
3 changes: 1 addition & 2 deletions frontend/cypress/e2e/complaint-list.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ describe('Complaint List Functionality', () => {

it('Verifies the complaint tabs, filter and table header are sticky', {scrollBehavior: false}, () => {
cy.visit("/");
cy.get('.comp-loader-overlay').should('exist');
cy.get('.comp-loader-overlay').should('not.exist');
cy.waitForSpinner();

cy.get(complaintTypes[index]).click({ force: true });

Expand Down
6 changes: 2 additions & 4 deletions frontend/cypress/e2e/complaint-pagination.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ describe('Complaint Paginate from list view', () => {


cy.visit("/");
cy.get('.comp-loader-overlay').should('exist');
cy.get('.comp-loader-overlay').should('not.exist');
cy.waitForSpinner();

cy.get(complaintTypes[index]).click({ force: true });


cy.get(".comp-loader-overlay").should("exist");
cy.get(".comp-loader-overlay").should("not.exist");
cy.waitForSpinner();

cy.get("#comp-zone-filter").click({ force: true }); //clear zone filter so this complaint is in the list view

Expand Down
106 changes: 93 additions & 13 deletions frontend/cypress/e2e/complaints-on-map-view.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Test to verify that the status and assignment popover displays when clicking the
HWLC and Enforcement list screens
*/
describe("Complaints on map tests", () => {
const complaintTypes = ["#hwcr-tab","#ers-tab"];
const complaintTypes = ["#hwcr-tab", "#ers-tab"];

beforeEach(function () {
cy.viewport("macbook-16");
Expand All @@ -12,26 +12,108 @@ describe("Complaints on map tests", () => {

// perform the same test on each of the tabs (HWCR and ERS)
Cypress._.times(complaintTypes.length, (index) => {
it("Switch to map view", () => {
it("Verify filters work and are maintained between list and map view", () => {
cy.visit("/");
cy.wait(3000);
cy.waitForSpinner();

cy.get(complaintTypes[index]).click({ force: true });

cy.waitForSpinner();

// switch to map view
cy.get("#map_toggle_id").click({ force: true });

// wait for the map to load
cy.waitForSpinner();

// verify default filters
cy.get("#comp-status-filter").should("exist");
cy.get("#comp-zone-filter").should("exist");

cy.get("#comp-zone-filter").click({ force: true }); //clear zone filter so this complaint is in the list view

// verify no other filters exist
cy.get("#comp-officer-filter").should("not.exist");
cy.get("#comp-community-filter").should("not.exist");
cy.get("#comp-region-filter").should("not.exist");

if ("#hwcr-tab".includes(complaintTypes[index])) {
cy.get("#comp-species-filter").should("not.exist");
cy.get("#comp-nature-of-complaint-filter").should("not.exist");
} else {
cy.get("#comp-violation-filter").should("not.exist");
}

// find how many markers there are, we'll compare this to the count after another filter is applied
cy.get(".leaflet-marker-icon").its("length").as("complaintCountWithoutFilters");

cy.get("#complaint-filter-image-id").click({ force: true });

if ("#hwcr-tab".includes(complaintTypes[index])) {
// add the hwcr filters
// add the region filter
cy.selectItemById("region-select-filter-id", "Thompson Cariboo");
cy.selectItemById("zone-select-id", "Cariboo Thompson");
cy.selectItemById("community-select-id", "Blue River");

cy.selectItemById("nature-of-complaint-select-id", "Food Conditioned");
cy.selectItemById("species-select-id", "Black Bear");
} else {
// add the alegation filters
// add the region filter
cy.selectItemById("region-select-filter-id", "Omineca");
cy.selectItemById("zone-select-id", "Nechako-Lakes");
cy.selectItemById("community-select-id", "Danskin");

cy.selectItemById("violation-type-select-id", "Other");
}

// count the markers again, they should now have a different count
cy.get(".leaflet-marker-icon")
.its("length")
.as("complaintCountWithFilters");

cy.wrap("@complaintCountWithoutFilters").should(
"not.eq",
"@complaintCountWithFilters"
);

// switch back to list view to verify filters are still applied
cy.get("#list_toggle_id").click({ force: true });

// verify the filters still exits
cy.get("#comp-status-filter").should("exist");
cy.get("#comp-zone-filter").should("exist");
cy.get("#comp-community-filter").should("exist");
cy.get("#comp-region-filter").should("exist");

if ("#hwcr-tab".includes(complaintTypes[index])) {
// add the hwcr filters
cy.get("#comp-species-filter").should("exist");
cy.get("#comp-nature-of-complaint-filter").should("exist");
} else {
cy.get("#comp-violation-filter").should("exist");
}
});

// test to verify that user can switch to map view and click a marker to see popup
it("Switch to map view and click marker", () => {
cy.visit("/");
cy.waitForSpinner();
cy.get(complaintTypes[index]).click({ force: true });

cy.get(".comp-loader-overlay").should("exist");
cy.get(".comp-loader-overlay").should("not.exist");
cy.waitForSpinner();

cy.get("#comp-status-filter").click({ force: true }); //clear status filter so this complaint is in the list view

cy.get(".comp-loader-overlay").should("exist");
cy.get(".comp-loader-overlay").should("not.exist");
cy.waitForSpinner();

cy.get("#list_toggle_id").should("exist");
cy.get("#map_toggle_id").should("exist"); //verifies that the list/map toggle button appears. Click the map view
cy.get("#map_toggle_id").click({ force: true });

// wait for the map to load
cy.get(".comp-loader-overlay").should("exist");
cy.get(".comp-loader-overlay").should("not.exist");
cy.waitForSpinner();

cy.get("div.leaflet-container").should("exist");

Expand All @@ -46,16 +128,14 @@ describe("Complaints on map tests", () => {
});

// wait for the popup to load
cy.get(".comp-loader-overlay").should("exist");
cy.get(".comp-loader-overlay").should("not.exist");
cy.waitForSpinner();

cy.get(".leaflet-popup").should("exist");

// click the "view details" button to navigate to the complaint
cy.get("#view-complaint-details-button-id").click({ force: true });

cy.get(".comp-loader-overlay").should("exist");
cy.get(".comp-loader-overlay").should("not.exist");
cy.waitForSpinner();
});
});
});
6 changes: 4 additions & 2 deletions frontend/cypress/e2e/hwcr-details-edit.cy.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import COMPLAINT_TYPES from "../../src/app/types/app/complaint-types";

/*
Test to verify that the user is able to click the edit button
on the wildlife contacts details page and see all the inputs
Expand All @@ -9,7 +11,7 @@ describe("Complaint Edit Page spec - Edit View", () => {
});

it("Navigate to the Complaint Edit page & check inputs", function() {
cy.navigateToHWLCEditScreen("23-007023");
cy.navigateToEditScreen(COMPLAINT_TYPES.HWCR,"23-007023");

// Note: if the layout of this page changes, these selectors that use classes may break
// Check the First Section inputs
Expand Down Expand Up @@ -167,7 +169,7 @@ describe("Complaint Edit Page spec - Edit View", () => {
});

it("it has a map on screen with a marker at the correct location", () => {
cy.navigateToHWLCEditScreen("23-007023");
cy.navigateToEditScreen(COMPLAINT_TYPES.HWCR,"23-007023");

cy.verifyMapMarkerExists();

Expand Down
Loading

0 comments on commit 6adbb02

Please sign in to comment.