Merge branch 'canary' into stable

This commit is contained in:
李华桥
2023-12-01 16:12:17 +08:00
147 changed files with 1775 additions and 1993 deletions
+7 -13
View File
@@ -265,7 +265,9 @@ test.describe('collaboration members', () => {
await addUserToWorkspace(workspaceId, userB.id, 1 /* READ */);
};
await Promise.all(
new Array(10).fill(1).map(() => createUserAndAddToWorkspace())
Array.from({ length: 10 })
.fill(1)
.map(() => createUserAndAddToWorkspace())
);
await openSettingModal(page);
@@ -366,18 +368,10 @@ test('can sync svg between different browsers', async ({ page, browser }) => {
expect(src).not.toBeNull();
// fetch the src resource in the browser
const svg2 = await page2.evaluate(async src => {
async function blobToString(blob: Blob) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onloadend = () => resolve(reader.result);
reader.onerror = reject;
reader.readAsText(blob);
});
}
const blob = fetch(src!).then(res => res.blob());
return blobToString(await blob);
const svg2 = await page2.evaluate(src => {
return fetch(src!)
.then(res => res.blob())
.then(blob => blob.text());
}, src);
// turn the blob into string and check if it contains the svg
+2 -6
View File
@@ -114,9 +114,7 @@ test('clientBorder value should disable by default on window', async ({
test('app theme', async ({ page, electronApp }) => {
const root = page.locator('html');
{
const themeMode = await root.evaluate(element =>
element.getAttribute('data-theme')
);
const themeMode = await root.evaluate(element => element.dataset.theme);
expect(themeMode).toBe('light');
const theme = await electronApp.evaluate(({ nativeTheme }) => {
@@ -131,9 +129,7 @@ test('app theme', async ({ page, electronApp }) => {
await page.getByTestId('appearance-panel-trigger').click();
await page.waitForTimeout(50);
await page.getByTestId('dark-theme-trigger').click();
const themeMode = await root.evaluate(element =>
element.getAttribute('data-theme')
);
const themeMode = await root.evaluate(element => element.dataset.theme);
expect(themeMode).toBe('dark');
const theme = await electronApp.evaluate(({ nativeTheme }) => {
return nativeTheme.shouldUseDarkColors ? 'dark' : 'light';
+1 -1
View File
@@ -1,3 +1,4 @@
/* eslint-disable unicorn/prefer-dom-node-dataset */
import { test } from '@affine-test/kit/playwright';
import {
changeFilter,
@@ -307,7 +308,6 @@ test('select a group of items by clicking "Select All" in group header', async (
const selectedGroupItemTotalCount = await page
.locator('[data-testid="page-list-group-header"]')
.getAttribute('data-group-items-count');
expect(selectedItemCount).toBe(selectedGroupItemTotalCount);
// check the selected count is equal to the one displayed in the floating toolbar
@@ -1,3 +1,4 @@
/* eslint-disable unicorn/prefer-dom-node-dataset */
import { openHomePage } from '@affine-test/kit/utils/load-page';
import {
clickNewPageButton,
+1 -1
View File
@@ -65,7 +65,7 @@ async function waitForScrollToFinish(page: Page) {
let lastScrollTop: number;
const interval = setInterval(() => {
const { scrollTop } = document.documentElement;
if (scrollTop != lastScrollTop) {
if (scrollTop !== lastScrollTop) {
lastScrollTop = scrollTop;
} else {
clearInterval(interval);
+2 -6
View File
@@ -49,15 +49,11 @@ test('Change theme', async ({ page }) => {
const root = page.locator('html');
await page.getByTestId('light-theme-trigger').click();
const lightMode = await root.evaluate(element =>
element.getAttribute('data-theme')
);
const lightMode = await root.evaluate(element => element.dataset.theme);
expect(lightMode).toBe('light');
await page.getByTestId('dark-theme-trigger').click();
const darkMode = await root.evaluate(element =>
element.getAttribute('data-theme')
);
const darkMode = await root.evaluate(element => element.dataset.theme);
expect(darkMode).toBe('dark');
});
+2 -6
View File
@@ -14,9 +14,7 @@ test('default white', async ({ browser }) => {
await openHomePage(page);
await waitForEditorLoad(page);
const root = page.locator('html');
const themeMode = await root.evaluate(element =>
element.getAttribute('data-theme')
);
const themeMode = await root.evaluate(element => element.dataset.theme);
expect(themeMode).toBe('light');
await page.screenshot({
path: resolve(testResultDir, 'affine-light-theme.png'),
@@ -25,9 +23,7 @@ test('default white', async ({ browser }) => {
await page.getByTestId('appearance-panel-trigger').click();
await page.waitForTimeout(50);
await page.getByTestId('dark-theme-trigger').click();
const darkMode = await root.evaluate(element =>
element.getAttribute('data-theme')
);
const darkMode = await root.evaluate(element => element.dataset.theme);
expect(darkMode).toBe('dark');
await page.screenshot({
path: resolve(testResultDir, 'affine-dark-theme.png'),
+2
View File
@@ -48,6 +48,8 @@ export const getPagesCount = async (page: Page) => {
return 0;
}
// locator is not a HTMLElement, so we can't use dataset
// eslint-disable-next-line unicorn/prefer-dom-node-dataset
const count = await locator.getAttribute('data-total-count');
return count ? parseInt(count) : 0;
};