Skip to content

Commit

Permalink
Merge pull request #17298 from CDCgov/deployment/2025-02-06
Browse files Browse the repository at this point in the history
Deployment of 2025-02-06
  • Loading branch information
adegolier authored Feb 6, 2025
2 parents f42c280 + c00ff52 commit b0a2dc3
Show file tree
Hide file tree
Showing 20 changed files with 937 additions and 163 deletions.
10 changes: 2 additions & 8 deletions frontend-react/.storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@ import type { StorybookConfig } from "@storybook/react-vite";
import remarkToc from "remark-mdx-toc";

const config: StorybookConfig = {
stories: [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)",
],
stories: ["../src/**/*.stories.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"],
addons: [
"storybook-addon-remix-react-router",
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
Expand All @@ -30,9 +26,7 @@ const config: StorybookConfig = {
core: {},
async viteFinal(config, { configType }) {
// Exclude our mdx plugin from vite config in favor of storybook's
config.plugins = config.plugins?.filter(
(x: any, i) => x.name !== "@mdx-js/rollup",
);
config.plugins = config.plugins?.filter((x: any, i) => x.name !== "@mdx-js/rollup");

return {
...config,
Expand Down
116 changes: 116 additions & 0 deletions frontend-react/e2e/mocks/message-test.ts

Large diffs are not rendered by default.

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)];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class OrganizationPage extends BasePage {
}

get isPageLoadExpected() {
return super.isPageLoadExpected && this.testArgs.storageState === this.testArgs.adminLogin.path;
return super.isPageLoadExpected && this.isAdminSession;
}

createMockOrganizationHandler(): RouteHandlerFulfillEntry {
Expand Down
Loading

0 comments on commit b0a2dc3

Please sign in to comment.