Skip to content

feat(cc-widgets): UI Automation for Station Login Tests#484

Merged
rsarika merged 11 commits into
webex:ccwidgetsfrom
PrayagGP:ccwidgets
Jul 7, 2025
Merged

feat(cc-widgets): UI Automation for Station Login Tests#484
rsarika merged 11 commits into
webex:ccwidgetsfrom
PrayagGP:ccwidgets

Conversation

@PrayagGP

@PrayagGP PrayagGP commented Jul 2, 2025

Copy link
Copy Markdown
Contributor

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

    1. Wrote tests for station login.

https://app.vidcast.io/share/2bb14805-839f-4944-9c45-988def87d0b3

Change Type

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Tooling change
  • Internal code refactor

The following scenarios were tested

  • The testing is done with the amplify link
    < ENUMERATE TESTS PERFORMED, WHETHER MANUAL OR AUTOMATED >

The GAI Coding Policy And Copyright Annotation Best Practices

  • GAI was not used (or, no additional notation is required)
  • Code was generated entirely by GAI
  • [x ] GAI was used to create a draft that was subsequently customized or modified
  • Coder created a draft manually that was non-substantively modified by GAI (e.g., refactoring was performed by GAI on manually written code)
  • Tool used for AI assistance (GitHub Copilot / Other - specify)
    • Github Copilot
    • Other - Please Specify
  • This PR is related to
    • Feature
    • Defect fix
    • Tech Debt
    • Automation

Checklist before merging

  • I have not skipped any automated checks
  • All existing and new tests passed
  • [ ] I have updated the testing document

@coderabbitai

coderabbitai Bot commented Jul 2, 2025

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

The changes introduce a new Playwright test suite, station-login-test.spec.ts, which implements comprehensive end-to-end tests for a station login widget across three modes: Dial Number, Extension, and Desktop. Helper functions were added for parsing time strings, monitoring WebSocket connection status, verifying login modes, and ensuring user state visibility. The initialiseWidgets utility function was updated to include retry logic and extended timeout for widget initialization. Additionally, the import and configuration of the dotenv package were removed from several Playwright setup and test files (global.setup.ts, login-user-state.spec.ts, and user-state-test.spec.ts). No changes were made to exported function signatures.


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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@aws-amplify-us-east-2

Copy link
Copy Markdown

This pull request is automatically being deployed by Amplify Hosting (learn more).

Access this pull request here: https://pr-484.d1b38q61t1z947.amplifyapp.com

@rsarika rsarika added validated Indicates that the PR is ready for actions run_e2e Add this label to run E2E test for meeting and CC widgets labels Jul 2, 2025
Comment thread playwright/Utils/initUtils.ts
Comment thread playwright/station-login-test.spec.ts Outdated
Comment thread playwright/station-login-test.spec.ts Outdated
Comment on lines +375 to +376
// 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 () => {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have a JIRA for this? If yes, let's add the JIRA link here

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not. Should I create a ticket for this?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should check the behaviour in agent desktop if its retining timer, if not its expected behaviour

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I had checked it last week. it resets timer in the Agent Desktop

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to create ticket for this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'll put a sticky note on the whiteboard regarding this bug.

@rarajes2

rarajes2 commented Jul 4, 2025

Copy link
Copy Markdown
Contributor

Please check the failing case
Screenshot 2025-07-04 at 5 35 04 PM

@PrayagGP

PrayagGP commented Jul 4, 2025

Copy link
Copy Markdown
Contributor Author

Please check the failing case Screenshot 2025-07-04 at 5 35 04 PM

Yeah. This test failed because of someone else using the same user. I found out about this when I checked the trace. The tests run fine otherwise.

Comment thread playwright/station-login-test.spec.ts Outdated
Comment thread playwright/station-login-test.spec.ts Outdated
@rsarika

rsarika commented Jul 5, 2025

Copy link
Copy Markdown
Contributor

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 5, 2025

Copy link
Copy Markdown
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 7ebd32f and 418efda.

📒 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 enableMultiLogin isn't called in the beforeAll hook.

Is multi-login not supported for Desktop mode, or should this test be added for consistency?

@rarajes2

rarajes2 commented Jul 7, 2025

Copy link
Copy Markdown
Contributor

Yeah. This test failed because of someone else using the same user. I found out about this when I checked the trace. The tests run fine otherwise.

Alright, let's re-run the tests and make sure this passes before we merge the PR.

@rarajes2 rarajes2 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Please address remaining comments before merging.

@rsarika
rsarika merged commit 7480fcd into webex:ccwidgets Jul 7, 2025
8 of 9 checks passed
github-actions Bot pushed a commit that referenced this pull request Jul 7, 2025
# [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))
@sreenara

sreenara commented Jul 7, 2025

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.28.0-ccwidgets.87 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released on @ccwidgets run_e2e Add this label to run E2E test for meeting and CC widgets validated Indicates that the PR is ready for actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants