Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…cement into CE-314
  • Loading branch information
jon-funk committed Oct 29, 2024
2 parents dab893a + ce476f2 commit 2645120
Show file tree
Hide file tree
Showing 24 changed files with 617 additions and 19 deletions.
39 changes: 39 additions & 0 deletions .github/actions/get-latest-pr-number/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Get Latest Merged PR Number
description: Get the latest merged PR number from the release branch, this is the production candidate
branding:
icon: git-pull-request
color: blue

inputs:
token:
description: Specify token (GH or PAT), instead of inheriting one from the calling workflow
default: ${{ github.token }}

outputs:
pr:
description: "Latest merged pull request number"
value: ${{ steps.vars.outputs.pr }}

runs:
using: composite
steps:
- id: vars
shell: bash
run: |
git fetch origin
release_branch="${{ github.event.pull_request.head.ref }}"
echo "Detected release branch: $release_branch"
latest_pr=$(git log origin/$release_branch --pretty=format:'%s' | grep -oP '(?<=#)\d+' | head -n 1)
if [ -z "$latest_pr" ]; then
echo "No merged PR found on $release_branch"
exit 1
elif [[ ! "$latest_pr" =~ ^[0-9]+$ ]]; then
echo "PR number format incorrect: $latest_pr"
exit 1
fi
echo "Latest PR number from $release_branch: $latest_pr"
echo "pr=$latest_pr" >> $GITHUB_OUTPUT
11 changes: 5 additions & 6 deletions .github/workflows/merge-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,16 @@ jobs:
vars:
name: Set Variables
outputs:
pr: ${{ steps.pr.outputs.pr }}
pr: ${{ steps.latest-pr.outputs.pr }}
runs-on: ubuntu-22.04
timeout-minutes: 1
steps:
- uses: actions/checkout@v4
# Get PR number for squash merges to release
- name: PR Number
id: pr
uses: ./.github/actions/get-pr-number
- name: Get Latest PR Number in release branch
id: latest-pr
uses: ./.github/actions/get-latest-pr-number
- name: Set PR Output
run: echo "pr=${{ steps.pr.outputs.pr }}" >> $GITHUB_OUTPUT
run: echo "pr=${{ steps.latest-pr.outputs.pr }}" >> $GITHUB_OUTPUT

