Skip to content

Commit

Permalink
chore(tests): Standardize imports and add page navigavion helper (#16914
Browse files Browse the repository at this point in the history
)

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and jonnigs committed Nov 26, 2024
1 parent 3478ad9 commit 5370180
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
3 changes: 2 additions & 1 deletion libs/testing/e2e/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export * from './lib/session/session'
export * from './lib/modules/urls'
export * from './lib/helpers/utils'
export * from './lib/config/playwright-config'
export { test, expect, Page, Locator, BrowserContext } from '@playwright/test'
export { test, expect } from '@playwright/test'
export type { Page, Locator, BrowserContext } from '@playwright/test'
18 changes: 17 additions & 1 deletion libs/testing/e2e/src/lib/helpers/api-tools.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Page } from '@playwright/test'
import { Page, BrowserContext } from '@playwright/test'

/**
* Waits for a network request to complete and verifies its operation name.
Expand All @@ -21,3 +21,19 @@ export const verifyRequestCompletion = async (

return await response.json()
}

/**
* Creates a new page in the given browser context and navigates to the specified URL.
*
* @param context - The browser context in which to create the new page.
* @param url - The URL to navigate to.
* @returns A promise that resolves to the created page.
*/
export const createPageAndNavigate = async (
context: BrowserContext,
url: string,
) => {
const page = await context.newPage()
await page.goto(url)
return page
}

0 comments on commit 5370180

Please sign in to comment.