|
| 1 | +import { test, type Page } from '@playwright/test'; |
| 2 | + |
| 3 | +export function buildAuthUrl(region: string, projectId: string, path: string = ''): string { |
| 4 | + return `./project-${region}-${projectId}/auth${path}`; |
| 5 | +} |
| 6 | + |
| 7 | +export function buildAuthUrlPattern(region: string, projectId: string, path: string = ''): RegExp { |
| 8 | + return new RegExp(`/project-${region}-${projectId}/auth${path}`); |
| 9 | +} |
| 10 | + |
| 11 | +export async function navigateToUsers( |
| 12 | + page: Page, |
| 13 | + region: string, |
| 14 | + projectId: string |
| 15 | +): Promise<void> { |
| 16 | + return test.step('navigate to users', async () => { |
| 17 | + await page.goto(buildAuthUrl(region, projectId)); |
| 18 | + await page.waitForURL(buildAuthUrlPattern(region, projectId)); |
| 19 | + await page.waitForLoadState('domcontentloaded'); |
| 20 | + }); |
| 21 | +} |
| 22 | + |
| 23 | +export async function navigateToUser( |
| 24 | + page: Page, |
| 25 | + region: string, |
| 26 | + projectId: string, |
| 27 | + userId: string |
| 28 | +): Promise<void> { |
| 29 | + return test.step(`navigate to user ${userId}`, async () => { |
| 30 | + await page.goto(buildAuthUrl(region, projectId, `/user-${userId}`)); |
| 31 | + await page.waitForURL(buildAuthUrlPattern(region, projectId, `/user-${userId}`)); |
| 32 | + await page.waitForLoadState('domcontentloaded'); |
| 33 | + }); |
| 34 | +} |
| 35 | + |
| 36 | +export async function navigateToTeams( |
| 37 | + page: Page, |
| 38 | + region: string, |
| 39 | + projectId: string |
| 40 | +): Promise<void> { |
| 41 | + return test.step('navigate to teams', async () => { |
| 42 | + await page.goto(buildAuthUrl(region, projectId, '/teams')); |
| 43 | + await page.waitForURL(buildAuthUrlPattern(region, projectId, '/teams')); |
| 44 | + }); |
| 45 | +} |
| 46 | + |
| 47 | +export async function navigateToTeam( |
| 48 | + page: Page, |
| 49 | + region: string, |
| 50 | + projectId: string, |
| 51 | + teamId: string |
| 52 | +): Promise<void> { |
| 53 | + return test.step(`navigate to team ${teamId}`, async () => { |
| 54 | + await page.goto(buildAuthUrl(region, projectId, `/teams/team-${teamId}`)); |
| 55 | + await page.waitForURL(buildAuthUrlPattern(region, projectId, `/teams/team-${teamId}`)); |
| 56 | + }); |
| 57 | +} |
| 58 | + |
| 59 | +export async function navigateToSecurity( |
| 60 | + page: Page, |
| 61 | + region: string, |
| 62 | + projectId: string |
| 63 | +): Promise<void> { |
| 64 | + return test.step('navigate to security settings', async () => { |
| 65 | + await page.goto(buildAuthUrl(region, projectId, '/security')); |
| 66 | + await page.waitForURL(buildAuthUrlPattern(region, projectId, '/security')); |
| 67 | + }); |
| 68 | +} |
| 69 | + |
| 70 | +export async function navigateToTemplates( |
| 71 | + page: Page, |
| 72 | + region: string, |
| 73 | + projectId: string |
| 74 | +): Promise<void> { |
| 75 | + return test.step('navigate to templates', async () => { |
| 76 | + await page.goto(buildAuthUrl(region, projectId, '/templates')); |
| 77 | + await page.waitForURL(buildAuthUrlPattern(region, projectId, '/templates')); |
| 78 | + }); |
| 79 | +} |
0 commit comments