61 lines
2.3 KiB
TypeScript
61 lines
2.3 KiB
TypeScript
import { expect, getStableWindow, test } from './fixtures/electron';
|
|
|
|
type PopupStyles = {
|
|
contentBackdropFilter: string;
|
|
overlayBackdropFilter: string;
|
|
};
|
|
|
|
async function readPopupStyles(page: Awaited<ReturnType<typeof getStableWindow>>): Promise<PopupStyles> {
|
|
return await page.evaluate(() => {
|
|
const content = document.querySelector<HTMLElement>('[role="dialog"]');
|
|
const overlay = [...document.querySelectorAll<HTMLElement>('.fixed.inset-0')]
|
|
.find((element) => element.getAttribute('role') !== 'dialog');
|
|
if (!overlay || !content) {
|
|
throw new Error('Expected the open dialog overlay and content');
|
|
}
|
|
|
|
const contentStyle = getComputedStyle(content);
|
|
const overlayStyle = getComputedStyle(overlay);
|
|
return {
|
|
contentBackdropFilter: contentStyle.backdropFilter,
|
|
overlayBackdropFilter: overlayStyle.backdropFilter,
|
|
};
|
|
});
|
|
}
|
|
|
|
test.describe('shared popup rendering cost', () => {
|
|
test('disables transient popup backdrop filters on every platform', async ({ launchElectronApp }) => {
|
|
const app = await launchElectronApp({ skipSetup: true });
|
|
|
|
try {
|
|
const page = await getStableWindow(app);
|
|
const actualPlatform = await page.evaluate(() => window.electron.platform);
|
|
await expect(page.locator('html')).toHaveAttribute('data-platform', actualPlatform);
|
|
|
|
await expect(page.getByTestId('ai-module-selection-page')).toBeVisible();
|
|
await page.getByTestId('ai-module-option-programming').click();
|
|
await expect(page.getByTestId('main-layout')).toBeVisible();
|
|
await page.getByTestId('sidebar-member-menu-trigger').click();
|
|
await page.getByTestId('sidebar-nav-settings').click();
|
|
await expect(page.getByTestId('settings-page')).toBeVisible();
|
|
await page.getByTestId('settings-reveal-additional').click();
|
|
await expect(page.getByRole('dialog')).toBeVisible();
|
|
|
|
await expect.poll(() => readPopupStyles(page)).toEqual({
|
|
contentBackdropFilter: 'none',
|
|
overlayBackdropFilter: 'none',
|
|
});
|
|
|
|
await page.evaluate(() => {
|
|
document.documentElement.dataset.platform = 'win32';
|
|
});
|
|
await expect.poll(() => readPopupStyles(page)).toEqual({
|
|
contentBackdropFilter: 'none',
|
|
overlayBackdropFilter: 'none',
|
|
});
|
|
} finally {
|
|
await app.evaluate(({ app: electronApp }) => electronApp.quit());
|
|
}
|
|
});
|
|
});
|