Files
AFFiNE-Mirror/tests/blocksuite/e2e/embed-synced-doc/toolbar.spec.ts
L-Sun 61ce1123ae refactor(editor): split synced-doc-block tests to serveral files (#11845)
This PR splits `synced-doc-block.spec.ts` into multiple files for better organization.
2025-04-21 08:54:04 +00:00

74 lines
2.4 KiB
TypeScript

import { expect } from '@playwright/test';
import {
enterPlaygroundRoom,
focusRichText,
initEmptyParagraphState,
waitNextFrame,
} from '../utils/actions';
import { getLinkedDocPopover } from '../utils/actions/linked-doc';
import { test } from '../utils/playwright';
import { initEmbedSyncedDocState } from './utils';
test.describe('embed-synced-doc toolbar', () => {
test.beforeEach(async ({ page }) => {
await enterPlaygroundRoom(page);
});
test('can change linked doc to embed synced doc', async ({ page }) => {
await initEmptyParagraphState(page);
await focusRichText(page);
const { createLinkedDoc } = getLinkedDocPopover(page);
const linkedDoc = await createLinkedDoc('page1');
await linkedDoc.hover();
const toolbar = page.locator('affine-toolbar-widget editor-toolbar');
await expect(toolbar).toBeVisible();
const switchButton = toolbar.getByRole('button', { name: 'Switch view' });
await switchButton.click();
const embedSyncedDocBtn = toolbar.getByRole('button', {
name: 'Embed view',
});
await expect(embedSyncedDocBtn).toBeVisible();
await embedSyncedDocBtn.click();
await waitNextFrame(page, 200);
const embedSyncedBlock = page.locator('affine-embed-synced-doc-block');
expect(await embedSyncedBlock.count()).toBe(1);
});
test('can change embed synced doc to card view', async ({ page }) => {
await initEmbedSyncedDocState(page, [
{ title: 'Root', content: 'Hello from Root' },
{ title: 'Doc 2', content: 'Hello from Doc 2' },
]);
const syncedDoc = page.locator('affine-embed-synced-doc-block');
await syncedDoc.click();
await waitNextFrame(page, 500);
const toolbar = page.locator(
// TODO(@L-Sun): simplify this selector after that toolbar widget are disabled in preview rendering is ready
'affine-page-root > div > affine-toolbar-widget editor-toolbar'
);
await expect(toolbar).toBeVisible();
const switchBtn = toolbar.getByRole('button', { name: 'Switch view' });
await expect(switchBtn).toBeVisible();
await switchBtn.click();
await waitNextFrame(page, 200);
const cardBtn = toolbar.getByRole('button', { name: 'Card view' });
await cardBtn.click();
await waitNextFrame(page, 200);
const embedSyncedBlock = page.locator('affine-embed-linked-doc-block');
expect(await embedSyncedBlock.count()).toBe(1);
});
});