import assert from 'node:assert/strict' import test from 'node:test' import { asciiHostFileName, buildHostFilePreviewPath, openDocumentFileType } from './host-file-preview-nav.js' test('ascii host file name keeps extension only', () => { assert.equal(asciiHostFileName('26-10生产任务.xlsx'), 'file.xlsx') assert.equal(asciiHostFileName('report.PDF'), 'file.pdf') assert.equal(asciiHostFileName('plain'), 'file.bin') }) test('openDocument file types cover office docs', () => { assert.equal(openDocumentFileType('a.xlsx'), 'xlsx') assert.equal(openDocumentFileType('a.XLS'), 'xls') assert.equal(openDocumentFileType('a.docx'), 'docx') assert.equal(openDocumentFileType('a.zip'), '') }) test('host file preview path is short and points at file-preview page', () => { const built = buildHostFilePreviewPath({ fileUrl: 'oa-approval/202610/abc.xlsx', fileName: '26-10生产任务.xlsx' }) assert.ok(built.path.startsWith('/pages/oa/file-preview/index?')) assert.ok(built.path.includes('fileUrl=')) assert.ok(built.path.includes('&f=')) assert.ok(built.path.includes('&n=file.xlsx')) assert.equal(built.fileType, 'xlsx') assert.ok(!built.path.includes('%E7%94%9F')) assert.ok(built.queryLen < 400) assert.ok(built.path.length < 500) })