create_release:
name: Create GitHub Release (Keep Version)
Expand Down
20 changes: 20 additions & 0 deletions backend/src/middleware/maps/automapper-entity-to-dto-maps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,10 @@ export const complaintToComplaintDtoMap = (mapper: Mapper) => {
(destination) => destination.webeocId,
mapFrom((source) => source.webeoc_identifier),
),
forMember(
(destination) => destination.referenceNumber,
mapFrom((source) => source.reference_number),
),
forMember(
(destination) => destination.complaintMethodReceivedCode,
mapFrom((source) => {
Expand Down Expand Up @@ -692,6 +696,10 @@ export const applyWildlifeComplaintMap = (mapper: Mapper) => {
(destination) => destination.webeocId,
mapFrom((source) => source.complaint_identifier.webeoc_identifier),
),
forMember(
(destination) => destination.referenceNumber,
mapFrom((source) => source.complaint_identifier.reference_number),
),
forMember(
(destination) => destination.complaintMethodReceivedCode,
mapFrom((source) => {
Expand Down Expand Up @@ -915,6 +923,10 @@ export const applyAllegationComplaintMap = (mapper: Mapper) => {
(destination) => destination.webeocId,
mapFrom((source) => source.complaint_identifier.webeoc_identifier),
),
forMember(
(destination) => destination.referenceNumber,
mapFrom((source) => source.complaint_identifier.reference_number),
),
forMember(
(destination) => destination.complaintMethodReceivedCode,
mapFrom((source) => {
Expand Down Expand Up @@ -1432,6 +1444,10 @@ export const mapWildlifeReport = (mapper: Mapper, tz: string = "America/Vancouve
(destination) => destination.webeocId,
mapFrom((source) => source.complaint_identifier.webeoc_identifier),
),
forMember(
(destination) => destination.referenceNumber,
mapFrom((source) => source.complaint_identifier.reference_number),
),
forMember(
(destination) => destination.complaintMethodReceivedCode,
mapFrom((source) => {
Expand Down Expand Up @@ -1723,6 +1739,10 @@ export const mapAllegationReport = (mapper: Mapper, tz: string = "America/Vancou
(destination) => destination.webeocId,
mapFrom((source) => source.complaint_identifier.webeoc_identifier),
),
forMember(
(destination) => destination.referenceNumber,
mapFrom((source) => source.complaint_identifier.reference_number),
),
forMember(
(destination) => destination.complaintMethodReceivedCode,
mapFrom((source) => {
Expand Down
6 changes: 6 additions & 0 deletions backend/src/middleware/maps/dto-to-table-map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,12 @@ export const mapComplaintDtoToComplaintTable = (mapper: Mapper) => {
};
}),
),
forMember(
(dest) => dest.reference_number,
mapFrom((src) => {
return src.referenceNumber;
}),
),
forMember(
(dest) => dest.is_privacy_requested,
mapFrom((src) => {
Expand Down
1 change: 1 addition & 0 deletions backend/src/types/models/complaints/complaint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface ComplaintDto {
};
delegates: Array<DelegateDto>;
webeocId: string;
referenceNumber: string;
complaintMethodReceivedCode: string;
isPrivacyRequested: string;
}
7 changes: 7 additions & 0 deletions backend/src/types/models/complaints/update-complaint.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,13 @@ export class UpdateComplaintDto {
})
webeoc_identifier: string;

@ApiProperty({
example: "54321",
description:
"Allows users to link complaints to files in external systems. Currently labeled in the system as COORS reference number and initially only used for COORS linkages.",
})
reference_number: string;

@ApiProperty({
example: "RAPP",
description: "Method in which the complaint was created",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface ComplaintReportData {
locationDescription: string;
description: string;
webeocId: string;
referenceNumber: string;
complaintMethodReceivedCode: string;

//-- caller information
Expand Down
3 changes: 3 additions & 0 deletions backend/src/v1/complaint/complaint.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,9 @@ export class ComplaintService {
qb.orWhere("complaint.reported_by_other_text ILIKE :query", {
query: `%${query}%`,
});
qb.orWhere("complaint.reference_number ILIKE :query", {
query: `%${query}%`,
});

qb.orWhere("reported_by.short_description ILIKE :query", {
query: `%${query}%`,
Expand Down
10 changes: 10 additions & 0 deletions backend/src/v1/complaint/entities/complaint.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ export class Complaint {
@Column({ length: 20 })
webeoc_identifier: string;

@ApiProperty({
example: "54321",
description:
"Allows users to link complaints to files in external systems. Currently labeled in the system as COORS reference number and initially only used for COORS linkages.",
})
@Column({ length: 20 })
reference_number: string;

@ApiProperty({
example: "43.43,-123.55",
description: "The lat/long point of the complaint",
Expand Down Expand Up @@ -235,6 +243,7 @@ export class Complaint {
cos_geo_org_unit?: CosGeoOrgUnit,
person_complaint_xref?: PersonComplaintXref[],
webeoc_identifier?: string,
reference_number?: string,
comp_mthd_recv_cd_agcy_cd_xref?: CompMthdRecvCdAgcyCdXref,
is_privacy_requested?: string,
) {
Expand Down Expand Up @@ -263,6 +272,7 @@ export class Complaint {
this.cos_geo_org_unit = cos_geo_org_unit;
this.person_complaint_xref = person_complaint_xref;
this.webeoc_identifier = webeoc_identifier;
this.reference_number = reference_number;
this.comp_mthd_recv_cd_agcy_cd_xref = comp_mthd_recv_cd_agcy_cd_xref;
this.is_privacy_requested = is_privacy_requested;
}
Expand Down
Binary file modified backend/templates/complaint/CDOGS-ERS-COMPLAINT-TEMPLATE-v1.docx
Binary file not shown.
Binary file modified backend/templates/complaint/CDOGS-HWCR-COMPLAINT-TEMPLATE-v1.docx
Binary file not shown.
6 changes: 3 additions & 3 deletions frontend/cypress/e2e/complaint-export.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ describe("Export Complaint Functionality", () => {
it(`Can export complaint: ${index === 0 ? "HWCR" : "ERS"}`, () => {
let fileName = "";

const date = fns.format(new Date(), "yyyy-MM-dd");
const date = fns.format(new Date(), "yyMMdd");

if ("#hwcr-tab".includes(complaintTypes[index])) {
fileName = `Complaint-23-000076-HWCR-${date}.pdf`;
fileName = `HWC_23-000076_${date}.pdf`;
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-000076", true);
} else {
fileName = `Complaint-23-006888-ERS-${date}.pdf`;
fileName = `EC_23-006888_${date}.pdf`;
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS, "23-006888", true);
}

Expand Down
132 changes: 132 additions & 0 deletions frontend/cypress/e2e/external-file-reference.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import COMPLAINT_TYPES from "../../src/app/types/app/complaint-types";

const complaintTypes = [COMPLAINT_TYPES.HWCR, COMPLAINT_TYPES.ERS];

describe("External File Reference", () => {
beforeEach(function () {
cy.viewport("macbook-16");
cy.kcLogout().kcLogin();
});

function enterReferenceNumber(number: string, shouldSave: boolean) {
cy.get("#external-file-reference-number-input").click({ force: true });
cy.get("#external-file-reference-number-input").clear().type(number, { delay: 0 });
if (shouldSave) {
cy.get("#external-file-reference-save-button").click();
}
}

function navigateToComplaint(index: number) {
if (COMPLAINT_TYPES.HWCR.includes(complaintTypes[index])) {
cy.navigateToDetailsScreen(COMPLAINT_TYPES.HWCR, "23-031226", true);
} else {
cy.navigateToDetailsScreen(COMPLAINT_TYPES.ERS, "23-027918", true);
}
}

function deleteReferenceNumber() {
cy.get("#external-file-reference").then(function ($externalref) {
if ($externalref.find("#external-file-reference-delete-button").length) {
cy.get("#external-file-reference-delete-button").click();
cy.get(".modal-footer > .btn-primary").click();
} else {
cy.log("No reference number to delete");
}
});
}

function validateFormIsEmpty() {
cy.get("#external-file-reference-number-input").should("exist");
cy.get("#external-file-reference-number-div").should(($div) => {
expect($div).to.not.contain.text("111111");
expect($div).to.not.contain.text("222222");
expect($div).to.not.contain.text("333333");
});
}

//Core tests - try these on both complaint types

Cypress._.times(complaintTypes.length, (index) => {
it(`Can enter an external reference number: ${complaintTypes[index]}`, () => {
//navigatetoComplaint
navigateToComplaint(index);

//make sure that there isn't an old one there from a failed run
deleteReferenceNumber();

//enter the number
enterReferenceNumber("111111", true);

//validate the number
cy.get("#external-file-reference-number-div").should(($div) => {
expect($div).to.contain.text("111111");
});
});

it(`Can edit an external reference number: ${complaintTypes[index]}`, () => {
//navigatetoComplaint
navigateToComplaint(index);

//press Edit
cy.get("#external-file-reference-edit-button").click();

//enter the number
enterReferenceNumber("222222", true);

//validate the number
cy.get("#external-file-reference-number-div").should(($div) => {
expect($div).to.contain.text("222222");
});
});

it(`Can delete an external reference number: ${complaintTypes[index]}`, () => {
//navigatetoComplaint
navigateToComplaint(index);

//press Delete
deleteReferenceNumber();

//validate the toast
cy.get(".Toastify__toast-body").then(($toast) => {
expect($toast).to.contain.text("Updates have been saved");
});

//validate that the empty input is showing
validateFormIsEmpty();
});
});

//Secondary tests - only need to try these on one complaint type
it("Can cancel pending changes to a reference file number (new)", () => {
//navigatetoComplaint
navigateToComplaint(0);

//attempt to delete if there is old data
deleteReferenceNumber();

//enter the number
enterReferenceNumber("333333", false);

cy.get("#external-file-reference").then(function ($externalref) {
cy.get("#external-file-reference-cancel-button").click();
cy.get(".modal-footer > .btn-primary").click();
});

//validate that the empty input is showing
validateFormIsEmpty();
});

it("Will not accept a reference file number with letters", () => {
//navigatetoComplaint
navigateToComplaint(1);

//make sure that there isn't an old one there from a failed run
deleteReferenceNumber();

//enter the number
enterReferenceNumber("444BADNUMBER44", true);

//validate the error message
cy.hasErrorMessage(["#external-file-reference-number-div"]);
});
});
11 changes: 7 additions & 4 deletions frontend/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,16 +131,19 @@ Cypress.Commands.add("kcLogout", () => {
});
});

Cypress.Commands.add("hasErrorMessage", (inputs: Array<string>, toastText: string) => {
Cypress.Commands.add("hasErrorMessage", (inputs: Array<string>, toastText?: string) => {
//validate all the inputs
Cypress._.times(inputs.length, (index) => {
cy.get(inputs[index]).find(".error-message").should("exist");
});

//validate the toast
cy.get(".Toastify__toast-body").then(($toast) => {
expect($toast).to.contain.text(toastText);
});
if(toastText)
{
cy.get(".Toastify__toast-body").then(($toast) => {
expect($toast).to.contain.text(toastText);
});
}
});

Cypress.Commands.add("verifyMapMarkerExists", (existIndicator: boolean) => {
Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ declare namespace Cypress {
validateComplaint(complaintIdentifier: string, species: string): Chainable<void>;
fillInHWCSection(section: HwcSection): Chainable<void>;
validateHWCSection(section: HwcSection): Chainable<void>;
hasErrorMessage(inputs: Array<string>, toastText: string): Chainable<void>;
hasErrorMessage(inputs: Array<string>, toastText?: string): Chainable<void>;
}
}
Loading

0 comments on commit 2645120

Please sign in to comment.