opsdash-app/opsdash/test/useVersionOverlay.test.ts
blade34242 381079731e
Some checks failed
Nextcloud Server Tests / version-consistency (push) Successful in 38s
Nextcloud Server Tests / matrix-config (push) Successful in 35s
Nextcloud Server Tests / Nextcloud stable30 / PHP 8.2 (stable30, 8.2) (push) Failing after 6m52s
Nextcloud Server Tests / Nextcloud stable31 / PHP 8.2 (stable31, 8.2) (push) Failing after 6m50s
Nextcloud Server Tests / Nextcloud stable31 / PHP 8.3 (stable31, 8.3) (push) Failing after 7m58s
Nextcloud Server Tests / Nextcloud stable32 / PHP 8.2 (stable32, 8.2) (push) Failing after 7m28s
Nextcloud Server Tests / Nextcloud stable32 / PHP 8.3 (stable32, 8.3) (push) Failing after 7m27s
Nextcloud Server Tests / Nextcloud stable33 / PHP 8.2 (stable33, 8.2) (push) Has been cancelled
Nextcloud Server Tests / Nextcloud stable33 / PHP 8.3 (stable33, 8.3) (push) Has been cancelled
release: add 0.8.0 in-app release notes with screenshots and reset-layout action
- 0.8.0 entry: edit bar two-row layout, toolbar groups, shared color picker
- 3 screenshots composited into one 1200px banner (sidebar + browse + edit bar)
- New action type 'reload' in ReleaseNotesAction — overlay emits 'action' event
- App.vue handles 'reload' via applyDashboardPreset(dashboardMode) which replaces
  the active tab widgets with the server-side default preset for the user's profile
  and queues a save. performLoad() is intentionally NOT called — calling it would
  race the debounced save and overwrite the local reset with stale server data
- Reset-layout block rendered below the image inside the content area with
  explanation text; footer stays clean with only 'Back to dashboard'
2026-05-06 14:58:47 +07:00

94 lines
2.9 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest'
import { computed, nextTick, ref } from 'vue'
import { useVersionOverlay } from '../composables/useVersionOverlay'
import type { OnboardingState } from '../composables/useDashboard'
describe('useVersionOverlay', () => {
it('opens the current release automatically when it has not been seen', async () => {
const onboardingState = ref<OnboardingState | null>({
completed: true,
version: 1,
strategy: 'total_only',
completed_at: '2026-04-01T00:00:00Z',
releaseNotesSeenVersion: '0.7.4',
})
const overlay = useVersionOverlay({
appVersion: ref('0.7.5'),
onboardingState,
hasInitialLoad: ref(true),
isBlocked: computed(() => false),
route: vi.fn().mockReturnValue('/persist'),
postJson: vi.fn().mockResolvedValue({}),
notifyError: vi.fn(),
})
await nextTick()
expect(overlay.isOpen.value).toBe(true)
expect(overlay.activeEntry.value?.version).toBe('0.7.5')
expect(overlay.entries.value.map((entry) => entry.version)).toEqual(['0.8.0', '0.7.6', '0.7.5', '0.7.4'])
})
it('marks the current version as seen when the current release closes', async () => {
const onboardingState = ref<OnboardingState | null>({
completed: true,
version: 1,
strategy: 'total_only',
completed_at: '2026-04-01T00:00:00Z',
releaseNotesSeenVersion: '0.7.4',
})
const route = vi.fn().mockReturnValue('/persist')
const postJson = vi.fn().mockResolvedValue({})
const overlay = useVersionOverlay({
appVersion: ref('0.7.5'),
onboardingState,
hasInitialLoad: ref(true),
isBlocked: computed(() => false),
route,
postJson,
notifyError: vi.fn(),
})
await nextTick()
await overlay.closeOverlay()
expect(route).toHaveBeenCalledWith('persist')
expect(postJson).toHaveBeenCalledWith('/persist', {
onboarding: expect.objectContaining({
releaseNotesSeenVersion: '0.7.5',
}),
})
expect(onboardingState.value).toMatchObject({
releaseNotesSeenVersion: '0.7.5',
})
expect(overlay.isOpen.value).toBe(false)
})
it('does not mark the current version as seen when browsing an older entry', async () => {
const onboardingState = ref<OnboardingState | null>({
completed: true,
version: 1,
strategy: 'total_only',
completed_at: '2026-04-01T00:00:00Z',
releaseNotesSeenVersion: '',
})
const postJson = vi.fn().mockResolvedValue({})
const overlay = useVersionOverlay({
appVersion: ref('0.7.5'),
onboardingState,
hasInitialLoad: ref(true),
isBlocked: computed(() => false),
route: vi.fn().mockReturnValue('/persist'),
postJson,
notifyError: vi.fn(),
})
await nextTick()
overlay.openVersion('0.7.4')
await overlay.closeOverlay()
expect(postJson).not.toHaveBeenCalled()
expect(onboardingState.value?.releaseNotesSeenVersion).toBe('')
})
})