import { describe, expect, it } from 'vitest';
import {
ARTIFACT_DEPLOY_TOOL,
artifactFileInputsFromArguments,
parseArtifactFileBundle,
prepareArtifactDeployment,
prepareHtmlArtifact,
} from './agent-tools';
describe('prepareHtmlArtifact', () => {
it('injects a deny-by-default CSP while preserving source for the code view', () => {
const source = '
x';
const artifact = prepareHtmlArtifact(source, 'Demo', 'artifact-1');
expect(artifact.source).toBe(source);
expect(artifact.sandboxedSource).toMatch(/^ {
expect(() => prepareHtmlArtifact('x'.repeat(256 * 1024 + 1), 'large', 'artifact-2')).toThrow(
'exceeds 256 KiB',
);
});
it('rejects direct document navigation while keeping ordinary inline scripts available', () => {
expect(() => prepareHtmlArtifact(''))
.toThrow('cannot navigate');
expect(() => prepareHtmlArtifact(''))
.toThrow('navigation, or refresh');
expect(() => prepareHtmlArtifact(''))
.not.toThrow();
});
});
describe('prepareArtifactDeployment', () => {
it('uses flat file pairs so Qwen tool parsing never nests source in array