feat(cc-widgets): UI Automation for Station Login Tests#484
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the 📝 WalkthroughWalkthroughThe changes introduce a new Playwright test suite, Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
|
This pull request is automatically being deployed by Amplify Hosting (learn more). |
| // TODO: The bug of timer reset for Available state should be fixed before implementing this test case | ||
| test.skip('should reset user state timer and maintain Available state after network disconnection with Extension mode', async () => { |
There was a problem hiding this comment.
Do we have a JIRA for this? If yes, let's add the JIRA link here
There was a problem hiding this comment.
We do not. Should I create a ticket for this?
There was a problem hiding this comment.
we should check the behaviour in agent desktop if its retining timer, if not its expected behaviour
There was a problem hiding this comment.
Yeah I had checked it last week. it resets timer in the Agent Desktop
There was a problem hiding this comment.
Do we need to create ticket for this?
There was a problem hiding this comment.
Yeah I'll put a sticky note on the whiteboard regarding this bug.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 0
♻️ Duplicate comments (8)
playwright/station-login-test.spec.ts (8)
235-236: Add JIRA ticket reference for the skipped test.Please add a JIRA ticket reference for tracking the timer reset bug in Available state.
372-373: Add JIRA ticket reference for the skipped test.Please add a JIRA ticket reference for tracking the timer reset bug in Available state.
501-502: Add JIRA ticket reference for the skipped test.Please add a JIRA ticket reference for tracking the timer reset bug in Available state.
25-41: Move helper function to utils file.This utility function should be moved to a separate utils file for better organization and reusability.
43-71: Move WebSocket monitoring function to utils.This WebSocket disconnection monitoring function could be useful for other tests and should be moved to a utils file.
73-99: Move WebSocket reconnection function to utils.Consistent with the disconnection function, this should also be moved to a utils file.
101-117: Move login mode verification to utils.This helper function should be moved to a station login utils file.
119-142: Move user state visibility helper to utils.This helper ensures the user state widget is visible and should be in a utils file.
🧹 Nitpick comments (1)
playwright/Utils/initUtils.ts (1)
140-153: Consider using a loop for cleaner retry logic.The retry implementation works well, but could be more maintainable with a loop structure.
Here's a cleaner approach:
- try { - await page.getByTestId('station-login-widget').waitFor({state: 'visible', timeout: 50000}); - } catch (error) { - // First attempt failed, try clicking init widgets button again - await page.getByTestId('samples:init-widgets-button').click(); - - try { - await page.getByTestId('station-login-widget').waitFor({state: 'visible', timeout: 50000}); - } catch (secondError) { - // Second attempt also failed, throw error - throw new Error('Station login widget failed to become visible after two initialization attempts (100 seconds total)'); - } - } + const maxAttempts = 2; + let lastError: Error | null = null; + + for (let attempt = 1; attempt <= maxAttempts; attempt++) { + try { + await page.getByTestId('station-login-widget').waitFor({state: 'visible', timeout: 50000}); + return; // Success + } catch (error) { + lastError = error as Error; + if (attempt < maxAttempts) { + // Retry by clicking the init button again + await page.getByTestId('samples:init-widgets-button').click(); + } + } + } + + // All attempts failed + throw new Error(`Station login widget failed to become visible after ${maxAttempts} initialization attempts (${maxAttempts * 50} seconds total)`);
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
playwright/Utils/initUtils.ts(2 hunks)playwright/global.setup.ts(0 hunks)playwright/login-user-state.spec.ts(0 hunks)playwright/station-login-test.spec.ts(1 hunks)playwright/user-state-test.spec.ts(0 hunks)
💤 Files with no reviewable changes (3)
- playwright/global.setup.ts
- playwright/user-state-test.spec.ts
- playwright/login-user-state.spec.ts
🧰 Additional context used
🧠 Learnings (3)
📓 Common learnings
Learnt from: Shreyas281299
PR: webex/widgets#362
File: packages/contact-center/task/tests/CallControl/index.tsx:29-46
Timestamp: 2025-01-20T09:52:57.754Z
Learning: UI testing is not mandatory for components in the @webex/widgets repository. Focus should be on functional testing rather than UI element verification.
Learnt from: Kesari3008
PR: webex/widgets#239
File: packages/contact-center/station-login/src/station-login/station-login.presentational.tsx:0-0
Timestamp: 2024-11-19T13:45:03.435Z
Learning: In `packages/contact-center/station-login/src/station-login/station-login.presentational.tsx`, certain code sections are temporary or removable, and comments regarding these sections can be ignored in future reviews.
Learnt from: Kesari3008
PR: webex/widgets#239
File: packages/contact-center/station-login/tests/station-login/station-login.presentational.tsx:0-0
Timestamp: 2024-11-19T13:44:14.152Z
Learning: The file `packages/contact-center/station-login/tests/station-login/station-login.presentational.tsx` is going to change completely, so writing tests for these changes are being ignored.
Learnt from: pagour98
PR: webex/widgets#385
File: packages/contact-center/station-login/src/station-login/index.tsx:10-10
Timestamp: 2025-02-13T06:58:01.805Z
Learning: In the StationLogin component (packages/contact-center/station-login/src/station-login/index.tsx), `handleContinue` and `showMultipleLoginAlert` props have been intentionally removed from store destructuring as part of the Agent Multi-Login configurability changes.
Learnt from: pagour98
PR: webex/widgets#385
File: packages/contact-center/station-login/src/station-login/station-login.types.ts:129-132
Timestamp: 2025-02-13T06:59:01.103Z
Learning: In the station-login component's type definitions, it's acceptable for `UseStationLoginProps` to have a subset of props (`cc`, `onLogin`, `onLogout`, `logger`, `isAgentLoggedIn`) compared to `IStationLoginProps` and `StationLoginPresentationalProps`, even if properties like `handleContinue` and `showMultipleLoginAlert` exist in the latter interfaces.
Learnt from: Kesari3008
PR: webex/widgets#239
File: packages/contact-center/station-login/src/station-login/styles.module.scss:0-0
Timestamp: 2024-11-19T13:35:53.226Z
Learning: The code in 'packages/contact-center/station-login/src/station-login/styles.module.scss' is temporary and is going to be removed.
Learnt from: Shreyas281299
PR: webex/widgets#362
File: packages/contact-center/task/tests/CallControl/call-control.presentational.tsx:0-0
Timestamp: 2025-01-20T09:52:20.775Z
Learning: UI testing is not mandatory for React components in the webex/widgets repository.
Learnt from: Shreyas281299
PR: webex/widgets#345
File: packages/contact-center/cc-widgets/webpack.config.js:6-12
Timestamp: 2024-12-04T07:40:14.027Z
Learning: In the webex-widgets project, optimizations such as reducing bundle size and improving webpack configurations in files like `packages/contact-center/cc-widgets/webpack.config.js` are handled in separate tickets.
Learnt from: mkesavan13
PR: webex/widgets#347
File: packages/contact-center/user-state/src/helper.ts:10-19
Timestamp: 2024-12-06T01:07:12.444Z
Learning: In `packages/contact-center/user-state/src/helper.ts`, within the `useUserState` hook, the timer reset in the `useEffect` hook is handled during the state change success. Therefore, modifying the dependency array is unnecessary.
Learnt from: Shreyas281299
PR: webex/widgets#345
File: package.json:43-43
Timestamp: 2024-12-04T07:33:18.636Z
Learning: The `cc-widgets` package only imports and exports existing widgets without making source code changes, so testing is not required for this package.
playwright/Utils/initUtils.ts (4)
Learnt from: Kesari3008
PR: webex/widgets#341
File: docs/web-component-samples/index.html:0-0
Timestamp: 2024-11-26T10:04:59.245Z
Learning: Ensure that in `docs/web-component-samples/index.html`, the `initWidgets` function includes proper error handling, even in sample applications, to improve user experience.
Learnt from: Kesari3008
PR: webex/widgets#239
File: packages/contact-center/station-login/tests/station-login/station-login.presentational.tsx:0-0
Timestamp: 2024-11-19T13:44:14.152Z
Learning: The file `packages/contact-center/station-login/tests/station-login/station-login.presentational.tsx` is going to change completely, so writing tests for these changes are being ignored.
Learnt from: Kesari3008
PR: webex/widgets#239
File: packages/contact-center/station-login/src/station-login/station-login.presentational.tsx:0-0
Timestamp: 2024-11-19T13:45:03.435Z
Learning: In `packages/contact-center/station-login/src/station-login/station-login.presentational.tsx`, certain code sections are temporary or removable, and comments regarding these sections can be ignored in future reviews.
Learnt from: mkesavan13
PR: webex/widgets#341
File: docs/react-samples/src/App.tsx:35-42
Timestamp: 2024-11-23T02:38:43.208Z
Learning: In sample application code, such as in `docs/react-samples/src/App.tsx`, we should avoid adding loading states and error handling to initialization code, to prevent unnecessary overhead and keep the examples straightforward.
playwright/station-login-test.spec.ts (7)
Learnt from: Kesari3008
PR: webex/widgets#239
File: packages/contact-center/station-login/tests/station-login/station-login.presentational.tsx:0-0
Timestamp: 2024-11-19T13:44:14.152Z
Learning: The file `packages/contact-center/station-login/tests/station-login/station-login.presentational.tsx` is going to change completely, so writing tests for these changes are being ignored.
Learnt from: Kesari3008
PR: webex/widgets#239
File: packages/contact-center/station-login/src/station-login/station-login.presentational.tsx:0-0
Timestamp: 2024-11-19T13:45:03.435Z
Learning: In `packages/contact-center/station-login/src/station-login/station-login.presentational.tsx`, certain code sections are temporary or removable, and comments regarding these sections can be ignored in future reviews.
Learnt from: pagour98
PR: webex/widgets#385
File: packages/contact-center/station-login/src/station-login/index.tsx:10-10
Timestamp: 2025-02-13T06:58:01.805Z
Learning: In the StationLogin component (packages/contact-center/station-login/src/station-login/index.tsx), `handleContinue` and `showMultipleLoginAlert` props have been intentionally removed from store destructuring as part of the Agent Multi-Login configurability changes.
Learnt from: pagour98
PR: webex/widgets#385
File: packages/contact-center/station-login/src/station-login/station-login.types.ts:129-132
Timestamp: 2025-02-13T06:59:01.103Z
Learning: In the station-login component's type definitions, it's acceptable for `UseStationLoginProps` to have a subset of props (`cc`, `onLogin`, `onLogout`, `logger`, `isAgentLoggedIn`) compared to `IStationLoginProps` and `StationLoginPresentationalProps`, even if properties like `handleContinue` and `showMultipleLoginAlert` exist in the latter interfaces.
Learnt from: Kesari3008
PR: webex/widgets#239
File: packages/contact-center/station-login/src/station-login/styles.module.scss:0-0
Timestamp: 2024-11-19T13:35:53.226Z
Learning: The code in 'packages/contact-center/station-login/src/station-login/styles.module.scss' is temporary and is going to be removed.
Learnt from: mkesavan13
PR: webex/widgets#341
File: packages/contact-center/store/tests/store.test.ts:67-92
Timestamp: 2024-11-23T02:51:41.787Z
Learning: When reviewing TypeScript code in this project, it's considered unnecessary to add test cases for invalid parameters if TypeScript's type system handles them.
Learnt from: Shreyas281299
PR: webex/widgets#362
File: packages/contact-center/task/tests/CallControl/index.tsx:29-46
Timestamp: 2025-01-20T09:52:57.754Z
Learning: UI testing is not mandatory for components in the @webex/widgets repository. Focus should be on functional testing rather than UI element verification.
🧬 Code Graph Analysis (1)
playwright/station-login-test.spec.ts (4)
playwright/Utils/stationLoginUtils.ts (2)
telephonyLogin(146-156)stationLogout(105-122)playwright/constants.ts (3)
LONG_WAIT(20-20)LOGIN_MODE(14-18)USER_STATES(3-7)playwright/Utils/initUtils.ts (6)
loginViaAccessToken(23-31)enableMultiLogin(106-108)enableAllWidgets(86-94)initialiseWidgets(137-153)agentRelogin(168-171)setupMultiLoginPage(191-196)playwright/Utils/userStateUtils.ts (3)
changeUserState(19-35)verifyCurrentState(64-69)getStateElapsedTime(83-87)
🔇 Additional comments (1)
playwright/station-login-test.spec.ts (1)
417-530: Desktop mode is missing multi-login synchronization test.Unlike the Dial Number and Extension modes, Desktop mode doesn't include a multi-login synchronization test. This appears intentional since
enableMultiLoginisn't called in thebeforeAllhook.Is multi-login not supported for Desktop mode, or should this test be added for consistency?
Alright, let's re-run the tests and make sure this passes before we merge the PR. |
rarajes2
left a comment
There was a problem hiding this comment.
Looks good. Please address remaining comments before merging.
# [1.28.0-ccwidgets.87](v1.28.0-ccwidgets.86...v1.28.0-ccwidgets.87) (2025-07-07) ### Features * **cc-widgets:** UI Automation for Station Login Tests ([#484](#484)) ([7480fcd](7480fcd))
|
🎉 This PR is included in version 1.28.0-ccwidgets.87 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |


COMPLETES #< https://jira-eng-sjc12.cisco.com/jira/browse/CAI-6641 >
This pull request addresses
UI automation for testing the station login widget
by making the following changes
https://app.vidcast.io/share/2bb14805-839f-4944-9c45-988def87d0b3
Change Type
The following scenarios were tested
< ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >
The GAI Coding Policy And Copyright Annotation Best Practices
Checklist before merging