mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-22 20:46:38 +08:00
test(electron): theme check (#2182)
This commit is contained in:
@@ -1,10 +1,18 @@
|
||||
import { ok } from 'node:assert';
|
||||
import crypto from 'node:crypto';
|
||||
import fs from 'node:fs';
|
||||
import path from 'node:path';
|
||||
import path, { resolve } from 'node:path';
|
||||
import process from 'node:process';
|
||||
|
||||
import { test as baseTest } from '@playwright/test';
|
||||
|
||||
export const rootDir = resolve(__dirname, '..', '..');
|
||||
// assert that the rootDir is the root of the project
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
ok(require(resolve(rootDir, 'package.json')).name.toLowerCase() === 'affine');
|
||||
|
||||
export const testResultDir = resolve(rootDir, 'test-results');
|
||||
|
||||
const istanbulTempDir = process.env.ISTANBUL_TEMP_DIR
|
||||
? path.resolve(process.env.ISTANBUL_TEMP_DIR)
|
||||
: path.join(process.cwd(), '.nyc_output');
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import { ok } from 'node:assert';
|
||||
import { resolve } from 'node:path';
|
||||
|
||||
import type { PageMeta } from '@blocksuite/store';
|
||||
import { faker } from '@faker-js/faker';
|
||||
import type { Page } from '@playwright/test';
|
||||
@@ -10,13 +7,6 @@ const user1 = require('@affine-test/fixtures/built-in-user1.json');
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
const user2 = require('@affine-test/fixtures/built-in-user2.json');
|
||||
|
||||
export const rootDir = resolve(__dirname, '..', '..');
|
||||
// assert that the rootDir is the root of the project
|
||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||
ok(require(resolve(rootDir, 'package.json')).name.toLowerCase() === 'affine');
|
||||
|
||||
export const testResultDir = resolve(rootDir, 'test-results');
|
||||
|
||||
export async function getBuiltInUser() {
|
||||
return Promise.all([
|
||||
fetch('http://localhost:3000/api/user/token', {
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 }) => {
|
||||
|
||||
Reference in New Issue
Block a user