-
Notifications
You must be signed in to change notification settings - Fork 70
feat(cc-widgets): UI Automation for Station Login Tests #484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
eb5077d
fix(cc-widgets): add station-login tests
PrayagGP e1a46ac
fix(cc-widgets): rename multi-session to mulit-login
PrayagGP c5df544
fix(cc-widgets): add delays while handling socket reconnection
PrayagGP 4964bb4
fix(cc-widgets): add timeouts for various expect statements
PrayagGP c8b509c
fix(cc-widgets): add a second attempt of intialising widgets
PrayagGP c34453d
fix(cc-widgets): add descriptions for helper functions
PrayagGP 2511b0d
fix(cc-widgets): update test.afterAll for Desktop mode
PrayagGP 418efda
fix(cc-widgets): remove unnecessary code
PrayagGP c1e344e
Merge branch 'ccwidgets' into ccwidgets
rsarika 982d5a2
fix(cc-widgets): shift functions from test file to util file
PrayagGP 9978507
Merge branch 'ccwidgets' of https://github.com/PrayagGP/widgets into …
PrayagGP File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /** | ||
| * Parses a time string in MM:SS format and converts it to total seconds | ||
| * @param timeString - Time string in format "MM:SS" (e.g., "01:30" for 1 minute 30 seconds) | ||
| * @returns Total number of seconds | ||
| * @example | ||
| * ```typescript | ||
| * parseTimeString("01:30"); // Returns 90 (1 minute 30 seconds) | ||
| * parseTimeString("00:45"); // Returns 45 (45 seconds) | ||
| * parseTimeString("10:00"); // Returns 600 (10 minutes) | ||
| * ``` | ||
| */ | ||
| export function parseTimeString(timeString: string): number { | ||
| const parts = timeString.split(':'); | ||
| const minutes = parseInt(parts[0], 10) || 0; | ||
| const seconds = parseInt(parts[1], 10) || 0; | ||
| return minutes * 60 + seconds; | ||
| } | ||
|
|
||
| /** | ||
| * Waits for WebSocket disconnection by monitoring console messages for specific disconnection indicators | ||
| * @param consoleMessages - Array of console messages to monitor | ||
| * @param timeoutMs - Maximum time to wait for disconnection in milliseconds (default: 15000) | ||
| * @returns Promise<boolean> - True if disconnection is detected, false if timeout is reached | ||
| * @description Monitors for network disconnection messages or WebSocket offline status changes | ||
| * @example | ||
| * ```typescript | ||
| * consoleMessages.length = 0; // Clear existing messages | ||
| * await page.context().setOffline(true); | ||
| * const isDisconnected = await waitForWebSocketDisconnection(consoleMessages); | ||
| * expect(isDisconnected).toBe(true); | ||
| * ``` | ||
| */ | ||
| export async function waitForWebSocketDisconnection(consoleMessages: string[], timeoutMs: number = 15000): Promise<boolean> { | ||
| const startTime = Date.now(); | ||
| while (Date.now() - startTime < timeoutMs) { | ||
| const webSocketDisconnectLog = consoleMessages.find( | ||
| (msg) => | ||
| msg.includes('Failed to load resource: net::ERR_INTERNET_DISCONNECTED') || | ||
| msg.includes('[WebSocketStatus] event=checkOnlineStatus | online status= false') | ||
| ); | ||
| if (webSocketDisconnectLog) { | ||
| return true; | ||
| } | ||
| await new Promise((resolve) => setTimeout(resolve, 100)); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| /** | ||
| * Waits for WebSocket reconnection by monitoring console messages for online status changes | ||
| * @param consoleMessages - Array of console messages to monitor | ||
| * @param timeoutMs - Maximum time to wait for reconnection in milliseconds (default: 15000) | ||
| * @returns Promise<boolean> - True if reconnection is detected, false if timeout is reached | ||
| * @description Monitors for WebSocket online status change messages indicating successful reconnection | ||
| * @example | ||
| * ```typescript | ||
| * consoleMessages.length = 0; // Clear existing messages | ||
| * await page.context().setOffline(false); | ||
| * const isReconnected = await waitForWebSocketReconnection(consoleMessages); | ||
| * expect(isReconnected).toBe(true); | ||
| * ``` | ||
| */ | ||
| export async function waitForWebSocketReconnection(consoleMessages: string[], timeoutMs: number = 15000): Promise<boolean> { | ||
| const startTime = Date.now(); | ||
| while (Date.now() - startTime < timeoutMs) { | ||
| const webSocketReconnectLog = consoleMessages.find((msg) => | ||
| msg.includes('[WebSocketStatus] event=checkOnlineStatus | online status= true') | ||
| ); | ||
| if (webSocketReconnectLog) { | ||
| return true; | ||
| } | ||
| await new Promise((resolve) => setTimeout(resolve, 100)); | ||
| } | ||
| return false; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.