Skip to content

Conversation

@amorask-bitwarden
Copy link
Contributor

🎟️ Tracking

https://bitwarden.atlassian.net/browse/PM-28479

📔 Objective

The previous iteration of this change was not clearing the state for premium interest when a user clicked outside of the upgrade dialog.

@rr-bw made the excellent point that we can just clear the premium state when the dialog opens and track premium interest within dialog-scope as the state has served it's purpose. This PR accomplishes that and updates the associated test file.

📸 Screenshots

⏰ Reminders before review

  • Contributor guidelines followed
  • All formatters and local linters executed and passed
  • Written new unit and / or integration tests where applicable
  • Protected functional changes with optionality (feature flags)
  • Used internationalization (i18n) for all UI strings
  • CI builds passed
  • Communicated to DevOps any deployment requirements
  • Updated any necessary documentation (Confluence, contributing docs) or informed the documentation team

🦮 Reviewer guidelines

  • 👍 (:+1:) or similar for great changes
  • 📝 (:memo:) or ℹ️ (:information_source:) for notes or general info
  • ❓ (:question:) for questions
  • 🤔 (:thinking:) or 💭 (:thought_balloon:) for more open inquiry that's not quite a confirmed issue and could potentially benefit from discussion
  • 🎨 (:art:) for suggestions / improvements
  • ❌ (:x:) or ⚠️ (:warning:) for more significant problems or concerns needing attention
  • 🌱 (:seedling:) or ♻️ (:recycle:) for future improvements or indications of technical debt
  • ⛏ (:pick:) for minor or nitpick changes

@claude
Copy link

claude bot commented Nov 20, 2025

Claude finished @amorask-bitwarden's task —— View job


Code Review Complete

I've reviewed the changes in this PR and everything looks excellent. The refactoring successfully addresses the issue from the previous implementation.

Summary

The PR simplifies premium interest state management by moving the clearing logic from multiple dialog exit points (close, back, complete) into a single location: ngOnInit. When the dialog opens, it:

  1. Checks if premium interest exists
  2. If yes, records it in a component-scoped signal (hasPremiumInterest)
  3. Immediately clears the user's premium interest state
  4. Uses the signal value later for routing decisions

This is a cleaner approach that eliminates the need to handle state clearing at every possible dialog exit point.

Code Quality

Strengths:

  • Clean refactoring that consolidates state management
  • Comprehensive test coverage with well-structured tests
  • Proper use of Angular Signals (ADR-0027 compliant)
  • OnPush change detection properly added to component and test mocks
  • Tests now use a helpful createComponentWithDialogData helper function to reduce duplication
  • Test descriptions are clear and explain the expected behavior

Implementation Details:

  • ngOnInit changed from void to Promise<void> to handle async premium interest operations
  • New hasPremiumInterest signal tracks the state at dialog open time
  • Removed premium interest clearing from onCloseClicked() and previousStep()
  • Simplified onComplete() to check the signal instead of calling the service again

Test Coverage:

  • New test suite: "ngOnInit premium interest handling" with 3 tests covering all scenarios
  • Tests verify service calls happen only during ngOnInit (not in close/back handlers)
  • Manual testing by @rr-bw confirms all user interactions work correctly (X button, ESC, click outside, back button)

Findings

No issues found. The code is well-architected, properly tested, and follows Bitwarden's coding standards.


@github-actions
Copy link
Contributor

github-actions bot commented Nov 20, 2025

Logo
Checkmarx One – Scan Summary & Details8729f0d1-68f7-4103-ab78-9229e97d63ec

New Issues (1)

Checkmarx found the following issues in this Pull Request

Severity Issue Source File / Package Checkmarx Insight
MEDIUM Missing_HSTS_Header /apps/web/src/app/dirt/reports/pages/inactive-two-factor-report.component.ts: 143
detailsThe web-application does not define an HSTS header, leaving it vulnerable to attack.
ID: alhjfubOVRYrjEwL%2BQtMJ8mzlvY%3D
Attack Vector

@codecov
Copy link

codecov bot commented Nov 20, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 41.26%. Comparing base (81453ed) to head (6607db3).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #17518   +/-   ##
=======================================
  Coverage   41.25%   41.26%           
=======================================
  Files        3546     3546           
  Lines      102040   102041    +1     
  Branches    15308    15309    +1     
=======================================
+ Hits        42099    42103    +4     
+ Misses      58177    58173    -4     
- Partials     1764     1765    +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@rr-bw
Copy link
Contributor

rr-bw commented Nov 20, 2025

Thanks @amorask-bitwarden, here are the tests I ran through - everything seems to work just fine. The only scenario I couldn't test fully is the successfully payment scenario (the test card wouldn't work). But it really should work similarly to the rest since you are clearing the state on dialog open.

Click Outside

click-outside-dialog.mov

Click X

click-x.mov

Click "Back"

click-back.mov

Press ESCAPE

press-escape.mov

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants