mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
fix(component): toast too many times when switch page mode (#2296)
This commit is contained in:
@@ -5,11 +5,26 @@ import { openHomePage } from '../libs/load-page';
|
||||
import { clickPageMoreActions, waitMarkdownImported } from '../libs/page-logic';
|
||||
|
||||
test('Switch to edgeless by switch edgeless item', async ({ page }) => {
|
||||
async function getCount(): Promise<number> {
|
||||
return page.evaluate(() => {
|
||||
return globalThis.__toastCount;
|
||||
});
|
||||
}
|
||||
await openHomePage(page);
|
||||
await waitMarkdownImported(page);
|
||||
const btn = await page.getByTestId('switch-edgeless-mode-button');
|
||||
await page.evaluate(() => {
|
||||
globalThis.__toastCount = 0;
|
||||
window.addEventListener('affine-toast:emit', () => {
|
||||
globalThis.__toastCount++;
|
||||
});
|
||||
});
|
||||
await btn.click();
|
||||
await page.waitForTimeout(100);
|
||||
{
|
||||
const count = await getCount();
|
||||
expect(count).toBe(1);
|
||||
}
|
||||
const edgeless = page.locator('affine-edgeless-page');
|
||||
expect(await edgeless.isVisible()).toBe(true);
|
||||
|
||||
@@ -19,6 +34,18 @@ test('Switch to edgeless by switch edgeless item', async ({ page }) => {
|
||||
return window.getComputedStyle(element).getPropertyValue('padding');
|
||||
});
|
||||
expect(editorWrapperPadding).toBe('0px');
|
||||
{
|
||||
const count = await getCount();
|
||||
expect(count).toBe(1);
|
||||
}
|
||||
await btn.click();
|
||||
await btn.click();
|
||||
await btn.click();
|
||||
await page.waitForTimeout(100);
|
||||
{
|
||||
const count = await getCount();
|
||||
expect(count).toBe(1);
|
||||
}
|
||||
});
|
||||
|
||||
test('Convert to edgeless by editor header items', async ({ page }) => {
|
||||
|
||||
Reference in New Issue
Block a user