mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-22 19:53:48 +08:00
test(core): rewrite some flaky assertions (#5287)
This commit is contained in:
@@ -24,7 +24,7 @@ const dragToFavourites = async (
|
||||
const dragToCollection = async (page: Page, dragItem: Locator) => {
|
||||
await page.getByTestId('slider-bar-add-collection-button').click();
|
||||
const input = page.getByTestId('input-collection-title');
|
||||
await input.isVisible();
|
||||
await expect(input).toBeVisible();
|
||||
await input.fill('test collection');
|
||||
await page.getByTestId('save-collection').click();
|
||||
const collection = page.getByTestId('collection-item');
|
||||
|
||||
@@ -13,10 +13,11 @@ test('Duplicate page should work', async ({ page }) => {
|
||||
await waitForEditorLoad(page);
|
||||
await clickNewPageButton(page);
|
||||
const title = getBlockSuiteEditorTitle(page);
|
||||
await title.pressSequentially('test');
|
||||
await expect(title).toBeVisible();
|
||||
await title.fill('test');
|
||||
await clickPageMoreActions(page);
|
||||
const duplicateButton = page.getByTestId('editor-option-menu-duplicate');
|
||||
await duplicateButton.click({ delay: 100 });
|
||||
await duplicateButton.click();
|
||||
const title2 = getBlockSuiteEditorTitle(page);
|
||||
await expect(title2).toHaveText('test(1)', { timeout: 1000 });
|
||||
await expect(title2).toHaveText('test(1)');
|
||||
});
|
||||
|
||||
@@ -82,7 +82,7 @@ test('image go left and right', async ({ page }) => {
|
||||
await importImage(page, 'http://localhost:8081/affine-preview.png');
|
||||
}
|
||||
const locator = page.getByTestId('image-preview-modal');
|
||||
expect(locator.isVisible()).toBeTruthy();
|
||||
await expect(locator).toBeHidden();
|
||||
await page.locator('img').first().dblclick();
|
||||
await page.waitForTimeout(1000);
|
||||
{
|
||||
@@ -125,7 +125,7 @@ test('image able to zoom in and out with mouse scroll', async ({ page }) => {
|
||||
const naturalWidth = await locator.evaluate(
|
||||
(img: HTMLImageElement) => img.naturalWidth
|
||||
);
|
||||
expect(locator.isVisible()).toBeTruthy();
|
||||
await expect(locator).toBeVisible();
|
||||
const { width, height } = await page.evaluate(() => ({
|
||||
width: window.innerWidth,
|
||||
height: window.innerHeight,
|
||||
@@ -660,10 +660,10 @@ test('keypress esc should close the modal', async ({ page }) => {
|
||||
await importImage(page, 'http://localhost:8081/large-image.png');
|
||||
await page.locator('img').first().dblclick();
|
||||
const locator = page.getByTestId('image-preview-modal');
|
||||
expect(locator.isVisible()).toBeTruthy();
|
||||
await expect(locator).toBeVisible();
|
||||
await page.keyboard.press('Escape');
|
||||
await page.waitForTimeout(1000);
|
||||
expect(await locator.isVisible()).toBeFalsy();
|
||||
await expect(locator).toBeHidden();
|
||||
});
|
||||
|
||||
test('when mouse moves outside, the modal should be closed', async ({
|
||||
@@ -706,7 +706,7 @@ test('caption should be visible and different styles were applied if image zoome
|
||||
await page.getByPlaceholder('Write a caption').fill(sampleCaption);
|
||||
await page.locator('img').first().dblclick();
|
||||
const locator = page.getByTestId('image-preview-modal');
|
||||
expect(await locator.isVisible()).toBeTruthy();
|
||||
await expect(locator).toBeVisible();
|
||||
await page.waitForTimeout(1000);
|
||||
let captionLocator = locator.getByTestId('image-caption-zoomedout');
|
||||
await expect(captionLocator).toBeVisible();
|
||||
|
||||
@@ -43,7 +43,7 @@ const createAndPinCollection = async (
|
||||
delay: 200,
|
||||
});
|
||||
const title = page.getByTestId('input-collection-title');
|
||||
await title.isVisible();
|
||||
await expect(title).toBeVisible();
|
||||
await title.fill(options?.collectionName ?? 'test collection');
|
||||
await page.getByTestId('save-collection').click();
|
||||
await page.waitForTimeout(100);
|
||||
@@ -162,7 +162,7 @@ test('add collection from sidebar', async ({ page }) => {
|
||||
await expect(nullCollection).toBeVisible();
|
||||
await page.getByTestId('slider-bar-add-collection-button').click();
|
||||
const title = page.getByTestId('input-collection-title');
|
||||
await title.isVisible();
|
||||
await expect(title).toBeVisible();
|
||||
await title.fill('test collection');
|
||||
await page.getByTestId('save-collection').click();
|
||||
await page.waitForTimeout(100);
|
||||
|
||||
@@ -10,7 +10,7 @@ test('Open shortcuts modal', async ({ page }) => {
|
||||
|
||||
const shortcutsIcon = page.locator('[data-testid=shortcuts-icon]');
|
||||
await page.waitForTimeout(1000);
|
||||
expect(await shortcutsIcon.isVisible()).toEqual(true);
|
||||
await expect(shortcutsIcon).toBeVisible();
|
||||
|
||||
await shortcutsIcon.click();
|
||||
await page.waitForTimeout(1000);
|
||||
|
||||
Reference in New Issue
Block a user