Skip to content

Commit

Permalink
test(e2e): Add coverage for recent user permission changes
Browse files Browse the repository at this point in the history
  • Loading branch information
DafyddLlyr committed Oct 5, 2023
1 parent fa02fbe commit a6143fa
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions e2e/tests/ui-driven/src/create-flow.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,66 @@ test.describe("Navigation", () => {
await expect(nodes.getByText(noBranchNoticeText)).toBeVisible();
});

test("user data persists on page refresh @regression", async ({
browser,
}) => {
const page = await createAuthenticatedSession({
browser,
userId: context.user!.id!,
});

let getUserRequestCount = 0;
page.on("request", (req) => {
const isHasuraRequest = req.url().includes("/graphql");
const isGetUserRequest =
isHasuraRequest && req.postData()?.toString().includes("GetUserById");

if (isGetUserRequest) getUserRequestCount++;
});

await page.goto("/");
await page.waitForLoadState("networkidle");

// Get user data on initial page load
expect(getUserRequestCount).toBe(1);

const team = page.locator("h2", { hasText: context.team.name });
team.click();
await page.waitForLoadState("networkidle");

// User data not refetched on navigation to a new page
expect(getUserRequestCount).toBe(1);

// User data is refetched when page reloaded
await page.reload();
await page.waitForLoadState("networkidle");
expect(getUserRequestCount).toBe(2);
});

test("team data persists on page refresh @regression", async ({
browser,
}) => {
const page = await createAuthenticatedSession({
browser,
userId: context.user!.id!,
});

await page.goto("/");
const team = page.locator("h2", { hasText: context.team.name });
await team.click();

const teamSlugInHeader = page.getByRole("link", {
name: context.team.slug,
});
await expect(teamSlugInHeader).toBeVisible();

await page.reload();
await expect(teamSlugInHeader).toBeVisible();

await page.goBack();
await expect(teamSlugInHeader).toBeHidden();
});

test("Preview a created flow", async ({ browser }: { browser: Browser }) => {
const page = await createAuthenticatedSession({
browser,
Expand Down

0 comments on commit a6143fa

Please sign in to comment.