Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Method Complaint Received Cypress Tests #701

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/.tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
uses: cypress-io/github-action@v5
with:
working-directory: ./frontend
command: npx cypress run --browser electron --config baseUrl=https://${{ env.PREFIX }}-frontend.${{ env.DOMAIN }} --env auth_base_url=${{ vars.KEYCLOAK_URL_DEV }},auth_realm=${{ vars.KEYCLOAK_REALM }},auth_client_id=${{ vars.KEYCLOAK_CLIENT_ID }},keycloak_user=${{ vars.KEYCLOAK_USER }},keycloak_password=${{ secrets.KEYCLOAK_PASSWORD }}
command: npx cypress run --browser electron --config baseUrl=https://${{ env.PREFIX }}-frontend.${{ env.DOMAIN }} --env auth_base_url=${{ vars.KEYCLOAK_URL_DEV }},auth_realm=${{ vars.KEYCLOAK_REALM }},auth_client_id=${{ vars.KEYCLOAK_CLIENT_ID }},keycloak_user=${{ vars.KEYCLOAK_USER }},keycloak_user_02=${{ vars.KEYCLOAK_USER_02 }},keycloak_password=${{ secrets.KEYCLOAK_PASSWORD }}

- name: Upload Artifacts
uses: actions/upload-artifact@v3
Expand Down
3 changes: 3 additions & 0 deletions frontend/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { defineConfig } from "cypress";
import dotenv from "dotenv";
import Roles from "./src/app/types/app/roles";
dotenv.config({ path: "./.env" });

