merge: integrate macOS popup compositing fix
This commit is contained in:
62
tests/e2e/popup-performance.spec.ts
Normal file
62
tests/e2e/popup-performance.spec.ts
Normal file
@@ -0,0 +1,62 @@
|
||||
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 only on macOS', 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 page.evaluate(() => {
|
||||
document.documentElement.dataset.platform = 'darwin';
|
||||
});
|
||||
await expect.poll(() => readPopupStyles(page)).toEqual({
|
||||
contentBackdropFilter: 'none',
|
||||
overlayBackdropFilter: 'none',
|
||||
});
|
||||
|
||||
await page.evaluate(() => {
|
||||
document.documentElement.dataset.platform = 'win32';
|
||||
});
|
||||
const nonMacStyles = await readPopupStyles(page);
|
||||
expect(nonMacStyles.contentBackdropFilter).not.toBe('none');
|
||||
expect(nonMacStyles.overlayBackdropFilter).not.toBe('none');
|
||||
} finally {
|
||||
await app.evaluate(({ app: electronApp }) => electronApp.quit());
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user