-
Couldn't load subscription status.
- Fork 11
tests: server store trial extensions #1504
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
Conversation
Consolidated trial message handling to reduce redundancy and improve readability. The logic now checks conditions for trial expiration and extension eligibility more efficiently, ensuring users receive accurate information based on their trial status.
…better clarity and maintainability
…ging Implemented new tests in `server.test.ts` to validate trial extension eligibility, expiration conditions, and corresponding user messages. This includes checks for eligibility based on `regGen` values and expiration timing, ensuring accurate feedback for users regarding their trial status.
WalkthroughThis update introduces new computed properties and logic in the server store to manage Unraid OS trial extension eligibility and renewal messaging. It updates localized strings for trial expiration scenarios and adds comprehensive tests to verify the new trial extension conditions, dynamic messages, and available actions in the user interface. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant UI
participant ServerStore
User->>UI: Views trial status
UI->>ServerStore: Reads computed properties
ServerStore-->>UI: Returns eligibility and renewal window status
alt Eligible and within renewal window
UI-->>User: Show extend option and expiring soon message
else Ineligible or outside window
UI-->>User: Show appropriate message (no extension or wait)
end
Possibly related PRs
Poem
✨ Finishing Touches
🪧 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
CodeRabbit Configuration File (
|
|
This plugin has been deployed to Cloudflare R2 and is available for testing. |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
web/store/server.ts (1)
514-523: Consider extracting hardcoded HTML messages to localization files.The conditional logic correctly handles all trial extension scenarios. However, the HTML content is hardcoded which could impact maintainability and localization.
Consider moving these messages to the localization files and referencing them here:
- trialMessage = '<p>Your <em>Trial</em> key includes all the functionality and device support of an <em>Unleashed</em> key.</p><p>Your trial is expiring soon. When it expires, <strong>the array will stop</strong>. You may extend your trial now, purchase a license key, or wait until expiration to take action.</p>'; + trialMessage = this.$t('server.trial.eligibleInsideRenewalWindow');
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
web/__test__/store/server.test.ts(1 hunks)web/locales/en_US.json(1 hunks)web/store/server.ts(3 hunks)
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: elibosley
PR: unraid/api#1101
File: api/src/unraid-api/unraid-file-modifier/modifications/patches/default-page-layout.patch:24-27
Timestamp: 2025-01-31T22:01:22.708Z
Learning: The Unraid UI uses a modern notification system with a custom `unraid-toaster` component replacing the legacy jGrowl notifications. The system is backed by a comprehensive GraphQL API with real-time subscription support for notification updates.
Learnt from: mdatelle
PR: unraid/api#1106
File: unraid-ui/src/components/index.ts:2-2
Timestamp: 2025-02-04T17:21:39.710Z
Learning: The unraid-ui package is undergoing a major refactoring process, and breaking changes are expected during this transition period.
Learnt from: elibosley
PR: unraid/api#1101
File: api/src/unraid-api/unraid-file-modifier/modifications/patches/default-page-layout.patch:6-20
Timestamp: 2025-01-31T22:01:41.842Z
Learning: The default-page-layout.patch removes the old jGrowl notification system and is complemented by the unraid-toaster component implementation. The new system is added through the DefaultPageLayout modification which inserts the toaster component with proper position configuration based on user preferences.
Learnt from: elibosley
PR: unraid/api#1211
File: unraid-ui/src/components/form/number/NumberFieldInput.vue:1-21
Timestamp: 2025-03-13T16:17:21.897Z
Learning: The unraid-ui is a UI library being published externally, where wrapping third-party components (like those from reka-ui) is an intentional design choice to maintain a consistent interface, standardize styling, and control the exposed API.
Learnt from: elibosley
PR: unraid/api#1082
File: api/src/unraid-api/unraid-file-modifier/modifications/log-rotate.modification.ts:33-37
Timestamp: 2025-01-29T16:36:04.777Z
Learning: The UnraidFileModifierService in the Unraid API provides comprehensive error handling for all FileModification implementations. It includes try/catch blocks, detailed error logging, and safe rollback mechanisms. Individual FileModification implementations (like LogRotateModification) should allow errors to propagate to this service layer rather than handling them internally.
Learnt from: elibosley
PR: unraid/api#1101
File: api/src/unraid-api/unraid-file-modifier/modifications/patches/default-page-layout.patch:6-20
Timestamp: 2025-01-31T22:01:41.842Z
Learning: The default-page-layout.patch is used to remove the old jGrowl notification system from Unraid pages, as notifications are handled by a new system implemented on a different page.
web/locales/en_US.json (1)
Learnt from: zackspear
PR: unraid/api#1257
File: plugin/source/dynamix.unraid.net/usr/local/emhttp/plugins/dynamix/include/ReplaceKey.php:184-184
Timestamp: 2025-03-20T01:58:31.676Z
Learning: Error messages from the key server or KeyInstaller do not contain PII or server details, so they can be safely used in notifications.
web/__test__/store/server.test.ts (11)
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify state changes by updating the store in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Mock external dependencies appropriately in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify state changes after actions in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test action side effects and state changes in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test getter dependencies are properly mocked in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test async operations completely in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test store interactions with other stores in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test action side effects if not stubbed in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Override specific action implementations when needed in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify proper error handling in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify actions are called with correct parameters in store tests
web/store/server.ts (10)
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify state changes by updating the store in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify state changes after actions in store tests
Learnt from: elibosley
PR: unraid/api#1063
File: web/_data/serverState.ts:137-147
Timestamp: 2025-01-27T14:57:46.617Z
Learning: The values in `web/_data/serverState.ts` are used for testing purposes and should remain as hardcoded mock data to facilitate testing different scenarios.
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test action side effects and state changes in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Verify proper error handling in store tests
Learnt from: CR
PR: unraid/api#0
File: CLAUDE.md:0-0
Timestamp: 2025-06-30T14:50:43.946Z
Learning: Applies to web/store/**/*.{ts,js} : Ensure Vue reactivity imports are added to store files (computed, ref, watchEffect)
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Set initial state for focused testing in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test store interactions with other stores in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Mock external dependencies appropriately in store tests
Learnt from: CR
PR: unraid/api#0
File: .cursor/rules/web-testing-rules.mdc:0-0
Timestamp: 2025-06-30T14:52:37.535Z
Learning: Applies to **/__test__/store/**/*.ts : Test action side effects if not stubbed in store tests
🔇 Additional comments (10)
web/locales/en_US.json (1)
26-29: LGTM! Well-structured trial extension messaging.The new locale strings are clear, consistent, and properly formatted. They effectively communicate the different trial extension scenarios and the updated behavior where the array stops upon expiration. The messaging provides users with appropriate guidance on available actions.
web/__test__/store/server.test.ts (5)
768-792: Comprehensive trial extension eligibility testing.The test correctly validates the eligibility logic based on
regGenvalues. The implementation properly covers all scenarios: undefined, 0, 1 (eligible) and 2+ (ineligible).
794-834: Thorough expiration window calculation testing.The test comprehensively validates the 5-day expiration window logic with proper edge cases including non-trial states, missing expiration times, and various day ranges. The use of dayjs for date calculations is appropriate.
836-904: Well-structured renewal window condition testing.The test effectively validates the combination of eligibility and expiration window conditions. The four scenarios (eligible inside/outside, ineligible inside/outside) are all properly tested with correct state expectations.
906-1001: Excellent dynamic message testing.The test validates that the correct trial messages are displayed based on extension eligibility and renewal window status. The message content verification ensures the UI will display appropriate guidance to users in each scenario.
1003-1084: Solid action availability testing.The test properly validates that the trial extend action is only available when eligible and within the renewal window. This ensures the UI only presents valid actions to users.
web/store/server.ts (4)
498-498: LGTM! Clean variable declaration.The
trialMessagevariable is properly declared to hold dynamic trial content.
528-528: Perfect conditional action inclusion.The trial extend action is correctly included only when the user is eligible and within the renewal window.
533-533: LGTM! Dynamic message implementation.The message field now correctly uses the dynamic
trialMessagevariable instead of static content.
787-798: Well-structured computed properties for trial logic.The computed properties are clearly named and implement the trial extension logic correctly. The
trialWithin5DaysOfExpirationproperly handles edge cases and the dependent computed properties create a clean separation of concerns.One minor note: The date calculation logic correctly handles the 0-5 day range using
daysUntilExpiration <= 5 && daysUntilExpiration >= 0.
Requested in feature PR #1490 (comment)
Summary by CodeRabbit
New Features
Bug Fixes
Tests
Documentation