test: fix flaky test (#2259)

This commit is contained in:
Nolan Lawson 2022-11-25 12:24:59 -08:00 committed by GitHub
parent abc39ef982
commit 098da30f2a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,7 +1,7 @@
import { import {
getActiveElementTagName, getActiveElementTagName,
getUrl, getUrl,
searchButton, searchInput, searchNavButton searchButton, searchInput, searchNavButton, sleep
} from '../utils' } from '../utils'
import { loginAsFoobar } from '../roles' import { loginAsFoobar } from '../roles'
import { Selector as $ } from 'testcafe' import { Selector as $ } from 'testcafe'
@ -40,6 +40,8 @@ test('Pressing / without logging in just goes to the search page', async t => {
await t await t
.expect(getUrl()).eql('http://localhost:4002/') .expect(getUrl()).eql('http://localhost:4002/')
.expect($('.main-content h1').innerText).eql('Pinafore') .expect($('.main-content h1').innerText).eql('Pinafore')
await sleep(500) // wait for keyboard shortcuts to be active
await t
.pressKey('/') .pressKey('/')
.expect(getUrl()).contains('/search') .expect(getUrl()).contains('/search')
.expect(getActiveElementTagName()).notMatch(/input/i) .expect(getActiveElementTagName()).notMatch(/input/i)