test: remove deprecated api usage (#4577)

This commit is contained in:
Alex Yang
2023-10-11 01:05:06 -05:00
committed by GitHub
parent 1f6a105e5c
commit 8f5ee9234c
11 changed files with 49 additions and 39 deletions

View File

@@ -124,7 +124,7 @@ test.describe('basic', () => {
}); });
const nameInput = page.getByPlaceholder('Input account name'); const nameInput = page.getByPlaceholder('Input account name');
await nameInput.clear(); await nameInput.clear();
await nameInput.type(newName, { await nameInput.pressSequentially(newName, {
delay: 50, delay: 50,
}); });
await page.getByTestId('save-user-name').click({ await page.getByTestId('save-user-name').click({

View File

@@ -49,7 +49,7 @@ test.describe('collaboration', () => {
); );
await enableCloudWorkspace(page); await enableCloudWorkspace(page);
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('TEST TITLE', { await title.pressSequentially('TEST TITLE', {
delay: 50, delay: 50,
}); });
await page.keyboard.press('Enter', { delay: 50 }); await page.keyboard.press('Enter', { delay: 50 });
@@ -102,7 +102,7 @@ test.describe('collaboration', () => {
await page2.goto(currentUrl); await page2.goto(currentUrl);
{ {
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('TEST TITLE', { await title.pressSequentially('TEST TITLE', {
delay: 50, delay: 50,
}); });
} }
@@ -124,7 +124,7 @@ test.describe('collaboration', () => {
await clickUserInfoCard(page); await clickUserInfoCard(page);
const input = page.getByTestId('user-name-input'); const input = page.getByTestId('user-name-input');
await input.clear(); await input.clear();
await input.type('TEST USER', { await input.pressSequentially('TEST USER', {
delay: 50, delay: 50,
}); });
await page.getByTestId('save-user-name').click({ await page.getByTestId('save-user-name').click({
@@ -167,7 +167,7 @@ test.describe('collaboration', () => {
const page2 = await context.newPage(); const page2 = await context.newPage();
await loginUser(page2, user.email); await loginUser(page2, user.email);
await page2.goto(page.url()); await page2.goto(page.url());
waitForEditorLoad(page2); await waitForEditorLoad(page2);
const collections = page2.getByTestId('collections'); const collections = page2.getByTestId('collections');
await expect(collections.getByText('test collection')).toBeVisible(); await expect(collections.getByText('test collection')).toBeVisible();
} }
@@ -235,7 +235,7 @@ test.describe('collaboration members', () => {
.all(); .all();
// make sure the first member is the owner // 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' 'Workspace Owner'
); );

View File

@@ -1,6 +1,7 @@
import { platform } from 'node:os'; import { platform } from 'node:os';
import { test } from '@affine-test/kit/electron'; 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 { clickSideBarSettingButton } from '@affine-test/kit/utils/sidebar';
import { expect } from '@playwright/test'; import { expect } from '@playwright/test';
@@ -27,8 +28,9 @@ if (platform() === 'darwin') {
delay: 100, delay: 100,
}); });
await page.waitForSelector('v-line'); await page.waitForSelector('v-line');
await page.focus('.affine-doc-page-block-title'); const title = getBlockSuiteEditorTitle(page);
await page.type('.affine-doc-page-block-title', 'test1', { await title.focus();
await title.pressSequentially('test1', {
delay: 100, delay: 100,
}); });
await page.waitForTimeout(500); await page.waitForTimeout(500);
@@ -36,8 +38,9 @@ if (platform() === 'darwin') {
delay: 100, delay: 100,
}); });
await page.waitForSelector('v-line'); 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, delay: 100,
}); });
await page.waitForTimeout(500); await page.waitForTimeout(500);
@@ -45,8 +48,8 @@ if (platform() === 'darwin') {
delay: 100, delay: 100,
}); });
await page.waitForSelector('v-line'); await page.waitForSelector('v-line');
await page.focus('.affine-doc-page-block-title'); await title.focus();
await page.type('.affine-doc-page-block-title', 'test3', { await title.pressSequentially('test3', {
delay: 100, delay: 100,
}); });
} }
@@ -155,9 +158,11 @@ test('windows only check', async ({ page }) => {
test('delete workspace', async ({ page }) => { test('delete workspace', async ({ page }) => {
await page.getByTestId('current-workspace').click(); await page.getByTestId('current-workspace').click();
await page.getByTestId('new-workspace').click(); await page.getByTestId('new-workspace').click();
await page.getByTestId('create-workspace-input').type('Delete Me', { await page
delay: 100, .getByTestId('create-workspace-input')
}); .pressSequentially('Delete Me', {
delay: 100,
});
await page.getByTestId('create-workspace-create-button').click({ await page.getByTestId('create-workspace-create-button').click({
delay: 100, delay: 100,
}); });
@@ -170,7 +175,7 @@ test('delete workspace', async ({ page }) => {
expect(await page.getByTestId('workspace-name-input').inputValue()).toBe( expect(await page.getByTestId('workspace-name-input').inputValue()).toBe(
'Delete Me' 'Delete Me'
); );
const contentElement = await page.getByTestId('setting-modal-content'); const contentElement = page.getByTestId('setting-modal-content');
const boundingBox = await contentElement.boundingBox(); const boundingBox = await contentElement.boundingBox();
if (!boundingBox) { if (!boundingBox) {
throw new Error('boundingBox is null'); throw new Error('boundingBox is null');
@@ -181,7 +186,9 @@ test('delete workspace', async ({ page }) => {
); );
await page.mouse.wheel(0, 500); await page.mouse.wheel(0, 500);
await page.getByTestId('delete-workspace-button').click(); 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.getByTestId('delete-workspace-confirm-button').click();
await page.waitForTimeout(1000); await page.waitForTimeout(1000);
expect(await page.getByTestId('workspace-name').textContent()).toBe( expect(await page.getByTestId('workspace-name').textContent()).toBe(

View File

@@ -21,7 +21,7 @@ test('database migration', async ({ page, context }) => {
}); });
await page.getByTestId('new-page-button').click(); await page.getByTestId('new-page-button').click();
const title = page.locator('.affine-default-page-block-title'); 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('Enter', { delay: 50 });
await page.keyboard.press('/', { delay: 50 }); await page.keyboard.press('/', { delay: 50 });
await page.keyboard.press('d'); await page.keyboard.press('d');

View File

@@ -24,7 +24,7 @@ test('surface migration', async ({ page, context }) => {
}); });
await page.getByTestId('new-page-button').click(); await page.getByTestId('new-page-button').click();
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('hello'); await title.pressSequentially('hello');
await page.keyboard.press('Enter', { delay: 50 }); await page.keyboard.press('Enter', { delay: 50 });
await page.keyboard.type('world', { await page.keyboard.type('world', {
delay: 50, delay: 50,

View File

@@ -23,7 +23,7 @@ test('database is useable', async ({ page }) => {
await clickNewPageButton(page); await clickNewPageButton(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('test title'); await title.pressSequentially('test title');
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');
expect(await title.innerText()).toBe('test title'); expect(await title.innerText()).toBe('test title');
await addDatabase(page); await addDatabase(page);
@@ -34,7 +34,7 @@ test('database is useable', async ({ page }) => {
await clickNewPageButton(page); await clickNewPageButton(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
const title2 = getBlockSuiteEditorTitle(page); const title2 = getBlockSuiteEditorTitle(page);
await title2.type('test title2'); await title2.pressSequentially('test title2');
await page.waitForTimeout(500); await page.waitForTimeout(500);
expect(await title2.innerText()).toBe('test title2'); expect(await title2.innerText()).toBe('test title2');
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');
@@ -48,14 +48,14 @@ test('link page is useable', async ({ page }) => {
await waitForEditorLoad(page); await waitForEditorLoad(page);
await clickNewPageButton(page); await clickNewPageButton(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
const title = await getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('page1'); await title.pressSequentially('page1');
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');
expect(await title.innerText()).toBe('page1'); expect(await title.innerText()).toBe('page1');
await clickNewPageButton(page); await clickNewPageButton(page);
await waitForEditorLoad(page); await waitForEditorLoad(page);
const title2 = await getBlockSuiteEditorTitle(page); const title2 = getBlockSuiteEditorTitle(page);
await title2.type('page2'); await title2.pressSequentially('page2');
await page.keyboard.press('Enter'); await page.keyboard.press('Enter');
expect(await title2.innerText()).toBe('page2'); expect(await title2.innerText()).toBe('page2');
await page.keyboard.press('@', { delay: 50 }); await page.keyboard.press('@', { delay: 50 });

View File

@@ -13,7 +13,7 @@ test('Duplicate page should work', async ({ page }) => {
await waitForEditorLoad(page); await waitForEditorLoad(page);
await clickNewPageButton(page); await clickNewPageButton(page);
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('test'); await title.pressSequentially('test');
await clickPageMoreActions(page); await clickPageMoreActions(page);
const duplicateButton = page.getByTestId('editor-option-menu-duplicate'); const duplicateButton = page.getByTestId('editor-option-menu-duplicate');
await duplicateButton.click({ delay: 100 }); await duplicateButton.click({ delay: 100 });

View File

@@ -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('new-workspace').click({ delay: 50 });
await page await page
.getByTestId('create-workspace-input') .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('create-workspace-create-button').click();
await page.getByTestId('workspace-name').click({ await page.getByTestId('workspace-name').click({
delay: 50, delay: 50,

View File

@@ -13,7 +13,7 @@ test('Create new workspace, then delete it', async ({ page, workspace }) => {
await page.getByTestId('new-workspace').click(); await page.getByTestId('new-workspace').click();
await page await page
.getByTestId('create-workspace-input') .getByTestId('create-workspace-input')
.type('Test Workspace', { delay: 50 }); .pressSequentially('Test Workspace', { delay: 50 });
await page.getByTestId('create-workspace-create-button').click(); await page.getByTestId('create-workspace-create-button').click();
await page.waitForTimeout(1000); await page.waitForTimeout(1000);
@@ -25,12 +25,13 @@ test('Create new workspace, then delete it', async ({ page, workspace }) => {
await openWorkspaceSettingPanel(page, 'Test Workspace'); await openWorkspaceSettingPanel(page, 'Test Workspace');
await page.getByTestId('delete-workspace-button').click(); await page.getByTestId('delete-workspace-button').click();
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
); )) as string;
expect(currentWorkspaceName).toBeDefined();
await page await page
.getByTestId('delete-workspace-input') .getByTestId('delete-workspace-input')
.type(currentWorkspaceName as string); .pressSequentially(currentWorkspaceName);
const promise = page const promise = page
.getByTestId('affine-notification') .getByTestId('affine-notification')
.waitFor({ state: 'attached' }); .waitFor({ state: 'attached' });
@@ -46,7 +47,7 @@ test('Create new workspace, then delete it', async ({ page, workspace }) => {
expect(currentWorkspace.flavour).toContain('local'); expect(currentWorkspace.flavour).toContain('local');
}); });
//FIXME: this test is broken
test('Delete last workspace', async ({ page }) => { test('Delete last workspace', async ({ page }) => {
await openHomePage(page); await openHomePage(page);
await waitForEditorLoad(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-button').click();
await page await page
.getByTestId('delete-workspace-input') .getByTestId('delete-workspace-input')
.type(currentWorkspaceName as string); .pressSequentially(currentWorkspaceName as string);
await page.getByTestId('delete-workspace-confirm-button').click(); await page.getByTestId('delete-workspace-confirm-button').click();
await openHomePage(page); await openHomePage(page);
await expect(page.getByTestId('new-workspace')).toBeVisible(); await expect(page.getByTestId('new-workspace')).toBeVisible();
await page.getByTestId('new-workspace').click(); 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.getByTestId('create-workspace-create-button').click();
await page.waitForTimeout(1000); await page.waitForTimeout(1000);
await page.waitForSelector('[data-testid="workspace-name"]'); await page.waitForSelector('[data-testid="workspace-name"]');

View File

@@ -52,7 +52,7 @@ test('New a page , then delete it in page, blockHub and option menu will not app
await waitForEditorLoad(page); await waitForEditorLoad(page);
await clickNewPageButton(page); await clickNewPageButton(page);
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('test'); await title.pressSequentially('test');
await clickPageMoreActions(page); await clickPageMoreActions(page);
await page.getByTestId('editor-option-menu-delete').click(); await page.getByTestId('editor-option-menu-delete').click();
await page.getByTestId('confirm-delete-page').click(); await page.getByTestId('confirm-delete-page').click();

View File

@@ -219,7 +219,7 @@ test('assert the recent browse pages are on the recent list', async ({
await clickNewPageButton(page); await clickNewPageButton(page);
{ {
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('sgtokidoki', { await title.pressSequentially('sgtokidoki', {
delay: 50, delay: 50,
}); });
} }
@@ -231,7 +231,7 @@ test('assert the recent browse pages are on the recent list', async ({
await addNewPage.click(); await addNewPage.click();
{ {
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('theliquidhorse', { await title.pressSequentially('theliquidhorse', {
delay: 50, delay: 50,
}); });
} }
@@ -242,7 +242,7 @@ test('assert the recent browse pages are on the recent list', async ({
await addNewPage.click(); await addNewPage.click();
{ {
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('battlekot', { await title.pressSequentially('battlekot', {
delay: 50, delay: 50,
}); });
} }
@@ -271,7 +271,7 @@ test('assert the recent browse pages are on the recent list', async ({
await page.waitForTimeout(200); await page.waitForTimeout(200);
{ {
const title = getBlockSuiteEditorTitle(page); const title = getBlockSuiteEditorTitle(page);
await title.type('affine is the best', { await title.pressSequentially('affine is the best', {
delay: 50, delay: 50,
}); });
} }