fix(e2e): wrong promise usage

This commit is contained in:
Andelf
2022-09-06 12:21:25 +08:00
parent 43dd321ce4
commit 320024f764
2 changed files with 11 additions and 11 deletions

View File

@@ -100,7 +100,6 @@ jobs:
needs: [ e2e-test-build ]
name: Test Shard ${{ matrix.shard }} Repeat ${{ matrix.repeat }}
runs-on: ubuntu-latest
continue-on-error: true # Don't block other runs in matrix for fast debugging
strategy:
matrix:
repeat: [1, 2]

View File

@@ -171,7 +171,7 @@ export async function openLeftSidebar(page: Page): Promise<void> {
export async function loadLocalGraph(page: Page, path: string): Promise<void> {
await setMockedOpenDirPath(page, path);
const onboardingOpenButton = page.locator('strong:has-text("Choose a folder")')
if (await onboardingOpenButton.isVisible()) {
@@ -183,12 +183,12 @@ export async function loadLocalGraph(page: Page, path: string): Promise<void> {
await page.click('#left-menu.button')
await expect(sidebar).toHaveClass(/is-open/)
}
await page.click('#left-sidebar #repo-switch');
await page.waitForSelector('#left-sidebar .dropdown-wrapper >> text="Add new graph"',
{ state: 'visible', timeout: 5000 })
{ state: 'visible', timeout: 5000 })
await page.click('text=Add new graph')
await page.waitForSelector('strong:has-text("Choose a folder")',{ state: 'visible', timeout: 5000 })
await page.waitForSelector('strong:has-text("Choose a folder")', { state: 'visible', timeout: 5000 })
expect(page.locator('#repo-name')).toHaveText(pathlib.basename(path))
}
@@ -210,11 +210,12 @@ export async function loadLocalGraph(page: Page, path: string): Promise<void> {
// If there is an error notification from a previous test graph being deleted,
// close it first so it doesn't cover up the UI
let locator = await page.locator('.notification-close-button').first()
let locator = page.locator('.notification-close-button').first()
while (await locator?.isVisible()) {
await locator.click()
await page.waitForTimeout(250)
locator = await page.locator('.notification-close-button', {timeout: 1000}).first()
expect(locator.isVisible()).resolves.toBe(false)
}
console.log('Graph loaded for ' + path)
@@ -245,7 +246,7 @@ export function systemModifier(shortcut: string): string {
}
}
export async function captureConsoleWithPrefix(page: Page, prefix: string, timeout: number=3000): Promise<string> {
export async function captureConsoleWithPrefix(page: Page, prefix: string, timeout: number = 3000): Promise<string> {
return new Promise((resolve, reject) => {
let console_handler = (msg: ConsoleMessage) => {
let text = msg.text()
@@ -263,12 +264,12 @@ export async function queryPermission(page: Page, permission: PermissionName): P
// Check if WebAPI clipboard supported
return await page.evaluate(async (eval_permission: PermissionName): Promise<boolean> => {
if (typeof navigator.permissions == "undefined")
return Promise.resolve(false);
return Promise.resolve(false);
return navigator.permissions.query({
name: eval_permission
name: eval_permission
}).then((result: PermissionStatus): boolean => {
return (result.state == "granted" || result.state == "prompt")
})
})
}, permission)
}