mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
test(02-12): make record switcher journeys deterministic
- Address granted records by their published username\n- Start the profile error mock before record navigation
This commit is contained in:
1 parent
c21957db9f
commit
e568caa2f1
3 files changed
+11
-11
No files matched your search
@@ -15,9 +15,9 @@ async function openProfileRecord(page: Page) {
|
||||
await page.goto("/");
|
||||
await page.getByRole("button", { name: "User menu" }).first().click();
|
||||
await page.locator('[data-slot="account-switcher-trigger"]').click();
|
||||
const entry = page
|
||||
.locator('[data-slot="account-switcher-entry"]')
|
||||
.filter({ hasText: "e2e-scope-profile" });
|
||||
const entry = page.locator(
|
||||
'[data-slot="account-switcher-entry"][data-account-username="e2e-scope-profile"]',
|
||||
);
|
||||
await expect(entry).toHaveCount(1);
|
||||
await entry.click();
|
||||
await expect(page).toHaveURL(/\/profile$/);
|
||||
@@ -60,11 +60,10 @@ test.describe("shared record accessibility states", () => {
|
||||
test("the shared profile read error state has no WCAG violations", async ({
|
||||
page,
|
||||
}) => {
|
||||
await openProfileRecord(page);
|
||||
await page.route("**/api/profile/summary", (route) =>
|
||||
route.fulfill({ status: 500, body: "{}" }),
|
||||
);
|
||||
await page.reload();
|
||||
await openProfileRecord(page);
|
||||
await expect(page.locator('[data-slot="query-error-card"]')).toBeVisible();
|
||||
await scan(page);
|
||||
await leaveRecord(page);
|
||||
|
||||
@@ -30,9 +30,9 @@ async function openRecord(page: Page, username: string) {
|
||||
await page.goto("/");
|
||||
await openSwitcher(page);
|
||||
|
||||
const entry = page
|
||||
.locator('[data-slot="account-switcher-entry"]')
|
||||
.filter({ hasText: username });
|
||||
const entry = page.locator(
|
||||
`[data-slot="account-switcher-entry"][data-account-username="${username}"]`,
|
||||
);
|
||||
await expect(entry).toHaveCount(1);
|
||||
const accountId = await entry.getAttribute("data-account-id");
|
||||
if (accountId === null) {
|
||||
@@ -59,9 +59,9 @@ test.describe.serial("scoped sharing browser journeys", () => {
|
||||
await page.goto("/");
|
||||
await openSwitcher(page);
|
||||
|
||||
const entry = page
|
||||
.locator('[data-slot="account-switcher-entry"]')
|
||||
.filter({ hasText: record.username });
|
||||
const entry = page.locator(
|
||||
`[data-slot="account-switcher-entry"][data-account-username="${record.username}"]`,
|
||||
);
|
||||
await expect(entry).toHaveCount(1);
|
||||
|
||||
const read = page.waitForResponse(
|
||||
|
||||
@@ -89,6 +89,7 @@ export function AccountSwitcherMenuItems() {
|
||||
key={account.accountId}
|
||||
data-slot="account-switcher-entry"
|
||||
data-account-id={account.accountId}
|
||||
data-account-username={account.username}
|
||||
data-access-level={presentation.access}
|
||||
data-record-kind={presentation.recordKind}
|
||||
className="cursor-pointer"
|
||||
|
||||
Reference in new issue
Block a user