opsdash-app/opsdash/test/useVersionOverlay.test.ts
blade34242 d7efcba67c
All checks were successful
Nextcloud Server Tests / version-consistency (push) Successful in 32s
Nextcloud Server Tests / matrix-config (push) Successful in 26s
Nextcloud Server Tests / Nextcloud stable30 / PHP 8.2 (stable30, 8.2) (push) Successful in 4m44s
Nextcloud Server Tests / Nextcloud stable31 / PHP 8.2 (stable31, 8.2) (push) Successful in 4m41s
Nextcloud Server Tests / Nextcloud stable31 / PHP 8.3 (stable31, 8.3) (push) Successful in 4m29s
Nextcloud Server Tests / Nextcloud stable32 / PHP 8.2 (stable32, 8.2) (push) Successful in 4m34s
Nextcloud Server Tests / Nextcloud stable32 / PHP 8.3 (stable32, 8.3) (push) Successful in 4m43s
Nextcloud Server Tests / Nextcloud stable33 / PHP 8.2 (stable33, 8.2) (push) Successful in 4m51s
Nextcloud Server Tests / Nextcloud stable33 / PHP 8.3 (stable33, 8.3) (push) Successful in 4m52s
Build And Publish Appstore Package / build_and_publish (push) Successful in 3m3s
fix: stabilize release notes and target progress
2026-04-28 11:51:14 +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.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('')
})
})