test: update commit page selector

This commit is contained in:
EnixCoda 2025-03-17 20:59:56 +08:00
parent 3c8e162159
commit 5c04d2c9e2
3 changed files with 4 additions and 4 deletions

View file

@ -13,13 +13,13 @@ describe(`in Gitako project page`, () => {
if (commitLinks.length < 2) throw new Error(`No enough commits`)
commitLinks[i].click()
await waitForRedirect()
await expectToFind(selectors.github.commitSummary)
await expectToFind(selectors.github.commitPage)
await sleep(1000)
page.goBack()
await sleep(1000)
// The selector for file content
await expectToNotFind(selectors.github.commitSummary)
await expectToNotFind(selectors.github.commitPage)
}
})
})

View file

@ -10,7 +10,7 @@ export const selectors = {
fileListItemFileLinks: `table[aria-labelledby="folders-and-files"] tr.react-directory-row td.react-directory-row-name-cell-large-screen .react-directory-filename-column .react-directory-truncate a[aria-label$="(File)"]`,
fileListItemLinkOf: (name: string) =>
`table[aria-labelledby="folders-and-files"] tr.react-directory-row td.react-directory-row-name-cell-large-screen .react-directory-filename-column .react-directory-truncate a[title="${name}"]`,
commitSummary: 'div.commit',
commitPage: ['div.commit', '#diff-content-parent'].join(),
navBarItemIssues: 'a[data-selected-links^="repo_issues "]',
navBarItemPulls: 'a[data-selected-links^="repo_pulls "]',
},

View file

@ -11,7 +11,7 @@ export async function expectToReject<T>(promise: Promise<T>) {
}
export async function expectToFind(selector: string) {
await expectToResolve(page.waitForSelector(selector))
await expectToResolve(page.waitForSelector(selector, { timeout: 2000 }))
}
export async function expectToNotFind(selector: string) {