const { isFileExist } = require("cy-verify-downloads");
Expand Down Expand Up @@ -39,6 +40,8 @@ export default defineConfig({
css_client_id: process.env.REACT_APP_CSS_CLIENT_ID,
css_client_secret: process.env.REACT_APP_CSS_CLIENT_SECRET,
css_api_url: process.env.REACT_APP_CSS_API_URL,
//Provide access to Role Enum for use in custom commands
roles: Roles,
},
},
retries: 2,
Expand Down
4 changes: 4 additions & 0 deletions frontend/cypress/e2e/allegation-details-create.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ describe("Complaint Create Page spec - Create View", () => {
office: "Victoria",
zone: "South Island",
region: "West Coast",
methodComplaintReceived: "RAPP",
status: "Closed",
statusIndex: 1,
assigned: "Kot, Steve",
Expand Down Expand Up @@ -94,6 +95,8 @@ describe("Complaint Create Page spec - Create View", () => {

cy.selectItemById("community-select-id", createCallDetails.community);

cy.selectItemById("complaint-received-method-select-id", createCallDetails.methodComplaintReceived);

cy.selectItemById("violation-type-select-id", createCallDetails.violationType);

cy.selectItemById("officer-assigned-select-id", createCallDetails.assigned);
Expand All @@ -118,6 +121,7 @@ describe("Complaint Create Page spec - Create View", () => {
cy.get('dd[id="comp-details-office"]').contains(createCallDetails.office);
cy.get('dd[id="comp-details-zone"]').contains(createCallDetails.zone);
cy.get('dd[id="comp-details-region"]').contains(createCallDetails.region);
cy.get('dd[id="comp-method-complaint-received"]').contains(createCallDetails.methodComplaintReceived);
cy.get('dd[id="comp-details-reported"]').contains(createCallerInformation.reported);

//-- verify caller information
Expand Down
17 changes: 17 additions & 0 deletions frontend/cypress/e2e/allegation-details-edit.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const originalCallDetails = {
officeCode: "BURNSLK",
zoneCode: "NCHKOLKS",
regionCode: "OMINECA",
methodComplaintReceived: "Observed in field",
status: "Open",
statusIndex: 0,
assigned: "None",
Expand Down Expand Up @@ -57,6 +58,7 @@ const editCallDetails = {
office: "Golden",
zone: "Columbia/Kootenay",
region: "Kootenay",
methodComplaintReceived: "BC wildlife federation app",
communityIndex: 0,
communityCode: "Blaeberry",
officeCode: "GLDN",
Expand Down Expand Up @@ -151,6 +153,8 @@ describe("Complaint Edit Page spec - Edit Allegation View", () => {

cy.selectItemById("community-select-id", editCallDetails.community);

cy.selectItemById("complaint-received-method-select-id", editCallDetails.methodComplaintReceived);

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

cy.selectItemById("violation-in-progress-select-id", editCallDetails.violationInProgressString);
Expand Down Expand Up @@ -202,6 +206,8 @@ describe("Complaint Edit Page spec - Edit Allegation View", () => {

cy.get('dd[id="comp-details-community"]').contains(editCallDetails.community);

cy.get('dd[id="comp-method-complaint-received"]').contains(editCallDetails.methodComplaintReceived);

cy.get('dd[id="comp-details-violation-in-progress"]').contains(editCallDetails.violationInProgressString);

cy.get('dd[id="comp-details-violation-observed"]').contains(editCallDetails.violationObservedString);
Expand Down Expand Up @@ -269,6 +275,8 @@ describe("Complaint Edit Page spec - Edit Allegation View", () => {

cy.selectItemById("community-select-id", originalCallDetails.community);

cy.selectItemById("complaint-received-method-select-id", originalCallDetails.methodComplaintReceived);

cy.selectItemById("violation-in-progress-select-id", originalCallDetails.violationInProgressString);

cy.selectItemById("violation-observed-select-id", originalCallDetails.violationObservedString);
Expand Down Expand Up @@ -318,6 +326,8 @@ describe("Complaint Edit Page spec - Edit Allegation View", () => {

cy.get('dd[id="comp-details-community"]').contains(originalCallDetails.community);

cy.get('dd[id="comp-method-complaint-received"]').contains(originalCallDetails.methodComplaintReceived);

cy.get('dd[id="comp-details-violation-in-progress"]').contains(originalCallDetails.violationInProgressString);

cy.get('dd[id="comp-details-violation-observed"]').contains(originalCallDetails.violationObservedString);
Expand All @@ -329,6 +339,7 @@ describe("Complaint Edit Page spec - Edit Allegation View", () => {
cy.get('dd[id="comp-details-zone"]').contains(originalCallDetails.zone);

cy.get('dd[id="comp-details-region"]').contains(originalCallDetails.region);

//end verifying changes are reverted
});

Expand Down Expand Up @@ -431,6 +442,12 @@ describe("Complaint Edit Page spec - Edit Allegation View", () => {
expect($input).to.have.prop("disabled", true);
});

//Method Complaint Received
cy.get('[for="complaint-received-method-label-id"]').should(($label) => {
expect($label).to.contain.text("Method complaint was received");
});
cy.get("#complaint-received-method-pair-id").should("exist");

// Check the Caller Information inputs
// Name
cy.get("#complaint-caller-info-name-label-id").should(($label) => {
Expand Down
43 changes: 43 additions & 0 deletions frontend/cypress/e2e/ceeb-user-complaint-method.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import COMPLAINT_TYPES from "../../src/app/types/app/complaint-types";
import Roles from "../../src/app/types/app/roles";

/*
Test that confirms that CEEB Users see different values in the Method Complaint Received field.
*/
describe("Validate CEEB method complaint received options", () => {
beforeEach(function () {
cy.viewport("macbook-16");
cy.kcLogout().kcLogin(Roles.CEEB);
});

function validateMethodReceivedOptions() {
//Check for CEEB values
cy.get(".comp-select__menu-list").contains("DGIR forward").should("exist");
cy.get(".comp-select__menu-list").contains("Direct contact").should("exist");
cy.get(".comp-select__menu-list").contains("Minister's office").should("exist");
cy.get(".comp-select__menu-list").contains("RAPP").should("exist");
cy.get(".comp-select__menu-list").contains("Referral").should("exist");

//Check that COS values aren't there
cy.get(".comp-select__menu-list").contains("BC wildlife federation app").should("not.exist");
cy.get(".comp-select__menu-list").contains("Observed in field").should("not.exist");
}

it("only has CEEB values on create", function () {
//Access dropdown from create screen
cy.navigateToCreateScreen();

cy.get("#complaint-received-method-select-id").find("div").first().click({ force: true });

validateMethodReceivedOptions();
});

it("only has CEEB values on edit", function () {
//Access dropdown from create screen
cy.navigateToEditScreen(COMPLAINT_TYPES.ERS, "23-006888", true);

cy.get("#complaint-received-method-select-id").find("div").first().click({ force: true });

validateMethodReceivedOptions();
});
});
4 changes: 4 additions & 0 deletions frontend/cypress/e2e/hwcr-details-create.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ describe("Complaint Create Page spec - Create View", () => {
office: "Victoria",
zone: "South Island",
region: "West Coast",
methodComplaintReceived: "RAPP",
natureOfComplaint: "Dead wildlife - no violation suspected",
natureOfComplaintIndex: 5,
species: "Coyote",
Expand Down Expand Up @@ -86,6 +87,8 @@ describe("Complaint Create Page spec - Create View", () => {

cy.selectItemById("community-select-id", createCallDetails.community);

cy.selectItemById("complaint-received-method-select-id", createCallDetails.methodComplaintReceived);

cy.selectItemById("nature-of-complaint-select-id", createCallDetails.natureOfComplaint);

cy.selectItemById("species-select-id", createCallDetails.species);
Expand Down Expand Up @@ -116,6 +119,7 @@ describe("Complaint Create Page spec - Create View", () => {
cy.get('dd[id="comp-details-office"]').contains(createCallDetails.office);
cy.get('dd[id="comp-details-zone"]').contains(createCallDetails.zone);
cy.get('dd[id="comp-details-region"]').contains(createCallDetails.region);
cy.get('dd[id="comp-method-complaint-received"]').contains(createCallDetails.methodComplaintReceived);
cy.get('dd[id="comp-details-reported"]').contains(createCallerInformation.reported);

//-- verify the caller information block
Expand Down
16 changes: 16 additions & 0 deletions frontend/cypress/e2e/hwcr-details-edit.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ describe("Complaint Edit Page spec - Edit View", () => {
officeCode: "KMLPS",
zoneCode: "TMPSNNCLA",
regionCode: "TMPSNCRBO",
methodComplaintReceived: "Observed in field",
natureOfComplaint: "Aggressive - present/recent",
natureOfComplaintIndex: 1,
species: "Black Bear",
Expand Down Expand Up @@ -70,6 +71,7 @@ describe("Complaint Edit Page spec - Edit View", () => {
officeCode: "GLDN",
zoneCode: "CLMBAKTNY",
regionCode: "KTNY",
methodComplaintReceived: "BC wildlife federation app",
natureOfComplaint: "Dead wildlife - no violation suspected",
natureOfComplaintIndex: 5,
species: "Coyote",
Expand Down Expand Up @@ -153,6 +155,8 @@ describe("Complaint Edit Page spec - Edit View", () => {

cy.selectItemById("community-select-id", editCallDetails.community);

cy.selectItemById("complaint-received-method-select-id", editCallDetails.methodComplaintReceived);

cy.selectItemById("nature-of-complaint-select-id", editCallDetails.natureOfComplaint);

cy.selectItemById("species-select-id", editCallDetails.species);
Expand Down Expand Up @@ -193,6 +197,8 @@ describe("Complaint Edit Page spec - Edit View", () => {

cy.get('dd[id="comp-details-region"]').contains(editCallDetails.region);

cy.get('dd[id="comp-method-complaint-received"]').contains(editCallDetails.methodComplaintReceived);

cy.get(".comp-attractant-badge").then(function ($defaultValue) {
expect($defaultValue).to.contain("Livestock");
expect($defaultValue).to.contain("BBQ");
Expand Down Expand Up @@ -245,6 +251,8 @@ describe("Complaint Edit Page spec - Edit View", () => {

cy.selectItemById("community-select-id", originalCallDetails.community);

cy.selectItemById("complaint-received-method-select-id", originalCallDetails.methodComplaintReceived);

cy.selectItemById("nature-of-complaint-select-id", originalCallDetails.natureOfComplaint);

cy.selectItemById("species-select-id", originalCallDetails.species);
Expand Down Expand Up @@ -286,6 +294,8 @@ describe("Complaint Edit Page spec - Edit View", () => {

cy.get('dd[id="comp-details-region"]').contains(originalCallDetails.region);

cy.get('dd[id="comp-method-complaint-received"]').contains(originalCallDetails.methodComplaintReceived);

cy.get(".comp-attractant-badge").then(function ($defaultValue) {
expect($defaultValue).to.contain("Garbage");
expect($defaultValue).to.contain("Freezer");
Expand Down Expand Up @@ -384,6 +394,12 @@ describe("Complaint Edit Page spec - Edit View", () => {
expect($input).to.have.prop("disabled", true);
});

//Method Complaint Received
cy.get('[for="complaint-received-method-label-id"]').should(($label) => {
expect($label).to.contain.text("Method complaint was received");
});
cy.get("#complaint-received-method-pair-id").should("exist");

// Check the Caller Information inputs
// Name
cy.get("#complaint-caller-info-name-label-id").should(($label) => {
Expand Down
48 changes: 9 additions & 39 deletions frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/// <reference types="cypress" />
// <reference types="cypress" />
// ***********************************************
// For comprehensive examples of custom
// commands please read more here:
// https://on.cypress.io/custom-commands
// ***********************************************

require("cy-verify-downloads").addCustomCommand();
require("cypress-delete-downloads-folder").addCustomCommand();

Expand Down Expand Up @@ -34,9 +33,14 @@ const sha256 = async (plain) => {
return hashHex;
};

Cypress.Commands.add("kcLogin", (account?: string) => {
Cypress.Commands.add("kcLogin", (role?: string) => {
Cypress.log({ name: "Login to Keycloak" });
console.log("account: ", account);
let account = "keycloak_user";

// Convert this to a switch in the future as more roles are added to the tests
if (role === Cypress.env("roles").CEEB) {
account = "keycloak_user_02";
}

cy.log("Keyloak Login").then(async () => {
const authBaseUrl = Cypress.env("auth_base_url");
Expand Down Expand Up @@ -76,7 +80,7 @@ Cypress.Commands.add("kcLogin", (account?: string) => {
const url = Array.isArray(redirectUrls) ? redirectUrls[0] : redirectUrls;
// Visit redirect URL.
const credentials = {
username: Cypress.env(!account ? "keycloak_user" : account),
username: Cypress.env(account),
password: Cypress.env("keycloak_password"),
url: url,
};
Expand Down Expand Up @@ -139,40 +143,6 @@ Cypress.Commands.add("hasErrorMessage", (inputs: Array<string>, toastText: strin
});
});

Cypress.Commands.add("applyRoles", (roles: Array<string>) => {
Cypress.log({ name: "Apply User Roles" });
const apiUrl = Cypress.env("css_api_url");
const testAccountGuid = Cypress.env("keycloak_user_guid");
const integrationId = Cypress.env("css_integration_id");

const _authorize = (): string => {
const authUrl = Cypress.env("auth_realm");
const clientId = Cypress.env("");
const clientSecret = Cypress.env("");

cy.request({
method: "POST",
url: authUrl,
form: true,
body: {
client_id: clientId,
client_secret: clientSecret,
grant_type: "client_credentials",
},
}).then((res) => {
cy.log(JSON.stringify(res));
});

return "moo";
};

_authorize();
});

Cypress.Commands.add("resetRoles", () => {
Cypress.log({ name: "Reset Roles" });
});

Cypress.Commands.add("verifyMapMarkerExists", (existIndicator: boolean) => {
cy.get(".leaflet-container").should("exist");
cy.get(".leaflet-marker-icon").should(existIndicator ? "exist" : "not.exist");
Expand Down
2 changes: 0 additions & 2 deletions frontend/cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,5 @@ declare namespace Cypress {
fillInHWCSection(section: HwcSection): Chainable<void>;
validateHWCSection(section: HwcSection): Chainable<void>;
hasErrorMessage(inputs: Array<string>, toastText: string): Chainable<void>;
applyRoles(roles: Array<string>): Chainable<void>;
resetRoles(): Chainable<void>;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const CallDetails: FC<ComplaintHeaderProps> = ({ complaintType }) => {
</div>
<div>
<dt>Method complaint was received</dt>
<dd className="comp-method-complaint-received">
<dd id="comp-method-complaint-received">
<span id="comp-method-complaint-received-span-id">{complaintMethodReceivedCode?.longDescription}</span>
</dd>
</div>
Expand Down
8 changes: 8 additions & 0 deletions migrations/test-only-migrations/R__Test-Data-Creation.sql
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,10 @@ VALUES('16dc87d5-2034-4d9a-bbf4-3ec0f927d3e8'::uuid, 'ENV', NULL, NULL, 'TestAcc
ON CONFLICT DO NOTHING;
INSERT INTO public.person
(person_guid, first_name, middle_name_1, middle_name_2, last_name, create_user_id, create_utc_timestamp, update_user_id, update_utc_timestamp)
VALUES('375bac7f-390a-4b32-91da-1ed9da71c1e3'::uuid, 'ENV', NULL, NULL, 'TestAcct 2', 'nr-compliance-enforcement', '2023-06-29 22:16:16.754', 'nr-compliance-enforcement', '2023-06-29 22:16:16.754')
ON CONFLICT DO NOTHING;
INSERT INTO public.person
(person_guid, first_name, middle_name_1, middle_name_2, last_name, create_user_id, create_utc_timestamp, update_user_id, update_utc_timestamp)
VALUES('5a724b5e-aa64-439d-a76d-3aa7320409a0'::uuid, 'Scarlett', NULL, NULL, 'Truong', 'FLYWAY', '2024-01-10 22:16:16.754', 'FLYWAY', '2024-01-10 22:16:16.754')
ON CONFLICT DO NOTHING;
INSERT INTO public.person
Expand Down Expand Up @@ -437,6 +441,10 @@ INSERT INTO public.officer
VALUES('fc91b041-7f1b-46e9-8c07-0813bb656a7f'::uuid, 'ENCETST1', 'nr-compliance-enforcement', '2023-06-29 22:16:16.754', 'nr-compliance-enforcement', '2023-06-29 22:20:48.186', '16dc87d5-2034-4d9a-bbf4-3ec0f927d3e8'::uuid, '79fe321b-7716-413f-b878-c5fd6100317d'::uuid, '0cf857a2-28a3-4867-af0f-d59449243057'::uuid)
ON CONFLICT DO NOTHING;
INSERT INTO public.officer
(officer_guid, user_id, create_user_id, create_utc_timestamp, update_user_id, update_utc_timestamp, person_guid, auth_user_guid)
VALUES('ac64c6e6-8233-4cee-807b-5bb2b4ddb15b'::uuid, 'ENCETST2', 'nr-compliance-enforcement', '2023-06-29 22:16:16.754', 'nr-compliance-enforcement', '2023-06-29 22:20:48.186', '375bac7f-390a-4b32-91da-1ed9da71c1e3'::uuid, '6d1bb908-0f03-4873-af49-916713583c7e'::uuid)
ON CONFLICT DO NOTHING;
INSERT INTO public.officer
(officer_guid, user_id, create_user_id, create_utc_timestamp, update_user_id, update_utc_timestamp, person_guid, office_guid)
VALUES('a534a1e0-bebc-499d-ba4b-eb5ed0726f26'::uuid, 'STRUONG', 'FLYWAY', '2024-01-10 22:16:16.754', 'FLYWAY', '2024-01-10 22:20:48.186', '5a724b5e-aa64-439d-a76d-3aa7320409a0'::uuid, '3f474308-68da-450a-b1ab-fb8a5b7a27ce'::uuid)
ON CONFLICT DO NOTHING;
Expand Down
Loading