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.
15839 - E2e tests (mock data) for all of Org/Receiver/Sender Settings…
… Pages (#15921) * 15839 - E2e tests (mock data) for all of Org/Receiver/Sender Settings Pages Fixed last Mile Failures e2e broken test * 15839 - added data-test-id for e2e testing * 15839 - fixed indentation * 15839 - added optional heading param to BasePage.ts
- Loading branch information
1 parent
b6bd185
commit f97a602
Showing
16 changed files
with
1,456 additions
and
429 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
6 changes: 3 additions & 3 deletions
6
...pages/authenticated/last-mile-failures.ts → ...authenticated/admin/last-mile-failures.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
4 changes: 2 additions & 2 deletions
4
...2e/pages/authenticated/message-details.ts → ...es/authenticated/admin/message-details.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
4 changes: 2 additions & 2 deletions
4
.../pages/authenticated/message-id-search.ts → .../authenticated/admin/message-id-search.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
182 changes: 182 additions & 0 deletions
182
frontend-react/e2e/pages/authenticated/admin/organization-edit.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,182 @@ | ||
import { expect, Locator, Page } from "@playwright/test"; | ||
import { RSReceiver, RSSender } from "../../../../src/config/endpoints/settings"; | ||
import { formatDate } from "../../../../src/utils/misc"; | ||
import { | ||
MOCK_GET_ORGANIZATION_IGNORE, | ||
MOCK_GET_RECEIVERS_IGNORE, | ||
MOCK_GET_SENDERS_IGNORE | ||
} from "../../../mocks/organizations"; | ||
import { BasePage, BasePageTestArgs, type RouteHandlerFulfillEntry } from "../../BasePage"; | ||
|
||
export class OrganizationEditPage extends BasePage { | ||
static readonly URL_ORGANIZATION_EDIT = `/admin/orgsettings/org/ignore`; | ||
static readonly API_ORGANIZATION_IGNORE = "/api/settings/organizations/ignore"; | ||
static readonly API_SENDERS = "/api/settings/organizations/ignore/senders"; | ||
static readonly API_RECEIVERS = "/api/settings/organizations/ignore/receivers"; | ||
protected _organizationSenders: RSSender[]; | ||
protected _organizationReceivers: RSReceiver[]; | ||
|
||
readonly orgSenderNew: { | ||
cancel: Locator; | ||
save: Locator; | ||
} | ||
readonly orgSenderEdit: { | ||
modal: Locator; | ||
cancelButton: Locator; | ||
editJsonButton: Locator; | ||
editJsonModal: { | ||
save: Locator; | ||
checkSyntax: Locator; | ||
back: Locator; | ||
}; | ||
} | ||
readonly orgReceiverNew: { | ||
cancel: Locator; | ||
save: Locator; | ||
} | ||
readonly orgReceiverEdit: { | ||
modal: Locator; | ||
cancelButton: Locator; | ||
editJsonButton: Locator; | ||
editJsonModal: { | ||
save: Locator; | ||
checkSyntax: Locator; | ||
back: Locator; | ||
}; | ||
} | ||
|
||
constructor(testArgs: BasePageTestArgs) { | ||
super( | ||
{ | ||
url: OrganizationEditPage.URL_ORGANIZATION_EDIT, | ||
title: "Organization edit - Admin", | ||
}, | ||
testArgs, | ||
); | ||
|
||
this._organizationSenders = []; | ||
this._organizationReceivers = []; | ||
|
||
this.addMockRouteHandlers( | ||
[this.createMockOrganizationIgnoreAPIHandler(), | ||
this.createMockOrganizationSenderAPIHandler(), | ||
this.createMockOrganizationReceiverAPIHandler()] | ||
); | ||
this.orgSenderNew = { | ||
cancel: this.page.getByRole("button", { | ||
name: "Cancel", | ||
}), | ||
save: this.page.getByRole("button", { | ||
name: "Save", | ||
}), | ||
} | ||
this.orgSenderEdit = { | ||
modal: this.page.getByTestId("modalWindow"), | ||
cancelButton: this.page.getByRole("button", { | ||
name: "Cancel", | ||
}), | ||
editJsonButton: this.page.getByRole("button", { | ||
name: "Edit json and save...", | ||
}), | ||
editJsonModal: { | ||
save: this.page.getByTestId("editCompareSaveButton"), | ||
checkSyntax: this.page.getByTestId("editCheckSyntaxButton"), | ||
back: this.page.getByRole("button", { | ||
name: "Back", | ||
}), | ||
} | ||
} | ||
this.orgReceiverNew = { | ||
cancel: this.page.getByRole("button", { | ||
name: "Cancel", | ||
}), | ||
save: this.page.getByRole("button", { | ||
name: "Save", | ||
}), | ||
} | ||
|
||
this.orgReceiverEdit = { | ||
modal: this.page.getByTestId("modalWindow"), | ||
cancelButton: this.page.getByRole("button", { | ||
name: "Cancel", | ||
}), | ||
editJsonButton: this.page.getByRole("button", { | ||
name: "Edit json and save...", | ||
}), | ||
editJsonModal: { | ||
save: this.page.getByTestId("editCompareSaveButton"), | ||
checkSyntax: this.page.getByTestId("editCheckSyntaxButton"), | ||
back: this.page.getByRole("button", { | ||
name: "Back", | ||
}), | ||
} | ||
} | ||
} | ||
|
||
get isPageLoadExpected() { | ||
return super.isPageLoadExpected && this.testArgs.storageState === this.testArgs.adminLogin.path; | ||
} | ||
|
||
createMockOrganizationIgnoreAPIHandler(): RouteHandlerFulfillEntry { | ||
return [ | ||
OrganizationEditPage.API_ORGANIZATION_IGNORE, | ||
() => { | ||
return { | ||
json: MOCK_GET_ORGANIZATION_IGNORE, | ||
}; | ||
}, | ||
]; | ||
} | ||
|
||
createMockOrganizationSenderAPIHandler(): RouteHandlerFulfillEntry { | ||
return [ | ||
OrganizationEditPage.API_SENDERS, | ||
() => { | ||
return { | ||
json: MOCK_GET_SENDERS_IGNORE, | ||
}; | ||
}, | ||
]; | ||
} | ||
|
||
createMockOrganizationReceiverAPIHandler(): RouteHandlerFulfillEntry { | ||
return [ | ||
OrganizationEditPage.API_RECEIVERS, | ||
() => { | ||
return { | ||
json: MOCK_GET_RECEIVERS_IGNORE, | ||
}; | ||
}, | ||
]; | ||
} | ||
|
||
async testTableHeaders() { | ||
await expect(this.page.locator(".usa-table th").nth(0)).toHaveText(/Name/); | ||
await expect(this.page.locator(".usa-table th").nth(1)).toHaveText(/Org Name/); | ||
await expect(this.page.locator(".usa-table th").nth(2)).toHaveText(/Topic/); | ||
await expect(this.page.locator(".usa-table th").nth(3)).toHaveText(/Status/); | ||
await expect(this.page.locator(".usa-table th").nth(4)).toHaveText(/Meta/); | ||
await expect(this.page.locator(".usa-table th").nth(4)).toHaveText(/Action/); | ||
|
||
return true; | ||
} | ||
|
||
getOrgMeta(metaData: any){ | ||
const { version, createdAt, createdBy } = metaData; | ||
|
||
// handle cases where individual metadata are not available | ||
const versionDisplay = version || version === 0 ? `v${version} ` : ""; | ||
const createdAtDisplay = createdAt | ||
? `[${formatDate(metaData.createdAt)}] ` | ||
: ""; | ||
const createdByDisplay = createdBy ?? ""; | ||
|
||
return `${versionDisplay}${createdAtDisplay}${createdByDisplay}`; | ||
} | ||
|
||
getApplyButton(page: Page) { | ||
return page.getByRole("button", { | ||
name: "Apply", | ||
}); | ||
} | ||
} |
6 changes: 3 additions & 3 deletions
6
...t/e2e/pages/authenticated/organization.ts → ...pages/authenticated/admin/organization.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
2 changes: 1 addition & 1 deletion
2
frontend-react/e2e/spec/all/authenticated/admin/last-mile-failures-page.spec.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
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
2 changes: 1 addition & 1 deletion
2
frontend-react/e2e/spec/all/authenticated/admin/message-id-search-page.spec.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
Oops, something went wrong.