feat(core): add outline viewer for share page (#8190)

This commit is contained in:
L-Sun
2024-09-10 14:00:16 +00:00
parent daa9d9ff5c
commit 6ce6cb33ef
3 changed files with 63 additions and 3 deletions

View File

@@ -69,6 +69,57 @@ test('can enable share page', async ({ page, browser }) => {
}
});
test('share page should have toc', async ({ page, browser }) => {
await page.reload();
await waitForEditorLoad(page);
await createLocalWorkspace(
{
name: 'test',
},
page
);
await enableCloudWorkspaceFromShareButton(page);
const title = getBlockSuiteEditorTitle(page);
await title.pressSequentially('TEST TITLE', {
delay: 50,
});
await page.keyboard.press('Enter', { delay: 50 });
await page.keyboard.type('# Heading 1');
await page.keyboard.press('Enter');
await page.keyboard.type('# Heading 2');
await page.keyboard.press('Enter');
// enable share page and copy page link
await enableShare(page);
await page.getByTestId('share-menu-copy-link-button').click();
await page.getByTestId('share-link-menu-copy-page').click();
// check share page is accessible
{
const context = await browser.newContext();
await skipOnboarding(context);
const url: string = await page.evaluate(() =>
navigator.clipboard.readText()
);
const page2 = await context.newPage();
await page2.goto(url);
await waitForEditorLoad(page2);
const tocIndicators = page2.locator(
'affine-outline-viewer .outline-viewer-indicator'
);
await expect(tocIndicators).toHaveCount(3);
await expect(tocIndicators.nth(0)).toBeVisible();
await expect(tocIndicators.nth(1)).toBeVisible();
await expect(tocIndicators.nth(2)).toBeVisible();
const viewer = page2.locator('affine-outline-viewer');
await tocIndicators.first().hover({ force: true });
await expect(viewer).toBeVisible();
}
});
test('share page with default edgeless', async ({ page, browser }) => {
await page.reload();
await waitForEditorLoad(page);