Skip to content

Commit

Permalink
Fix e2e onboarding helper
Browse files Browse the repository at this point in the history
  • Loading branch information
hyphenized committed Jun 26, 2023
1 parent 274e01e commit dad8022
Showing 1 changed file with 6 additions and 34 deletions.
40 changes: 6 additions & 34 deletions e2e-tests/utils/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,21 @@ import { BrowserContext, test as base, expect, Page } from "@playwright/test"
export const getOnboardingPage = async (
context: BrowserContext
): Promise<Page> => {
await expect(async () => {
const getOnboardingOrThrow = () => {
const pages = context.pages()

const onboarding = pages.find((page) => /onboarding/.test(page.url()))

if (!onboarding) {
throw new Error("Unable to find onboarding tab")
}

expect(onboarding).toHaveURL(/onboarding/)
}).toPass()

const onboarding = context.pages().at(-1)

if (!onboarding) {
// Should never happen
throw new Error("Onboarding page closed too early")
return onboarding
}

return onboarding
await expect(async () => getOnboardingOrThrow()).toPass()

return getOnboardingOrThrow()
}

const DEFAULT_PASSWORD = "12345678"
Expand All @@ -37,30 +33,6 @@ export default class OnboardingHelper {
public readonly context: BrowserContext
) {}

async getOnboardingPage(): Promise<Page> {
await expect(async () => {
const pages = this.context.pages()
const onboarding = pages.find((page) => /onboarding/.test(page.url()))

if (!onboarding) {
throw new Error("Unable to find onboarding tab")
}

expect(onboarding).toHaveURL(/onboarding/)
}).toPass()

const onboarding = this.context
.pages()
.find((page) => /onboarding/.test(page.url()))

if (!onboarding) {
// Should never happen
throw new Error("Onboarding page closed too early")
}

return onboarding
}

async addReadOnlyAccount(
addressOrName: string,
onboardingPage?: Page
Expand Down

0 comments on commit dad8022

Please sign in to comment.