Repository navigation
fix(web): polish combined header on mobile and desktop #2109
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
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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,93 @@ | ||
| import { nextTick } from 'vue'; | ||
| import { createPinia, setActivePinia } from 'pinia'; | ||
| import { mount } from '@vue/test-utils'; | ||
|
|
||
| import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; | ||
|
|
||
| import type { VueWrapper } from '@vue/test-utils'; | ||
|
|
||
| import ServerStatus from '~/components/UserProfile/ServerStatus.vue'; | ||
| import UptimeExpire from '~/components/UserProfile/UptimeExpire.vue'; | ||
| import { useServerStore } from '~/store/server'; | ||
| import { createTestI18n } from '../utils/i18n'; | ||
|
|
||
| vi.mock('~/store/server', async () => { | ||
| const { defineStore } = await import('pinia'); | ||
| return { | ||
| useServerStore: defineStore('server', { | ||
| state: () => ({ | ||
| state: 'LIFETIME', | ||
| uptime: Date.now() - 9 * 86400000, | ||
| expireTime: Date.now() + 14 * 86400000, | ||
| dateTimeFormat: { date: '%c', time: '%R' }, | ||
| }), | ||
| }), | ||
| }; | ||
| }); | ||
|
|
||
| vi.mock('@unraid/ui', () => { | ||
| const slot = { template: '<div><slot /></div>' }; | ||
| return { | ||
| cn: (...values: string[]) => values.filter(Boolean).join(' '), | ||
| Tooltip: slot, | ||
| TooltipContent: slot, | ||
| TooltipProvider: slot, | ||
| TooltipTrigger: slot, | ||
| }; | ||
| }); | ||
|
|
||
| describe('header uptime and expiry states', () => { | ||
| let wrapper: VueWrapper | undefined; | ||
|
|
||
| beforeEach(() => { | ||
| vi.useFakeTimers(); | ||
| vi.setSystemTime(new Date('2026-10-10T12:00:00Z')); | ||
| setActivePinia(createPinia()); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| wrapper?.unmount(); | ||
| vi.clearAllTimers(); | ||
| vi.useRealTimers(); | ||
| }); | ||
|
|
||
| it('refreshes the compact timestamp when a running server changes to a trial or expired trial', async () => { | ||
| wrapper = mount(ServerStatus, { | ||
| global: { plugins: [createTestI18n()], stubs: { UpcServerState: true } }, | ||
| }); | ||
| const server = useServerStore(); | ||
| expect(wrapper.text()).toContain('Uptime 9 days'); | ||
|
|
||
| server.state = 'TRIAL'; | ||
| await nextTick(); | ||
| expect(wrapper.text()).toContain('Expires in 14 days'); | ||
| expect(wrapper.text()).not.toContain('Expires in 9 days'); | ||
|
|
||
| server.expireTime = Date.now() + 17 * 86400000; | ||
| await nextTick(); | ||
| expect(wrapper.text()).toContain('Expires in 17 days'); | ||
|
|
||
| server.state = 'ENOCONN'; | ||
| await nextTick(); | ||
| expect(wrapper.text()).toContain('Expires in 17 days'); | ||
|
|
||
| server.state = 'EEXPIRED'; | ||
| server.expireTime = Date.now() - 2 * 86400000; | ||
| await nextTick(); | ||
| expect(wrapper.text()).toContain('Expired 2 days'); | ||
| }); | ||
|
|
||
| it('keeps compact expiry to its largest unit while preserving the full expiry display', () => { | ||
| const server = useServerStore(); | ||
| server.state = 'TRIAL'; | ||
| server.expireTime = Date.now() + 14 * 86400000 + 2 * 3600000 + 3 * 60000; | ||
| wrapper = mount(UptimeExpire, { | ||
| props: { shortText: true }, | ||
| global: { plugins: [createTestI18n()] }, | ||
| }); | ||
| expect(wrapper.text()).toBe('Expires in 14 days'); | ||
| wrapper.unmount(); | ||
| wrapper = mount(UptimeExpire, { global: { plugins: [createTestI18n()] } }); | ||
| expect(wrapper.text()).toContain('14 days 2 hours 3 minutes'); | ||
| }); | ||
| }); | ||
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.
This Vue component test initializes a plain
createPinia()while replacing the server store with a module mock. Component tests in this repository are required to usecreateTestingPinia()for mocked stores; bypassing that harness can make action stubbing and initialization differ from the rest of the component suite. ConfigureinitialStateandstubActionsoncreateTestingPinia()instead.AGENTS.md reference: AGENTS.md:L138-L138
Useful? React with 👍 / 👎.