mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-27 02:42:25 +08:00
fix(core): stuck when quick switch doc mode (#7599)
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import { test } from '@affine-test/kit/playwright';
|
||||
import {
|
||||
ensureInEdgelessMode,
|
||||
ensureInPageMode,
|
||||
getPageMode,
|
||||
} from '@affine-test/kit/utils/editor';
|
||||
import { openHomePage } from '@affine-test/kit/utils/load-page';
|
||||
import {
|
||||
clickNewPageButton,
|
||||
@@ -55,6 +60,40 @@ test('Switch to edgeless by switch edgeless item', async ({ page }) => {
|
||||
}
|
||||
});
|
||||
|
||||
test('Quick Switch Doc Mode, Doc Mode should stable', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await waitForEditorLoad(page);
|
||||
await ensureInEdgelessMode(page);
|
||||
await page.keyboard.down('Alt');
|
||||
await page.keyboard.down('S');
|
||||
await page.keyboard.up('S');
|
||||
await page.keyboard.up('Alt');
|
||||
|
||||
await page.keyboard.down('Alt');
|
||||
await page.keyboard.down('S');
|
||||
await page.keyboard.up('S');
|
||||
await page.keyboard.up('Alt');
|
||||
|
||||
await page.keyboard.down('Alt');
|
||||
await page.keyboard.down('S');
|
||||
await page.keyboard.up('S');
|
||||
await page.keyboard.up('Alt');
|
||||
|
||||
await page.keyboard.down('Alt');
|
||||
await page.keyboard.down('S');
|
||||
await page.keyboard.up('S');
|
||||
await page.keyboard.up('Alt');
|
||||
|
||||
await page.keyboard.down('Alt');
|
||||
await page.keyboard.down('S');
|
||||
await page.keyboard.up('S');
|
||||
await page.keyboard.up('Alt');
|
||||
|
||||
await ensureInPageMode(page);
|
||||
await page.waitForTimeout(1000);
|
||||
expect(await getPageMode(page)).toBe('page');
|
||||
});
|
||||
|
||||
test('Convert to edgeless by editor header items', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await waitForEditorLoad(page);
|
||||
|
||||
@@ -19,3 +19,37 @@ export async function clickPageModeButton(page: Page) {
|
||||
page.locator('[data-testid="switch-page-mode-button"][data-active="true"]')
|
||||
).toBeVisible();
|
||||
}
|
||||
|
||||
export async function ensureInPageMode(page: Page) {
|
||||
await expect(
|
||||
page.locator('[data-testid="switch-page-mode-button"][data-active="true"]')
|
||||
).toBeVisible();
|
||||
}
|
||||
|
||||
export async function ensureInEdgelessMode(page: Page) {
|
||||
await expect(
|
||||
page.locator(
|
||||
'[data-testid="switch-edgeless-mode-button"][data-active="true"]'
|
||||
)
|
||||
).toBeVisible();
|
||||
}
|
||||
|
||||
export async function getPageMode(page: Page): Promise<'page' | 'edgeless'> {
|
||||
if (
|
||||
await page
|
||||
.locator('[data-testid="switch-page-mode-button"][data-active="true"]')
|
||||
.isVisible()
|
||||
) {
|
||||
return 'page';
|
||||
}
|
||||
if (
|
||||
await page
|
||||
.locator(
|
||||
'[data-testid="switch-edgeless-mode-button"][data-active="true"]'
|
||||
)
|
||||
.isVisible()
|
||||
) {
|
||||
return 'edgeless';
|
||||
}
|
||||
throw new Error('Unknown mode');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user