fix(test): e2e fails

refactor(e2e): print logs when error
pull/4750/head
Andelf 2022-04-01 03:41:49 +08:00 committed by Tienson Qin
parent 3758a9e1c0
commit ec43dd7ee1
3 changed files with 15 additions and 12 deletions

View File

@ -105,7 +105,6 @@ test('delete and backspace', async ({ page }) => {
await createRandomPage(page)
await page.fill('textarea >> nth=0', 'test')
expect(await page.inputValue('textarea >> nth=0')).toBe('test')
// backspace
@ -114,7 +113,8 @@ test('delete and backspace', async ({ page }) => {
expect(await page.inputValue('textarea >> nth=0')).toBe('te')
// refill
await page.fill('textarea >> nth=0', 'test')
await enterNextBlock(page)
await page.type('textarea >> nth=0', 'test')
await page.keyboard.press('ArrowLeft')
await page.keyboard.press('ArrowLeft')

View File

@ -17,18 +17,19 @@ if (fs.existsSync(testTmpDir)) {
export let graphDir = path.resolve(testTmpDir, "e2e-test", repoName)
// NOTE: This is a console log watcher for error logs.
// NOTE: This following is a console log watcher for error logs.
// Save and print all logs when error happens.
let logs: string
const consoleLogWatcher = (msg: ConsoleMessage) => {
// console.log(msg.text())
let msgText = msg.text()
expect(msgText).not.toMatch(/^Failed to/)
// console.log(msg.text())
logs += msg.text() + '\n'
expect(msg.text(), logs).not.toMatch(/^(Failed to|Uncaught)/)
// youtube video
if (!msgText.match(/^Error with Permissions-Policy header: Unrecognized feature/)) {
expect(msgText).not.toMatch(/^Error/)
if (!logs.match(/^Error with Permissions-Policy header: Unrecognized feature/)) {
expect(logs).not.toMatch(/^Error/)
}
expect(msgText).not.toMatch(/^Uncaught/)
// NOTE: React warnings will be logged as error.
// expect(msg.type()).not.toBe('error')
}

View File

@ -232,9 +232,11 @@
(let [[matched {:keys [on-chosen-open-link]}] (:rum/args state)
current-idx (get state :frontend.ui/current-idx)]
(util/stop e)
(when (and (seq matched)
(> (count matched)
@current-idx))
;; FIXME: on-chosen-open-link might be nil
(when (and on-chosen-open-link
(seq matched)
(> (count matched)
@current-idx))
(on-chosen-open-link (nth matched @current-idx) false))))
;; date-picker