edit-source.test.ts (1461B)
1 import { expect, it } from 'vitest'; 2 import { render } from 'svelte/server'; 3 import ConflictNotice from '../../src/lib/components/ConflictNotice.svelte'; 4 import { 5 openOwnedEditSource, 6 ownedEditSourceSnapshot, 7 authorizeOwnedEditSource, 8 closeOwnedEditSource, 9 type OwnedEditSource 10 } from '../../src/lib/publishing/edit-source.ts'; 11 import type { PublicPublicationRepository } from '../../src/lib/persistence/public-publications.ts'; 12 import type { IdentityViewContext } from '../../src/lib/runtime/view-context.ts'; 13 it('HCP118 copied repositories and unmounted identities cannot adopt a remote source', async () => { 14 expect( 15 await openOwnedEditSource( 16 {} as PublicPublicationRepository, 17 {} as IdentityViewContext, 18 'untrusted' 19 ) 20 ).toBeUndefined(); 21 }); 22 it('HCP118 copied ready snapshots cannot authorize editing or supply current/proposed authority', () => { 23 const copied = { 24 status: 'ready', 25 owner: '0'.repeat(64) 26 } as unknown as OwnedEditSource; 27 expect(ownedEditSourceSnapshot(copied)).toBeUndefined(); 28 expect(authorizeOwnedEditSource(copied)).toBeUndefined(); 29 expect( 30 render(ConflictNotice, { props: { source: copied } }).body 31 ).not.toContain('This listing changed elsewhere'); 32 }); 33 it('HCP118 closing copied or absent custody never manufactures readiness', () => { 34 const copied = {} as OwnedEditSource; 35 closeOwnedEditSource(copied); 36 expect(authorizeOwnedEditSource(copied)).toBeUndefined(); 37 });