diff --git a/playwright/src/pages/BoardPage.ts b/playwright/src/pages/BoardPage.ts index e1825462..f589b8cc 100644 --- a/playwright/src/pages/BoardPage.ts +++ b/playwright/src/pages/BoardPage.ts @@ -287,10 +287,14 @@ export function BoardPage(page: Page, browser: Browser) { await this.assertSelected(items[i], true) } }, - userInfo: { - async dismiss() { - await page.locator(".user-info button").click() - }, + async setNickname(nickname: string) { + await page + .locator(".user-info .icon") + .or(page.locator(".user-info .nickname")) + .first() + .click({ force: true }) + await page.locator(".user-info .nickname input").fill(nickname) + await page.locator(".user-info button").click() }, contextMenu: ContextMenu(page), async deleteIndexedDb() { diff --git a/playwright/src/pages/DashboardPage.ts b/playwright/src/pages/DashboardPage.ts index 4a94d2df..341be6d2 100644 --- a/playwright/src/pages/DashboardPage.ts +++ b/playwright/src/pages/DashboardPage.ts @@ -1,4 +1,4 @@ -import { Browser, Page, selectors } from "@playwright/test" +import { Browser, Page, selectors, test } from "@playwright/test" import { BoardPage, semiUniqueId, NewBoardOptions } from "./BoardPage" export async function navigateToDashboard(page: Page, browser: Browser) { @@ -10,17 +10,20 @@ export async function navigateToDashboard(page: Page, browser: Browser) { export function DashboardPage(page: Page, browser: Browser) { return { async createNewBoard(options?: NewBoardOptions) { - const name = options?.boardName ?? `Test board ${semiUniqueId()}` - const useCRDT = options?.useCRDT ?? true + return await test.step("Create new board", async () => { + const name = options?.boardName ?? `Test board ${semiUniqueId()}` + const useCRDT = options?.useCRDT ?? true - await page.getByPlaceholder("Enter board name").fill(name) - if (useCRDT) { - await page.getByText("use collaborative text editor").click() - } - await page.getByRole("button", { name: "Create" }).click() - const board = BoardPage(page, browser) - await board.assertBoardName(name) - return board + await page.getByPlaceholder("Enter board name").fill(name) + if (useCRDT) { + await page.getByText("use collaborative text editor").click() + } + await page.getByRole("button", { name: "Create" }).click() + const board = BoardPage(page, browser) + // TODO: this is flaky in at least "Switching between boards" + await board.assertBoardName(name) + return board + }) }, async goToBoard(name: string) { await page.locator(".recent-boards li").filter({ hasText: name }).first().click() diff --git a/playwright/src/tests/board.spec.ts b/playwright/src/tests/board.spec.ts index aa092230..a14472ea 100644 --- a/playwright/src/tests/board.spec.ts +++ b/playwright/src/tests/board.spec.ts @@ -184,7 +184,7 @@ test.describe("Basic board functionality", () => { await test.step("Check with new session", async () => { const newBoard = await board.openBoardInNewBrowser() - await newBoard.userInfo.dismiss() + await newBoard.setNickname("User 2") await expect(newBoard.getNote("Monads")).toBeVisible() }) }) @@ -208,7 +208,7 @@ test.describe("Basic board functionality", () => { await test.step("Check with new session", async () => { await board.deleteIndexedDb() const newBoard = await board.openBoardInNewBrowser() - await newBoard.userInfo.dismiss() + await newBoard.setNickname("User 2") await expect(newBoard.getArea("Monads")).toBeVisible() }) }) @@ -256,7 +256,7 @@ test.describe("Basic board functionality", () => { await test.step("Check with new session", async () => { await board.deleteIndexedDb() const newBoard = await board.openBoardInNewBrowser() - await newBoard.userInfo.dismiss() + await newBoard.setNickname("User 2") await expect(newBoard.getNote("text")).not.toBeVisible() }) }) @@ -311,7 +311,7 @@ test.describe("Basic board functionality", () => { await test.step("Check with new session", async () => { await board.deleteIndexedDb() const newBoard = await board.openBoardInNewBrowser() - await newBoard.userInfo.dismiss() + await newBoard.setNickname("User 2") await expect(newBoard.getArea("Semigroups")).toBeVisible() }) }) diff --git a/playwright/src/tests/collaboration.spec.ts b/playwright/src/tests/collaboration.spec.ts index cba91a33..878a30fe 100644 --- a/playwright/src/tests/collaboration.spec.ts +++ b/playwright/src/tests/collaboration.spec.ts @@ -15,6 +15,13 @@ test.describe("Two simultaneous users", () => { await expect(userPage.getNote(anotherUserPageNoteText)).toBeVisible() }) + test("Change board name", async ({ page, browser }) => { + const { user1Page: userPage, user2Page } = await createBoardWithTwoUsers(page, browser) + // create 2 notes, one on each page + await userPage.renameBoard("Renamed board") + await user2Page.assertBoardName("Renamed board") + }) + const onTopPart = { position: { x: 9, y: 15 } } as const test("Users can collaboratively edit a text area", async ({ page, browser }) => { @@ -126,12 +133,14 @@ test.describe("Two simultaneous users", () => { async function createBoardWithTwoUsers(page: Page, browser: Browser) { const user1Page = await navigateToNewBoard(page, browser, { boardName: "Collab test board" }) + await user1Page.setNickname("User 1") const boardId = user1Page.getBoardId() const user2Page = await user1Page.openBoardInNewBrowser() + await user2Page.setNickname("User 2") - await user1Page.userInfo.dismiss() - await user2Page.userInfo.dismiss() + await user1Page.assertBoardName("Collab test board") + await user2Page.assertBoardName("Collab test board") return { user1Page, user2Page, boardId } }