Skip to content

Commit

Permalink
Add cypress option to direct nav to complaint. (#286)
Browse files Browse the repository at this point in the history
Co-authored-by: barrfalk <[email protected]>
  • Loading branch information
afwilcox and barrfalk authored Feb 20, 2024
1 parent 27c7397 commit 466e9f1
Show file tree
Hide file tree
Showing 11 changed files with 67 additions and 55 deletions.
2 changes: 1 addition & 1 deletion frontend/cypress/e2e/allegation-details-create.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe("Complaint Create Page spec - Create View", () => {
violationType: "Boating",
violationIndex: 1,
};

const createCallerInformation = {
name: "Phoebe ---- testing",
phone: "(250) 555-5555",
Expand Down
10 changes: 5 additions & 5 deletions frontend/cypress/e2e/allegation-details-edit.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe("Complaint Edit Page spec - Edit Allegation View", () => {

it("Navigate to the Complaint Edit page & change data, save, navigate to read-only, return to edit and reset data", function () {
//start edit
cy.navigateToEditScreen(COMPLAINT_TYPES.ERS, "23-006888");
cy.navigateToEditScreen(COMPLAINT_TYPES.ERS, "23-006888", false);
cy.get("#caller-name-id").click({force: true}).click({force: true}).clear().type(editCallerInformation.name);
cy.get("#complaint-address-id").click({force: true}).clear().type(editCallerInformation.address);
cy.get("#complaint-email-id").click({force: true}).clear().type(editCallerInformation.email);
Expand Down Expand Up @@ -249,7 +249,7 @@ describe("Complaint Edit Page spec - Edit Allegation View", () => {

it("Puts everything back to the original details", () => {
//start reverting changes
cy.navigateToEditScreen(COMPLAINT_TYPES.ERS, "23-006888");
cy.navigateToEditScreen(COMPLAINT_TYPES.ERS, "23-006888", true);
cy.get("#caller-name-id").click({force: true}).click({force: true}).clear().type(originalCallerInformation.name);
cy.get("#complaint-address-id")
.click({force: true}).clear()
Expand Down Expand Up @@ -394,7 +394,7 @@ describe("Complaint Edit Page spec - Edit Allegation View", () => {
});

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

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

it("it has a map on screen with a marker at the correct location", function () {
cy.navigateToEditScreen(COMPLAINT_TYPES.ERS,"23-006888");
cy.navigateToEditScreen(COMPLAINT_TYPES.ERS,"23-006888", true);
cy.verifyMapMarkerExists(true);
cy.get(".comp-complaint-details-alert").should("not.exist");
});

it("it has a map on screen with no marker", function () {
cy.navigateToEditScreen(COMPLAINT_TYPES.ERS,"23-032528");
cy.navigateToEditScreen(COMPLAINT_TYPES.ERS,"23-032528", true);
cy.verifyMapMarkerExists(false);
cy.get(".comp-complaint-details-alert").should("exist");
});
Expand Down
8 changes: 4 additions & 4 deletions frontend/cypress/e2e/allegation-details.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ describe("COMPENF-37 Display ECR Details", () => {
});

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

//-- 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.navigateToDetailsScreen(COMPLAINT_TYPES.ERS, "23-007890");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS, "23-007890", true);

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

it("it has a map on screen with no marker", function () {
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS,"23-032528");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS,"23-032528", true);
cy.verifyMapMarkerExists(false);
cy.get(".comp-complaint-details-alert").should("exist");
});

it("validates breadcrumb styles", function () {
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS, "23-007890");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS, "23-007890", true);

cy.get(".comp-nav-item-name-inverted > a").should('have.css', 'text-decoration').should('include', 'underline');
cy.get(".comp-nav-item-name-inverted > a").should('have.css', 'color').should('include', 'rgb(255, 255, 255)');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ 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.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076", true);
} else {
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS, "23-006888");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS, "23-006888", true);
}

cy.get("#details-screen-assign-button").click({ force: true });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,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.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076", true);
} else {
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS, "23-006888");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS, "23-006888", true);
}

cy.get("#details-screen-update-status-button").click({ force: true });
Expand Down
8 changes: 4 additions & 4 deletions frontend/cypress/e2e/complaint-attachments.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ describe("Complaint Attachments", () => {
Cypress._.times(complaintTypes.length, (index) => {
it("Verifies that the attachments appear", () => {
if ("#hwcr-tab".includes(complaintTypes[index])) {
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076", true);
} else {
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS, "23-006888");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS, "23-006888", true);
}

// verify the attachments section exists
Expand Down Expand Up @@ -49,9 +49,9 @@ describe("Complaint Attachments", () => {
Cypress._.times(complaintTypes.length, (index) => {
it("Verifies that upload option exists on edit page", () => {
if ("#hwcr-tab".includes(complaintTypes[index])) {
cy.navigateToEditScreen(COMPLAINT_TYPES.HWCR, "23-000076");
cy.navigateToEditScreen(COMPLAINT_TYPES.HWCR, "23-000076", true);
} else {
cy.navigateToEditScreen(COMPLAINT_TYPES.ERS, "23-006888");
cy.navigateToEditScreen(COMPLAINT_TYPES.ERS, "23-006888", true);
}

// should be able to upload on details view
Expand Down
10 changes: 5 additions & 5 deletions frontend/cypress/e2e/hwcr-details-edit.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe("Complaint Edit Page spec - Edit View", () => {

it("Navigate to the Complaint Edit page & change data, save, navigate to read-only", function () {
//start edit
cy.navigateToEditScreen(COMPLAINT_TYPES.HWCR, "23-000076");
cy.navigateToEditScreen(COMPLAINT_TYPES.HWCR, "23-000076", true);
cy.get("#caller-name-id").click({ force: true }).clear().type(editCallerInformation.name);
cy.get("#complaint-address-id").click({ force: true }).clear().type(editCallerInformation.address);
cy.get("#complaint-email-id").click({ force: true }).clear().type(editCallerInformation.email);
Expand Down Expand Up @@ -227,7 +227,7 @@ describe("Complaint Edit Page spec - Edit View", () => {

it("Puts everything back to the original details", function () {
//start reverting changes
cy.navigateToEditScreen(COMPLAINT_TYPES.HWCR, "23-000076");
cy.navigateToEditScreen(COMPLAINT_TYPES.HWCR, "23-000076", true);
cy.get("#caller-name-id").click({ force: true }).clear().type(originalCallerInformation.name);
cy.get("#complaint-address-id")
.click({ force: true }).clear()
Expand Down Expand Up @@ -366,7 +366,7 @@ describe("Complaint Edit Page spec - Edit View", () => {
});

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

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

it("it has a map on screen with a marker at the correct location", function () {
cy.navigateToEditScreen(COMPLAINT_TYPES.HWCR,"23-032525");
cy.navigateToEditScreen(COMPLAINT_TYPES.HWCR,"23-032525", true);
cy.verifyMapMarkerExists(true);
cy.get(".comp-complaint-details-alert").should("not.exist");
});

it("it has a map on screen with no marker", function () {
cy.navigateToEditScreen(COMPLAINT_TYPES.HWCR,"23-032527");
cy.navigateToEditScreen(COMPLAINT_TYPES.HWCR,"23-032527", true);
cy.verifyMapMarkerExists(false);
cy.get(".comp-complaint-details-alert").should("exist");
});
Expand Down
12 changes: 6 additions & 6 deletions frontend/cypress/e2e/hwcr-details.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ describe("COMPENF-35 Display HWCR Details", () => {
});

it("it can select record", () => {
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076", false);

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

it("it has correct call details", () => {
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076", true);

//-- verify the call details block
cy.get('p[id="comp-details-description"]').contains(
Expand Down Expand Up @@ -86,7 +86,7 @@ describe("COMPENF-35 Display HWCR Details", () => {

it("it has correct call information details", () => {
//-- navigate to application root
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076", true);

//-- verify the call details block
cy.get('div[id="comp-details-name"]').contains(callerInformation.name);
Expand All @@ -108,19 +108,19 @@ describe("COMPENF-35 Display HWCR Details", () => {
});

it("it has a map on screen with a marker at the correct location", function () {
cy.navigateToEditScreen(COMPLAINT_TYPES.HWCR,"23-032525");
cy.navigateToEditScreen(COMPLAINT_TYPES.HWCR,"23-032525", true);
cy.verifyMapMarkerExists(true);
cy.get(".comp-complaint-details-alert").should("not.exist");
});

it("it has a map on screen with no marker", function () {
cy.navigateToEditScreen(COMPLAINT_TYPES.HWCR,"23-032527");
cy.navigateToEditScreen(COMPLAINT_TYPES.HWCR,"23-032527", true);
cy.verifyMapMarkerExists(false);
cy.get(".comp-complaint-details-alert").should("exist");
});

it("validates breadcrumb styles", function () {
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-007023");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-007023", true);

cy.get(".comp-nav-item-name-inverted > a").should('have.css', 'text-decoration').should('include', 'underline');
cy.get(".comp-nav-item-name-inverted > a").should('have.css', 'color').should('include', 'rgb(255, 255, 255)');
Expand Down
4 changes: 2 additions & 2 deletions frontend/cypress/e2e/sticky-headers.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("Sticky Headers", () => {
cy.visit("/");
cy.waitForSpinner();

cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076");
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076", true);

//scroll to the bottom of the page
cy.scrollTo("bottom");
Expand All @@ -80,7 +80,7 @@ describe("Sticky Headers", () => {
cy.visit("/");
cy.waitForSpinner();

cy.navigateToEditScreen(COMPLAINT_TYPES.ERS, "23-006888");
cy.navigateToEditScreen(COMPLAINT_TYPES.ERS, "23-006888", true);

//scroll to the bottom of the page
cy.scrollTo("bottom");
Expand Down
58 changes: 34 additions & 24 deletions frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,45 +147,55 @@ Cypress.Commands.add("verifyMapMarkerExists", (existIndicator: boolean) => {

Cypress.Commands.add(
"navigateToDetailsScreen",
(complaintType: string, complaintIdentifier: string) => {
//-- navigate to application root
cy.visit("/");
(complaintType: string, complaintIdentifier: string, navigateByURL: boolean) => {

//Need to make sure the filters are loaded before switching tabs.
cy.waitForSpinner();
if (navigateByURL)
{
cy.visit(`/complaint/${complaintType.toUpperCase()}/${complaintIdentifier}`); //errors happen without converting to upper case!

//-- click on HWCR tab
cy.get(`#${complaintType.toLowerCase()}-tab`).click({ force: true });
cy.waitForSpinner();
} else // go to the list, remove filters and find complaint (must be sure it will be in the first 50 results)
{
//-- navigate to application root
cy.visit("/");

cy.get("#comp-zone-filter").should("exist").click({ force: true }); //clear zone filter so this complaint is in the list view
cy.get("#comp-zone-filter").should("not.exist");
cy.waitForSpinner();
//Need to make sure the filters are loaded before switching tabs.
cy.waitForSpinner();

cy.get("#comp-status-filter").should("exist").click({ force: true }); //clear status filter so this complaint is in the list view
cy.get("#comp-status-filter").should("not.exist");
cy.waitForSpinner();
//-- click on HWCR tab
cy.get(`#${complaintType.toLowerCase()}-tab`).click({ force: true });

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

//-- check to make sure there are items in the table
cy.get("#complaint-list")
.find("tr")
.then(({ length }) => {
expect(length, "rows N").to.be.gt(0);
});
cy.get("#comp-status-filter").should("exist").click({ force: true }); //clear status filter so this complaint is in the list view
cy.get("#comp-status-filter").should("not.exist");
cy.waitForSpinner();

cy.get("#complaint-list > tbody > tr")
.contains(complaintIdentifier)
.click({ force: true });
//-- check to make sure there are items in the table
cy.get("#complaint-list")
.find("tr")
.then(({ length }) => {
expect(length, "rows N").to.be.gt(0);
});

cy.get("#complaint-list > tbody > tr")
.contains(complaintIdentifier)
.click({ force: true });

cy.waitForSpinner();
cy.waitForSpinner();
}
},
);

Cypress.Commands.add(
"navigateToEditScreen",
(complaintType: string, complaintIdentifier: string) => {
(complaintType: string, complaintIdentifier: string, navigateByUrl: boolean) => {
cy.navigateToDetailsScreen(
complaintType.toLowerCase(),
complaintIdentifier,
navigateByUrl
);
cy.get("#details-screen-edit-button").click({ force: true });
},
Expand Down
2 changes: 2 additions & 0 deletions frontend/cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ declare namespace Cypress {
navigateToDetailsScreen(
complaintType: string,
complaintIdentifier: string,
navigateByURL: boolean
): Chainable<any>;
navigateToEditScreen(
complaintType: string,
complaintIdentifier: string,
navigateByURL: boolean
): Chainable<any>;
navigateToCreateScreen(): Chainable<any>;
isInViewport(): Chainable<any>;
Expand Down

0 comments on commit 466e9f1

Please sign in to comment.