AFFiNE/tests/affine-local/e2e/theme.spec.ts

31 lines
1.0 KiB
TypeScript
Raw Normal View History

import { resolve } from 'node:path';
2023-04-28 09:40:44 +03:00
import { test, testResultDir } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic';
2023-02-05 13:41:18 +03:00
import { expect } from '@playwright/test';
2023-02-17 10:33:32 +03:00
2023-04-28 09:40:44 +03:00
// default could be anything, according to the system
test('default white', async ({ browser }) => {
const context = await browser.newContext({
colorScheme: 'light',
2022-11-10 15:51:06 +03:00
});
const page = await context.newPage();
await openHomePage(page);
await waitEditorLoad(page);
const root = page.locator('html');
const themeMode = await root.evaluate(element =>
element.getAttribute('data-theme')
);
expect(themeMode).toBe('light');
2023-04-28 09:40:44 +03:00
await page.screenshot({
path: resolve(testResultDir, 'affine-light-theme.png'),
});
await page.getByTestId('editor-option-menu').click();
await page.getByTestId('change-theme-dark').click();
await page.waitForTimeout(50);
2023-04-28 09:40:44 +03:00
await page.screenshot({
path: resolve(testResultDir, 'affine-dark-theme.png'),
});
2022-11-10 15:51:06 +03:00
});