Skip to content

fix(station-login): doStationLogout prop to logout on signout confirm#473

Merged
mkesavan13 merged 6 commits into
webex:ccwidgetsfrom
mkesavan13:station-logout
Jun 24, 2025
Merged

fix(station-login): doStationLogout prop to logout on signout confirm#473
mkesavan13 merged 6 commits into
webex:ccwidgetsfrom
mkesavan13:station-logout

Conversation

@mkesavan13

@mkesavan13 mkesavan13 commented Jun 17, 2025

Copy link
Copy Markdown
Contributor

COMPLETES Ad-Hoc

This pull request addresses

  • Signout of CC in the Agent Desktop does a station signout
  • We did not have that setup in our widgets
  • This PR is to address the same

by making the following changes

  • Adding a toggle doStationSignout and have it enabled by default
    • If this boolean is false, the agent will not be logged out from the station but the onCCSignOut will be called.
    • By default, it is true which means the agent will be logged out from the station and onCCSignOut will be called.
  • Not attempting to call stationLogout if the user is not logged in at all
  • Updated all the UTs accordingly

Vidcast

https://app.vidcast.io/share/9f02d056-796a-47bd-b8b8-4968342affc3

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
  1. Do station logout if the toggle is enabled & then call ccSignout ✅
  2. Do not attempt station logout if the toggle is not enabled but call ccSignout ✅
  3. Do not attempt station logout if the user is not logged in at all but call ccSignout ✅

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
  • 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 Jun 17, 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 enhanced keyboard accessibility and new sign-out behavior options to the Contact Center Station Login components. A keyboard event handler is added to the sign-out modal to allow closing it with the Escape key. A new optional boolean prop, doStationLogout, is introduced across relevant types, components, and hooks, enabling conditional station logout behavior when signing out. The useStationLogin hook and StationLogin component are updated to support this new prop and to expose a new onCCSignOut method. Test suites are expanded to cover these new features and behaviors, and a sample UI toggle is added to demonstrate the new prop in action. No breaking changes to exported entities are made.


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.

@mkesavan13 mkesavan13 added the validated Indicates that the PR is ready for actions label Jun 17, 2025
@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-473.d1b38q61t1z947.amplifyapp.com

@mkesavan13 mkesavan13 added the run_e2e Add this label to run E2E test for meeting and CC widgets label Jun 17, 2025

@akulakum akulakum 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.

LGTM

@mkesavan13

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 19, 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: 1

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e15bb93 and 2767042.

📒 Files selected for processing (11)
  • packages/contact-center/cc-components/src/components/StationLogin/station-login.tsx (3 hunks)
  • packages/contact-center/cc-components/src/components/StationLogin/station-login.types.ts (1 hunks)
  • packages/contact-center/cc-components/src/components/StationLogin/station-login.utils.tsx (2 hunks)
  • packages/contact-center/cc-components/tests/components/StationLogin/station-login.tsx (3 hunks)
  • packages/contact-center/cc-components/tests/components/StationLogin/station-login.utils.tsx (2 hunks)
  • packages/contact-center/station-login/src/helper.ts (3 hunks)
  • packages/contact-center/station-login/src/station-login/index.tsx (2 hunks)
  • packages/contact-center/station-login/src/station-login/station-login.types.ts (1 hunks)
  • packages/contact-center/station-login/tests/helper.ts (6 hunks)
  • packages/contact-center/station-login/tests/station-login/index.tsx (1 hunks)
  • widgets-samples/cc/samples-cc-react-app/src/App.tsx (3 hunks)
🧰 Additional context used
🧠 Learnings (11)
📓 Common learnings
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.
packages/contact-center/cc-components/src/components/StationLogin/station-login.tsx (1)
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.
widgets-samples/cc/samples-cc-react-app/src/App.tsx (1)
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.
packages/contact-center/station-login/src/station-login/station-login.types.ts (1)
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.
packages/contact-center/cc-components/tests/components/StationLogin/station-login.utils.tsx (1)
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.
packages/contact-center/station-login/tests/station-login/index.tsx (3)
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/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: 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.
packages/contact-center/cc-components/src/components/StationLogin/station-login.types.ts (1)
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.
packages/contact-center/cc-components/tests/components/StationLogin/station-login.tsx (1)
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.
packages/contact-center/station-login/src/station-login/index.tsx (2)
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.
packages/contact-center/station-login/src/helper.ts (2)
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.
packages/contact-center/station-login/tests/helper.ts (1)
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.
🔇 Additional comments (26)
packages/contact-center/station-login/tests/station-login/index.tsx (1)

