test: improve data migration suite (#4124)

This commit is contained in:
Alex Yang
2023-09-01 22:31:07 -05:00
committed by GitHub
parent eb1a21265f
commit 70b5a9deeb
43 changed files with 273 additions and 265 deletions

View File

@@ -5,7 +5,7 @@ import {
getLoginCookie, getLoginCookie,
loginUser, loginUser,
} from '@affine-test/kit/utils/cloud'; } from '@affine-test/kit/utils/cloud';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
let user: { let user: {
@@ -37,7 +37,7 @@ test('enable cloud success', async ({ page, context }) => {
afterLogin: async () => { afterLogin: async () => {
expect(await getLoginCookie(context)).toBeTruthy(); expect(await getLoginCookie(context)).toBeTruthy();
await page.reload(); await page.reload();
await waitEditorLoad(page); await waitForEditorLoad(page);
expect(await getLoginCookie(context)).toBeTruthy(); expect(await getLoginCookie(context)).toBeTruthy();
}, },
}); });

View File

@@ -1,13 +1,13 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar'; import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test.describe('login', () => { test.describe('login', () => {
test('can open login modal in workspace list', async ({ page }) => { test('can open login modal in workspace list', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await clickSideBarCurrentWorkspaceBanner(page); await clickSideBarCurrentWorkspaceBanner(page);
await page.getByTestId('cloud-signin-button').click({ await page.getByTestId('cloud-signin-button').click({
delay: 200, delay: 200,

View File

@@ -1,74 +1,29 @@
import { resolve } from 'node:path'; import { resolve } from 'node:path';
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { newPage, waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import {
check8080Available,
setupProxyServer,
} from '@affine-test/kit/utils/proxy';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
import express from 'express';
import { createProxyMiddleware } from 'http-proxy-middleware';
let app: express.Express; const { switchToNext } = setupProxyServer(
let server: ReturnType<express.Express['listen']>; test,
resolve(__dirname, '..', 'static')
process.env.DEBUG = 'http-proxy-middleware*'; );
async function switchToNext() {
// close previous express server
await new Promise<void>((resolve, reject) => {
server.close(err => {
if (err) {
reject(err);
}
resolve();
});
});
app = express();
app.use(
createProxyMiddleware({
target: 'http://localhost:8080',
pathFilter: ['**'],
changeOrigin: true,
})
);
return new Promise<void>(resolve => {
server = app.listen(8081, () => {
console.log('proxy to next.js server');
resolve();
});
});
}
test.beforeEach(() => {
app = express();
app.use(express.static(resolve(__dirname, '..', 'static')));
server = app.listen(8081);
});
test.afterEach(() => {
server.close();
});
test('init page', async ({ page, context }) => { test('init page', async ({ page, context }) => {
{ await check8080Available(context);
// make sure 8080 is ready
const page = await context.newPage();
await page.goto('http://localhost:8080/');
await page.waitForSelector('v-line', {
timeout: 10000,
});
await page.close();
}
await page.goto('http://localhost:8081/'); await page.goto('http://localhost:8081/');
await page.waitForSelector('v-line', { await waitForEditorLoad(page);
timeout: 10000, await newPage(page);
});
await page.getByTestId('new-page-button').click();
const locator = page.locator('v-line').nth(0); const locator = page.locator('v-line').nth(0);
await locator.fill('hello'); await locator.fill('hello');
await switchToNext(); await switchToNext();
await page.waitForTimeout(1000); await page.waitForTimeout(1000);
await page.goto('http://localhost:8081/'); await page.goto('http://localhost:8081/');
await page.waitForSelector('v-line', { await waitForEditorLoad(page);
timeout: 10000,
});
expect(await page.locator('v-line').nth(0).textContent()).toBe('hello'); expect(await page.locator('v-line').nth(0).textContent()).toBe('hello');
}); });

View File

@@ -6,6 +6,9 @@
}, },
"include": ["e2e"], "include": ["e2e"],
"references": [ "references": [
{
"path": "../../fixtures"
},
{ {
"path": "../../kit" "path": "../../kit"
} }

View File

@@ -1,60 +1,20 @@
import { resolve } from 'node:path'; import { resolve } from 'node:path';
import { clickEdgelessModeButton } from '@affine-test/kit/utils/editor';
import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import {
check8080Available,
setupProxyServer,
} from '@affine-test/kit/utils/proxy';
import { expect, test } from '@playwright/test'; import { expect, test } from '@playwright/test';
import express from 'express';
import { createProxyMiddleware } from 'http-proxy-middleware';
let app: express.Express; const { switchToNext } = setupProxyServer(
let server: ReturnType<express.Express['listen']>; test,
resolve(__dirname, '..', 'static')
process.env.DEBUG = 'http-proxy-middleware*'; );
async function switchToNext() {
// close previous express server
await new Promise<void>((resolve, reject) => {
server.close(err => {
if (err) {
reject(err);
}
resolve();
});
});
app = express();
app.use(
createProxyMiddleware({
target: 'http://localhost:8080',
pathFilter: ['**'],
changeOrigin: true,
})
);
return new Promise<void>(resolve => {
server = app.listen(8081, () => {
console.log('proxy to next.js server');
resolve();
});
});
}
test.beforeEach(() => {
app = express();
app.use(express.static(resolve(__dirname, '..', 'static')));
server = app.listen(8081);
});
test.afterEach(() => {
server.close();
});
test('database migration', async ({ page, context }) => { test('database migration', async ({ page, context }) => {
{ await check8080Available(context);
// make sure 8080 is ready
const page = await context.newPage();
await page.goto('http://localhost:8080/');
await page.waitForSelector('v-line', {
timeout: 10000,
});
await page.close();
}
await page.goto('http://localhost:8081/'); await page.goto('http://localhost:8081/');
await page.waitForSelector('v-line', { await page.waitForSelector('v-line', {
timeout: 10000, timeout: 10000,
@@ -76,9 +36,14 @@ test('database migration', async ({ page, context }) => {
await page.waitForTimeout(1000); await page.waitForTimeout(1000);
await page.goto('http://localhost:8081/'); await page.goto('http://localhost:8081/');
await page.click('text=hello'); await page.click('text=hello');
await page.waitForSelector('v-line', { await waitForEditorLoad(page);
timeout: 10000, // check page mode is correct
});
expect(await page.locator('v-line').nth(0).textContent()).toBe('hello'); expect(await page.locator('v-line').nth(0).textContent()).toBe('hello');
expect(await page.locator('affine-database').isVisible()).toBe(true); expect(await page.locator('affine-database').isVisible()).toBe(true);
// check edgeless mode is correct
await page.getByTestId('switch-edgeless-mode-button').click();
await clickEdgelessModeButton(page);
await page.waitForTimeout(200);
expect(await page.locator('affine-database').isVisible()).toBe(true);
}); });

View File

@@ -4,5 +4,13 @@
"esModuleInterop": true, "esModuleInterop": true,
"outDir": "lib" "outDir": "lib"
}, },
"include": ["e2e"] "include": ["e2e"],
"references": [
{
"path": "../../fixtures"
},
{
"path": "../../kit"
}
]
} }

View File

@@ -17,8 +17,8 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage, newPage,
waitEditorLoad,
waitForAllPagesLoad, waitForAllPagesLoad,
waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar'; import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar';
import type { Page } from '@playwright/test'; import type { Page } from '@playwright/test';
@@ -45,14 +45,14 @@ function getAllPage(page: Page) {
test('all page', async ({ page }) => { test('all page', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await clickSideBarAllPageButton(page); await clickSideBarAllPageButton(page);
}); });
test('all page can create new page', async ({ page }) => { test('all page can create new page', async ({ page }) => {
const { clickNewPageButton } = getAllPage(page); const { clickNewPageButton } = getAllPage(page);
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await clickSideBarAllPageButton(page); await clickSideBarAllPageButton(page);
await clickNewPageButton(); await clickNewPageButton();
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
@@ -65,7 +65,7 @@ test('all page can create new page', async ({ page }) => {
test('all page can create new edgeless page', async ({ page }) => { test('all page can create new edgeless page', async ({ page }) => {
const { clickNewEdgelessDropdown } = getAllPage(page); const { clickNewEdgelessDropdown } = getAllPage(page);
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await clickSideBarAllPageButton(page); await clickSideBarAllPageButton(page);
await clickNewEdgelessDropdown(); await clickNewEdgelessDropdown();
await expect(page.locator('affine-edgeless-page')).toBeVisible(); await expect(page.locator('affine-edgeless-page')).toBeVisible();
@@ -73,7 +73,7 @@ test('all page can create new edgeless page', async ({ page }) => {
test('allow creation of filters by favorite', async ({ page }) => { test('allow creation of filters by favorite', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await clickSideBarAllPageButton(page); await clickSideBarAllPageButton(page);
await createFirstFilter(page, 'Favourited'); await createFirstFilter(page, 'Favourited');
await page await page
@@ -87,7 +87,7 @@ test('allow creation of filters by favorite', async ({ page }) => {
test('allow creation of filters by created time', async ({ page }) => { test('allow creation of filters by created time', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await clickSideBarAllPageButton(page); await clickSideBarAllPageButton(page);
await waitForAllPagesLoad(page); await waitForAllPagesLoad(page);
@@ -122,7 +122,7 @@ test('creation of filters by created time, then click date picker to modify the
page, page,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await clickSideBarAllPageButton(page); await clickSideBarAllPageButton(page);
await waitForAllPagesLoad(page); await waitForAllPagesLoad(page);
@@ -155,7 +155,7 @@ test('creation of filters by created time, then click date picker to modify the
test('use monthpicker to modify the month of datepicker', async ({ page }) => { test('use monthpicker to modify the month of datepicker', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await clickSideBarAllPageButton(page); await clickSideBarAllPageButton(page);
await createFirstFilter(page, 'Created'); await createFirstFilter(page, 'Created');
await checkFilterName(page, 'after'); await checkFilterName(page, 'after');
@@ -179,7 +179,7 @@ test('use monthpicker to modify the month of datepicker', async ({ page }) => {
test('allow creation of filters by tags', async ({ page }) => { test('allow creation of filters by tags', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await clickSideBarAllPageButton(page); await clickSideBarAllPageButton(page);
await waitForAllPagesLoad(page); await waitForAllPagesLoad(page);
const pages = await page.locator('[data-testid="title"]').all(); const pages = await page.locator('[data-testid="title"]').all();

View File

@@ -1,10 +1,10 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { checkBlockHub } from '@affine-test/kit/utils/editor'; import { checkBlockHub } from '@affine-test/kit/utils/editor';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
test('block-hub should work', async ({ page }) => { test('block-hub should work', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await checkBlockHub(page); await checkBlockHub(page);
}); });

View File

@@ -3,7 +3,7 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage, newPage,
waitEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import type { Page } from '@playwright/test'; import type { Page } from '@playwright/test';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -19,9 +19,9 @@ const addDatabase = async (page: Page) => {
test('database is useable', async ({ page }) => { test('database is useable', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('test title'); await title.type('test title');
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');
@@ -30,9 +30,9 @@ test('database is useable', async ({ page }) => {
const database = page.locator('affine-database'); const database = page.locator('affine-database');
await expect(database).toBeVisible(); await expect(database).toBeVisible();
await page.reload(); await page.reload();
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const title2 = getBlockSuiteEditorTitle(page); const title2 = getBlockSuiteEditorTitle(page);
await title2.type('test title2'); await title2.type('test title2');
await page.waitForTimeout(500); await page.waitForTimeout(500);
@@ -45,15 +45,15 @@ test('database is useable', async ({ page }) => {
test('link page is useable', async ({ page }) => { test('link page is useable', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
await title.type('page1'); await title.type('page1');
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');
expect(await title.innerText()).toBe('page1'); expect(await title.innerText()).toBe('page1');
await newPage(page); await newPage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const title2 = await getBlockSuiteEditorTitle(page); const title2 = await getBlockSuiteEditorTitle(page);
await title2.type('page2'); await title2.type('page2');
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');

View File

@@ -2,7 +2,7 @@ import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
clickPageMoreActions, clickPageMoreActions,
waitEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -14,7 +14,7 @@ test('Switch to edgeless by switch edgeless item', async ({ page }) => {
}); });
} }
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const btn = await page.getByTestId('switch-edgeless-mode-button'); const btn = await page.getByTestId('switch-edgeless-mode-button');
await page.evaluate(() => { await page.evaluate(() => {
// @ts-expect-error // @ts-expect-error
@@ -55,7 +55,7 @@ test('Switch to edgeless by switch edgeless item', async ({ page }) => {
test('Convert to edgeless by editor header items', async ({ page }) => { test('Convert to edgeless by editor header items', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await clickPageMoreActions(page); await clickPageMoreActions(page);
const menusEdgelessItem = page.getByTestId('editor-option-menu-edgeless'); const menusEdgelessItem = page.getByTestId('editor-option-menu-edgeless');
await menusEdgelessItem.click({ delay: 100 }); await menusEdgelessItem.click({ delay: 100 });
@@ -65,7 +65,7 @@ test('Convert to edgeless by editor header items', async ({ page }) => {
test('Able to insert the title of an untitled page', async ({ page }) => { test('Able to insert the title of an untitled page', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const titleBarTextContent = await page.getByTestId('title-edit-button'); const titleBarTextContent = await page.getByTestId('title-edit-button');
await titleBarTextContent.click({ delay: 100 }); await titleBarTextContent.click({ delay: 100 });
const titleContent = await page.getByTestId('title-content'); const titleContent = await page.getByTestId('title-content');
@@ -76,7 +76,7 @@ test('Able to insert the title of an untitled page', async ({ page }) => {
test('Able to edit the title of an existing page', async ({ page }) => { test('Able to edit the title of an existing page', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const titleBarTextContent = await page.getByTestId('title-edit-button'); const titleBarTextContent = await page.getByTestId('title-edit-button');
await titleBarTextContent.click({ delay: 100 }); await titleBarTextContent.click({ delay: 100 });
const titleContent = await page.getByTestId('title-content'); const titleContent = await page.getByTestId('title-content');
@@ -93,7 +93,7 @@ test('Clearing out the title bar will remove the page title', async ({
page, page,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const titleBarTextContent = await page.getByTestId('title-edit-button'); const titleBarTextContent = await page.getByTestId('title-edit-button');
await titleBarTextContent.click({ delay: 100 }); await titleBarTextContent.click({ delay: 100 });
const titleContent = await page.getByTestId('title-content'); const titleContent = await page.getByTestId('title-content');
@@ -108,7 +108,7 @@ test('Clearing out the title bar will remove the page title', async ({
test('Rename by editor header items, save with shortcut', async ({ page }) => { test('Rename by editor header items, save with shortcut', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await clickPageMoreActions(page); await clickPageMoreActions(page);
const menusRenameItem = page.getByTestId('editor-option-menu-rename'); const menusRenameItem = page.getByTestId('editor-option-menu-rename');
await menusRenameItem.click({ delay: 100 }); await menusRenameItem.click({ delay: 100 });

View File

@@ -1,11 +1,11 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('Click right-bottom corner contact icon', async ({ page }) => { test('Click right-bottom corner contact icon', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await page.locator('[data-testid=help-island]').click(); await page.locator('[data-testid=help-island]').click();
const rightBottomContactUs = page.locator( const rightBottomContactUs = page.locator(
'[data-testid=right-bottom-contact-us-icon]' '[data-testid=right-bottom-contact-us-icon]'

View File

@@ -1,6 +1,6 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('drag a page from "All pages" list onto the "Trash" folder in the sidebar to move it to trash list', async ({ test('drag a page from "All pages" list onto the "Trash" folder in the sidebar to move it to trash list', async ({
@@ -10,7 +10,7 @@ test('drag a page from "All pages" list onto the "Trash" folder in the sidebar t
// Init test db with known workspaces and open "All Pages" page via url directly // Init test db with known workspaces and open "All Pages" page via url directly
{ {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await page.getByText('All Pages').click(); await page.getByText('All Pages').click();
await page.waitForTimeout(500); await page.waitForTimeout(500);
} }

View File

@@ -4,13 +4,13 @@ import {
clickPageMoreActions, clickPageMoreActions,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage, newPage,
waitEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('Duplicate page should work', async ({ page }) => { test('Duplicate page should work', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('test'); await title.type('test');

View File

@@ -2,7 +2,7 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage, newPage,
waitEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import type { Page } from '@playwright/test'; import type { Page } from '@playwright/test';
import { expect, test } from '@playwright/test'; import { expect, test } from '@playwright/test';
@@ -42,7 +42,7 @@ async function closeImagePreviewModal(page: Page) {
test('image preview should be shown', async ({ page }) => { test('image preview should be shown', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
await title.click(); await title.click();
@@ -57,7 +57,7 @@ test('image preview should be shown', async ({ page }) => {
test('image go left and right', async ({ page }) => { test('image go left and right', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
let blobId: string; let blobId: string;
{ {
@@ -104,7 +104,7 @@ test('image go left and right', async ({ page }) => {
test('image able to zoom in and out with mouse scroll', async ({ page }) => { test('image able to zoom in and out with mouse scroll', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
let blobId: string; let blobId: string;
{ {
@@ -157,7 +157,7 @@ test('image able to zoom in and out with mouse scroll', async ({ page }) => {
test('image able to zoom in and out with button click', async ({ page }) => { test('image able to zoom in and out with button click', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
let blobId: string; let blobId: string;
{ {
@@ -203,7 +203,7 @@ test('image able to zoom in and out with button click', async ({ page }) => {
test('image should able to go left and right by buttons', async ({ page }) => { test('image should able to go left and right by buttons', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
let blobId: string; let blobId: string;
{ {
@@ -257,7 +257,7 @@ test('image should able to go left and right by buttons', async ({ page }) => {
test('image able to fit to screen by button', async ({ page }) => { test('image able to fit to screen by button', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
let blobId: string; let blobId: string;
{ {
@@ -314,7 +314,7 @@ test('image able to fit to screen by button', async ({ page }) => {
test('image able to reset zoom to 100%', async ({ page }) => { test('image able to reset zoom to 100%', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
let blobId: string; let blobId: string;
{ {
@@ -367,7 +367,7 @@ test('image able to reset zoom to 100%', async ({ page }) => {
test('image able to copy to clipboard', async ({ page }) => { test('image able to copy to clipboard', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
let blobId: string; let blobId: string;
{ {
@@ -394,7 +394,7 @@ test('image able to copy to clipboard', async ({ page }) => {
test('image able to download', async ({ page }) => { test('image able to download', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
let blobId: string; let blobId: string;
{ {
@@ -426,7 +426,7 @@ test('image should only able to move when image is larger than viewport', async
page, page,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
let blobId: string; let blobId: string;
{ {
@@ -483,7 +483,7 @@ test('image should able to delete and when delete, it will move to previous/next
page, page,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
let blobId: string; let blobId: string;
{ {
@@ -558,7 +558,7 @@ test('tooltips for all buttons should be visible when hovering', async ({
page, page,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
let blobId: string; let blobId: string;
{ {
@@ -653,7 +653,7 @@ test('tooltips for all buttons should be visible when hovering', async ({
test('keypress esc should close the modal', async ({ page }) => { test('keypress esc should close the modal', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
await title.click(); await title.click();
@@ -671,7 +671,7 @@ test('when mouse moves outside, the modal should be closed', async ({
page, page,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
await title.click(); await title.click();
@@ -692,7 +692,7 @@ test('caption should be visible and different styles were applied if image zoome
}) => { }) => {
const sampleCaption = 'affine owns me and all'; const sampleCaption = 'affine owns me and all';
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
const title = await getBlockSuiteEditorTitle(page); const title = await getBlockSuiteEditorTitle(page);
await title.click(); await title.click();

View File

@@ -1,11 +1,11 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('Collapse Sidebar', async ({ page }) => { test('Collapse Sidebar', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await page await page
.locator('[data-testid=app-sidebar-arrow-button-collapse][data-show=true]') .locator('[data-testid=app-sidebar-arrow-button-collapse][data-show=true]')
.click(); .click();
@@ -15,7 +15,7 @@ test('Collapse Sidebar', async ({ page }) => {
test('Expand Sidebar', async ({ page }) => { test('Expand Sidebar', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await page await page
.locator('[data-testid=app-sidebar-arrow-button-collapse][data-show=true]') .locator('[data-testid=app-sidebar-arrow-button-collapse][data-show=true]')
.click(); .click();
@@ -30,7 +30,7 @@ test('Expand Sidebar', async ({ page }) => {
test('Click resizer can close sidebar', async ({ page }) => { test('Click resizer can close sidebar', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const sliderBarArea = page.getByTestId('sliderBar-inner'); const sliderBarArea = page.getByTestId('sliderBar-inner');
await expect(sliderBarArea).toBeVisible(); await expect(sliderBarArea).toBeVisible();
@@ -40,7 +40,7 @@ test('Click resizer can close sidebar', async ({ page }) => {
test('Drag resizer can resize sidebar', async ({ page }) => { test('Drag resizer can resize sidebar', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const sliderBarArea = page.getByTestId('sliderBar-inner'); const sliderBarArea = page.getByTestId('sliderBar-inner');
await expect(sliderBarArea).toBeVisible(); await expect(sliderBarArea).toBeVisible();
@@ -57,7 +57,7 @@ test('Drag resizer can resize sidebar', async ({ page }) => {
test('Sidebar in between sm & md breakpoint', async ({ page }) => { test('Sidebar in between sm & md breakpoint', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const sliderBarArea = page.getByTestId('sliderBar-inner'); const sliderBarArea = page.getByTestId('sliderBar-inner');
const sliderBarModalBackground = page.getByTestId('app-sidebar-float-mask'); const sliderBarModalBackground = page.getByTestId('app-sidebar-float-mask');
await expect(sliderBarArea).toBeInViewport(); await expect(sliderBarArea).toBeInViewport();

View File

@@ -2,7 +2,7 @@ import { resolve } from 'node:path';
import { rootDir, test } from '@affine-test/kit/playwright'; import { rootDir, test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { newPage, waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { newPage, waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('should create a page with a local first avatar', async ({ test('should create a page with a local first avatar', async ({
@@ -10,7 +10,7 @@ test('should create a page with a local first avatar', async ({
workspace, workspace,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await page.getByTestId('workspace-name').click(); await page.getByTestId('workspace-name').click();
await page.getByTestId('new-workspace').click({ delay: 50 }); await page.getByTestId('new-workspace').click({ delay: 50 });

View File

@@ -7,7 +7,7 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage, newPage,
waitEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import type { Page } from '@playwright/test'; import type { Page } from '@playwright/test';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -19,7 +19,7 @@ const createAndPinCollection = async (
} }
) => { ) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('test page'); await getBlockSuiteEditorTitle(page).fill('test page');
@@ -140,7 +140,7 @@ test('edit collection and change filter date', async ({ page }) => {
test('create temporary filter by click tag', async ({ page }) => { test('create temporary filter by click tag', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('test page'); await getBlockSuiteEditorTitle(page).fill('test page');
@@ -162,7 +162,7 @@ test('create temporary filter by click tag', async ({ page }) => {
test('add collection from sidebar', async ({ page }) => { test('add collection from sidebar', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('test page'); await getBlockSuiteEditorTitle(page).fill('test page');

View File

@@ -3,7 +3,7 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage, newPage,
waitEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -12,7 +12,7 @@ test('page delete -> refresh page -> it should be disappear', async ({
workspace, workspace,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page delete'); await getBlockSuiteEditorTitle(page).fill('this is a new page delete');
@@ -55,7 +55,7 @@ test('page delete -> create new page -> refresh page -> new page should be appea
workspace, workspace,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page delete'); await getBlockSuiteEditorTitle(page).fill('this is a new page delete');
@@ -113,7 +113,7 @@ test('delete multiple pages -> create multiple pages -> refresh', async ({
workspace, workspace,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
// create 1st page // create 1st page
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();

View File

@@ -1,6 +1,6 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { openWorkspaceSettingPanel } from '@affine-test/kit/utils/setting'; import { openWorkspaceSettingPanel } from '@affine-test/kit/utils/setting';
import { openSettingModal } from '@affine-test/kit/utils/setting'; import { openSettingModal } from '@affine-test/kit/utils/setting';
import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar'; import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar';
@@ -8,7 +8,7 @@ import { expect } from '@playwright/test';
test('Create new workspace, then delete it', async ({ page, workspace }) => { test('Create new workspace, then delete it', async ({ page, workspace }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await clickSideBarCurrentWorkspaceBanner(page); await clickSideBarCurrentWorkspaceBanner(page);
await page.getByTestId('new-workspace').click(); await page.getByTestId('new-workspace').click();
await page await page
@@ -49,7 +49,7 @@ test('Create new workspace, then delete it', async ({ page, workspace }) => {
//FIXME: this test is broken //FIXME: this test is broken
test('Delete last workspace', async ({ page }) => { test('Delete last workspace', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const workspaceNameDom = await page.getByTestId('workspace-name'); const workspaceNameDom = await page.getByTestId('workspace-name');
const currentWorkspaceName = await workspaceNameDom.evaluate( const currentWorkspaceName = await workspaceNameDom.evaluate(
node => node.textContent node => node.textContent

View File

@@ -4,7 +4,7 @@ import {
clickPageMoreActions, clickPageMoreActions,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage, newPage,
waitEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -13,7 +13,7 @@ test.skip('New a page ,then open it and export html', async ({
workspace, workspace,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await page await page

View File

@@ -4,7 +4,7 @@ import {
clickPageMoreActions, clickPageMoreActions,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage, newPage,
waitEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { waitForLogMessage } from '@affine-test/kit/utils/utils'; import { waitForLogMessage } from '@affine-test/kit/utils/utils';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -14,7 +14,7 @@ test('New a page and open it ,then favorite it', async ({
workspace, workspace,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite'); await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
@@ -35,7 +35,7 @@ test('New a page and open it ,then favorite it', async ({
test('Export to html, markdown and png', async ({ page }) => { test('Export to html, markdown and png', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
{ {
await clickPageMoreActions(page); await clickPageMoreActions(page);
await page.getByTestId('export-menu').click(); await page.getByTestId('export-menu').click();
@@ -69,7 +69,7 @@ test.skip('Export to pdf', async ({ page }) => {
}); });
}); });
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
{ {
await clickPageMoreActions(page); await clickPageMoreActions(page);
await page.getByTestId('export-menu').click(); await page.getByTestId('export-menu').click();
@@ -80,7 +80,7 @@ test.skip('Export to pdf', async ({ page }) => {
test('Cancel favorite', async ({ page, workspace }) => { test('Cancel favorite', async ({ page, workspace }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite'); await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');

View File

@@ -5,13 +5,13 @@ import {
createLinkedPage, createLinkedPage,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage, newPage,
waitEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('Show favorite items in sidebar', async ({ page, workspace }) => { test('Show favorite items in sidebar', async ({ page, workspace }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite'); await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
@@ -39,7 +39,7 @@ test('Show favorite items in sidebar', async ({ page, workspace }) => {
test('Show favorite reference in sidebar', async ({ page, workspace }) => { test('Show favorite reference in sidebar', async ({ page, workspace }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite'); await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
@@ -82,7 +82,7 @@ test("Deleted page's reference will not be shown in sidebar", async ({
workspace, workspace,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite'); await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');

View File

@@ -3,13 +3,13 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage, newPage,
waitEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('click btn new page', async ({ page, workspace }) => { test('click btn new page', async ({ page, workspace }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const originPageId = page.url().split('/').reverse()[0]; const originPageId = page.url().split('/').reverse()[0];
await newPage(page); await newPage(page);
const newPageId = page.url().split('/').reverse()[0]; const newPageId = page.url().split('/').reverse()[0];
@@ -24,7 +24,7 @@ test('click btn bew page and find it in all pages', async ({
workspace, workspace,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page'); await getBlockSuiteEditorTitle(page).fill('this is a new page');

View File

@@ -3,13 +3,13 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage, newPage,
waitEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('click btn bew page and open in tab', async ({ page, workspace }) => { test('click btn bew page and open in tab', async ({ page, workspace }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page'); await getBlockSuiteEditorTitle(page).fill('this is a new page');

View File

@@ -3,7 +3,7 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage, newPage,
waitEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -12,7 +12,7 @@ test('New a page , then delete it in all pages, restore it', async ({
workspace, workspace,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to restore'); await getBlockSuiteEditorTitle(page).fill('this is a new page to restore');

View File

@@ -4,7 +4,7 @@ import {
clickPageMoreActions, clickPageMoreActions,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage, newPage,
waitEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -13,7 +13,7 @@ test('New a page ,then open it and show delete modal', async ({
workspace, workspace,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to delete'); await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');
@@ -39,7 +39,7 @@ test('New a page ,then go to all pages and show delete modal', async ({
workspace, workspace,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to delete'); await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');

View File

@@ -4,7 +4,7 @@ import {
clickPageMoreActions, clickPageMoreActions,
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage, newPage,
waitEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -13,7 +13,7 @@ test('New a page , then delete it in all pages, finally find it in trash', async
workspace, workspace,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await getBlockSuiteEditorTitle(page).click(); await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to delete'); await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');
@@ -49,7 +49,7 @@ test('New a page , then delete it in page, blockHub and option menu will not app
page, page,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('test'); await title.type('test');

View File

@@ -1,6 +1,6 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar'; import { clickSideBarAllPageButton } from '@affine-test/kit/utils/sidebar';
import { import {
createWorkspace, createWorkspace,
@@ -13,7 +13,7 @@ test('just one item in the workspace list at first', async ({
workspace, workspace,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const workspaceName = page.getByTestId('workspace-name'); const workspaceName = page.getByTestId('workspace-name');
await workspaceName.click(); await workspaceName.click();
expect( expect(
@@ -32,7 +32,7 @@ test('create one workspace in the workspace list', async ({
workspace, workspace,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const newWorkspaceNameStr = 'New Workspace'; const newWorkspaceNameStr = 'New Workspace';
await createWorkspace({ name: newWorkspaceNameStr }, page); await createWorkspace({ name: newWorkspaceNameStr }, page);
@@ -66,7 +66,7 @@ test('create multi workspace in the workspace list', async ({
workspace, workspace,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await createWorkspace({ name: 'New Workspace 2' }, page); await createWorkspace({ name: 'New Workspace 2' }, page);
await createWorkspace({ name: 'New Workspace 3' }, page); await createWorkspace({ name: 'New Workspace 3' }, page);

View File

@@ -1,11 +1,11 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('preset workspace name', async ({ page, workspace }) => { test('preset workspace name', async ({ page, workspace }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const workspaceName = page.getByTestId('workspace-name'); const workspaceName = page.getByTestId('workspace-name');
await page.waitForTimeout(1000); await page.waitForTimeout(1000);
expect(await workspaceName.textContent()).toBe('Demo Workspace'); expect(await workspaceName.textContent()).toBe('Demo Workspace');

View File

@@ -1,14 +1,14 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { createWorkspace } from '@affine-test/kit/utils/workspace'; import { createWorkspace } from '@affine-test/kit/utils/workspace';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('Open last workspace when back to affine', async ({ page }) => { test('Open last workspace when back to affine', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await createWorkspace({ name: 'New Workspace 2' }, page); await createWorkspace({ name: 'New Workspace 2' }, page);
await waitEditorLoad(page); await waitForEditorLoad(page);
// show workspace list // show workspace list
await page.getByTestId('workspace-name').click(); await page.getByTestId('workspace-name').click();
@@ -46,7 +46,7 @@ test.skip('Download client tip', async ({ page }) => {
test('Check the class name for the scrollbar', async ({ page }) => { test('Check the class name for the scrollbar', async ({ page }) => {
//Because the scroll bar in page mode depends on the class name of blocksuite //Because the scroll bar in page mode depends on the class name of blocksuite
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const affineDocViewport = page.locator('.affine-doc-viewport'); const affineDocViewport = page.locator('.affine-doc-viewport');
await expect(affineDocViewport).toBeVisible(); await expect(affineDocViewport).toBeVisible();
}); });

View File

@@ -4,7 +4,7 @@ import { openHomePage } from '@affine-test/kit/utils/load-page';
import { import {
getBlockSuiteEditorTitle, getBlockSuiteEditorTitle,
newPage, newPage,
waitEditorLoad, waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic'; } from '@affine-test/kit/utils/page-logic';
import { expect, type Page } from '@playwright/test'; import { expect, type Page } from '@playwright/test';
@@ -38,7 +38,7 @@ async function titleIsFocused(page: Page) {
test('Click slider bar button', async ({ page }) => { test('Click slider bar button', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
const quickSearchButton = page.locator( const quickSearchButton = page.locator(
'[data-testid=slider-bar-quick-search-button]' '[data-testid=slider-bar-quick-search-button]'
@@ -50,7 +50,7 @@ test('Click slider bar button', async ({ page }) => {
test('Click arrowDown icon after title', async ({ page }) => { test('Click arrowDown icon after title', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
const quickSearchButton = page.locator( const quickSearchButton = page.locator(
'[data-testid=slider-bar-quick-search-button]' '[data-testid=slider-bar-quick-search-button]'
@@ -62,7 +62,7 @@ test('Click arrowDown icon after title', async ({ page }) => {
test('Press the shortcut key cmd+k', async ({ page }) => { test('Press the shortcut key cmd+k', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
const quickSearch = page.locator('[data-testid=quickSearch]'); const quickSearch = page.locator('[data-testid=quickSearch]');
@@ -71,7 +71,7 @@ test('Press the shortcut key cmd+k', async ({ page }) => {
test('Create a new page without keyword', async ({ page }) => { test('Create a new page without keyword', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
const addNewPage = page.locator('[data-testid=quick-search-add-new-page]'); const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');
@@ -82,7 +82,7 @@ test('Create a new page without keyword', async ({ page }) => {
test('Create a new page with keyword', async ({ page }) => { test('Create a new page with keyword', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
await page.keyboard.insertText('test123456'); await page.keyboard.insertText('test123456');
@@ -94,7 +94,7 @@ test('Create a new page with keyword', async ({ page }) => {
test('Enter a keyword to search for', async ({ page }) => { test('Enter a keyword to search for', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
await page.keyboard.insertText('test123456'); await page.keyboard.insertText('test123456');
@@ -104,7 +104,7 @@ test('Enter a keyword to search for', async ({ page }) => {
test('Create a new page and search this page', async ({ page }) => { test('Create a new page and search this page', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
// input title and create new page // input title and create new page
@@ -124,7 +124,7 @@ test('Create a new page and search this page', async ({ page }) => {
await assertTitle(page, 'test123456'); await assertTitle(page, 'test123456');
await page.reload(); await page.reload();
await waitEditorLoad(page); await waitForEditorLoad(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
await page.keyboard.insertText('test123456'); await page.keyboard.insertText('test123456');
await page.waitForTimeout(300); await page.waitForTimeout(300);
@@ -146,7 +146,7 @@ test('Navigate to the 404 page and try to open quick search', async ({
test('Open quick search on local page', async ({ page }) => { test('Open quick search on local page', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
const publishedSearchResults = page.locator('[publishedSearchResults]'); const publishedSearchResults = page.locator('[publishedSearchResults]');
@@ -155,7 +155,7 @@ test('Open quick search on local page', async ({ page }) => {
test('Autofocus input after opening quick search', async ({ page }) => { test('Autofocus input after opening quick search', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
const locator = page.locator('[cmdk-input]'); const locator = page.locator('[cmdk-input]');
@@ -164,7 +164,7 @@ test('Autofocus input after opening quick search', async ({ page }) => {
}); });
test('Autofocus input after select', async ({ page }) => { test('Autofocus input after select', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
await page.keyboard.press('ArrowUp'); await page.keyboard.press('ArrowUp');
@@ -174,7 +174,7 @@ test('Autofocus input after select', async ({ page }) => {
}); });
test('Focus title after creating a new page', async ({ page }) => { test('Focus title after creating a new page', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await newPage(page); await newPage(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
const addNewPage = page.locator('[data-testid=quick-search-add-new-page]'); const addNewPage = page.locator('[data-testid=quick-search-add-new-page]');
@@ -186,7 +186,7 @@ test('Not show navigation path if page is not a subpage or current page is not i
page, page,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
expect(await page.getByTestId('navigation-path').count()).toBe(0); expect(await page.getByTestId('navigation-path').count()).toBe(0);
}); });
@@ -195,7 +195,7 @@ test('assert the recent browse pages are on the recent list', async ({
page, page,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
// create first page // create first page
await newPage(page); await newPage(page);
@@ -242,7 +242,7 @@ test('assert the recent browse pages are on the recent list', async ({
// create forth page, and check does the recent page list only contains three pages // create forth page, and check does the recent page list only contains three pages
await page.reload(); await page.reload();
await waitEditorLoad(page); await waitForEditorLoad(page);
await openQuickSearchByShortcut(page); await openQuickSearchByShortcut(page);
{ {
const addNewPage = page.getByTestId('quick-search-add-new-page'); const addNewPage = page.getByTestId('quick-search-add-new-page');

View File

@@ -1,11 +1,11 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { coreUrl, openHomePage } from '@affine-test/kit/utils/load-page'; import { coreUrl, openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('goto not found page', async ({ page }) => { test('goto not found page', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const currentUrl = page.url(); const currentUrl = page.url();
const invalidUrl = currentUrl.replace('hello-world', 'invalid'); const invalidUrl = currentUrl.replace('hello-world', 'invalid');
await page.goto(invalidUrl); await page.goto(invalidUrl);
@@ -14,7 +14,7 @@ test('goto not found page', async ({ page }) => {
test('goto not found workspace', async ({ page }) => { test('goto not found workspace', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
// if doesn't wait for timeout, data won't be saved into indexedDB // if doesn't wait for timeout, data won't be saved into indexedDB
await page.waitForTimeout(1000); await page.waitForTimeout(1000);
await page.goto(new URL('/workspace/invalid/all', coreUrl).toString()); await page.goto(new URL('/workspace/invalid/all', coreUrl).toString());

View File

@@ -1,6 +1,6 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { import {
openAboutPanel, openAboutPanel,
openAppearancePanel, openAppearancePanel,
@@ -13,7 +13,7 @@ import { expect } from '@playwright/test';
test('Open settings modal', async ({ page }) => { test('Open settings modal', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await openSettingModal(page); await openSettingModal(page);
const modal = await page.getByTestId('setting-modal'); const modal = await page.getByTestId('setting-modal');
@@ -22,7 +22,7 @@ test('Open settings modal', async ({ page }) => {
test('change language using keyboard', async ({ page }) => { test('change language using keyboard', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await openSettingModal(page); await openSettingModal(page);
const locator = page.getByTestId('language-menu-button'); const locator = page.getByTestId('language-menu-button');
@@ -55,7 +55,7 @@ test('change language using keyboard', async ({ page }) => {
test('Change theme', async ({ page }) => { test('Change theme', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await openSettingModal(page); await openSettingModal(page);
await openAppearancePanel(page); await openAppearancePanel(page);
const root = page.locator('html'); const root = page.locator('html');
@@ -75,7 +75,7 @@ test('Change theme', async ({ page }) => {
test('Change layout width', async ({ page }) => { test('Change layout width', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await openSettingModal(page); await openSettingModal(page);
await openAppearancePanel(page); await openAppearancePanel(page);
@@ -88,7 +88,7 @@ test('Change layout width', async ({ page }) => {
test('Open shortcuts panel', async ({ page }) => { test('Open shortcuts panel', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await openSettingModal(page); await openSettingModal(page);
await openShortcutsPanel(page); await openShortcutsPanel(page);
const title = await page.getByTestId('keyboard-shortcuts-title'); const title = await page.getByTestId('keyboard-shortcuts-title');
@@ -97,7 +97,7 @@ test('Open shortcuts panel', async ({ page }) => {
test('Open plugins panel', async ({ page }) => { test('Open plugins panel', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await openSettingModal(page); await openSettingModal(page);
await openPluginsPanel(page); await openPluginsPanel(page);
const title = await page.getByTestId('plugins-title'); const title = await page.getByTestId('plugins-title');
@@ -106,7 +106,7 @@ test('Open plugins panel', async ({ page }) => {
test('Open about panel', async ({ page }) => { test('Open about panel', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await openSettingModal(page); await openSettingModal(page);
await openAboutPanel(page); await openAboutPanel(page);
const title = await page.getByTestId('about-title'); const title = await page.getByTestId('about-title');
@@ -117,7 +117,7 @@ test('Different workspace should have different name in the setting panel', asyn
page, page,
}) => { }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await createWorkspace({ name: 'New Workspace 2' }, page); await createWorkspace({ name: 'New Workspace 2' }, page);
await createWorkspace({ name: 'New Workspace 3' }, page); await createWorkspace({ name: 'New Workspace 3' }, page);
await openSettingModal(page); await openSettingModal(page);

View File

@@ -1,11 +1,11 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('Open shortcuts modal', async ({ page }) => { test('Open shortcuts modal', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await page.locator('[data-testid=help-island]').click(); await page.locator('[data-testid=help-island]').click();
const shortcutsIcon = page.locator('[data-testid=shortcuts-icon]'); const shortcutsIcon = page.locator('[data-testid=shortcuts-icon]');

View File

@@ -1,11 +1,11 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('Create subpage', async ({ page }) => { test('Create subpage', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await page await page
.locator('[data-testid=app-sidebar-arrow-button-collapse][data-show=true]') .locator('[data-testid=app-sidebar-arrow-button-collapse][data-show=true]')
.click(); .click();

View File

@@ -2,7 +2,7 @@ import { resolve } from 'node:path';
import { test, testResultDir } from '@affine-test/kit/playwright'; import { test, testResultDir } from '@affine-test/kit/playwright';
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
// default could be anything, according to the system // default could be anything, according to the system
@@ -12,7 +12,7 @@ test('default white', async ({ browser }) => {
}); });
const page = await context.newPage(); const page = await context.newPage();
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
const root = page.locator('html'); const root = page.locator('html');
const themeMode = await root.evaluate(element => const themeMode = await root.evaluate(element =>
element.getAttribute('data-theme') element.getAttribute('data-theme')

View File

@@ -1,6 +1,6 @@
import { test } from '@affine-test/kit/playwright'; import { test } from '@affine-test/kit/playwright';
import { openHomePage, openPluginPage } from '@affine-test/kit/utils/load-page'; import { openHomePage, openPluginPage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
test('plugin map should valid', async ({ page }) => { test('plugin map should valid', async ({ page }) => {
@@ -10,7 +10,7 @@ test('plugin map should valid', async ({ page }) => {
test('plugin should exist', async ({ page }) => { test('plugin should exist', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await page.route('**/plugins/**/package.json', route => route.fetch(), { await page.route('**/plugins/**/package.json', route => route.fetch(), {
times: 5, times: 5,
}); });

View File

@@ -8,9 +8,13 @@
}, },
"devDependencies": { "devDependencies": {
"@node-rs/argon2": "^1.5.2", "@node-rs/argon2": "^1.5.2",
"@playwright/test": "^1.37.1" "@playwright/test": "^1.37.1",
"express": "^4.18.2",
"http-proxy-middleware": "^3.0.0-beta.1"
}, },
"peerDependencies": { "peerDependencies": {
"@playwright/test": "*" "@playwright/test": "*",
"express": "*",
"http-proxy-middleware": "*"
} }
} }

View File

@@ -1,5 +1,5 @@
import { openHomePage } from '@affine-test/kit/utils/load-page'; import { openHomePage } from '@affine-test/kit/utils/load-page';
import { waitEditorLoad } from '@affine-test/kit/utils/page-logic'; import { waitForEditorLoad } from '@affine-test/kit/utils/page-logic';
import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar'; import { clickSideBarCurrentWorkspaceBanner } from '@affine-test/kit/utils/sidebar';
import { faker } from '@faker-js/faker'; import { faker } from '@faker-js/faker';
import { hash } from '@node-rs/argon2'; import { hash } from '@node-rs/argon2';
@@ -76,7 +76,7 @@ export async function loginUser(
} }
) { ) {
await openHomePage(page); await openHomePage(page);
await waitEditorLoad(page); await waitForEditorLoad(page);
await clickSideBarCurrentWorkspaceBanner(page); await clickSideBarCurrentWorkspaceBanner(page);
await page.getByTestId('cloud-signin-button').click({ await page.getByTestId('cloud-signin-button').click({

View File

@@ -10,3 +10,15 @@ export async function checkBlockHub(page: Page) {
if (!box2) throw new Error('block-hub not found'); if (!box2) throw new Error('block-hub not found');
expect(box2.height).toBeGreaterThan(box.height); expect(box2.height).toBeGreaterThan(box.height);
} }
export async function clickEdgelessModeButton(page: Page) {
await page.getByTestId('switch-edgeless-mode-button').click({
delay: 50,
});
}
export async function clickPageModeButton(page: Page) {
return page.getByTestId('switch-page-mode-button').click({
delay: 50,
});
}

View File

@@ -1,7 +1,7 @@
import type { Page } from '@playwright/test'; import type { Page } from '@playwright/test';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
export async function waitEditorLoad(page: Page) { export async function waitForEditorLoad(page: Page) {
await page.waitForSelector('v-line', { await page.waitForSelector('v-line', {
timeout: 10000, timeout: 10000,
}); });
@@ -19,7 +19,7 @@ export async function newPage(page: Page) {
await page.getByTestId('new-page-button').click({ await page.getByTestId('new-page-button').click({
delay: 100, delay: 100,
}); });
await waitEditorLoad(page); await waitForEditorLoad(page);
} }
export function getBlockSuiteEditorTitle(page: Page) { export function getBlockSuiteEditorTitle(page: Page) {
@@ -30,11 +30,6 @@ export async function type(page: Page, content: string, delay = 50) {
await page.keyboard.type(content, { delay }); await page.keyboard.type(content, { delay });
} }
export async function pressEnter(page: Page) {
// avoid flaky test by simulate real user input
await page.keyboard.press('Enter', { delay: 50 });
}
export const createLinkedPage = async (page: Page, pageName?: string) => { export const createLinkedPage = async (page: Page, pageName?: string) => {
await page.keyboard.type('@', { delay: 50 }); await page.keyboard.type('@', { delay: 50 });
const linkedPagePopover = page.locator('.linked-page-popover'); const linkedPagePopover = page.locator('.linked-page-popover');

62
tests/kit/utils/proxy.ts Normal file
View File

@@ -0,0 +1,62 @@
import type Test from '@playwright/test';
import type { BrowserContext } from '@playwright/test';
import express from 'express';
import { createProxyMiddleware } from 'http-proxy-middleware';
import { waitForEditorLoad } from './page-logic';
export async function check8080Available(context: BrowserContext) {
// make sure 8080 is ready
const page = await context.newPage();
await page.goto('http://localhost:8080/');
await waitForEditorLoad(page);
await page.close();
}
export function setupProxyServer(test: typeof Test, dir: string) {
let app: express.Express;
let server: ReturnType<express.Express['listen']>;
test.beforeEach(() => {
app = express();
app.use(express.static(dir));
server = app.listen(8081);
});
test.afterEach(() => {
server.close();
});
return {
get app() {
return app;
},
get server() {
return server;
},
switchToNext: async function () {
// close previous express server
await new Promise<void>((resolve, reject) => {
server.close(err => {
if (err) {
reject(err);
}
resolve();
});
});
app = express();
app.use(
createProxyMiddleware({
target: 'http://localhost:8080',
pathFilter: ['**'],
changeOrigin: true,
})
);
return new Promise<void>(resolve => {
server = app.listen(8081, () => {
console.log('proxy to next.js server');
resolve();
});
});
},
};
}

View File

@@ -105,8 +105,12 @@ __metadata:
dependencies: dependencies:
"@node-rs/argon2": ^1.5.2 "@node-rs/argon2": ^1.5.2
"@playwright/test": ^1.37.1 "@playwright/test": ^1.37.1
express: ^4.18.2
http-proxy-middleware: ^3.0.0-beta.1
peerDependencies: peerDependencies:
"@playwright/test": "*" "@playwright/test": "*"
express: "*"
http-proxy-middleware: "*"
languageName: unknown languageName: unknown
linkType: soft linkType: soft