opsdash-app/opsdash/test/useVersionOverlay.test.ts
blade34242 2a27a1120b
All checks were successful
Nextcloud Server Tests / version-consistency (push) Successful in 36s
Nextcloud Server Tests / matrix-config (push) Successful in 28s
Nextcloud Server Tests / Nextcloud stable31 / PHP 8.2 (stable31, 8.2) (push) Successful in 16m50s
Nextcloud Server Tests / Nextcloud stable31 / PHP 8.3 (stable31, 8.3) (push) Successful in 16m24s
Nextcloud Server Tests / Nextcloud stable32 / PHP 8.2 (stable32, 8.2) (push) Successful in 16m43s
Nextcloud Server Tests / Nextcloud stable32 / PHP 8.3 (stable32, 8.3) (push) Successful in 16m59s
Nextcloud Server Tests / Nextcloud stable33 / PHP 8.2 (stable33, 8.2) (push) Successful in 17m14s
Nextcloud Server Tests / Nextcloud stable33 / PHP 8.3 (stable33, 8.3) (push) Successful in 17m32s
Nextcloud Server Tests / Nextcloud stable34 / PHP 8.2 (stable34, 8.2) (push) Successful in 17m24s
Nextcloud Server Tests / Nextcloud stable34 / PHP 8.3 (stable34, 8.3) (push) Successful in 16m26s
Prepare 0.8.3 time summary release
2026-07-11 16:37:30 +07:00

94 lines
3 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.3', '0.8.2', '0.8.1', '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('')
})
})