mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-23 19:42:19 +03:00
75e02bb088
close AF-1170 - bump `@toeverything/theme` - refactor page-mode-switch - use global `<RadioGroup />` - reuse for doc history - remove `styled` usage - bind hotkey via cmdk - Update `<RadioGroup />` color scheme with latest design system - Update right sidebar header tab style - Update tooltip with shortcut for app nav button
44 lines
1.3 KiB
TypeScript
44 lines
1.3 KiB
TypeScript
import { expect, type Page } from '@playwright/test';
|
|
|
|
export function locateModeSwitchButton(
|
|
page: Page,
|
|
mode: 'page' | 'edgeless',
|
|
active?: boolean
|
|
) {
|
|
// switch is implemented as RadioGroup button,
|
|
// so we can use aria-checked to determine the active state
|
|
const checkedSelector = active ? '[aria-checked="true"]' : '';
|
|
|
|
return page.locator(
|
|
`[data-testid="switch-${mode}-mode-button"]${checkedSelector}`
|
|
);
|
|
}
|
|
|
|
export async function clickEdgelessModeButton(page: Page) {
|
|
await locateModeSwitchButton(page, 'edgeless').click({ delay: 50 });
|
|
await ensureInEdgelessMode(page);
|
|
}
|
|
|
|
export async function clickPageModeButton(page: Page) {
|
|
await locateModeSwitchButton(page, 'page').click({ delay: 50 });
|
|
await ensureInPageMode(page);
|
|
}
|
|
|
|
export async function ensureInPageMode(page: Page) {
|
|
await expect(locateModeSwitchButton(page, 'page', true)).toBeVisible();
|
|
}
|
|
|
|
export async function ensureInEdgelessMode(page: Page) {
|
|
await expect(locateModeSwitchButton(page, 'edgeless', true)).toBeVisible();
|
|
}
|
|
|
|
export async function getPageMode(page: Page): Promise<'page' | 'edgeless'> {
|
|
if (await locateModeSwitchButton(page, 'page', true).isVisible()) {
|
|
return 'page';
|
|
}
|
|
if (await locateModeSwitchButton(page, 'edgeless', true).isVisible()) {
|
|
return 'edgeless';
|
|
}
|
|
throw new Error('Unknown mode');
|
|
}
|