81-82: LGTM: Test correctly reflects new props.

The test properly validates that the useStationLogin hook is called with the new onCCSignOut and doStationLogout props, maintaining consistency with the component's extended functionality.

packages/contact-center/cc-components/src/components/StationLogin/station-login.utils.tsx (2)

222-229: LGTM: Clean keyboard accessibility implementation.

The function properly handles the Escape key to close the sign-out modal, following standard accessibility practices. The implementation is focused and well-typed.


244-244: LGTM: Proper export addition.

The new utility function is correctly added to the exports list.

widgets-samples/cc/samples-cc-react-app/src/App.tsx (3)

58-58: LGTM: Proper state initialization.

The doStationLogout state is correctly initialized with a sensible default value of true.


499-508: LGTM: Consistent UI control implementation.

The checkbox implementation follows the same pattern as other toggles in the app and provides a clear way to test the new station logout behavior.


649-649: LGTM: Correct prop usage.

The doStationLogout prop is appropriately passed only to the non-profile mode StationLogin component, which makes sense since this behavior is relevant for the login/logout flow rather than profile editing.

packages/contact-center/cc-components/tests/components/StationLogin/station-login.utils.tsx (1)

16-16: LGTM: Comprehensive test coverage.

The tests thoroughly cover the new handleCCSignoutKeyDown function with both positive (Escape key) and negative (other keys) test cases. The test implementation follows established patterns and provides clear assertions.

Also applies to: 38-52

packages/contact-center/cc-components/src/components/StationLogin/station-login.tsx (3)

17-17: LGTM: Proper import addition.

The handleCCSignoutKeyDown utility function is correctly imported for use in the component.


102-107: LGTM: Enhanced keyboard accessibility.

The onKeyDown event handler properly integrates keyboard support for the sign-out modal, allowing users to close it with the Escape key. This improves accessibility and follows standard modal behavior patterns.


123-129: LGTM: Improved modal behavior.

The sign-out button now immediately closes the modal before proceeding with the sign-out logic. This prevents the modal from remaining open during the sign-out process and provides better user experience.

packages/contact-center/station-login/src/station-login/station-login.types.ts (2)

15-16: LGTM! Type definitions properly extended.

The addition of onCCSignOut and doStationLogout to UseStationLoginProps is consistent with the feature requirements and maintains type safety.


21-21: LGTM! StationLoginProps updated consistently.

The StationLoginProps type correctly includes the new props, ensuring consistency across the component interface.

packages/contact-center/cc-components/src/components/StationLogin/station-login.types.ts (1)

114-118: Excellent documentation and type definition.

The doStationLogout property is well-documented with clear explanation of both true/false behaviors and the default value. The optional nature maintains backward compatibility.

packages/contact-center/station-login/src/station-login/index.tsx (2)

10-10: LGTM! Props correctly destructured.

The component properly extracts the new doStationLogout prop alongside existing props.


36-37: LGTM! Props correctly passed to hook.

Both onCCSignOut and doStationLogout are properly passed to the useStationLogin hook, enabling the new functionality.

packages/contact-center/cc-components/tests/components/StationLogin/station-login.tsx (3)

126-126: LGTM! Modal class assertion added.

Good addition to verify that the sign-out modal has the expected CSS class for proper styling.


497-497: LGTM! Test suite name updated appropriately.

The test suite name now accurately reflects that it covers both modal popup and keyboard handling functionality.


593-596: LGTM! Keyboard event handler test added.

The test properly verifies that pressing the Escape key calls the state setter to close the modal. Good direct testing of the utility function.

packages/contact-center/station-login/src/helper.ts (2)

16-17: LGTM! Props extraction and default value handling.

