mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-11 20:08:37 +00:00
test(electron): theme check (#2182)
This commit is contained in:
@@ -1,15 +1,33 @@
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
import { test } from '@affine-test/kit/playwright';
|
||||
import { test, testResultDir } from '@affine-test/kit/playwright';
|
||||
import type { Page } from '@playwright/test';
|
||||
import { expect } from '@playwright/test';
|
||||
import type { ElectronApplication } from 'playwright';
|
||||
import { _electron as electron } from 'playwright';
|
||||
|
||||
test('new page', async () => {
|
||||
const electronApp = await electron.launch({
|
||||
let electronApp: ElectronApplication;
|
||||
let page: Page;
|
||||
|
||||
test.beforeEach(async () => {
|
||||
electronApp = await electron.launch({
|
||||
args: [resolve(__dirname, '..')],
|
||||
executablePath: resolve(__dirname, '../node_modules/.bin/electron'),
|
||||
colorScheme: 'light',
|
||||
});
|
||||
const page = await electronApp.firstWindow();
|
||||
page = await electronApp.firstWindow();
|
||||
// cleanup page data
|
||||
await page.evaluate(() => localStorage.clear());
|
||||
});
|
||||
|
||||
test.afterEach(async () => {
|
||||
// cleanup page data
|
||||
await page.evaluate(() => localStorage.clear());
|
||||
await page.close();
|
||||
await electronApp.close();
|
||||
});
|
||||
|
||||
test('new page', async () => {
|
||||
await page.getByTestId('new-page-button').click({
|
||||
delay: 100,
|
||||
});
|
||||
@@ -19,15 +37,34 @@ test('new page', async () => {
|
||||
() => globalThis.currentWorkspace.flavour
|
||||
);
|
||||
expect(flavour).toBe('local');
|
||||
await electronApp.close();
|
||||
});
|
||||
|
||||
test('app theme', async () => {
|
||||
await page.waitForSelector('v-line');
|
||||
const root = page.locator('html');
|
||||
{
|
||||
const themeMode = await root.evaluate(element =>
|
||||
element.getAttribute('data-theme')
|
||||
);
|
||||
expect(themeMode).toBe('light');
|
||||
}
|
||||
await page.screenshot({
|
||||
path: resolve(testResultDir, 'affine-light-theme-electron.png'),
|
||||
});
|
||||
await page.getByTestId('change-theme-dark').click();
|
||||
await page.waitForTimeout(50);
|
||||
{
|
||||
const themeMode = await root.evaluate(element =>
|
||||
element.getAttribute('data-theme')
|
||||
);
|
||||
expect(themeMode).toBe('dark');
|
||||
}
|
||||
await page.screenshot({
|
||||
path: resolve(testResultDir, 'affine-dark-theme-electron.png'),
|
||||
});
|
||||
});
|
||||
|
||||
test('affine cloud disabled', async () => {
|
||||
const electronApp = await electron.launch({
|
||||
args: [resolve(__dirname, '..')],
|
||||
executablePath: resolve(__dirname, '../node_modules/.bin/electron'),
|
||||
});
|
||||
const page = await electronApp.firstWindow();
|
||||
await page.getByTestId('new-page-button').click({
|
||||
delay: 100,
|
||||
});
|
||||
@@ -37,5 +74,4 @@ test('affine cloud disabled', async () => {
|
||||
await page.getByTestId('disable-affine-cloud-modal').waitFor({
|
||||
state: 'visible',
|
||||
});
|
||||
await electronApp.close();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user