import { describe, expect, it } from 'vitest' import { versionFileName, versionDownloadPath, wordOpenUrl } from '../app/utils/versionDownload' describe('version downloads', () => { it('names v0 and later artifacts', () => { expect(versionFileName('คำร้อง.DOCX', 0)).toBe('คำร้อง_v0.docx') expect(versionFileName('คำร้อง.docx', 1, 'pdf')).toBe('คำร้อง_v1.pdf') }) it('requests the authenticated download-link format', () => { expect(versionDownloadPath('d', 'v')).toBe('/api/documents/d/versions/v/download-link') expect(versionDownloadPath('d', 'v', 'pdf')).toBe('/api/documents/d/versions/v/download-link?format=pdf') }) it('preserves the signed URL exactly inside the Office URI', () => { const url = 'https://files.example/d.docx?X-Amz-Signature=abc&response-content-disposition=attachment%3B%20filename%2A%3DUTF-8%27%27' expect(wordOpenUrl(url)).toBe(`ms-word:ofe|u|${url}`) }) })