mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-09-21 00:18:02 +03:00
feat: add e2e test for creating multi workspaces
This commit is contained in:
parent
274505590c
commit
9548cc1ed1
@ -23,6 +23,7 @@ export const WorkspaceCard = ({
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<StyledCard
|
||||
data-testid="workspace-card"
|
||||
onClick={() => {
|
||||
onClick(workspaceData);
|
||||
}}
|
||||
|
@ -17,6 +17,7 @@ const config: PlaywrightTestConfig = {
|
||||
browserName: 'chromium',
|
||||
viewport: { width: 1440, height: 800 },
|
||||
actionTimeout: 5 * 1000,
|
||||
locale: 'en-US',
|
||||
// Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer
|
||||
// You can open traces locally(`npx playwright show-trace trace.zip`)
|
||||
// or in your browser on [Playwright Trace Viewer](https://trace.playwright.dev/).
|
||||
|
24
tests/libs/workspace-logic.ts
Normal file
24
tests/libs/workspace-logic.ts
Normal file
@ -0,0 +1,24 @@
|
||||
import type { Page } from '@playwright/test';
|
||||
interface CreateWorkspaceParams {
|
||||
name: string;
|
||||
}
|
||||
export async function createWorkspace(
|
||||
params: CreateWorkspaceParams,
|
||||
page: Page
|
||||
) {
|
||||
// open workspace list modal
|
||||
const workspaceName = page.getByTestId('workspace-name');
|
||||
await workspaceName.click();
|
||||
|
||||
// open create workspace modal
|
||||
await page.locator('.add-icon').click();
|
||||
|
||||
// input workspace name
|
||||
await page.getByPlaceholder('Set a Workspace name').click();
|
||||
await page.getByPlaceholder('Set a Workspace name').fill(params.name);
|
||||
|
||||
// click create button
|
||||
await page.getByRole('button', { name: 'Create' }).click();
|
||||
|
||||
return page.waitForTimeout(300);
|
||||
}
|
40
tests/local-first-workspace-list.spec.ts
Normal file
40
tests/local-first-workspace-list.spec.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import { expect } from '@playwright/test';
|
||||
import { test } from './libs/playwright.js';
|
||||
import { loadPage } from './libs/load-page.js';
|
||||
import { createWorkspace } from './libs/workspace-logic.js';
|
||||
loadPage();
|
||||
|
||||
test.describe('Local first workspace list', () => {
|
||||
test('just one item in the workspace list at first', async ({ page }) => {
|
||||
const workspaceName = page.getByTestId('workspace-name');
|
||||
await workspaceName.click();
|
||||
expect(
|
||||
page
|
||||
.locator('div')
|
||||
.filter({ hasText: 'AFFiNE TestLocal WorkspaceAvailable Offline' })
|
||||
.nth(3)
|
||||
).not.toBeNull();
|
||||
});
|
||||
|
||||
test('create one workspace in the workspace list', async ({ page }) => {
|
||||
const newWorkspaceNameStr = 'New Workspace';
|
||||
await createWorkspace({ name: newWorkspaceNameStr }, page);
|
||||
|
||||
// check new workspace name
|
||||
const newWorkspaceName = page.getByTestId('workspace-name');
|
||||
expect(await newWorkspaceName.textContent()).toBe(newWorkspaceNameStr);
|
||||
});
|
||||
|
||||
test('create multi workspace in the workspace list', async ({ page }) => {
|
||||
await createWorkspace({ name: 'New Workspace 2' }, page);
|
||||
await createWorkspace({ name: 'New Workspace 3' }, page);
|
||||
|
||||
// show workspace list
|
||||
const workspaceName = page.getByTestId('workspace-name');
|
||||
await workspaceName.click();
|
||||
|
||||
//check workspace list length
|
||||
const workspaceCards = await page.$$('data-testid=workspace-card');
|
||||
expect(workspaceCards.length).toBe(3);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user