mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 20:38:52 +00:00
fix(core): flaky tests (#5804)
This commit is contained in:
@@ -111,8 +111,7 @@ export class WorkspacePropertiesAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getJournalPageDateString(id: string) {
|
getJournalPageDateString(id: string) {
|
||||||
this.ensurePageProperties(id);
|
return this.pageProperties[id]?.system[PageSystemPropertyId.Journal]?.value;
|
||||||
return this.pageProperties[id].system[PageSystemPropertyId.Journal].value;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setJournalPageDateString(id: string, date: string) {
|
setJournalPageDateString(id: string, date: string) {
|
||||||
@@ -127,9 +126,9 @@ export class WorkspacePropertiesAdapter {
|
|||||||
|
|
||||||
// page tags could be reactive
|
// page tags could be reactive
|
||||||
getPageTags(pageId: string) {
|
getPageTags(pageId: string) {
|
||||||
this.ensurePageProperties(pageId);
|
|
||||||
const tags =
|
const tags =
|
||||||
this.pageProperties[pageId].system[PageSystemPropertyId.Tags].value;
|
this.getPageProperties(pageId)?.system[PageSystemPropertyId.Tags].value ??
|
||||||
|
[];
|
||||||
const optionsMap = Object.fromEntries(this.tagOptions.map(o => [o.id, o]));
|
const optionsMap = Object.fromEntries(this.tagOptions.map(o => [o.id, o]));
|
||||||
return tags.map(tag => optionsMap[tag]).filter((t): t is TagOption => !!t);
|
return tags.map(tag => optionsMap[tag]).filter((t): t is TagOption => !!t);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,10 +18,10 @@ const addDatabase = async (page: Page) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
test('database is useable', async ({ page }) => {
|
test('database is useable', async ({ page }) => {
|
||||||
|
test.slow();
|
||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
await waitForEditorLoad(page);
|
|
||||||
const title = getBlockSuiteEditorTitle(page);
|
const title = getBlockSuiteEditorTitle(page);
|
||||||
await title.pressSequentially('test title');
|
await title.pressSequentially('test title');
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
@@ -32,7 +32,6 @@ test('database is useable', async ({ page }) => {
|
|||||||
await page.reload();
|
await page.reload();
|
||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
await clickNewPageButton(page);
|
await clickNewPageButton(page);
|
||||||
await waitForEditorLoad(page);
|
|
||||||
const title2 = getBlockSuiteEditorTitle(page);
|
const title2 = getBlockSuiteEditorTitle(page);
|
||||||
await title2.pressSequentially('test title2');
|
await title2.pressSequentially('test title2');
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
@@ -66,9 +65,11 @@ test('link page is useable', async ({ page }) => {
|
|||||||
await page.keyboard.press('1');
|
await page.keyboard.press('1');
|
||||||
await page.keyboard.press('Enter');
|
await page.keyboard.press('Enter');
|
||||||
const link = page.locator('.affine-reference');
|
const link = page.locator('.affine-reference');
|
||||||
await page.waitForTimeout(500);
|
|
||||||
await expect(link).toBeVisible();
|
await expect(link).toBeVisible();
|
||||||
await page.click('.affine-reference');
|
await page.click('.affine-reference');
|
||||||
await page.waitForTimeout(500);
|
await page.waitForTimeout(500);
|
||||||
expect(await title.innerText()).toBe('page1');
|
|
||||||
|
await expect(
|
||||||
|
page.locator('.doc-title-container:has-text("page1")')
|
||||||
|
).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
getBlockSuiteEditorTitle,
|
getBlockSuiteEditorTitle,
|
||||||
getPageByTitle,
|
getPageByTitle,
|
||||||
waitForEditorLoad,
|
waitForEditorLoad,
|
||||||
|
waitForEmptyEditor,
|
||||||
} from '@affine-test/kit/utils/page-logic';
|
} from '@affine-test/kit/utils/page-logic';
|
||||||
import { expect } from '@playwright/test';
|
import { expect } from '@playwright/test';
|
||||||
|
|
||||||
@@ -101,6 +102,10 @@ test("Deleted page's reference will not be shown in sidebar", async ({
|
|||||||
// goto "Another page"
|
// goto "Another page"
|
||||||
await page.locator('.affine-reference-title').click();
|
await page.locator('.affine-reference-title').click();
|
||||||
|
|
||||||
|
await expect(
|
||||||
|
page.locator('.doc-title-container:has-text("Another page")')
|
||||||
|
).toBeVisible();
|
||||||
|
|
||||||
// delete the page
|
// delete the page
|
||||||
await clickPageMoreActions(page);
|
await clickPageMoreActions(page);
|
||||||
|
|
||||||
@@ -131,7 +136,7 @@ test('Add new favorite page via sidebar', async ({ page }) => {
|
|||||||
await openHomePage(page);
|
await openHomePage(page);
|
||||||
await waitForEditorLoad(page);
|
await waitForEditorLoad(page);
|
||||||
await page.getByTestId('slider-bar-add-favorite-button').first().click();
|
await page.getByTestId('slider-bar-add-favorite-button').first().click();
|
||||||
await waitForEditorLoad(page);
|
await waitForEmptyEditor(page);
|
||||||
|
|
||||||
// enter random page title
|
// enter random page title
|
||||||
await getBlockSuiteEditorTitle(page).fill('this is a new fav page');
|
await getBlockSuiteEditorTitle(page).fill('this is a new fav page');
|
||||||
|
|||||||
@@ -19,7 +19,12 @@ export async function clickNewPageButton(page: Page) {
|
|||||||
await page.getByTestId('sidebar-new-page-button').click({
|
await page.getByTestId('sidebar-new-page-button').click({
|
||||||
delay: 100,
|
delay: 100,
|
||||||
});
|
});
|
||||||
await waitForEditorLoad(page);
|
await expect(page.locator('.doc-title-container-empty')).toBeVisible();
|
||||||
|
await waitForEmptyEditor(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function waitForEmptyEditor(page: Page) {
|
||||||
|
await expect(page.locator('.doc-title-container-empty')).toBeVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getBlockSuiteEditorTitle(page: Page) {
|
export function getBlockSuiteEditorTitle(page: Page) {
|
||||||
|
|||||||
Reference in New Issue
Block a user