BangSo/apps/web/e2e/onboarding-conversation.spe...

59 lines
2.4 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { expect, type Page, test } from "@playwright/test";
import { captureScreenshot, completeOnboarding, rpc, signup } from "./helpers";
function slackCard(page: Page) {
return page.getByRole("group", { name: "Slack connection" });
}
test("focus choice suggests apps and preserves a completed connection", async ({
page,
}, testInfo) => {
const stamp = Date.now();
await signup(page, `onboarding-${stamp}@rakazo.test`, "password12", "Robin");
await completeOnboarding(page);
await expect(
page.getByText("Hey Robin. Fresh start on my side, so Ill keep this short."),
).toBeVisible();
await expect(page.getByText("What do you want me on first?", { exact: true })).toBeVisible();
await page.mouse.move(1, 1);
await captureScreenshot(page, testInfo, "01-focus-choice");
await page.getByRole("button", { name: /Day-to-day work/ }).click();
// The focus step suggests apps but must not rename the bot: the name the
// user chose during creation ("Chief") is preserved.
await expect(page.locator("main").getByText("Chief", { exact: true })).toBeVisible();
await expect(page.getByPlaceholder("Message Chief")).toBeVisible();
await expect(page.getByText("Slack", { exact: true })).toBeVisible();
await expect(page.getByText("Gmail", { exact: true })).toBeVisible();
await page
.getByTestId("transcript")
.getByText("Hit those three and Ill start pulling the picture.")
.scrollIntoViewIfNeeded();
await page.mouse.move(1, 1);
await captureScreenshot(page, testInfo, "02-app-suggestions");
await slackCard(page).getByRole("button", { name: "Authorize" }).click();
await expect(slackCard(page).getByText("Connected", { exact: true })).toBeVisible();
await expect(slackCard(page).getByText("Connected", { exact: true })).toHaveCSS("opacity", "1");
await expect
.poll(async () => {
const connections = await rpc<Array<{ provider: string; status: string }>>(
page,
"connections/list",
{},
);
return connections.some(
(connection) => connection.provider === "SLACK" && connection.status === "connected",
);
})
.toBe(true);
await page.mouse.move(1, 1);
await captureScreenshot(page, testInfo, "03-slack-connected");
await page.reload();
await expect(slackCard(page).getByText("Connected", { exact: true })).toBeVisible();
await page.mouse.move(1, 1);
await captureScreenshot(page, testInfo, "04-connected-after-reload");
});