mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
test: adjust test code for passing CI
This commit is contained in:
parent
a483a4f7d3
commit
dd2a7d583a
3 changed files with 13 additions and 14 deletions
|
|
@ -9,8 +9,9 @@ describe(`in Gitako project page`, () => {
|
|||
`.js-details-container div[role="row"] div[role="rowheader"] a[title*="."]`,
|
||||
)
|
||||
if (commitLinks.length < 2) throw new Error(`No enough files`)
|
||||
await commitLinks[i].click()
|
||||
await waitForLegacyPJAXRedirect()
|
||||
await waitForLegacyPJAXRedirect(async () => {
|
||||
await commitLinks[i].click()
|
||||
})
|
||||
await expectToFind('table.js-file-line-container')
|
||||
await sleep(1000)
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {
|
|||
patientClick,
|
||||
selectFileTreeItem,
|
||||
sleep,
|
||||
waitForPJAXAPIRedirect
|
||||
waitForLegacyPJAXRedirect
|
||||
} from '../../utils'
|
||||
|
||||
describe(`in Gitako project page`, () => {
|
||||
|
|
@ -16,17 +16,17 @@ describe(`in Gitako project page`, () => {
|
|||
|
||||
await expandFloatModeSidebar()
|
||||
await patientClick(selectFileTreeItem('.babelrc'))
|
||||
await waitForPJAXAPIRedirect()
|
||||
await waitForLegacyPJAXRedirect()
|
||||
|
||||
// The selector for file content
|
||||
await expectToFind('table.js-file-line-container')
|
||||
|
||||
page.goBack()
|
||||
await waitForPJAXAPIRedirect()
|
||||
await waitForLegacyPJAXRedirect(async () => {
|
||||
await sleep(1000) // This prevents failing in some cases due to some mystery scheduling issue of puppeteer or jest
|
||||
page.goBack()
|
||||
})
|
||||
|
||||
// The selector for file content
|
||||
await expectToNotFind('table.js-file-line-container')
|
||||
|
||||
// await waitForPJAXAPIRedirect()
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -68,12 +68,10 @@ export function once(event: string, target: 'document' | 'window') {
|
|||
})
|
||||
}
|
||||
|
||||
export function waitForLegacyPJAXRedirect() {
|
||||
return once('pjax:end', 'document')
|
||||
}
|
||||
|
||||
export function waitForPJAXAPIRedirect() {
|
||||
return once('pjax:ready', 'document')
|
||||
export async function waitForLegacyPJAXRedirect(action?: () => void | Promise<void>) {
|
||||
const promise = once('pjax:end', 'document')
|
||||
await action?.()
|
||||
return promise
|
||||
}
|
||||
|
||||
export function selectFileTreeItem(path: string): string {
|
||||
|
|
|
|||
Loading…
Reference in a new issue