fix(editor): inline latex editor should not be shown when doc is readonly (#9794)

[BS-2442](https://linear.app/affine-design/issue/BS-2442/只读时-inline-latex-node-点击不应该弹出-modal)
This commit is contained in:
donteatfriedrice
2025-01-20 15:44:07 +00:00
parent 092f9c84fa
commit f995f216bd
2 changed files with 65 additions and 0 deletions

View File

@@ -347,3 +347,61 @@ test('Should show no permission page when the share page is not found', async ({
page.getByText('You do not have access or this content does not exist.')
).toBeVisible();
});
test('Inline latex modal should be not shown in shared mode when clicking', 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('$$E=mc^2$$');
await page.keyboard.press('Space');
// there should be a inline latex node
const latexLocator = page.locator('affine-latex-node');
await expect(latexLocator).toBeVisible();
// click the latex node
// the latex editor should be shown when the doc can be editing
await latexLocator.click();
const modalLocator = page.locator('.latex-editor-container');
await expect(modalLocator).toBeVisible();
// 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);
// click the latex node
const latexLocator = page2.locator('affine-latex-node');
await latexLocator.click();
// the latex editor should not be shown when the doc is readonly
const modalLocator = page2.locator('.latex-editor-container');
await expect(modalLocator).not.toBeVisible();
}
});