Skip to content

Commit

Permalink
Cypress tests and some small bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cnesmithsalus committed Oct 17, 2023
1 parent d4f5071 commit b8d4440
Show file tree
Hide file tree
Showing 6 changed files with 209 additions and 4 deletions.
6 changes: 6 additions & 0 deletions backend/db/migrations/R__Create-Test-Data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1300,3 +1300,9 @@ INSERT INTO public.officer
(officer_guid, user_id, create_user_id, create_utc_timestamp, update_user_id, update_utc_timestamp, person_guid, office_guid, auth_user_guid)
VALUES('49af7913-bfee-48f3-b1b7-51e2b6134b64'::uuid, 'JOCHARTR', 'FLYWAY', '2023-10-06 11:22:45.560', 'FLYWAY', '2023-10-06 11:25:55.828', '85484a31-5370-4763-81cc-f9c2b5f97110'::uuid, '3f474308-68da-450a-b1ab-fb8a5b7a27ce'::uuid, 'b4bb40f5-ee23-4c99-b63c-e741ce61b589'::uuid)
ON CONFLICT DO NOTHING;

-- Fixing spelling issue
UPDATE public.attractant_code SET long_description = 'Barbeque' WHERE short_description = 'BBQ' AND attractant_code = 'BBQ';
UPDATE public.attractant_code SET short_description = 'Fruit/Berries' WHERE long_description = 'Residential Fruit/Berries' AND attractant_code = 'RESFRUIT';
UPDATE public.attractant_code SET short_description = 'Hunter Kill' WHERE long_description = 'Wildlife:Hunter Kill' AND attractant_code = 'WLDLFEHK';

9 changes: 8 additions & 1 deletion backend/src/v1/attractant_code/attractant_code.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ export class AttractantCodeService {
}

async findAll(): Promise<AttractantCode[]> {
return this.attractantCodeRepository.find();
return this.attractantCodeRepository.find(
{
order:
{
display_order: "ASC"
}
}
);
}

