-
Notifications
You must be signed in to change notification settings - Fork 18
feat(web): add helper text to UPC manage-license action #1930
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
Merged
elibosley
merged 4 commits into
codex/manage-license-start-trial
from
codex/manage-license-helper-text
Mar 18, 2026
+369
−193
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6100969
feat(web): add UPC manage-license helper text
elibosley 6b70635
fix(web): always include activation payload in account callbacks
elibosley bc1dc9d
Fix manage-license helper visibility and i18n keys
elibosley 5ab1370
Preserve key action behavior for Manage License
elibosley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,211 @@ | ||
| import { createPinia, setActivePinia } from 'pinia'; | ||
| import { shallowMount } from '@vue/test-utils'; | ||
|
|
||
| import { beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import type { ServerStateData, ServerStateDataAction } from '~/types/server'; | ||
| import type { UserProfileLink } from '~/types/userProfile'; | ||
| import type { Ref } from 'vue'; | ||
|
|
||
| import DropdownContent from '~/components/UserProfile/DropdownContent.vue'; | ||
| import { createTestI18n } from '../utils/i18n'; | ||
|
|
||
| const { accountStoreMocks, errorsStoreRefs, serverStoreRefs, updateOsStoreRefs } = vi.hoisted(() => ({ | ||
| accountStoreMocks: { | ||
| manage: vi.fn(), | ||
| myKeys: vi.fn(), | ||
| }, | ||
| errorsStoreRefs: { | ||
| errors: null as Ref<unknown[]> | null, | ||
| }, | ||
| serverStoreRefs: { | ||
| connectPluginInstalled: null as Ref<'dynamix.unraid.net.plg' | ''> | null, | ||
| keyActions: null as Ref<ServerStateDataAction[] | undefined> | null, | ||
| rebootType: null as Ref<string> | null, | ||
| registered: null as Ref<boolean> | null, | ||
| regUpdatesExpired: null as Ref<boolean> | null, | ||
| stateData: null as Ref<ServerStateData> | null, | ||
| stateDataError: null as Ref<{ message: string } | undefined> | null, | ||
| }, | ||
| updateOsStoreRefs: { | ||
| available: null as Ref<string | null> | null, | ||
| availableWithRenewal: null as Ref<string | null> | null, | ||
| }, | ||
| })); | ||
|
|
||
| vi.mock('~/store/account', () => ({ | ||
| useAccountStore: () => accountStoreMocks, | ||
| })); | ||
|
|
||
| vi.mock('~/store/errors', async () => { | ||
| const { ref } = await import('vue'); | ||
| const { defineStore } = await import('pinia'); | ||
|
|
||
| errorsStoreRefs.errors = ref([]); | ||
|
|
||
| const useErrorsStore = defineStore('errorsMockForDropdownContent', () => ({ | ||
| errors: errorsStoreRefs.errors!, | ||
| })); | ||
|
|
||
| return { useErrorsStore }; | ||
| }); | ||
|
|
||
| vi.mock('~/store/updateOs', async () => { | ||
| const { ref } = await import('vue'); | ||
| const { defineStore } = await import('pinia'); | ||
|
|
||
| updateOsStoreRefs.available = ref(null); | ||
| updateOsStoreRefs.availableWithRenewal = ref(null); | ||
|
|
||
| const useUpdateOsStore = defineStore('updateOsMockForDropdownContent', () => ({ | ||
| available: updateOsStoreRefs.available!, | ||
| availableWithRenewal: updateOsStoreRefs.availableWithRenewal!, | ||
| localCheckForUpdate: vi.fn(), | ||
| setModalOpen: vi.fn(), | ||
| })); | ||
|
|
||
| return { useUpdateOsStore }; | ||
| }); | ||
|
|
||
| vi.mock('~/store/server', async () => { | ||
| const { ref } = await import('vue'); | ||
| const { defineStore } = await import('pinia'); | ||
|
|
||
| serverStoreRefs.keyActions = ref([]); | ||
| serverStoreRefs.connectPluginInstalled = ref('dynamix.unraid.net.plg'); | ||
| serverStoreRefs.rebootType = ref(''); | ||
| serverStoreRefs.registered = ref(false); | ||
| serverStoreRefs.regUpdatesExpired = ref(false); | ||
| serverStoreRefs.stateData = ref({ | ||
| actions: [], | ||
| error: false, | ||
| heading: '', | ||
| humanReadable: '', | ||
| message: '', | ||
| }); | ||
| serverStoreRefs.stateDataError = ref(undefined); | ||
|
|
||
| const useServerStore = defineStore('serverMockForDropdownContent', () => ({ | ||
| keyActions: serverStoreRefs.keyActions!, | ||
| connectPluginInstalled: serverStoreRefs.connectPluginInstalled!, | ||
| rebootType: serverStoreRefs.rebootType!, | ||
| registered: serverStoreRefs.registered!, | ||
| regUpdatesExpired: serverStoreRefs.regUpdatesExpired!, | ||
| stateData: serverStoreRefs.stateData!, | ||
| stateDataError: serverStoreRefs.stateDataError!, | ||
| })); | ||
|
|
||
| return { useServerStore }; | ||
| }); | ||
|
|
||
| describe('DropdownContent', () => { | ||
| const isManageLicenseItem = ( | ||
| item: unknown | ||
| ): item is UserProfileLink<'manageLicense'> & { name: 'manageLicense' } => { | ||
| return ( | ||
| typeof item === 'object' && item !== null && (item as { name?: string }).name === 'manageLicense' | ||
| ); | ||
| }; | ||
|
|
||
| beforeEach(() => { | ||
| setActivePinia(createPinia()); | ||
|
|
||
| serverStoreRefs.keyActions!.value = []; | ||
| serverStoreRefs.connectPluginInstalled!.value = 'dynamix.unraid.net.plg'; | ||
| serverStoreRefs.rebootType!.value = ''; | ||
| serverStoreRefs.registered!.value = false; | ||
| serverStoreRefs.regUpdatesExpired!.value = false; | ||
| serverStoreRefs.stateData!.value = { | ||
| actions: [{ name: 'signIn', text: 'Sign in to Unraid Connect' }], | ||
| error: false, | ||
| heading: '', | ||
| humanReadable: '', | ||
| message: '', | ||
| }; | ||
| serverStoreRefs.stateDataError!.value = undefined; | ||
|
|
||
| errorsStoreRefs.errors!.value = []; | ||
| updateOsStoreRefs.available!.value = null; | ||
| updateOsStoreRefs.availableWithRenewal!.value = null; | ||
| }); | ||
|
|
||
| it('does not show manage-license helper text when sign-in is the only action', () => { | ||
| const wrapper = shallowMount(DropdownContent, { | ||
| global: { | ||
| plugins: [createTestI18n()], | ||
| }, | ||
| }); | ||
|
|
||
| expect(wrapper.text()).toContain('Sign In to your Unraid.net account to get started'); | ||
| expect(wrapper.text()).not.toContain( | ||
| 'Replace, recover, or link your license on your Unraid Account.' | ||
| ); | ||
| }); | ||
|
|
||
| it('shows manage-license helper text when key actions are available', () => { | ||
| serverStoreRefs.keyActions!.value = [{ name: 'replace', text: 'Replace Key' }]; | ||
|
|
||
| const wrapper = shallowMount(DropdownContent, { | ||
| global: { | ||
| plugins: [createTestI18n()], | ||
| }, | ||
| }); | ||
|
|
||
| expect(wrapper.text()).toContain('Replace, recover, or link your license on your Unraid Account.'); | ||
| }); | ||
|
|
||
| it('shows the localized trial helper text when trial start is available', () => { | ||
| serverStoreRefs.keyActions!.value = [{ name: 'trialStart', text: 'Start Trial' }]; | ||
|
|
||
| const wrapper = shallowMount(DropdownContent, { | ||
| global: { | ||
| plugins: [createTestI18n()], | ||
| }, | ||
| }); | ||
|
|
||
| expect(wrapper.text()).toContain('Start your trial from Manage License in your Unraid Account.'); | ||
| }); | ||
|
|
||
| it('uses the first key action behavior for Manage License', () => { | ||
| const replaceClick = vi.fn(); | ||
| serverStoreRefs.registered!.value = true; | ||
| serverStoreRefs.stateData!.value = { | ||
| actions: [], | ||
| error: false, | ||
| heading: '', | ||
| humanReadable: '', | ||
| message: '', | ||
| }; | ||
| serverStoreRefs.keyActions!.value = [ | ||
| { | ||
| click: replaceClick, | ||
| clickParams: ['foo'], | ||
| disabled: true, | ||
| external: true, | ||
| name: 'replace', | ||
| text: 'Replace Key', | ||
| title: 'Replace', | ||
| }, | ||
| ]; | ||
|
|
||
| const wrapper = shallowMount(DropdownContent, { | ||
| global: { | ||
| plugins: [createTestI18n()], | ||
| }, | ||
| }); | ||
|
|
||
| const dropdownItems = wrapper.findAllComponents({ name: 'DropdownItem' }); | ||
| const manageItem = dropdownItems | ||
| .map((itemWrapper) => itemWrapper.props('item')) | ||
| .find(isManageLicenseItem); | ||
|
|
||
| expect(manageItem).toBeDefined(); | ||
| expect(manageItem?.disabled).toBe(true); | ||
| expect(manageItem?.external).toBe(true); | ||
|
|
||
| manageItem?.click?.(manageItem.clickParams); | ||
|
|
||
| expect(replaceClick).toHaveBeenCalledTimes(1); | ||
| expect(accountStoreMocks.myKeys).not.toHaveBeenCalled(); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
The new
trialStartbranch bypassesvue-i18nand returns a hard-coded English sentence, while the rest of this dropdown and the existing helper text use translation keys. That means any non-English user who has atrialStartaction will now see untranslated helper copy in the profile menu, even thoughweb/src/locales/*.jsonalready carries the surrounding strings.Useful? React with 👍 / 👎.