Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

test(core): add missing await for expect (#11900)

L-Sun9baef237f249
diff --git a/tests/affine-cloud-copilot/e2e/chat-with/network.spec.ts b/tests/affine-cloud-copilot/e2e/chat-with/network.spec.ts
index c012f35356..b22182d399 100644
--- a/tests/affine-cloud-copilot/e2e/chat-with/network.spec.ts
+++ b/tests/affine-cloud-copilot/e2e/chat-with/network.spec.ts
@@ -70,7 +70,7 @@ test.describe('AIChatWith/Network', () => {
20000
);
const { message } = await utils.chatPanel.getLatestAssistantMessage(page);
- expect(await message.locator('affine-footnote-node').count()).toBe(0);
+ await expect(message.locator('affine-footnote-node')).toHaveCount(0);
});
test('should disable network search when chating with image', async ({
diff --git a/tests/affine-cloud-copilot/e2e/chat-with/tags.spec.ts b/tests/affine-cloud-copilot/e2e/chat-with/tags.spec.ts
index 5865d6a399..b72554ae2b 100644
--- a/tests/affine-cloud-copilot/e2e/chat-with/tags.spec.ts
+++ b/tests/affine-cloud-copilot/e2e/chat-with/tags.spec.ts
@@ -37,7 +37,7 @@ test.describe('AIChatWith/tags', () => {
const { content, message } =
await utils.chatPanel.getLatestAssistantMessage(page);
expect(content).toMatch(/TagAAaa.*cat/);
- expect(await message.locator('affine-footnote-node').count()).toBe(1);
+ await expect(message.locator('affine-footnote-node')).toHaveCount(1);
}).toPass();
});
@@ -67,7 +67,7 @@ test.describe('AIChatWith/tags', () => {
await utils.chatPanel.getLatestAssistantMessage(page);
expect(content).toMatch(/TagEEee.*cat/);
expect(content).toMatch(/TagFFff.*dog/);
- expect(await message.locator('affine-footnote-node').count()).toBe(2);
+ await expect(message.locator('affine-footnote-node')).toHaveCount(2);
}).toPass();
});
});
diff --git a/tests/affine-cloud-copilot/e2e/insertion/save-as-doc.spec.ts b/tests/affine-cloud-copilot/e2e/insertion/save-as-doc.spec.ts
index b4de24e848..d84eb4b79c 100644
--- a/tests/affine-cloud-copilot/e2e/insertion/save-as-doc.spec.ts
+++ b/tests/affine-cloud-copilot/e2e/insertion/save-as-doc.spec.ts
@@ -31,7 +31,7 @@ test.describe('AIInsertion/SaveAsDoc', () => {
const { actions, content } =
await utils.chatPanel.getLatestAssistantMessage(page);
await actions.saveAsDoc();
- await page.getByText('New doc created');
+ await page.getByText('New doc created').waitFor({ state: 'visible' });
// Verify the ai block is created
const editorContent = await utils.editor.getEditorContent(page);
@@ -63,7 +63,7 @@ test.describe('AIInsertion/SaveAsDoc', () => {
const { actions, content } =
await utils.chatPanel.getLatestAssistantMessage(page);
await actions.saveAsDoc();
- await page.getByText('New doc created');
+ await page.getByText('New doc created').waitFor({ state: 'visible' });
// Switch to page mode
await utils.editor.isPageMode(page);
diff --git a/tests/affine-cloud/e2e/login.spec.ts b/tests/affine-cloud/e2e/login.spec.ts
index e9154e15bf..675430109b 100644
--- a/tests/affine-cloud/e2e/login.spec.ts
+++ b/tests/affine-cloud/e2e/login.spec.ts
@@ -85,8 +85,8 @@ test.describe('login first', () => {
{
await clickSideBarSettingButton(page);
const locator = page.getByTestId('user-info-card');
- expect(locator.getByText(user.email)).toBeTruthy();
- expect(locator.getByText(user.name)).toBeTruthy();
+ await expect(locator.getByText(user.email)).toBeVisible();
+ await expect(locator.getByText(user.name)).toBeVisible();
await locator.click({
delay: 50,
});
@@ -103,8 +103,8 @@ test.describe('login first', () => {
{
await clickSideBarSettingButton(page);
const locator = page.getByTestId('user-info-card');
- expect(locator.getByText(user.email)).toBeTruthy();
- expect(locator.getByText(newName)).toBeTruthy();
+ await expect(locator.getByText(user.email)).toBeVisible();
+ await expect(locator.getByText(newName)).toBeVisible();
}
});
});
diff --git a/tests/affine-cloud/e2e/share-page.spec.ts b/tests/affine-cloud/e2e/share-page.spec.ts
index c43db08589..d347b3b06a 100644
--- a/tests/affine-cloud/e2e/share-page.spec.ts
+++ b/tests/affine-cloud/e2e/share-page.spec.ts
@@ -68,7 +68,7 @@ test('can enable share page', async ({ page, browser }) => {
await waitForEditorLoad(page2);
const title = getBlockSuiteEditorTitle(page2);
await expect(title).toContainText('TEST TITLE');
- expect(page2.locator('affine-paragraph').first()).toContainText(
+ await expect(page2.locator('affine-paragraph').first()).toContainText(
'TEST CONTENT'
);
}
@@ -174,7 +174,7 @@ test('append paragraph should be disabled in shared mode', async ({
}
expect(error).toBeNull();
- expect(await paragraph.count()).toBe(numParagraphs);
+ await expect(paragraph).toHaveCount(numParagraphs);
}
});
@@ -217,7 +217,7 @@ test('share page with default edgeless', async ({ page, browser }) => {
await expect(page.locator('affine-edgeless-root')).toBeVisible({
timeout: 1000,
});
- expect(page2.locator('affine-paragraph').first()).toContainText(
+ await expect(page2.locator('affine-paragraph').first()).toContainText(
'TEST CONTENT'
);
}
diff --git a/tests/affine-cloud/e2e/workspace.spec.ts b/tests/affine-cloud/e2e/workspace.spec.ts
index 1a774f2c6f..372e4c5194 100644
--- a/tests/affine-cloud/e2e/workspace.spec.ts
+++ b/tests/affine-cloud/e2e/workspace.spec.ts
@@ -93,11 +93,11 @@ test('should have pagination in member list', async ({ page }) => {
// Click left arrow to back to first page
await navigationItems[0].click();
await page.waitForTimeout(500);
- expect(await page.locator('[data-testid="member-item"]').count()).toBe(8);
+ await expect(page.locator('[data-testid="member-item"]')).toHaveCount(8);
// Click right arrow to second page
await navigationItems[3].click();
await page.waitForTimeout(500);
- expect(await page.locator('[data-testid="member-item"]').count()).toBe(3);
+ await expect(page.locator('[data-testid="member-item"]')).toHaveCount(3);
});
test('should transform local favorites data', async ({ page }) => {
diff --git a/tests/affine-local/e2e/blocksuite/edgeless/embed.spec.ts b/tests/affine-local/e2e/blocksuite/edgeless/embed.spec.ts
index be98567818..ccff5985c8 100644
--- a/tests/affine-local/e2e/blocksuite/edgeless/embed.spec.ts
+++ b/tests/affine-local/e2e/blocksuite/edgeless/embed.spec.ts
@@ -36,7 +36,7 @@ test('should close embed editing modal when editor switching to page mode by sho
await page.keyboard.press('Alt+s');
await waitForEditorLoad(page);
- expect(editingModal).toBeHidden();
+ await expect(editingModal).toBeHidden();
});
test('embed card should not overflow the edgeless note', async ({ page }) => {
diff --git a/tests/affine-local/e2e/blocksuite/embed/synced.spec.ts b/tests/affine-local/e2e/blocksuite/embed/synced.spec.ts
index 67d8d834a7..d27e366a0b 100644
--- a/tests/affine-local/e2e/blocksuite/embed/synced.spec.ts
+++ b/tests/affine-local/e2e/blocksuite/embed/synced.spec.ts
@@ -53,6 +53,6 @@ test('should not show hidden note in embed view page mode', async ({
// check the content
const embedLink = page.locator('affine-embed-synced-doc-block');
- expect(embedLink.getByText(/visible content/)).toBeVisible();
- expect(embedLink.getByText(/hidden content/)).toBeHidden();
+ await expect(embedLink.getByText(/visible content/)).toBeVisible();
+ await expect(embedLink.getByText(/hidden content/)).toBeHidden();
});
diff --git a/tests/affine-local/e2e/blocksuite/outline/outline-panel.spec.ts b/tests/affine-local/e2e/blocksuite/outline/outline-panel.spec.ts
index 652cd28d71..13c38ca64b 100644
--- a/tests/affine-local/e2e/blocksuite/outline/outline-panel.spec.ts
+++ b/tests/affine-local/e2e/blocksuite/outline/outline-panel.spec.ts
@@ -193,15 +193,15 @@ test.describe('TOC display', () => {
const toc = await openTocPanel(page);
const sortingButton = locateSortingButton(toc);
await expect(sortingButton).not.toHaveClass(/active/);
- expect(toc.locator('[data-sortable="false"]')).toHaveCount(1);
+ await expect(toc.locator('[data-sortable="false"]')).toHaveCount(1);
await clickEdgelessModeButton(page);
await expect(sortingButton).toHaveClass(/active/);
- expect(toc.locator('[data-sortable="true"]')).toHaveCount(1);
+ await expect(toc.locator('[data-sortable="true"]')).toHaveCount(1);
await sortingButton.click();
await expect(sortingButton).not.toHaveClass(/active/);
- expect(toc.locator('[data-sortable="false"]')).toHaveCount(1);
+ await expect(toc.locator('[data-sortable="false"]')).toHaveCount(1);
});
test('should notify user when there are some page only notes and sorting is disabled', async ({
diff --git a/tests/affine-local/e2e/blocksuite/outline/outline-viewer.spec.ts b/tests/affine-local/e2e/blocksuite/outline/outline-viewer.spec.ts
index 77710dc4e2..d463df870b 100644
--- a/tests/affine-local/e2e/blocksuite/outline/outline-viewer.spec.ts
+++ b/tests/affine-local/e2e/blocksuite/outline/outline-viewer.spec.ts
@@ -176,7 +176,7 @@ test('should hide edgeless-only note headings', async ({ page }) => {
.getByTestId('outline-block-preview-h1')
.locator('span');
await h1InPanel.waitFor({ state: 'visible' });
- expect(h1InPanel).toContainText(['Heading 1']);
+ await expect(h1InPanel).toContainText(['Heading 1']);
});
test('outline viewer should be useable in doc peek preview', async ({
diff --git a/tests/affine-local/e2e/local-first-collections-items.spec.ts b/tests/affine-local/e2e/local-first-collections-items.spec.ts
index 37a50d2209..b54a0ecf8d 100644
--- a/tests/affine-local/e2e/local-first-collections-items.spec.ts
+++ b/tests/affine-local/e2e/local-first-collections-items.spec.ts
@@ -87,9 +87,9 @@ test('Show collections items in sidebar', async ({ page }) => {
const deletePage = page.getByText('Move to trash');
await deletePage.click();
await page.getByTestId('confirm-modal-confirm').click();
- expect(
- await first.locator('[data-testid^="navigation-panel-doc-"]').count()
- ).toBe(0);
+ await expect(
+ first.locator('[data-testid^="navigation-panel-doc-"]')
+ ).toHaveCount(0);
// position is a workaround for the hover issue when empty collection status's height > 26px (will cause scroll)
await first.hover({ position: { x: 10, y: 10 } });
await first
@@ -100,7 +100,7 @@ test('Show collections items in sidebar', async ({ page }) => {
await page.waitForTimeout(50);
await expect(items).toHaveCount(0);
await createAndPinCollection(page);
- expect(await items.count()).toBe(1);
+ await expect(items).toHaveCount(1);
await clickSideBarAllPageButton(page);
await createLocalWorkspace(
{
@@ -109,7 +109,7 @@ test('Show collections items in sidebar', async ({ page }) => {
page
);
await waitForEditorLoad(page);
- expect(await items.count()).toBe(0);
+ await expect(items).toHaveCount(0);
await clickSideBarCurrentWorkspaceBanner(page);
await page.getByTestId('workspace-card').nth(0).click();
});
@@ -122,7 +122,7 @@ test('edit collection', async ({ page }) => {
const items = collections.locator(
'[data-testid^="navigation-panel-collection-"]'
);
- expect(await items.count()).toBe(1);
+ await expect(items).toHaveCount(1);
const first = items.first();
await first.hover();
await first
@@ -144,7 +144,7 @@ test('edit collection and change filter date', async ({ page }) => {
const items = collections.locator(
'[data-testid^="navigation-panel-collection-"]'
);
- expect(await items.count()).toBe(1);
+ await expect(items).toHaveCount(1);
const first = items.first();
await first.hover();
await first
@@ -184,6 +184,6 @@ test('add collection from sidebar', async ({ page }) => {
const items = collections.locator(
'[data-testid^="navigation-panel-collection-"]'
);
- expect(await items.count()).toBe(1);
+ await expect(items).toHaveCount(1);
await expect(nullCollection).not.toBeVisible();
});
diff --git a/tests/affine-local/e2e/local-first-delete-page.spec.ts b/tests/affine-local/e2e/local-first-delete-page.spec.ts
index 42b49a438c..71d90bc4b1 100644
--- a/tests/affine-local/e2e/local-first-delete-page.spec.ts
+++ b/tests/affine-local/e2e/local-first-delete-page.spec.ts
@@ -21,21 +21,20 @@ test('page delete -> refresh page -> it should be disappear', async ({
await getBlockSuiteEditorTitle(page).fill('this is a new page delete');
const newPageId = getCurrentDocIdFromUrl(page);
await page.getByTestId('all-pages').click();
- const cell = page.getByRole('cell', {
- name: 'this is a new page delete',
- });
- expect(cell).not.toBeUndefined();
+ const allPages = page.getByTestId('virtualized-page-list');
+ const cell = allPages.getByText('this is a new page delete');
+ await expect(cell).toBeVisible();
await getPageOperationButton(page, newPageId).click();
const deleteBtn = page.getByTestId('move-to-trash');
await deleteBtn.click();
- const confirmTip = page.getByText('Delete page?');
- expect(confirmTip).not.toBeUndefined();
+ const confirmTip = page.getByRole('dialog', { name: 'Delete doc?' });
+ await expect(confirmTip).toBeVisible();
await page.getByRole('button', { name: 'Delete' }).click();
await page.getByTestId('trash-page').click();
await getPageItem(page, newPageId).getByTestId('delete-page-button').click();
await page.getByText('Delete permanently?').dblclick();
await page.getByRole('button', { name: 'Delete' }).click();
- expect(page.getByText("There's no page here yet")).not.toBeUndefined();
+ await expect(page.getByText('Deleted docs will appear here.')).toBeVisible();
await page.getByTestId('all-pages').click();
const currentWorkspace = await workspace.current();
@@ -55,15 +54,14 @@ test('page delete -> create new page -> refresh page -> new page should be appea
await getBlockSuiteEditorTitle(page).fill('this is a new page delete');
const newPageDeleteId = getCurrentDocIdFromUrl(page);
await page.getByTestId('all-pages').click();
- const cellDelete = page.getByRole('cell', {
- name: 'this is a new page delete',
- });
- expect(cellDelete).not.toBeUndefined();
+ const allPages = page.getByTestId('virtualized-page-list');
+ const cellDelete = allPages.getByText('this is a new page delete');
+ await expect(cellDelete).toBeVisible();
await getPageOperationButton(page, newPageDeleteId).click();
const deleteBtn = page.getByTestId('move-to-trash');
await deleteBtn.click();
- const confirmTip = page.getByText('Delete page?');
- expect(confirmTip).not.toBeUndefined();
+ const confirmTip = page.getByRole('dialog', { name: 'Delete doc?' });
+ await expect(confirmTip).toBeVisible();
await page.getByRole('button', { name: 'Delete' }).click();
await page.getByTestId('trash-page').click();
await getPageItem(page, newPageDeleteId)
@@ -71,7 +69,7 @@ test('page delete -> create new page -> refresh page -> new page should be appea
.click();
await page.getByText('Delete permanently?').dblclick();
await page.getByRole('button', { name: 'Delete' }).click();
- expect(page.getByText('Deleted docs will appear here')).not.toBeUndefined();
+ await expect(page.getByText('Deleted docs will appear here')).toBeVisible();
await page.getByTestId('all-pages').click();
await clickNewPageButton(page);
@@ -116,15 +114,14 @@ test('delete multiple pages -> create multiple pages -> refresh', async ({
await page.getByTestId('all-pages').click();
// 1st cell to be deleted
- const cellDelete1 = page.getByRole('cell', {
- name: 'this is a new page1',
- });
- expect(cellDelete1).not.toBeUndefined();
+ const allPages = page.getByTestId('virtualized-page-list');
+ const cellDelete1 = allPages.getByText('this is a new page1');
+ await expect(cellDelete1).toBeVisible();
await getPageOperationButton(page, newPageId1).click();
const deleteBtn1 = page.getByTestId('move-to-trash');
await deleteBtn1.click();
- const confirmTip1 = page.getByText('Delete page?');
- expect(confirmTip1).not.toBeUndefined();
+ const confirmTip1 = page.getByRole('dialog', { name: 'Delete doc?' });
+ await expect(confirmTip1).toBeVisible();
await page.getByRole('button', { name: 'Delete' }).click();
await page.getByTestId('trash-page').click();
await getPageItem(page, newPageId1).getByTestId('delete-page-button').click();
@@ -133,15 +130,13 @@ test('delete multiple pages -> create multiple pages -> refresh', async ({
await page.getByTestId('all-pages').click();
// 2nd cell to be deleted
- const cellDelete2 = page.getByRole('cell', {
- name: 'this is a new page2',
- });
- expect(cellDelete2).not.toBeUndefined();
+ const cellDelete2 = allPages.getByText('this is a new page2');
+ await expect(cellDelete2).toBeVisible();
await getPageOperationButton(page, newPageId2).click();
const deleteBtn2 = page.getByTestId('move-to-trash');
await deleteBtn2.click();
- const confirmTip2 = page.getByText('Delete page?');
- expect(confirmTip2).not.toBeUndefined();
+ const confirmTip2 = page.getByRole('dialog', { name: 'Delete doc?' });
+ await expect(confirmTip2).toBeVisible();
await page.getByRole('button', { name: 'Delete' }).click();
await page.getByTestId('trash-page').click();
await getPageItem(page, newPageId2).getByTestId('delete-page-button').click();
diff --git a/tests/affine-local/e2e/local-first-export-page.spec.ts b/tests/affine-local/e2e/local-first-export-page.spec.ts
index f359f959ca..f9ef683522 100644
--- a/tests/affine-local/e2e/local-first-export-page.spec.ts
+++ b/tests/affine-local/e2e/local-first-export-page.spec.ts
@@ -24,7 +24,7 @@ test.skip('New a page ,then open it and export html', async ({
const cell = page.getByRole('cell', {
name: 'this is a new page to export html content',
});
- expect(cell).not.toBeUndefined();
+ await expect(cell).toBeVisible();
await cell.click();
await clickPageMoreActions(page);
@@ -57,7 +57,7 @@ test.skip('New a page ,then open it and export markdown', async ({
const cell = page.getByRole('cell', {
name: 'this is a new page to export markdown content',
});
- expect(cell).not.toBeUndefined();
+ await expect(cell).toBeVisible();
await cell.click();
await clickPageMoreActions(page);
diff --git a/tests/affine-local/e2e/local-first-favorite-page.spec.ts b/tests/affine-local/e2e/local-first-favorite-page.spec.ts
index 0b0fdbe451..4c703d311a 100644
--- a/tests/affine-local/e2e/local-first-favorite-page.spec.ts
+++ b/tests/affine-local/e2e/local-first-favorite-page.spec.ts
@@ -22,7 +22,7 @@ test('New a page and open it, then favorite it', async ({
const cell = page
.getByTestId('page-list-item')
.getByText('this is a new page to favorite');
- expect(cell).not.toBeUndefined();
+ await expect(cell).toBeVisible();
await cell.click();
await clickPageMoreActions(page);
@@ -69,7 +69,7 @@ test('Cancel favorite', async ({ page, workspace }) => {
await getBlockSuiteEditorTitle(page).fill('this is a new page to favorite');
await page.getByTestId('all-pages').click();
const cell = getPageByTitle(page, 'this is a new page to favorite');
- expect(cell).not.toBeUndefined();
+ await expect(cell).toBeVisible();
await cell.click();
await clickPageMoreActions(page);
@@ -77,10 +77,12 @@ test('Cancel favorite', async ({ page, workspace }) => {
const favoriteBtn = page.getByTestId('editor-option-menu-favorite');
await favoriteBtn.click();
+ const favorites = page.getByTestId('navigation-panel-favorites');
+
// expect it in favorite list
- expect(
- page.getByRole('cell', { name: 'this is a new page to favorite' })
- ).not.toBeUndefined();
+ await expect(
+ favorites.getByText('this is a new page to favorite')
+ ).toBeVisible();
// cancel favorite
@@ -96,11 +98,9 @@ test('Cancel favorite', async ({ page, workspace }) => {
await page.getByTestId('favorited-icon').nth(0).click();
// expect it not in favorite list
- expect(
- page.getByText(
- 'Tips: Click Add to Favorites/Trash and the page will appear here.'
- )
- ).not.toBeUndefined();
+ await expect(
+ favorites.getByTestId('slider-bar-favorites-empty-message')
+ ).toBeVisible();
const currentWorkspace = await workspace.current();
expect(currentWorkspace.meta.flavour).toContain('local');
diff --git a/tests/affine-local/e2e/local-first-new-page.spec.ts b/tests/affine-local/e2e/local-first-new-page.spec.ts
index aa96c887a4..26db185a6b 100644
--- a/tests/affine-local/e2e/local-first-new-page.spec.ts
+++ b/tests/affine-local/e2e/local-first-new-page.spec.ts
@@ -30,8 +30,9 @@ test('click btn bew page and find it in all pages', async ({
await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page');
await page.getByTestId('all-pages').click();
- const cell = page.getByRole('cell', { name: 'this is a new page' });
- expect(cell).not.toBeUndefined();
+ const allPages = page.getByTestId('virtualized-page-list');
+ const cell = allPages.getByText('this is a new page');
+ await expect(cell).toBeVisible();
const currentWorkspace = await workspace.current();
expect(currentWorkspace.meta.flavour).toContain('local');
diff --git a/tests/affine-local/e2e/local-first-restore-page.spec.ts b/tests/affine-local/e2e/local-first-restore-page.spec.ts
index 3bd9f2d9f7..02e63ea8e5 100644
--- a/tests/affine-local/e2e/local-first-restore-page.spec.ts
+++ b/tests/affine-local/e2e/local-first-restore-page.spec.ts
@@ -20,16 +20,16 @@ test('New a page , then delete it in all pages, restore it', async ({
await getBlockSuiteEditorTitle(page).fill('this is a new page to restore');
const newPageId = getCurrentDocIdFromUrl(page);
await page.getByTestId('all-pages').click();
- const cell = page.getByRole('cell', {
- name: 'this is a new page to restore',
- });
- expect(cell).not.toBeUndefined();
+ const cell = page
+ .getByTestId('virtualized-page-list')
+ .getByText('this is a new page to restore');
+ await expect(cell).toBeVisible();
await getPageOperationButton(page, newPageId).click();
const deleteBtn = page.getByTestId('move-to-trash');
await deleteBtn.click();
- const confirmTip = page.getByText('Delete page?');
- expect(confirmTip).not.toBeUndefined();
+ const confirmTip = page.getByRole('dialog', { name: 'Delete doc?' });
+ await expect(confirmTip).toBeVisible();
await page.getByRole('button', { name: 'Delete' }).click();
@@ -42,10 +42,9 @@ test('New a page , then delete it in all pages, restore it', async ({
// stay in trash page
expect(page.url()).toBe(trashPage);
await page.getByTestId('all-pages').click();
- const restoreCell = page.getByRole('cell', {
- name: 'this is a new page to restore',
- });
- expect(restoreCell).not.toBeUndefined();
+ const allPages = page.getByTestId('virtualized-page-list');
+ const restoreCell = allPages.getByText('this is a new page to restore');
+ await expect(restoreCell).toBeVisible();
const currentWorkspace = await workspace.current();
expect(currentWorkspace.meta.flavour).toContain('local');
diff --git a/tests/affine-local/e2e/local-first-show-delete-modal.spec.ts b/tests/affine-local/e2e/local-first-show-delete-modal.spec.ts
index 52465d897e..272cea7d40 100644
--- a/tests/affine-local/e2e/local-first-show-delete-modal.spec.ts
+++ b/tests/affine-local/e2e/local-first-show-delete-modal.spec.ts
@@ -23,14 +23,14 @@ test('New a page ,then open it and show delete modal', async ({
const cell = page
.getByTestId('page-list-item')
.getByText('this is a new page to delete');
- expect(cell).not.toBeUndefined();
+ await expect(cell).toBeVisible();
await cell.click();
await clickPageMoreActions(page);
const deleteBtn = page.getByTestId('editor-option-menu-delete');
await deleteBtn.click();
- const confirmTip = page.getByText('Delete page?');
- expect(confirmTip).not.toBeUndefined();
+ const confirmTip = page.getByRole('dialog', { name: 'Delete doc?' });
+ await expect(confirmTip).toBeVisible();
const currentWorkspace = await workspace.current();
expect(currentWorkspace.meta.flavour).toContain('local');
@@ -47,16 +47,15 @@ test('New a page ,then go to all pages and show delete modal', async ({
await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');
const newPageId = getCurrentDocIdFromUrl(page);
await page.getByTestId('all-pages').click();
- const cell = page.getByRole('cell', {
- name: 'this is a new page to delete',
- });
- expect(cell).not.toBeUndefined();
+ const allPages = page.getByTestId('virtualized-page-list');
+ const cell = allPages.getByText('this is a new page to delete');
+ await expect(cell).toBeVisible();
await getPageOperationButton(page, newPageId).click();
const deleteBtn = page.getByTestId('move-to-trash');
await deleteBtn.click();
- const confirmTip = page.getByText('Delete page?');
- expect(confirmTip).not.toBeUndefined();
+ const confirmTip = page.getByRole('dialog', { name: 'Delete doc?' });
+ await expect(confirmTip).toBeVisible();
const currentWorkspace = await workspace.current();
expect(currentWorkspace.meta.flavour).toContain('local');
diff --git a/tests/affine-local/e2e/local-first-trash-page.spec.ts b/tests/affine-local/e2e/local-first-trash-page.spec.ts
index 255b37687c..6a0808b60c 100644
--- a/tests/affine-local/e2e/local-first-trash-page.spec.ts
+++ b/tests/affine-local/e2e/local-first-trash-page.spec.ts
@@ -20,23 +20,22 @@ test('New a page , then delete it in all pages, finally find it in trash', async
await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');
const newPageId = getCurrentDocIdFromUrl(page);
await page.getByTestId('all-pages').click();
- const cell = page.getByRole('cell', {
- name: 'this is a new page to delete',
- });
- expect(cell).not.toBeUndefined();
+ const allPages = page.getByTestId('virtualized-page-list');
+ const cell = allPages.getByText('this is a new page to delete');
+ await expect(cell).toBeVisible();
await getPageOperationButton(page, newPageId).click();
const deleteBtn = page.getByTestId('move-to-trash');
await deleteBtn.click();
- const confirmTip = page.getByText('Delete page?');
- expect(confirmTip).not.toBeUndefined();
+ const confirmTip = page.getByRole('dialog', { name: 'Delete doc?' });
+ await expect(confirmTip).toBeVisible();
await page.getByRole('button', { name: 'Delete' }).click();
await page.getByTestId('trash-page').click();
- expect(
- page.getByRole('cell', { name: 'this is a new page to delete' })
- ).not.toBeUndefined();
+ await expect(
+ allPages.getByText('this is a new page to delete')
+ ).toBeVisible();
const currentWorkspace = await workspace.current();
expect(currentWorkspace.meta.flavour).toContain('local');
diff --git a/tests/affine-local/e2e/local-first-workspace-list.spec.ts b/tests/affine-local/e2e/local-first-workspace-list.spec.ts
index 656c944bf6..b919e78ea5 100644
--- a/tests/affine-local/e2e/local-first-workspace-list.spec.ts
+++ b/tests/affine-local/e2e/local-first-workspace-list.spec.ts
@@ -17,12 +17,7 @@ test('just one item in the workspace list at first', async ({
await waitForEditorLoad(page);
const workspaceName = page.getByTestId('workspace-name');
await workspaceName.click();
- expect(
- page
- .locator('div')
- .filter({ hasText: 'AFFiNE TestLocal WorkspaceAvailable Offline' })
- .nth(3)
- ).not.toBeNull();
+ await expect(page.getByTestId('workspace-card')).toHaveCount(1);
const currentWorkspace = await workspace.current();
expect(currentWorkspace.meta.flavour).toContain('local');
diff --git a/tests/blocksuite/e2e/edgeless/linked-doc.spec.ts b/tests/blocksuite/e2e/edgeless/linked-doc.spec.ts
index a50f2b3bfe..375e719988 100644
--- a/tests/blocksuite/e2e/edgeless/linked-doc.spec.ts
+++ b/tests/blocksuite/e2e/edgeless/linked-doc.spec.ts
@@ -89,7 +89,7 @@ test.describe('note to linked doc', () => {
const moreButton = locatorComponentToolbarMoreButton(page);
await moreButton.click();
const turnButton = page.locator('.turn-into-linked-doc');
- expect(turnButton).toBeNull();
+ await expect(turnButton).toBeHidden();
});
// TODO FIX ME
@@ -110,7 +110,7 @@ test.describe('note to linked doc', () => {
const moreButton = locatorComponentToolbarMoreButton(page);
await moreButton.click();
const turnButton = page.locator('.turn-into-linked-doc');
- expect(turnButton).toBeNull();
+ await expect(turnButton).toBeHidden();
});
});