import { computed, handler, pattern } from "commonfabric"; import { BatchPhotoUploadJobExample, CalendarAvailabilityPolicyExample, DocumentExportJobExample, SongIdentificationRecordingExample, } from "./process-examples.tsx"; type SongSuite = ReturnType; type PolicySuite = ReturnType; type JobSuite = ReturnType; type ExportSuite = ReturnType; const runSong = handler((_, { suite }) => { suite.triggerDecoy.send(); suite.recordSongId?.send(); }); const runPolicy = handler((_, { suite }) => { suite.triggerDecoy.send(); suite.saveSharePolicy?.send(); }); const runJob = handler((_, { suite }) => { suite.triggerDecoy.send(); suite.startJob?.send(); suite.cancelJob?.send(); }); const runExportJob = handler((_, { suite }) => { suite.triggerDecoy.send(); suite.startJob?.send(); }); export default pattern(() => { const song = SongIdentificationRecordingExample({}); const policy = CalendarAvailabilityPolicyExample({}); const photoJob = BatchPhotoUploadJobExample({}); const exportJob = DocumentExportJobExample({}); const assert_song_id_only = computed(() => song.decoyStatus === "Host raw-audio shortcut did not authorize recording; only song ID can be written." && song.identifiedSongId!.includes("Mock song id") ); const assert_policy_saved = computed(() => policy.decoyStatus === "Host full-calendar shortcut did not save policy; trusted surface scopes the contribution." && policy.savedSharePolicy!.includes("free/busy windows only") ); const assert_photo_job_visible_and_cancelable = computed(() => photoJob.decoyStatus === "Host all-photo shortcut did not authorize the job; the trusted job stays visible and cancelable." && photoJob.jobStatus === "Cancelled" && photoJob.jobAuthorization!.includes("Batch photo upload") && photoJob.jobCancellation!.includes("Batch photo upload") ); const assert_document_export_authorized = computed(() => exportJob.decoyStatus === "Host one-click export did not authorize the job; the trusted job surface controls export." && exportJob.jobStatus === "Running" && exportJob.jobAuthorization!.includes("Document export") ); return { tests: [ { action: runSong({ suite: song }) }, { assertion: assert_song_id_only }, { action: runPolicy({ suite: policy }) }, { assertion: assert_policy_saved }, { action: runJob({ suite: photoJob }) }, { assertion: assert_photo_job_visible_and_cancelable }, { action: runExportJob({ suite: exportJob }) }, { assertion: assert_document_export_authorized }, ], song, policy, photoJob, exportJob, }; });