test(electron): theme check (#2182)

This commit is contained in:
Himself65
2023-04-28 01:40:44 -05:00
committed by GitHub
parent 73d5b2081a
commit ef0521fa2a
6 changed files with 64 additions and 31 deletions

View File

@@ -1,12 +1,11 @@
import { resolve } from 'node:path';
import { test } from '@affine-test/kit/playwright';
import { test, testResultDir } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
import { waitMarkdownImported } from '../libs/page-logic';
import { clickSideBarSettingButton } from '../libs/sidebar';
import { testResultDir } from '../libs/utils';
test('Should highlight the setting page menu when selected', async ({
page,

View File

@@ -1,13 +1,12 @@
import { resolve } from 'node:path';
import { test } from '@affine-test/kit/playwright';
import { test, testResultDir } from '@affine-test/kit/playwright';
import { expect } from '@playwright/test';
import { openHomePage } from '../libs/load-page';
import { waitMarkdownImported } from '../libs/page-logic';
import { testResultDir } from '../libs/utils';
// default could be anything according to the system
// default could be anything, according to the system
test('default white', async ({ browser }) => {
const context = await browser.newContext({
colorScheme: 'light',
@@ -20,15 +19,14 @@ test('default white', async ({ browser }) => {
element.getAttribute('data-theme')
);
expect(themeMode).toBe('light');
const prev = await page.screenshot({
await page.screenshot({
path: resolve(testResultDir, 'affine-light-theme.png'),
});
await page.getByTestId('change-theme-dark').click();
await page.waitForTimeout(50);
const after = await page.screenshot({
await page.screenshot({
path: resolve(testResultDir, 'affine-dark-theme.png'),
});
expect(prev).not.toEqual(after);
});
// test('change theme to dark', async ({ page }) => {