The props are correctly extracted and the default value for doStationLogout is appropriately set to true, maintaining backward compatibility.


246-246: LGTM! Conditional function return.

The function is correctly returned only when onCCSignOut is provided, ensuring the API is clean and type-safe.

packages/contact-center/station-login/tests/helper.ts (6)

37-37: LGTM! Mock method addition aligns with new functionality.

The addition of the deregister mock method properly supports the new onCCSignOut functionality that requires both stationLogout and deregister calls.


558-585: Well-structured test for unchanged login options scenario.

The test properly verifies that saveLoginOptions doesn't perform unnecessary operations when no changes are detected, and includes appropriate logging verification.


586-631: Comprehensive test coverage for successful save operation.

The test thoroughly validates the save functionality including:

  • State changes triggering save operations
  • Proper API calls with correct parameters
  • State updates after successful save
  • Logging verification

632-666: Good error handling test coverage.

The test properly verifies error scenarios including error state updates and error logging, ensuring the application gracefully handles API failures.


667-707: Excellent edge case coverage for BROWSER device type.

The test correctly verifies that the dialNumber parameter is omitted when the device type is BROWSER, which is important for API contract compliance.


709-766: Comprehensive test suite for new onCCSignOut functionality.

The test suite thoroughly covers both scenarios for the new doStationLogout prop:

  • When true: verifies both stationLogout and deregister are called along with the callback
  • When false: verifies station logout operations are skipped but callback is still invoked

The setup with proper mock clearing and state management is well-implemented.

Comment thread packages/contact-center/station-login/src/helper.ts

@Kesari3008 Kesari3008 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.

What about a case where IU only want to do station logout but not deregister ?

Comment thread packages/contact-center/station-login/src/helper.ts Outdated
Comment thread packages/contact-center/station-login/src/helper.ts Outdated
Comment thread packages/contact-center/station-login/tests/station-login/index.tsx
Comment thread packages/contact-center/station-login/tests/helper.ts Outdated
});

describe('SignOut Modal Popup', () => {
describe('SignOut Modal Popup and handleCCSignoutKeyDown', () => {

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 would need test for setShowCCsignoutModal being invoked from cc-logout-button also right

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.

True. To test that, we had to move the setShowCCsignoutModal into continueClicked as we cannot test it directly by mocking prop method. Updated the test as well to test this case.

@mkesavan13

Copy link
Copy Markdown
Contributor Author

What about a case where IU only want to do station logout but not deregister ?

We decided on the DSM call that we won't do that as they are logging out of Webex anyway so it won't make sense to not deregister

await cc.deregister();
} catch (error) {
logger.error(`CC-Widgets: Error during station logout: ${error}`, {
module: 'widget-station-login#station-login/helper.ts',

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 don't need #station-login right, module: 'widget-station-login#helper.ts', is how I observed we are logging eveywhere

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.

There were other logs in this format and some other format. Now fixed everything to the format you observed

const continueBtn = screen.getByTestId('ContinueButton');
fireEvent.click(continueBtn);
expect(stationLoginUtils.continueClicked).toHaveBeenCalledWith(mockModal, handleContinue);
expect(stationLoginUtils.continueClicked).toHaveBeenCalledWith(mockModal, handleContinue, expect.any(Function));

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.

Instead of expect.any(Function), is it possible to make it more accurate which function, use the spy on the function

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 cannot do that because it is a state inside the component and jest doesn't give that much control there.

@mkesavan13
mkesavan13 merged commit a38cc5b into webex:ccwidgets Jun 24, 2025
8 of 9 checks passed
github-actions Bot pushed a commit that referenced this pull request Jun 24, 2025
# [1.28.0-ccwidgets.77](v1.28.0-ccwidgets.76...v1.28.0-ccwidgets.77) (2025-06-24)

### Bug Fixes

* **station-login:** doStationLogout prop to logout on signout confirm ([#473](#473)) ([a38cc5b](a38cc5b))
@sreenara

Copy link
Copy Markdown
Contributor

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

The release is available on GitHub release

Your semantic-release bot 📦🚀

@mkesavan13
mkesavan13 deleted the station-logout branch July 4, 2025 05:13
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