From cd8a4fe33959efae5c6f51caa5794195f06e52be Mon Sep 17 00:00:00 2001 From: Andelf Date: Sat, 9 Apr 2022 11:01:24 +0800 Subject: [PATCH] fix(e2e): occasional failures --- e2e-tests/basic.spec.ts | 3 ++- e2e-tests/code-editing.spec.ts | 2 -- e2e-tests/editor.spec.ts | 14 +++++++------- 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/e2e-tests/basic.spec.ts b/e2e-tests/basic.spec.ts index cba6c16bb..18e95dc75 100644 --- a/e2e-tests/basic.spec.ts +++ b/e2e-tests/basic.spec.ts @@ -2,7 +2,7 @@ import { expect } from '@playwright/test' import fs from 'fs/promises' import path from 'path' import { test } from './fixtures' -import { randomString, createRandomPage, enterNextBlock } from './utils' +import { randomString, createRandomPage } from './utils' test('render app', async ({ page }) => { // NOTE: part of app startup tests is moved to `fixtures.ts`. @@ -280,5 +280,6 @@ test('invalid page props #3944', async ({ page, block }) => { await block.mustFill('public:: true\nsize:: 65535') await page.press('textarea >> nth=0', 'Enter') + // Force rendering property block await block.clickNext() }) diff --git a/e2e-tests/code-editing.spec.ts b/e2e-tests/code-editing.spec.ts index 8eec2ea65..e978316b0 100644 --- a/e2e-tests/code-editing.spec.ts +++ b/e2e-tests/code-editing.spec.ts @@ -56,8 +56,6 @@ test('switch code editing mode', async ({ page }) => { await page.press('.CodeMirror textarea', 'Escape') await page.waitForSelector('.CodeMirror pre', { state: 'hidden' }) expect(await page.inputValue('.block-editor textarea')).toBe('```clojure\n;; comment\n\n \n(+ 1 1)\n```') - - await page.waitForTimeout(500) }) diff --git a/e2e-tests/editor.spec.ts b/e2e-tests/editor.spec.ts index aa6f65965..505b66f78 100644 --- a/e2e-tests/editor.spec.ts +++ b/e2e-tests/editor.spec.ts @@ -65,16 +65,16 @@ test('hashtag and quare brackets in same line #4178', async ({ page }) => { ) }) -test('disappeared children #4814', async ({ page }) => { +test('disappeared children #4814', async ({ page, block }) => { await createRandomPage(page) - await page.type('textarea >> nth=0', 'parent') - await enterNextBlock(page) - await page.press('textarea >> nth=0', 'Tab') + await block.mustType('parent') + await block.enterNext() + expect(await block.indent()).toBe(true) for (let i = 0; i < 5; i++) { - await page.type('textarea >> nth=0', i.toString()) - await enterNextBlock(page) + await block.mustType(i.toString()) + await block.enterNext() } // collapse @@ -83,7 +83,7 @@ test('disappeared children #4814', async ({ page }) => { // expand await page.click('.block-control >> nth=0') - await page.waitForSelector('.ls-block >> nth=6') // 7 blocks + await block.waitForBlocks(7) // 1 + 5 + 1 empty // Ensures there's no active editor await expect(page.locator('.editor-inner')).toHaveCount(0, {timeout: 500})