generated from CDCgov/template
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17298 from CDCgov/deployment/2025-02-06
Deployment of 2025-02-06
- Loading branch information
Showing
20 changed files
with
937 additions
and
163 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
122 changes: 122 additions & 0 deletions
122
frontend-react/e2e/pages/authenticated/admin/organization-receiver-message-test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
import type { Locator } from "@playwright/test"; | ||
import language from "../../../../src/components/Admin/MessageTesting/language.json" assert { type: "json" }; | ||
import { | ||
errorMessageResult, | ||
passMessageResult, | ||
} from "../../../../src/components/Admin/MessageTesting/MessageTestingResult.fixtures"; | ||
import { RSMessage } from "../../../../src/config/endpoints/reports"; | ||
import { MOCK_GET_TEST_MESSAGES } from "../../../mocks/message-test"; | ||
import { BasePage, BasePageTestArgs, type RouteHandlerFulfillEntry } from "../../BasePage"; | ||
|
||
/** | ||
* Uses org ignore's FULL_ELR receiver | ||
*/ | ||
export class OrganizationReceiverMessageTestPage extends BasePage { | ||
static readonly API_REPORTS_TESTING = "/api/reports/testing"; | ||
static readonly API_REPORTS_TEST = "/api/reports/testing/test?*"; | ||
protected customI: number; | ||
testMessages: RSMessage[]; | ||
|
||
readonly expectedStatusSuccess = new RegExp(`^${language.successAlertHeading}`); | ||
readonly expectedStatusFailure = new RegExp(`^${language.errorAlertHeading}`); | ||
|
||
readonly form: Locator; | ||
readonly addCustomMessageButton: Locator; | ||
readonly submitCustomMessageButton: Locator; | ||
readonly cancelCustomMessageButton: Locator; | ||
readonly customMessageTextArea: Locator; | ||
readonly submitButton: Locator; | ||
readonly submitStatus: Locator; | ||
readonly submitAlert: Locator; | ||
readonly submissionOutputMessageButton: Locator; | ||
readonly submissionOutputMessage: Locator; | ||
readonly submissionTestMessageButton: Locator; | ||
readonly submissionTestMessage: Locator; | ||
readonly submissionTransformErrorsButton: Locator; | ||
readonly submissionTransformErrors: Locator; | ||
|
||
constructor(testArgs: BasePageTestArgs) { | ||
super( | ||
{ | ||
url: "/admin/orgreceiversettings/org/ignore/receiver/FULL_ELR/action/edit/message-testing", | ||
title: "Message testing - ReportStream", | ||
heading: testArgs.page.getByRole("heading", { | ||
name: "Message testing", | ||
}), | ||
}, | ||
testArgs, | ||
); | ||
|
||
this.testMessages = []; | ||
this.customI = 0; | ||
this.form = this.page.getByRole("form"); | ||
this.addCustomMessageButton = this.form.getByRole("button", { name: "Test custom message" }); | ||
this.submitCustomMessageButton = this.form.getByRole("button", { name: "Add" }); | ||
this.cancelCustomMessageButton = this.form.getByRole("button", { name: "Cancel" }); | ||
this.customMessageTextArea = this.form.getByRole("textbox", { name: "Custom message text" }); | ||
this.submitButton = this.form.getByRole("button", { name: "Run test" }); | ||
this.submitStatus = this.page.getByRole("status"); | ||
this.submitAlert = this.page.getByRole("alert"); | ||
this.submissionOutputMessageButton = this.page.getByRole("button", { name: "Output message" }); | ||
this.submissionOutputMessage = this.page.getByLabel("Output message"); | ||
this.submissionTestMessageButton = this.page.getByRole("button", { name: "Test message" }); | ||
this.submissionTestMessage = this.page.getByLabel("Test message"); | ||
this.submissionTransformErrorsButton = this.page.getByRole("button", { name: "Transform errors" }); | ||
this.submissionTransformErrors = this.page.getByLabel("Transform errors"); | ||
this.addMockRouteHandlers([this.createMockTestMessagesHandler()]); | ||
this.addResponseHandlers([ | ||
[ | ||
OrganizationReceiverMessageTestPage.API_REPORTS_TESTING, | ||
async (res) => (this.testMessages = await res.json()), | ||
], | ||
]); | ||
} | ||
|
||
get isPageLoadExpected() { | ||
return super.isPageLoadExpected && this.isAdminSession; | ||
} | ||
|
||
createMockTestMessagesHandler(): RouteHandlerFulfillEntry { | ||
return [ | ||
OrganizationReceiverMessageTestPage.API_REPORTS_TESTING, | ||
() => { | ||
return { | ||
json: MOCK_GET_TEST_MESSAGES, | ||
}; | ||
}, | ||
]; | ||
} | ||
|
||
createMockTestSubmissionHandler(isFailed = false): RouteHandlerFulfillEntry { | ||
const result = isFailed ? errorMessageResult : passMessageResult; | ||
return [ | ||
OrganizationReceiverMessageTestPage.API_REPORTS_TEST, | ||
() => { | ||
return { | ||
json: result, | ||
}; | ||
}, | ||
]; | ||
} | ||
|
||
addMockTestSubmissionHandler(isFailed = false) { | ||
return this.addMockRouteHandlers([this.createMockTestSubmissionHandler(isFailed)]); | ||
} | ||
|
||
async submit() { | ||
const p = this.route(); | ||
const reqP = this.page.waitForRequest(OrganizationReceiverMessageTestPage.API_REPORTS_TEST); | ||
await this.submitButton.click(); | ||
await p; | ||
return reqP; | ||
} | ||
|
||
async addCustomMessage(message: string) { | ||
await this.addCustomMessageButton.click(); | ||
await this.customMessageTextArea.fill(message); | ||
await this.submitCustomMessageButton.click(); | ||
this.customI++; | ||
const fileName = `Custom message ${this.customI}`; | ||
return [this.form.getByLabel(fileName), this.form.getByText(fileName)]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.