Skip to content

Commit ae9749c

Browse files
Copilotarii
andcommitted
Address code review feedback: improve documentation and code organization
Co-authored-by: arii <342438+arii@users.noreply.github.com>
1 parent 6309c0d commit ae9749c

3 files changed

Lines changed: 24 additions & 13 deletions

File tree

tests/playwright/lib/auth.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,19 +154,26 @@ export async function verifySpotifyTokenStatus(
154154
* Create an authenticated browser context with stored credentials.
155155
* Useful for tests that require pre-authenticated state.
156156
*
157+
* Note: This function provides a foundation for custom auth state management.
158+
* For production use, implement storage state handling with context.storageState().
159+
*
157160
* @param context - The Playwright BrowserContext object
158-
* @param storageState - Optional path to saved storage state
159-
* @returns The configured context
161+
* @param _storageState - Reserved for future storage state path parameter
162+
* @returns The configured context (passthrough for now)
163+
* @example
164+
* ```typescript
165+
* // Save authenticated state
166+
* await context.storageState({ path: 'auth.json' })
167+
*
168+
* // Create context with saved state
169+
* const context = await browser.newContext({ storageState: 'auth.json' })
170+
* ```
160171
*/
161172
export async function createAuthenticatedContext(
162173
context: BrowserContext,
163174
_storageState?: string,
164175
): Promise<BrowserContext> {
165-
// If storage state is provided, apply it
166-
// Note: This is a placeholder for custom auth state management
167-
// In practice, you would use context.storageState() to save and restore
168-
169-
// For now, just return the context as-is
176+
// Returns context as-is - implement storage state handling as needed
170177
return context
171178
}
172179

tests/playwright/lib/setup.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,8 @@ export async function setupVisualRegressionTest(pages: {
170170
const baseUrl = getBaseURL()
171171

172172
// Navigate all pages in parallel
173-
// Note: Uses legacy routes for backward compatibility with existing tests
173+
// Note: Uses LEGACY_ROUTES for control/mock/connect for backward compatibility with existing tests.
174+
// Dashboard uses HRM_ROUTES.DASHBOARD since it's just '/'.
174175
await Promise.all([
175176
dashboardPage.goto(`${baseUrl}${HRM_ROUTES.DASHBOARD}`),
176177
controlPage.goto(`${baseUrl}${LEGACY_ROUTES.PHONE}`),
@@ -227,6 +228,8 @@ export async function setupComprehensiveTest(options: {
227228
const mockTab = await context.newPage()
228229
const connectTab = await context.newPage()
229230

231+
// Note: Uses LEGACY_ROUTES for control/mock/connect for backward compatibility with existing tests.
232+
// Dashboard uses HRM_ROUTES.DASHBOARD since it's just '/'.
230233
await Promise.all([
231234
dashboardTab.goto(`${baseUrl}${HRM_ROUTES.DASHBOARD}`),
232235
controlTab.goto(`${baseUrl}${LEGACY_ROUTES.PHONE}`),
@@ -345,14 +348,17 @@ export async function setupMockHrStreaming(
345348
): Promise<void> {
346349
const { bpm = 155, zone = 4 } = options
347350

351+
// Get the BPM input element
352+
const bpmInput = mockPage.getByLabel('Current BPM')
353+
348354
// Set HR value
349-
await mockPage.getByLabel('Current BPM').fill(String(bpm))
355+
await bpmInput.fill(String(bpm))
350356

351357
// Set zone
352358
await mockPage.getByRole('button', { name: `Zone ${zone}` }).click()
353359

354360
// Verify BPM is set
355-
await expect(mockPage.getByLabel('Current BPM')).toHaveValue(String(bpm))
361+
await expect(bpmInput).toHaveValue(String(bpm))
356362
}
357363

358364
/**

tests/playwright/lib/waits.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@
88
* - WebSocket connection verification
99
* - Font loading guarantees
1010
*/
11-
import type { Page } from '@playwright/test'
12-
13-
import type { Response as PlaywrightResponse } from '@playwright/test'
11+
import type { Page, Response as PlaywrightResponse } from '@playwright/test'
1412

1513
/**
1614
* Default timeout values for wait operations (in milliseconds)

0 commit comments

Comments
 (0)