mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-08-08 08:04:32 +00:00
The update Download button opened the GitHub release page; it now downloads the right artifact for the running platform directly: arm64 or x64 dmg on macOS (preload newly exposes process.arch), the Setup exe on Windows. Linux keeps the release page since it ships three formats and the user picks. Unknown platforms and preloads without arch fall back to the page. URL mapping is unit-tested per platform. Co-authored-by: reviewer <review@local>
44 lines
1.8 KiB
TypeScript
44 lines
1.8 KiB
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
|
|
vi.mock('../lib/ipc', () => ({
|
|
codeburn: { platform: 'linux', arch: 'x64' },
|
|
}))
|
|
|
|
import { directDownloadUrl, releasePageUrl, updateDownloadUrl } from './useUpdateStatus'
|
|
|
|
const TAG = 'desktop-v0.9.19'
|
|
const BASE = 'https://github.com/getagentseal/codeburn/releases/download/desktop-v0.9.19'
|
|
|
|
describe('directDownloadUrl', () => {
|
|
it('maps macOS arm64 to the arm64 dmg', () => {
|
|
expect(directDownloadUrl(TAG, 'darwin', 'arm64')).toBe(`${BASE}/CodeBurn-0.9.19-arm64.dmg`)
|
|
})
|
|
|
|
it('maps macOS x64 to the plain dmg', () => {
|
|
expect(directDownloadUrl(TAG, 'darwin', 'x64')).toBe(`${BASE}/CodeBurn-0.9.19.dmg`)
|
|
})
|
|
|
|
it('maps Windows to the Setup exe regardless of arch', () => {
|
|
expect(directDownloadUrl(TAG, 'win32', 'x64')).toBe(`${BASE}/CodeBurn-Setup-0.9.19.exe`)
|
|
expect(directDownloadUrl(TAG, 'win32', undefined)).toBe(`${BASE}/CodeBurn-Setup-0.9.19.exe`)
|
|
})
|
|
|
|
it('returns null for Linux (three formats, the user picks on the page)', () => {
|
|
expect(directDownloadUrl(TAG, 'linux', 'x64')).toBeNull()
|
|
})
|
|
|
|
it('returns null for unknown platforms, missing mac arch, and foreign tags', () => {
|
|
expect(directDownloadUrl(TAG, 'freebsd', 'x64')).toBeNull()
|
|
expect(directDownloadUrl(TAG, 'darwin', undefined)).toBeNull()
|
|
expect(directDownloadUrl('mac-v0.9.19', 'darwin', 'arm64')).toBeNull()
|
|
})
|
|
})
|
|
|
|
describe('updateDownloadUrl fallback', () => {
|
|
it('falls back to the release page when no direct asset fits', () => {
|
|
// The mocked bridge reports linux, where no single asset fits, so the
|
|
// click target is the release page.
|
|
expect(releasePageUrl(TAG)).toBe('https://github.com/getagentseal/codeburn/releases/tag/desktop-v0.9.19')
|
|
expect(updateDownloadUrl(TAG)).toBe(releasePageUrl(TAG))
|
|
})
|
|
})
|