Skip to content

Commit 1a632cc

Browse files
committed
chore: add e2e test
1 parent 82ca6f1 commit 1a632cc

7 files changed

Lines changed: 152 additions & 2 deletions

File tree

bciers/apps/reporting-e2e/poms/past-reports.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Page, expect } from "@playwright/test";
22
import { CurrentReportsPOM } from "@/reporting-e2e/poms/current-reports";
3-
import { AppRoutes } from "../utils/enums";
3+
import { AppRoutes } from "@/reporting-e2e/utils/enums";
4+
import { GRID_BUTTON_TEXT } from "@/reporting-e2e/utils/constants";
45
import { waitForGridReady } from "@bciers/e2e/utils/helpers";
56

67
export class PastReportsPOM extends CurrentReportsPOM {
@@ -32,4 +33,21 @@ export class PastReportsPOM extends CurrentReportsPOM {
3233

3334
await expect(row).toBeVisible({ timeout: 30_000 });
3435
}
36+
37+
async clickFileReport(): Promise<void> {
38+
const expectedUrl = new RegExp(`${AppRoutes.PAGE_START_PAST_REPORT}$`, "i");
39+
40+
const link = this.page.getByRole("link", {
41+
name: GRID_BUTTON_TEXT.FILE_PREVIOUS_YEARS_REPORT,
42+
});
43+
44+
await expect(link).toBeVisible({ timeout: 30_000 });
45+
await expect(link).toBeEnabled({ timeout: 30_000 });
46+
47+
await link.click();
48+
49+
await expect(this.page).toHaveURL(expectedUrl, {
50+
timeout: 30_000,
51+
});
52+
}
3553
}

bciers/apps/reporting-e2e/poms/report-operation.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
assertFieldVisibility,
44
checkFormFieldsReadOnly,
55
} from "@bciers/e2e/utils/helpers";
6+
import { ReportPageTitles, ReportRoutes } from "@/reporting-e2e/utils/enums";
67

