mirror of
https://github.com/nexu-io/open-design.git
synced 2026-07-07 06:34:10 +08:00
Resolves short pointer-only HTML artifacts to the existing project HTML target before persisting preview artifacts, with helper and ProjectView regression coverage for #536. Validation: CI and nix-check were green on PR head 8c7ee5f38d.
63 lines
2.1 KiB
TypeScript
63 lines
2.1 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
|
|
import { resolveHtmlPointerArtifactTarget } from '../../src/artifacts/pointer';
|
|
|
|
describe('resolveHtmlPointerArtifactTarget', () => {
|
|
it('resolves a short Chinese pointer artifact to an existing HTML file', () => {
|
|
const result = resolveHtmlPointerArtifactTarget({
|
|
content: '见 worker-edition-v2.html',
|
|
candidateFileName: 'worker-edition-v2-3.html',
|
|
projectFiles: [
|
|
{ name: 'worker-edition-v2.html' },
|
|
{ name: 'worker-edition-v2-3.html' },
|
|
],
|
|
});
|
|
|
|
expect(result).toBe('worker-edition-v2.html');
|
|
});
|
|
|
|
it('resolves a minimal HTML wrapper whose visible body only points elsewhere', () => {
|
|
const result = resolveHtmlPointerArtifactTarget({
|
|
content:
|
|
'<!doctype html><html><body>见 <a href="worker-edition-v2.html">worker-edition-v2.html</a></body></html>',
|
|
candidateFileName: 'worker-edition-v2-3.html',
|
|
projectFiles: [{ name: 'worker-edition-v2.html' }],
|
|
});
|
|
|
|
expect(result).toBe('worker-edition-v2.html');
|
|
});
|
|
|
|
it('returns null when the pointer target is not an existing project HTML file', () => {
|
|
const result = resolveHtmlPointerArtifactTarget({
|
|
content: '见 worker-edition-v2.html',
|
|
candidateFileName: 'worker-edition-v2-3.html',
|
|
projectFiles: [{ name: 'summary.html' }],
|
|
});
|
|
|
|
expect(result).toBeNull();
|
|
});
|
|
|
|
it('returns null when a basename pointer would match multiple nested files', () => {
|
|
const result = resolveHtmlPointerArtifactTarget({
|
|
content: 'see index.html',
|
|
candidateFileName: 'index-2.html',
|
|
projectFiles: [
|
|
{ name: 'desktop/index.html' },
|
|
{ name: 'mobile/index.html' },
|
|
],
|
|
});
|
|
|
|
expect(result).toBeNull();
|
|
});
|
|
|
|
it('does not treat real prose that mentions an HTML file as a pointer artifact', () => {
|
|
const result = resolveHtmlPointerArtifactTarget({
|
|
content: 'I updated worker-edition-v2.html with the final responsive layout and accessibility fixes.',
|
|
candidateFileName: 'worker-edition-v2-3.html',
|
|
projectFiles: [{ name: 'worker-edition-v2.html' }],
|
|
});
|
|
|
|
expect(result).toBeNull();
|
|
});
|
|
});
|