app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

resume-preparation.test.ts (1632B)


      1 import { describe, it, expect } from 'vitest';
      2 import {
      3   captureResumePreparation,
      4   resumeEncryptedPreparation,
      5   resumePreparationSnapshot,
      6   resumeRecoveredRumor,
      7   type ResumePreparation
      8 } from '../../src/lib/messaging/resume-preparation.ts';
      9 import type { PrivateStorageRepository } from '../../src/lib/persistence/private-storage.ts';
     10 import type { IdentitySession } from '../../src/lib/runtime/identity-session.ts';
     11 describe('explicit encrypted recovery cannot manufacture a new message', () => {
     12   it('SSR and forged preparation are inert', async () => {
     13     expect(
     14       captureResumePreparation(
     15         {} as PrivateStorageRepository,
     16         {} as IdentitySession,
     17         '12345678-1234-4234-8234-123456789abc',
     18         'reviewed_private_resume'
     19       )
     20     ).toBeUndefined();
     21     expect(
     22       await resumeEncryptedPreparation(
     23         {} as ResumePreparation,
     24         undefined,
     25         'reviewed_private_resume'
     26       )
     27     ).toEqual({ status: 'invalid' });
     28   });
     29   it('detached tokens expose neither recovered text nor acknowledgement', () => {
     30     expect(resumePreparationSnapshot({} as ResumePreparation)).toBeUndefined();
     31     expect(resumeRecoveredRumor({} as ResumePreparation)).toBeUndefined();
     32   });
     33   it('unreviewed input cannot coerce itself into Resume', async () => {
     34     let calls = 0;
     35     const review = {
     36       toString() {
     37         calls++;
     38         return 'reviewed_private_resume';
     39       }
     40     };
     41     expect(
     42       await resumeEncryptedPreparation(
     43         {} as ResumePreparation,
     44         undefined,
     45         review
     46       )
     47     ).toEqual({ status: 'invalid' });
     48     expect(calls).toBe(0);
     49   });
     50 });