mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-14 00:26:51 +08:00
test: remove deprecated api usage (#4577)
This commit is contained in:
@@ -124,7 +124,7 @@ test.describe('basic', () => {
|
||||
});
|
||||
const nameInput = page.getByPlaceholder('Input account name');
|
||||
await nameInput.clear();
|
||||
await nameInput.type(newName, {
|
||||
await nameInput.pressSequentially(newName, {
|
||||
delay: 50,
|
||||
});
|
||||
await page.getByTestId('save-user-name').click({
|
||||
|
||||
@@ -49,7 +49,7 @@ test.describe('collaboration', () => {
|
||||
);
|
||||
await enableCloudWorkspace(page);
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.type('TEST TITLE', {
|
||||
await title.pressSequentially('TEST TITLE', {
|
||||
delay: 50,
|
||||
});
|
||||
await page.keyboard.press('Enter', { delay: 50 });
|
||||
@@ -102,7 +102,7 @@ test.describe('collaboration', () => {
|
||||
await page2.goto(currentUrl);
|
||||
{
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.type('TEST TITLE', {
|
||||
await title.pressSequentially('TEST TITLE', {
|
||||
delay: 50,
|
||||
});
|
||||
}
|
||||
@@ -124,7 +124,7 @@ test.describe('collaboration', () => {
|
||||
await clickUserInfoCard(page);
|
||||
const input = page.getByTestId('user-name-input');
|
||||
await input.clear();
|
||||
await input.type('TEST USER', {
|
||||
await input.pressSequentially('TEST USER', {
|
||||
delay: 50,
|
||||
});
|
||||
await page.getByTestId('save-user-name').click({
|
||||
@@ -167,7 +167,7 @@ test.describe('collaboration', () => {
|
||||
const page2 = await context.newPage();
|
||||
await loginUser(page2, user.email);
|
||||
await page2.goto(page.url());
|
||||
waitForEditorLoad(page2);
|
||||
await waitForEditorLoad(page2);
|
||||
const collections = page2.getByTestId('collections');
|
||||
await expect(collections.getByText('test collection')).toBeVisible();
|
||||
}
|
||||
@@ -235,7 +235,7 @@ test.describe('collaboration members', () => {
|
||||
.all();
|
||||
|
||||
// make sure the first member is the owner
|
||||
expect(page.getByTestId('member-item').first()).toContainText(
|
||||
await expect(page.getByTestId('member-item').first()).toContainText(
|
||||
'Workspace Owner'
|
||||
);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { platform } from 'node:os';
|
||||
|
||||
import { test } from '@affine-test/kit/electron';
|
||||
import { getBlockSuiteEditorTitle } from '@affine-test/kit/utils/page-logic';
|
||||
import { clickSideBarSettingButton } from '@affine-test/kit/utils/sidebar';
|
||||
import { expect } from '@playwright/test';
|
||||
|
||||
@@ -27,8 +28,9 @@ if (platform() === 'darwin') {
|
||||
delay: 100,
|
||||
});
|
||||
await page.waitForSelector('v-line');
|
||||
await page.focus('.affine-doc-page-block-title');
|
||||
await page.type('.affine-doc-page-block-title', 'test1', {
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.focus();
|
||||
await title.pressSequentially('test1', {
|
||||
delay: 100,
|
||||
});
|
||||
await page.waitForTimeout(500);
|
||||
@@ -36,8 +38,9 @@ if (platform() === 'darwin') {
|
||||
delay: 100,
|
||||
});
|
||||
await page.waitForSelector('v-line');
|
||||
await page.focus('.affine-doc-page-block-title');
|
||||
await page.type('.affine-doc-page-block-title', 'test2', {
|
||||
|
||||
await title.focus();
|
||||
await title.pressSequentially('test2', {
|
||||
delay: 100,
|
||||
});
|
||||
await page.waitForTimeout(500);
|
||||
@@ -45,8 +48,8 @@ if (platform() === 'darwin') {
|
||||
delay: 100,
|
||||
});
|
||||
await page.waitForSelector('v-line');
|
||||
await page.focus('.affine-doc-page-block-title');
|
||||
await page.type('.affine-doc-page-block-title', 'test3', {
|
||||
await title.focus();
|
||||
await title.pressSequentially('test3', {
|
||||
delay: 100,
|
||||
});
|
||||
}
|
||||
@@ -155,9 +158,11 @@ test('windows only check', async ({ page }) => {
|
||||
test('delete workspace', async ({ page }) => {
|
||||
await page.getByTestId('current-workspace').click();
|
||||
await page.getByTestId('new-workspace').click();
|
||||
await page.getByTestId('create-workspace-input').type('Delete Me', {
|
||||
delay: 100,
|
||||
});
|
||||
await page
|
||||
.getByTestId('create-workspace-input')
|
||||
.pressSequentially('Delete Me', {
|
||||
delay: 100,
|
||||
});
|
||||
await page.getByTestId('create-workspace-create-button').click({
|
||||
delay: 100,
|
||||
});
|
||||
@@ -170,7 +175,7 @@ test('delete workspace', async ({ page }) => {
|
||||
expect(await page.getByTestId('workspace-name-input').inputValue()).toBe(
|
||||
'Delete Me'
|
||||
);
|
||||
const contentElement = await page.getByTestId('setting-modal-content');
|
||||
const contentElement = page.getByTestId('setting-modal-content');
|
||||
const boundingBox = await contentElement.boundingBox();
|
||||
if (!boundingBox) {
|
||||
throw new Error('boundingBox is null');
|
||||
@@ -181,7 +186,9 @@ test('delete workspace', async ({ page }) => {
|
||||
);
|
||||
await page.mouse.wheel(0, 500);
|
||||
await page.getByTestId('delete-workspace-button').click();
|
||||
await page.getByTestId('delete-workspace-input').type('Delete Me');
|
||||
await page
|
||||
.getByTestId('delete-workspace-input')
|
||||
.pressSequentially('Delete Me');
|
||||
await page.getByTestId('delete-workspace-confirm-button').click();
|
||||
await page.waitForTimeout(1000);
|
||||
expect(await page.getByTestId('workspace-name').textContent()).toBe(
|
||||
|
||||
@@ -21,7 +21,7 @@ test('database migration', async ({ page, context }) => {
|
||||
});
|
||||
await page.getByTestId('new-page-button').click();
|
||||
const title = page.locator('.affine-default-page-block-title');
|
||||
await title.type('hello');
|
||||
await title.pressSequentially('hello');
|
||||
await page.keyboard.press('Enter', { delay: 50 });
|
||||
await page.keyboard.press('/', { delay: 50 });
|
||||
await page.keyboard.press('d');
|
||||
|
||||
@@ -24,7 +24,7 @@ test('surface migration', async ({ page, context }) => {
|
||||
});
|
||||
await page.getByTestId('new-page-button').click();
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.type('hello');
|
||||
await title.pressSequentially('hello');
|
||||
await page.keyboard.press('Enter', { delay: 50 });
|
||||
await page.keyboard.type('world', {
|
||||
delay: 50,
|
||||
|
||||
@@ -23,7 +23,7 @@ test('database is useable', async ({ page }) => {
|
||||
await clickNewPageButton(page);
|
||||
await waitForEditorLoad(page);
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.type('test title');
|
||||
await title.pressSequentially('test title');
|
||||
await page.keyboard.press('Enter');
|
||||
expect(await title.innerText()).toBe('test title');
|
||||
await addDatabase(page);
|
||||
@@ -34,7 +34,7 @@ test('database is useable', async ({ page }) => {
|
||||
await clickNewPageButton(page);
|
||||
await waitForEditorLoad(page);
|
||||
const title2 = getBlockSuiteEditorTitle(page);
|
||||
await title2.type('test title2');
|
||||
await title2.pressSequentially('test title2');
|
||||
await page.waitForTimeout(500);
|
||||
expect(await title2.innerText()).toBe('test title2');
|
||||
await page.keyboard.press('Enter');
|
||||
@@ -48,14 +48,14 @@ test('link page is useable', async ({ page }) => {
|
||||
await waitForEditorLoad(page);
|
||||
await clickNewPageButton(page);
|
||||
await waitForEditorLoad(page);
|
||||
const title = await getBlockSuiteEditorTitle(page);
|
||||
await title.type('page1');
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.pressSequentially('page1');
|
||||
await page.keyboard.press('Enter');
|
||||
expect(await title.innerText()).toBe('page1');
|
||||
await clickNewPageButton(page);
|
||||
await waitForEditorLoad(page);
|
||||
const title2 = await getBlockSuiteEditorTitle(page);
|
||||
await title2.type('page2');
|
||||
const title2 = getBlockSuiteEditorTitle(page);
|
||||
await title2.pressSequentially('page2');
|
||||
await page.keyboard.press('Enter');
|
||||
expect(await title2.innerText()).toBe('page2');
|
||||
await page.keyboard.press('@', { delay: 50 });
|
||||
|
||||
@@ -13,7 +13,7 @@ test('Duplicate page should work', async ({ page }) => {
|
||||
await waitForEditorLoad(page);
|
||||
await clickNewPageButton(page);
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.type('test');
|
||||
await title.pressSequentially('test');
|
||||
await clickPageMoreActions(page);
|
||||
const duplicateButton = page.getByTestId('editor-option-menu-duplicate');
|
||||
await duplicateButton.click({ delay: 100 });
|
||||
|
||||
@@ -19,7 +19,7 @@ test('should create a page with a local first avatar and remove it', async ({
|
||||
await page.getByTestId('new-workspace').click({ delay: 50 });
|
||||
await page
|
||||
.getByTestId('create-workspace-input')
|
||||
.type('Test Workspace 1', { delay: 50 });
|
||||
.pressSequentially('Test Workspace 1', { delay: 50 });
|
||||
await page.getByTestId('create-workspace-create-button').click();
|
||||
await page.getByTestId('workspace-name').click({
|
||||
delay: 50,
|
||||
|
||||
@@ -13,7 +13,7 @@ test('Create new workspace, then delete it', async ({ page, workspace }) => {
|
||||
await page.getByTestId('new-workspace').click();
|
||||
await page
|
||||
.getByTestId('create-workspace-input')
|
||||
.type('Test Workspace', { delay: 50 });
|
||||
.pressSequentially('Test Workspace', { delay: 50 });
|
||||
await page.getByTestId('create-workspace-create-button').click();
|
||||
|
||||
await page.waitForTimeout(1000);
|
||||
@@ -25,12 +25,13 @@ test('Create new workspace, then delete it', async ({ page, workspace }) => {
|
||||
await openWorkspaceSettingPanel(page, 'Test Workspace');
|
||||
await page.getByTestId('delete-workspace-button').click();
|
||||
const workspaceNameDom = await page.getByTestId('workspace-name');
|
||||
const currentWorkspaceName = await workspaceNameDom.evaluate(
|
||||
const currentWorkspaceName = (await workspaceNameDom.evaluate(
|
||||
node => node.textContent
|
||||
);
|
||||
)) as string;
|
||||
expect(currentWorkspaceName).toBeDefined();
|
||||
await page
|
||||
.getByTestId('delete-workspace-input')
|
||||
.type(currentWorkspaceName as string);
|
||||
.pressSequentially(currentWorkspaceName);
|
||||
const promise = page
|
||||
.getByTestId('affine-notification')
|
||||
.waitFor({ state: 'attached' });
|
||||
@@ -46,7 +47,7 @@ test('Create new workspace, then delete it', async ({ page, workspace }) => {
|
||||
|
||||
expect(currentWorkspace.flavour).toContain('local');
|
||||
});
|
||||
//FIXME: this test is broken
|
||||
|
||||
test('Delete last workspace', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
await waitForEditorLoad(page);
|
||||
@@ -59,12 +60,14 @@ test('Delete last workspace', async ({ page }) => {
|
||||
await page.getByTestId('delete-workspace-button').click();
|
||||
await page
|
||||
.getByTestId('delete-workspace-input')
|
||||
.type(currentWorkspaceName as string);
|
||||
.pressSequentially(currentWorkspaceName as string);
|
||||
await page.getByTestId('delete-workspace-confirm-button').click();
|
||||
await openHomePage(page);
|
||||
await expect(page.getByTestId('new-workspace')).toBeVisible();
|
||||
await page.getByTestId('new-workspace').click();
|
||||
await page.type('[data-testid="create-workspace-input"]', 'Test Workspace');
|
||||
await page
|
||||
.locator('[data-testid="create-workspace-input"]')
|
||||
.pressSequentially('Test Workspace');
|
||||
await page.getByTestId('create-workspace-create-button').click();
|
||||
await page.waitForTimeout(1000);
|
||||
await page.waitForSelector('[data-testid="workspace-name"]');
|
||||
|
||||
@@ -52,7 +52,7 @@ test('New a page , then delete it in page, blockHub and option menu will not app
|
||||
await waitForEditorLoad(page);
|
||||
await clickNewPageButton(page);
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.type('test');
|
||||
await title.pressSequentially('test');
|
||||
await clickPageMoreActions(page);
|
||||
await page.getByTestId('editor-option-menu-delete').click();
|
||||
await page.getByTestId('confirm-delete-page').click();
|
||||
|
||||
@@ -219,7 +219,7 @@ test('assert the recent browse pages are on the recent list', async ({
|
||||
await clickNewPageButton(page);
|
||||
{
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.type('sgtokidoki', {
|
||||
await title.pressSequentially('sgtokidoki', {
|
||||
delay: 50,
|
||||
});
|
||||
}
|
||||
@@ -231,7 +231,7 @@ test('assert the recent browse pages are on the recent list', async ({
|
||||
await addNewPage.click();
|
||||
{
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.type('theliquidhorse', {
|
||||
await title.pressSequentially('theliquidhorse', {
|
||||
delay: 50,
|
||||
});
|
||||
}
|
||||
@@ -242,7 +242,7 @@ test('assert the recent browse pages are on the recent list', async ({
|
||||
await addNewPage.click();
|
||||
{
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.type('battlekot', {
|
||||
await title.pressSequentially('battlekot', {
|
||||
delay: 50,
|
||||
});
|
||||
}
|
||||
@@ -271,7 +271,7 @@ test('assert the recent browse pages are on the recent list', async ({
|
||||
await page.waitForTimeout(200);
|
||||
{
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.type('affine is the best', {
|
||||
await title.pressSequentially('affine is the best', {
|
||||
delay: 50,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user