78
const OPERATION_INFO_FIELDS = {
89
// Field labels
@@ -42,6 +43,19 @@ export class ReportOperationPOM {
4243
this.page = page;
4344
}
4445

46+
async isLoaded(): Promise<void> {
47+
await expect(this.page).toHaveURL(
48+
new RegExp(`/reports/\\d+/${ReportRoutes.REVIEW_OPERATION_INFORMATION}$`),
49+
{ timeout: 30_000 },
50+
);
51+
52+
await expect(
53+
this.page.getByRole("heading", {
54+
name: ReportPageTitles.REVIEW_OPERATION_INFORMATION,
55+
}),
56+
).toBeVisible();
57+
}
58+
4559
async verifyBugleSfoFields(): Promise<void> {
4660
// 1. Report type — combobox (name matches the start of the long label)
4761
await expect(
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { Page, expect } from "@playwright/test";
2+
import { fillComboxboxWidget } from "@bciers/e2e/utils/helpers";
3+
import { AppRoutes } from "@/reporting-e2e/utils/enums";
4+
import { FORM_BUTTON_TEXT } from "@/reporting-e2e/utils/constants";
5+
6+
export class StartPastReportPOM {
7+
constructor(private readonly page: Page) {}
8+
9+
async isLoaded(): Promise<void> {
10+
await expect(this.page).toHaveURL(
11+
new RegExp(`${AppRoutes.PAGE_START_PAST_REPORT}$`),
12+
);
13+
14+
await expect(
15+
this.page.getByRole("button", {
16+
name: FORM_BUTTON_TEXT.START,
17+
}),
18+
).toBeVisible();
19+
}
20+
21+
async selectReportingYear(year: string): Promise<void> {
22+
await fillComboxboxWidget(this.page, /select reporting year/i, year, true);
23+
}
24+
25+
async selectOperation(operation: string): Promise<void> {
26+
await fillComboxboxWidget(this.page, /select operation/i, operation, true);
27+
}
28+
29+
async selectRegistrationPurpose(purpose: string): Promise<void> {
30+
await fillComboxboxWidget(
31+
this.page,
32+
/select the registration/i,
33+
purpose,
34+
true,
35+
);
36+
}
37+
38+
async clickStart(): Promise<void> {
39+
await this.page
40+
.getByRole("button", {
41+
name: FORM_BUTTON_TEXT.START,
42+
})
43+
.click();
44+
}
45+
46+
async clickCancel(): Promise<void> {
47+
await this.page
48+
.getByRole("button", {
49+
name: FORM_BUTTON_TEXT.CANCEL,
50+
})
51+
.click();
52+
}
53+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { PastReportsPOM } from "@/reporting-e2e/poms/past-reports";
2+
import { StartPastReportPOM } from "@/reporting-e2e/poms/start-past-report";
3+
import { ReportOperationPOM } from "@/reporting-e2e/poms/report-operation";
4+
import { REGULATED_OPERATION_REGISTRATION_PURPOSE } from "@reporting/src/app/utils/constants";
5+
import { OPERATION_NAMES } from "@/reporting-e2e/utils/enums";
6+
import { setupBeforeAllTest } from "@bciers/e2e/setupBeforeAll";
7+
import { UserRole } from "@bciers/e2e/utils/enums";
8+
9+
const test = setupBeforeAllTest(UserRole.INDUSTRY_USER_ADMIN);
10+
test.describe.configure({ mode: "serial" });
11+
12+
test.describe("Start Past Report", () => {
13+
test("Industry user can start a report for a previous reporting year", async ({
14+
page,
15+
}) => {
16+
// Setup POMs
17+
const pastReports = new PastReportsPOM(page);
18+
const startPastReport = new StartPastReportPOM(page);
19+
const reportOperation = new ReportOperationPOM(page);
20+
21+
// Navigate to the past reports grid
22+
await pastReports.route();
23+
24+
// Click button File previous years report
25+
await pastReports.clickFileReport();
26+
27+
// Assert Report on a previous year page displays
28+
await startPastReport.isLoaded();
29+
30+
// Complete form
31+
await startPastReport.selectReportingYear("2024");
32+
await startPastReport.selectOperation(OPERATION_NAMES.BUGLE_SFO);
33+
await startPastReport.selectRegistrationPurpose(
34+
REGULATED_OPERATION_REGISTRATION_PURPOSE,
35+
);
36+
// Submit form
37+
await startPastReport.clickStart();
38+
39+
// Assert Review Operation Information page displays
40+
await reportOperation.isLoaded();
41+
});
42+
});

bciers/apps/reporting-e2e/utils/constants.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ export const DIALOG_BUTTON_TEXT = {
2929

3030
// Form submit / navigation buttons
3131
export const FORM_BUTTON_TEXT = {
32+
START: "Start",
3233
SAVE_AND_CONTINUE: "Save & Continue",
3334
SAVE: "Save",
3435
BACK: "Back",
3536
CONTINUE: "Continue",
37+
CANCEL: "Cancel",
3638
RETURN_TO_FACILITY_REPORTS: "Return To All Facility Reports",
3739
} as const;
3840

@@ -48,3 +50,7 @@ export const ACTION_BUTTON_TEXT = {
4850
VIEW_REPORT: "View Report",
4951
REPORT_HISTORY: "Report history",
5052
} as const;
53+
54+
export const GRID_BUTTON_TEXT = {
55+
FILE_PREVIOUS_YEARS_REPORT: "File previous years report",
56+
} as const;

bciers/apps/reporting-e2e/utils/enums.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
export enum AppRoutes {
33
GRID_REPORTING_CURRENT_REPORTS = "reporting/reports",
44
GRID_REPORTING_PAST_REPORTS = "reporting/reports/previous-years",
5+
PAGE_START_PAST_REPORT = "reporting/reports/previous-years/report-on-a-previous-year",
56
GRID_REPORT_HISTORY = "reporting/reports/report-history",
67
GRID_REPORTING_ATTACHMENTS_LIST = "reporting/reports/attachments",
78
}
@@ -50,6 +51,22 @@ export enum ReportRoutes {
5051
ANNUAL_REPORT = "annual-report",
5152
}
5253

54+
export const ReportPageTitles = {
55+
REVIEW_OPERATION_INFORMATION: "Review Operation Information",
56+
PERSON_RESPONSIBLE: "Person Responsible for Submitting Report",
57+
REVIEW_FACILITIES: "Review Facilities",
58+
REVIEW_FACILITY_INFORMATION: "Review Facility Information",
59+
FACILITY_GRID: "Facilities",
60+
ADDITIONAL_REPORTING_DATA: "Additional Reporting Data",
61+
EMISSION_SUMMARY: "Emission Summary",
62+
COMPLIANCE_SUMMARY: "Compliance Summary",
63+
REPORT_VALIDATION: "Report validation",
64+
FINAL_REVIEW: "Final Review",
65+
VERIFICATION: "Verification",
66+
ATTACHMENTS: "Attachments",
67+
SUBMISSION: "Submission",
68+
} as const;
69+
5370
// Attachment checkboxes
5471
export enum AttachmentCheckboxLabel {
5572
UPDATED_REQUIRED = "uploaded any attachments that are required to be updated",

bciers/apps/reporting/src/app/components/operations/PastReportsPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export default async function PastReportsPage({
1515
<div className="flex w-full justify-end pb-6">
1616
<Link
1717
className="link-button-blue"
18-
href="../reports/previous-years/report-on-a-previous-year"
18+
href="/reporting/reports/previous-years/report-on-a-previous-year"
1919
>
2020
File previous years report
2121
</Link>

0 commit comments

Comments
 (0)