Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

2.5 KB
Raw Blame
import { randomUUID } from "node:crypto";
import { expect, test } from "@playwright/test";

test("sign up, create a workspace with a starter project, and sign in again", async ({
  page,
  context,
}) => {
  const suffix = randomUUID();
  const email = `browser-${suffix}@example.com`;
  const password = `Browser-test-${suffix}`;
  const workspaceName = `Browser test ${suffix.slice(0, 8)}`;

  await page.goto("/auth/sign-up");
  await page.getByLabel("Name", { exact: true }).fill("Browser Tester");
  await page.getByLabel("Email", { exact: true }).fill(email);
  await page.locator('input[name="password"]').fill(password);
  await page
    .getByRole("button", { name: "Create account", exact: true })
    .click();

  await expect(page).toHaveURL(/\/onboarding$/);
  await page.getByLabel("Workspace name", { exact: true }).fill(workspaceName);
  await page.getByRole("button", { name: "Continue", exact: true }).click();
  await expect(
    page.getByRole("heading", { name: "Who's it for?", exact: true }),
  ).toBeVisible();
  await page.getByRole("button", { name: "Continue", exact: true }).click();
  await expect(page.getByLabel("Project name", { exact: true })).toHaveValue(
    "My first project",
  );
  await page.getByRole("button", { name: "Continue", exact: true }).click();
  await expect(
    page.getByRole("heading", {
      name: `${workspaceName} is ready`,
      exact: true,
    }),
  ).toBeVisible();
  await page
    .getByRole("button", { name: `Open ${workspaceName}`, exact: true })
    .click();
  await expect(page).toHaveURL(
    /\/dashboard\/workspace\/[^/]+\/project\/[^/]+\/board$/,
  );
  await expect(
    page.getByText("Drag this card to the next column", { exact: true }),
  ).toBeVisible();
  await expect(
    page.getByText("My first project", { exact: true }).first(),
  ).toBeVisible();
  const boardUrl = page.url();

  // A reload proves that the server persisted the workspace and session.
  await page.reload();
  await expect(page).toHaveURL(boardUrl);
  await expect(
    page.getByText(workspaceName, { exact: true }).first(),
  ).toBeVisible();

  await context.clearCookies();
  await page.goto(boardUrl);
  await expect(page).toHaveURL(/\/auth\/sign-in/);
  await page.getByLabel("Email", { exact: true }).fill(email);
  await page.locator('input[name="password"]').fill(password);
  await page.getByRole("button", { name: "Sign in", exact: true }).click();
  await expect(page).toHaveURL(boardUrl);
  await expect(
    page.getByText(workspaceName, { exact: true }).first(),
  ).toBeVisible();
});