CI (SIAX Cloud) / integration (push) Has been skipped
masterplan-lock / check (push) Successful in 4s
CI (SIAX Cloud) / security (push) Successful in 15s
masterplan-lock / check (pull_request) Successful in 12s
Security Scan (SIAX Cloud) / security (pull_request) Successful in 14s
CI (SIAX Cloud) / security (pull_request) Successful in 14s
CI (SIAX Cloud) / quality (pull_request) Successful in 32s
Security Scan (SIAX Cloud) / security (push) Successful in 1m21s
CI (SIAX Cloud) / quality (push) Successful in 1m34s
CI (SIAX Cloud) / integration (pull_request) Successful in 1m46s
102 lines
4.0 KiB
TypeScript
102 lines
4.0 KiB
TypeScript
/**
|
|
* `exit-manifest.test.ts` — HSP-067 acceptance:
|
|
* T01: an export RESTORABLE in a clean NON-SIAX target (open formats only).
|
|
* T02: sources/notice-krav FOLLOW the allowed artifacts.
|
|
* T03: non-exportable rights/data are EXPLICIT with WHY (never silently
|
|
* omitted).
|
|
* Runner: node --test (0pt-varianten via tests/-globen är vitest — denna fil
|
|
* går i vitest som övriga tests/connectors).
|
|
*/
|
|
import { describe, expect, it } from 'vitest';
|
|
|
|
import {
|
|
buildExitManifest,
|
|
isPortableToNonSiaxTarget,
|
|
applicableNoticeRequirements,
|
|
type ExitManifest,
|
|
} from '../../src/connectors/exit-manifest';
|
|
|
|
function aManifest(overrides: Partial<ExitManifest> = {}): ExitManifest {
|
|
return {
|
|
manifestId: 'exit_1',
|
|
tenantId: 't_exit',
|
|
artifacts: [
|
|
{ artifactId: 'art_1', format: 'json', contentHash: 'sha256:aa', recordCount: 100 },
|
|
{ artifactId: 'art_2', format: 'csv', contentHash: 'sha256:bb', recordCount: 200 },
|
|
],
|
|
noticeRequirements: [{ artifactId: 'art_1', requirement: 'CC-BY attribution required' }],
|
|
nonExportable: [],
|
|
createdAt: '2026-09-22T00:00:00Z',
|
|
...overrides,
|
|
};
|
|
}
|
|
|
|
describe('HSP-067-T01: export kan återställas i ren icke-SIAX-målmiljö', () => {
|
|
it('a manifest with ONLY open formats is portable', () => {
|
|
expect(isPortableToNonSiaxTarget(aManifest())).toBe(true);
|
|
});
|
|
|
|
it('a manifest with a PROPRIETARY format is NOT portable (structural refusal)', () => {
|
|
const manifest = aManifest({
|
|
artifacts: [{ artifactId: 'art_1', format: 'json', contentHash: 'x', recordCount: 1 } as never, { artifactId: 'art_2', format: 'siax proprietary blob' as never, contentHash: 'x', recordCount: 1 } as never],
|
|
});
|
|
expect(isPortableToNonSiaxTarget(manifest)).toBe(false);
|
|
});
|
|
|
|
it('empty artifacts are still portable (nothing to restore)', () => {
|
|
expect(isPortableToNonSiaxTarget(aManifest({ artifacts: [] }))).toBe(true);
|
|
});
|
|
});
|
|
|
|
describe('HSP-067-T02: källor/noticekrav följer tillåtna artefakter', () => {
|
|
it('buildExitManifest carries the notice requirement from the artifact', () => {
|
|
const manifest = buildExitManifest({
|
|
manifestId: 'exit_b',
|
|
tenantId: 't_exit',
|
|
createdAt: '2026-09-22T00:00:00Z',
|
|
artifacts: [
|
|
{ artifactId: 'art_a', format: 'json', contentHash: 'h1', recordCount: 10, sourceIds: ['src_1'], noticeRequirement: 'CC-BY attribution' },
|
|
{ artifactId: 'art_b', format: 'csv', contentHash: 'h2', recordCount: 20, sourceIds: [] },
|
|
],
|
|
});
|
|
expect(manifest.noticeRequirements).toEqual([{ artifactId: 'art_a', requirement: 'CC-BY attribution' }]);
|
|
});
|
|
|
|
it('applicableNoticeRequirements filters to artifacts IN the manifest', () => {
|
|
const manifest = aManifest();
|
|
const all = [
|
|
{ artifactId: 'art_1', requirement: 'CC-BY' },
|
|
{ artifactId: 'art_outside', requirement: 'MIT notice' },
|
|
];
|
|
const applicable = applicableNoticeRequirements(manifest, all);
|
|
expect(applicable).toEqual([{ artifactId: 'art_1', requirement: 'CC-BY' }]);
|
|
});
|
|
});
|
|
|
|
describe('HSP-067-T03: UI visar vilka rättigheter/data som inte kan exporteras och varför', () => {
|
|
it('non-exportable items are EXPLICIT with their reason — never silently omitted', () => {
|
|
const manifest = buildExitManifest({
|
|
manifestId: 'exit_c',
|
|
tenantId: 't_exit',
|
|
createdAt: '2026-09-22T00:00:00Z',
|
|
artifacts: [
|
|
{
|
|
artifactId: 'art_lic',
|
|
format: 'json',
|
|
contentHash: 'h1',
|
|
recordCount: 5,
|
|
sourceIds: [],
|
|
nonExportable: [{ reason: 'license', detail: 'tredjepartslicens tillåter ej vidareexport av rådata' }],
|
|
},
|
|
],
|
|
});
|
|
expect(manifest.nonExportable).toHaveLength(1);
|
|
expect(manifest.nonExportable[0]!.reason).toBe('license');
|
|
expect(manifest.nonExportable[0]!.detail).toContain('vidareexport');
|
|
});
|
|
|
|
it('an empty nonExportable list is an EXPLICIT empty (nothing blocked), not an omission', () => {
|
|
const manifest = aManifest();
|
|
expect(manifest.nonExportable).toEqual([]);
|
|
});
|
|
}); |