async findOne(id: any): Promise<AttractantCode> {
Expand Down
190 changes: 190 additions & 0 deletions frontend/cypress/e2e/allegation-details-create.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
/*
Test to verify that the user is able to click the edit button
on the wildlife contacts details page and see all the inputs
*/
describe("Complaint Create Page spec - Create View", () => {
const createCallDetails = {
description:
"Caller was involved in an altercation yesterday with a person who was exceeding the Callers understanding of the limit. SUBs were attempting to catch 5 fish, of each type, each person (total 20.) SUBs male and their wife. Caller requesting CO clarification regarding fish quotas for region 3. Caller has contacted front counter BC, who referred the answer to COS. ---- testing",
location: "Keefes Landing Rd and Danskin Rd ---- testing",
locationDescription: "tester call description 8 ---- testing",
incidentDate: "2030-04-13",
xCoord: "-118",
yCoord: "49",
community: "Blaeberry",
office: "Golden",
zone: "Columbia/Kootenay",
region: "Kootenay",
communityIndex: 0,
communityCode: "Blaeberry",
officeCode: "GLDN",
zoneCode: "CLMBAKTNY",
regionCode: "KTNY",
status: "Closed",
statusIndex: 1,
assigned: "Olivia Benson",
assignedIndex: 1,
violationInProgressIndex: 1,
violationInProgressString: "No",
violationObservedIndex: 0,
violationObservedString: "Yes",
violationType: "Boating",
violationIndex: 1,
};

const createCallerInformation = {
name: "Phoebe ---- testing",
phone: "(250) 555-5555",
phoneInput: "2505555555",
secondary: "(250) 666-6666",
secondaryInput: "2506666666",
alternate: "(250) 666-8888",
alternateInput: "2506668888",
address: "135 fake st ---- testing",
email: "[email protected]",
referred: "BC Wildlife Federation",
referredCode: "BCWF",
referredIndex: 1,
witnessDetails: "----- testing",
};

beforeEach(function () {
cy.viewport("macbook-16");
cy.kcLogout().kcLogin();
});

it("Navigate to the Complaint Create page & create and verify data", function () {
//start create
cy.navigateToCreateScreen();

cy.selectItemById("complaint-type-select-id", "Enforcement");
cy.get("#caller-name-id").clear().type(createCallerInformation.name);
cy.get("#complaint-address-id")
.clear()
.type(createCallerInformation.address);
cy.get("#complaint-email-id").clear().type(createCallerInformation.email);

cy.get("#caller-primary-phone-id").click({ force: true });
cy.get("#caller-primary-phone-id").clear();
cy.get("#caller-primary-phone-id").typeAndTriggerChange(
createCallerInformation.phoneInput,
);

cy.get("#caller-info-secondary-phone-id")
.clear()
.typeAndTriggerChange(createCallerInformation.secondaryInput);
cy.get("#caller-info-alternate-phone-id")
.clear()
.typeAndTriggerChange(createCallerInformation.alternateInput);

cy.selectItemById("referred-select-id", createCallerInformation.referred);

cy.get("#location-edit-id").click({ force: true });
cy.get("#location-edit-id").clear().type(createCallDetails.location);
cy.get("#complaint-location-description-textarea-id").click({
force: true,
});
cy.get("#complaint-location-description-textarea-id")
.clear()
.type(createCallDetails.locationDescription, { delay: 0 });
cy.get("#complaint-description-textarea-id").click({ force: true });
cy.get("#complaint-description-textarea-id")
.clear()
.type(createCallDetails.description, { delay: 0 });
cy.get("#complaint-description-textarea-id").click({ force: true });

cy.get("#complaint-incident-time")
.click({ force: true })
.get(".react-datepicker__day--019")
.should("exist")
.click({ force: true });

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

cy.selectItemById("violation-observed-select-id", createCallDetails.violationObservedString);

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

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

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

cy.get("#details-screen-cancel-save-button-top").click({ force: true });
//end create changes
//start verifying changes are created
cy.waitForSpinner();

cy.get('div[id="comp-details-name"]').contains(
createCallerInformation.name,
);
cy.get('div[id="comp-details-address"]').contains(
createCallerInformation.address,
);
cy.get('div[id="comp-details-email"]').contains(
createCallerInformation.email,
);

cy.get('div[id="comp-details-phone"]').contains(
createCallerInformation.phone,
);
cy.get('div[id="comp-details-phone-2"]').should(($el) => {
expect($el.text().trim()).equal(createCallerInformation.secondary);
});
cy.get('div[id="comp-details-phone-3"]').should(($el) => {
expect($el.text().trim()).equal(createCallerInformation.alternate);
});

cy.get('div[id="comp-details-referred"]').contains(
createCallerInformation.referred,
);

cy.get('div[id="comp-details-location"]').contains(
createCallDetails.location,
);

cy.get('p[id="comp-details-location-description"]').should(
"have.text",
createCallDetails.locationDescription,
);

//Commented out until COMPENF-843 is Fixed
//cy.get('div[id="complaint-incident-date-time"]').contains(
// originalCallDetails.incidentDate
//);

cy.get('p[id="comp-details-description"]').should(
"have.text",
createCallDetails.description,
);

cy.get('span[id="comp-details-community"]').contains(
createCallDetails.community,
);

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

cy.get('span[id="comp-details-violation-observed"]').contains(
createCallDetails.violationObservedString,
);

cy.get('span[id="comp-details-office"]').contains(createCallDetails.office);

cy.get('span[id="comp-details-zone"]').contains(createCallDetails.zone);

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

//Commented out until COMPENF-987 is Fixed
//cy.get(".comp-attactant-badge").then(function ($defaultValue) {
// expect($defaultValue.eq(0)).to.contain("Garbage");
// expect($defaultValue.eq(1)).to.contain("Freezer");
// expect($defaultValue.eq(2)).to.contain("Compost");
//});
//end verifying changes are created
});
});

2 changes: 2 additions & 0 deletions frontend/cypress/e2e/hwcr-details-create.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ describe("Complaint Create Page spec - Create View", () => {
it("Navigate to the Complaint Create page & create and verify data", function () {
//start create
cy.navigateToCreateScreen();

cy.selectItemById("complaint-type-select-id", "Human Wildlife Conflicts");
cy.get("#caller-name-id").clear().type(createCallerInformation.name);
cy.get("#complaint-address-id")
.clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1218,7 +1218,7 @@ export const CreateComplaint: FC = () => {
options={yesNoOptions}
placeholder="Select"
id="violation-in-progress-select-id"
classNamePrefix="comp-violation-ip-select"
classNamePrefix="comp-select"
onChange={(e) => handleViolationInProgessChange(e)}
/>
</div>
Expand All @@ -1235,7 +1235,7 @@ export const CreateComplaint: FC = () => {
options={yesNoOptions}
placeholder="Select"
id="violation-observed-select-id"
classNamePrefix="comp-violation-observed-select"
classNamePrefix="comp-select"
onChange={(e) => handleViolationObservedChange(e)}
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/app/store/reducers/code-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export const codeTableSlice = createSlice({
const data = payload.map(
({
attractant_code: value,
long_description: label,
short_description: label,
short_description: description,
}) => {
return { value, label, description } as CodeTable;
Expand Down

0 comments on commit b8d4440

Please sign in to comment.