@taskforcehq/taskforce 0.3.311 → 0.3.313
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -2
- package/dist/TaskforceCore.js +1 -1
- package/dist/components/features/InitiativesModule.js +1 -1
- package/dist/components/features/TaskSettings.js +1 -1
- package/dist/components/views/StandaloneLayout.js +3 -6
- package/dist/components/views/standalone/modals/AccountHubModal.d.ts +1 -2
- package/dist/components/views/standalone/modals/AccountHubModal.js +2 -3
- package/dist/components/views/standalone/modals/HelpModal.js +15 -2
- package/dist/hooks/useFilterSort.js +1 -1
- package/dist/hooks/useTaskforce.js +2 -2
- package/dist/hooks/workspace/useTaskforceWorkspaceBootstrap.js +5 -2
- package/dist/ui/assets/{AgentsModule-D8u9P5dZ.js → AgentsModule-BULqIo8e.js} +1 -1
- package/dist/ui/assets/{AnnotatedAttachmentWorkspace-CsUauFA2.js → AnnotatedAttachmentWorkspace-DHr4rHK9.js} +1 -1
- package/dist/ui/assets/{ContextAttachmentManager-DbQvDHFz.js → ContextAttachmentManager-DoMe2OpY.js} +1 -1
- package/dist/ui/assets/{DocumentWorkspace-BmTkN1A8.js → DocumentWorkspace-DumBWhvb.js} +1 -1
- package/dist/ui/assets/{EntityActivityTimeline-BXHTM-Nh.js → EntityActivityTimeline-sHk8Nzbq.js} +1 -1
- package/dist/ui/assets/{InitiativesModule-D33RyXx0.js → InitiativesModule-3X9UNzHh.js} +1 -1
- package/dist/ui/assets/{PlansPage-D0RXlT9_.js → PlansPage-C3A3EYaV.js} +1 -1
- package/dist/ui/assets/{TaskContextUpload-Vsg67lpR.js → TaskContextUpload-C8G7pWkX.js} +1 -1
- package/dist/ui/assets/{TaskSettings-DshLw7_d.js → TaskSettings-DM1o9Wla.js} +2 -2
- package/dist/ui/assets/{WorkflowsModule-CLM-1BnF.js → WorkflowsModule-CW0crzvD.js} +1 -1
- package/dist/ui/assets/documentReferences-BZB3nMRb.js +1 -0
- package/dist/ui/assets/index-BWFQ9mGn.js +5 -0
- package/dist/ui/assets/{index-DOR9PRqt.css → index-DcK_8tuE.css} +1 -1
- package/dist/ui/index.html +2 -2
- package/package.json +12 -4
- package/scripts/postinstall.js +4 -3
- package/dist/TaskforceCore.CategoryFallback.test.d.ts +0 -1
- package/dist/TaskforceCore.CategoryFallback.test.js +0 -101
- package/dist/TaskforceCore.filter-persistence.test.d.ts +0 -1
- package/dist/TaskforceCore.filter-persistence.test.js +0 -402
- package/dist/TaskforceCore.routing.test.d.ts +0 -1
- package/dist/TaskforceCore.routing.test.js +0 -311
- package/dist/TaskforceCore.test.d.ts +0 -1
- package/dist/TaskforceCore.test.js +0 -7910
- package/dist/TaskforceWidget.test.d.ts +0 -1
- package/dist/TaskforceWidget.test.js +0 -92
- package/dist/UnsavedChangesRelaxed.test.d.ts +0 -1
- package/dist/UnsavedChangesRelaxed.test.js +0 -16
- package/dist/__tests__/localizationCatalogs.test.d.ts +0 -1
- package/dist/__tests__/localizationCatalogs.test.js +0 -54
- package/dist/__tests__/workflowSimulation.test.d.ts +0 -1
- package/dist/__tests__/workflowSimulation.test.js +0 -113
- package/dist/annotatedAttachments/AnnotatedAttachmentSessionStore.test.d.ts +0 -1
- package/dist/annotatedAttachments/AnnotatedAttachmentSessionStore.test.js +0 -278
- package/dist/annotatedAttachments/payload.test.d.ts +0 -1
- package/dist/annotatedAttachments/payload.test.js +0 -67
- package/dist/compat/workspaceSyncCompat.test.d.ts +0 -1
- package/dist/compat/workspaceSyncCompat.test.js +0 -124
- package/dist/components/features/AgentsModule.test.d.ts +0 -1
- package/dist/components/features/AgentsModule.test.js +0 -601
- package/dist/components/features/AnnotatedAttachmentWorkspace.test.d.ts +0 -1
- package/dist/components/features/AnnotatedAttachmentWorkspace.test.js +0 -2883
- package/dist/components/features/DocumentWorkspace.test.d.ts +0 -1
- package/dist/components/features/DocumentWorkspace.test.js +0 -1439
- package/dist/components/features/TaskSettings.test.d.ts +0 -1
- package/dist/components/features/TaskSettings.test.js +0 -1674
- package/dist/components/features/settings/TaxonomyLibraryManager.test.d.ts +0 -1
- package/dist/components/features/settings/TaxonomyLibraryManager.test.js +0 -141
- package/dist/components/task/TaskActionHeader.test.d.ts +0 -1
- package/dist/components/task/TaskActionHeader.test.js +0 -91
- package/dist/components/task/TaskCard.test.d.ts +0 -1
- package/dist/components/task/TaskCard.test.js +0 -513
- package/dist/components/task/TaskContextUpload.test.d.ts +0 -1
- package/dist/components/task/TaskContextUpload.test.js +0 -506
- package/dist/components/task/TaskForm.test.d.ts +0 -1
- package/dist/components/task/TaskForm.test.js +0 -946
- package/dist/components/task/TaskKanban.empty-column-drop.test.d.ts +0 -1
- package/dist/components/task/TaskKanban.empty-column-drop.test.js +0 -66
- package/dist/components/task/TaskKanban.planning-drop.test.d.ts +0 -1
- package/dist/components/task/TaskKanban.planning-drop.test.js +0 -93
- package/dist/components/task/TaskKanban.test.d.ts +0 -1
- package/dist/components/task/TaskKanban.test.js +0 -99
- package/dist/components/task/TaskList.test.d.ts +0 -1
- package/dist/components/task/TaskList.test.js +0 -473
- package/dist/components/task/TaskStatusActions.test.d.ts +0 -1
- package/dist/components/task/TaskStatusActions.test.js +0 -54
- package/dist/components/task/taskKanbanDropRules.test.d.ts +0 -1
- package/dist/components/task/taskKanbanDropRules.test.js +0 -114
- package/dist/components/ui/LevelSelector.test.d.ts +0 -1
- package/dist/components/ui/LevelSelector.test.js +0 -55
- package/dist/components/ui/Markdown.test.d.ts +0 -1
- package/dist/components/ui/Markdown.test.js +0 -38
- package/dist/components/ui/MultiSelectFilter.test.d.ts +0 -1
- package/dist/components/ui/MultiSelectFilter.test.js +0 -74
- package/dist/components/ui/TaxonomyDropdown.test.d.ts +0 -1
- package/dist/components/ui/TaxonomyDropdown.test.js +0 -130
- package/dist/components/ui/TopNoticeLayer.test.d.ts +0 -1
- package/dist/components/ui/TopNoticeLayer.test.js +0 -25
- package/dist/components/views/AppShellHeader.test.d.ts +0 -1
- package/dist/components/views/AppShellHeader.test.js +0 -42
- package/dist/components/views/PlanComparisonPage.test.d.ts +0 -1
- package/dist/components/views/PlanComparisonPage.test.js +0 -758
- package/dist/components/views/PlansPage.test.d.ts +0 -1
- package/dist/components/views/PlansPage.test.js +0 -710
- package/dist/components/views/chrome/WorkspaceChromeSections.test.d.ts +0 -1
- package/dist/components/views/chrome/WorkspaceChromeSections.test.js +0 -54
- package/dist/components/views/chrome/workspaceChrome.test.d.ts +0 -1
- package/dist/components/views/chrome/workspaceChrome.test.js +0 -52
- package/dist/components/views/panels/DocumentFilterToolbar.test.d.ts +0 -1
- package/dist/components/views/panels/DocumentFilterToolbar.test.js +0 -19
- package/dist/components/views/panels/FilterToolbar.test.d.ts +0 -1
- package/dist/components/views/panels/FilterToolbar.test.js +0 -47
- package/dist/components/views/panels/PlanningDrawer.test.d.ts +0 -1
- package/dist/components/views/panels/PlanningDrawer.test.js +0 -529
- package/dist/components/views/planningScope.test.d.ts +0 -1
- package/dist/components/views/planningScope.test.js +0 -60
- package/dist/components/views/standalone/modals/AccountHubModal.test.d.ts +0 -1
- package/dist/components/views/standalone/modals/AccountHubModal.test.js +0 -72
- package/dist/components/views/standalone/modals/HelpModal.test.d.ts +0 -1
- package/dist/components/views/standalone/modals/HelpModal.test.js +0 -23
- package/dist/components/views/standalone/modals/SyncEnableWarningModal.test.d.ts +0 -1
- package/dist/components/views/standalone/modals/SyncEnableWarningModal.test.js +0 -24
- package/dist/components/views/teamManagementAccess.test.d.ts +0 -1
- package/dist/components/views/teamManagementAccess.test.js +0 -44
- package/dist/config/deployment.test.d.ts +0 -1
- package/dist/config/deployment.test.js +0 -90
- package/dist/config/envSchema.test.d.ts +0 -1
- package/dist/config/envSchema.test.js +0 -125
- package/dist/core/AiProfileService.test.d.ts +0 -1
- package/dist/core/AiProfileService.test.js +0 -184
- package/dist/core/AiProfiles.test.d.ts +0 -1
- package/dist/core/AiProfiles.test.js +0 -1873
- package/dist/core/AuthTokenService.test.d.ts +0 -1
- package/dist/core/AuthTokenService.test.js +0 -78
- package/dist/core/BulkUpdateFieldsPreview.test.d.ts +0 -1
- package/dist/core/BulkUpdateFieldsPreview.test.js +0 -62
- package/dist/core/CompletedAt.test.d.ts +0 -1
- package/dist/core/CompletedAt.test.js +0 -44
- package/dist/core/CreatedBy.test.d.ts +0 -1
- package/dist/core/CreatedBy.test.js +0 -188
- package/dist/core/DeletedTaskTrash.test.d.ts +0 -1
- package/dist/core/DeletedTaskTrash.test.js +0 -104
- package/dist/core/EntitlementsPolicy.test.d.ts +0 -1
- package/dist/core/EntitlementsPolicy.test.js +0 -280
- package/dist/core/GlobalSettingsService.test.d.ts +0 -1
- package/dist/core/GlobalSettingsService.test.js +0 -45
- package/dist/core/JsonBackupRuntime.test.d.ts +0 -1
- package/dist/core/JsonBackupRuntime.test.js +0 -155
- package/dist/core/PlanFeatureCatalog.test.d.ts +0 -1
- package/dist/core/PlanFeatureCatalog.test.js +0 -139
- package/dist/core/PlanVersionPolicy.test.d.ts +0 -1
- package/dist/core/PlanVersionPolicy.test.js +0 -236
- package/dist/core/PlanningEntities.test.d.ts +0 -1
- package/dist/core/PlanningEntities.test.js +0 -509
- package/dist/core/ScheduleFields.test.d.ts +0 -1
- package/dist/core/ScheduleFields.test.js +0 -193
- package/dist/core/SetupState.test.d.ts +0 -1
- package/dist/core/SetupState.test.js +0 -113
- package/dist/core/SignupMonetizationSettings.test.d.ts +0 -1
- package/dist/core/SignupMonetizationSettings.test.js +0 -515
- package/dist/core/Stats.test.d.ts +0 -1
- package/dist/core/Stats.test.js +0 -36
- package/dist/core/SystemAdmin.test.d.ts +0 -1
- package/dist/core/SystemAdmin.test.js +0 -1106
- package/dist/core/TaskActivitySync.test.d.ts +0 -1
- package/dist/core/TaskActivitySync.test.js +0 -90
- package/dist/core/TaskAttachmentsCanonical.test.d.ts +0 -1
- package/dist/core/TaskAttachmentsCanonical.test.js +0 -356
- package/dist/core/TaskAuditTimeline.test.d.ts +0 -1
- package/dist/core/TaskAuditTimeline.test.js +0 -319
- package/dist/core/TaskTaxonomyValidation.test.d.ts +0 -1
- package/dist/core/TaskTaxonomyValidation.test.js +0 -440
- package/dist/core/Taskforce.ids.test.d.ts +0 -1
- package/dist/core/Taskforce.ids.test.js +0 -611
- package/dist/core/Taskforce.listTasksSlim.test.d.ts +0 -1
- package/dist/core/Taskforce.listTasksSlim.test.js +0 -91
- package/dist/core/Taskforce.mcpAuth.test.d.ts +0 -1
- package/dist/core/Taskforce.mcpAuth.test.js +0 -450
- package/dist/core/Taskforce.realtimeMutation.test.d.ts +0 -1
- package/dist/core/Taskforce.realtimeMutation.test.js +0 -131
- package/dist/core/UserProfileAvatarDrafts.test.d.ts +0 -1
- package/dist/core/UserProfileAvatarDrafts.test.js +0 -138
- package/dist/core/WorkspaceDelete.test.d.ts +0 -1
- package/dist/core/WorkspaceDelete.test.js +0 -159
- package/dist/core/WorkspacePermissions.test.d.ts +0 -1
- package/dist/core/WorkspacePermissions.test.js +0 -270
- package/dist/core/WorkspacePlanMode.test.d.ts +0 -1
- package/dist/core/WorkspacePlanMode.test.js +0 -383
- package/dist/core/WorkspaceSyncSettings.test.d.ts +0 -1
- package/dist/core/WorkspaceSyncSettings.test.js +0 -65
- package/dist/core/__tests__/TaskAttachmentsCanonical.test.d.ts +0 -1
- package/dist/core/__tests__/TaskAttachmentsCanonical.test.js +0 -212
- package/dist/documentReviews/DocumentReviewSessionStore.test.d.ts +0 -1
- package/dist/documentReviews/DocumentReviewSessionStore.test.js +0 -127
- package/dist/hooks/authGuardPolicy.test.d.ts +0 -1
- package/dist/hooks/authGuardPolicy.test.js +0 -76
- package/dist/hooks/bootstrapTimeouts.test.d.ts +0 -1
- package/dist/hooks/bootstrapTimeouts.test.js +0 -12
- package/dist/hooks/sync/controlPlane.test.d.ts +0 -1
- package/dist/hooks/sync/controlPlane.test.js +0 -121
- package/dist/hooks/sync/lifecyclePolicy.test.d.ts +0 -1
- package/dist/hooks/sync/lifecyclePolicy.test.js +0 -124
- package/dist/hooks/sync/orchestratorShared.test.d.ts +0 -1
- package/dist/hooks/sync/orchestratorShared.test.js +0 -98
- package/dist/hooks/sync/pullLifecycle.test.d.ts +0 -1
- package/dist/hooks/sync/pullLifecycle.test.js +0 -80
- package/dist/hooks/sync/recovery.test.d.ts +0 -1
- package/dist/hooks/sync/recovery.test.js +0 -292
- package/dist/hooks/sync/transfers.test.d.ts +0 -1
- package/dist/hooks/sync/transfers.test.js +0 -928
- package/dist/hooks/sync/useRecentSyncEvents.test.d.ts +0 -1
- package/dist/hooks/sync/useRecentSyncEvents.test.js +0 -124
- package/dist/hooks/sync/useSyncStatusActions.test.d.ts +0 -1
- package/dist/hooks/sync/useSyncStatusActions.test.js +0 -133
- package/dist/hooks/sync/useSyncStatusControls.test.d.ts +0 -1
- package/dist/hooks/sync/useSyncStatusControls.test.js +0 -88
- package/dist/hooks/useFilterSort.test.d.ts +0 -1
- package/dist/hooks/useFilterSort.test.js +0 -419
- package/dist/hooks/useRealtimeSync.test.d.ts +0 -1
- package/dist/hooks/useRealtimeSync.test.js +0 -311
- package/dist/hooks/useSyncOrchestrator.aiProfiles.test.d.ts +0 -1
- package/dist/hooks/useSyncOrchestrator.aiProfiles.test.js +0 -54
- package/dist/hooks/useSyncOrchestrator.context-assets.test.d.ts +0 -1
- package/dist/hooks/useSyncOrchestrator.context-assets.test.js +0 -228
- package/dist/hooks/useSyncOrchestrator.retry-closure.test.d.ts +0 -1
- package/dist/hooks/useSyncOrchestrator.retry-closure.test.js +0 -2027
- package/dist/hooks/useTaskData.test.d.ts +0 -1
- package/dist/hooks/useTaskData.test.js +0 -291
- package/dist/hooks/useTaskMutations.test.d.ts +0 -1
- package/dist/hooks/useTaskMutations.test.js +0 -256
- package/dist/hooks/useTaskforce.contract.test.d.ts +0 -1
- package/dist/hooks/useTaskforce.contract.test.js +0 -7
- package/dist/hooks/useTaskforce.priority-filters.test.d.ts +0 -1
- package/dist/hooks/useTaskforce.priority-filters.test.js +0 -28
- package/dist/hooks/useTaskforce.runtime-routing.test.d.ts +0 -1
- package/dist/hooks/useTaskforce.runtime-routing.test.js +0 -246
- package/dist/hooks/useTaskforce.sync-behavior.test.d.ts +0 -1
- package/dist/hooks/useTaskforce.sync-behavior.test.js +0 -3644
- package/dist/hooks/useWorkspaceSyncController.test.d.ts +0 -1
- package/dist/hooks/useWorkspaceSyncController.test.js +0 -192
- package/dist/hooks/workspace/useTaskforceApiRouting.test.d.ts +0 -1
- package/dist/hooks/workspace/useTaskforceApiRouting.test.js +0 -77
- package/dist/hooks/workspace/workspaceLocalState.test.d.ts +0 -1
- package/dist/hooks/workspace/workspaceLocalState.test.js +0 -59
- package/dist/localization/localizationCatalogs.test.d.ts +0 -1
- package/dist/localization/localizationCatalogs.test.js +0 -37
- package/dist/mcp/aiProfileBootstrap.test.d.ts +0 -1
- package/dist/mcp/aiProfileBootstrap.test.js +0 -68
- package/dist/mcp/canonicalAssetHelpers.test.d.ts +0 -1
- package/dist/mcp/canonicalAssetHelpers.test.js +0 -67
- package/dist/mcp/clientIntegrations.test.d.ts +0 -1
- package/dist/mcp/clientIntegrations.test.js +0 -219
- package/dist/mcp/optionResolution.test.d.ts +0 -1
- package/dist/mcp/optionResolution.test.js +0 -43
- package/dist/mcp/runtime.test.d.ts +0 -1
- package/dist/mcp/runtime.test.js +0 -5211
- package/dist/mcp/structuredCommentValidation.test.d.ts +0 -1
- package/dist/mcp/structuredCommentValidation.test.js +0 -31
- package/dist/mcp/structuredDocValidation.test.d.ts +0 -1
- package/dist/mcp/structuredDocValidation.test.js +0 -35
- package/dist/mcp/toolRegistry.test.d.ts +0 -1
- package/dist/mcp/toolRegistry.test.js +0 -34
- package/dist/migrations/billingSchemaParity.test.d.ts +0 -1
- package/dist/migrations/billingSchemaParity.test.js +0 -160
- package/dist/migrations/taskSchemaMigrations.test.d.ts +0 -1
- package/dist/migrations/taskSchemaMigrations.test.js +0 -225
- package/dist/qaOpen.test.d.ts +0 -1
- package/dist/qaOpen.test.js +0 -56
- package/dist/releaseVersion.test.d.ts +0 -1
- package/dist/releaseVersion.test.js +0 -32
- package/dist/runtime/appGates.test.d.ts +0 -1
- package/dist/runtime/appGates.test.js +0 -42
- package/dist/server/aiProfileAvatarAssets.test.d.ts +0 -1
- package/dist/server/aiProfileAvatarAssets.test.js +0 -213
- package/dist/server/annotatedAttachmentsRoutes.test.d.ts +0 -1
- package/dist/server/annotatedAttachmentsRoutes.test.js +0 -532
- package/dist/server/auth.test.d.ts +0 -1
- package/dist/server/auth.test.js +0 -131
- package/dist/server/buildInfo.test.d.ts +0 -1
- package/dist/server/buildInfo.test.js +0 -29
- package/dist/server/cors.test.d.ts +0 -1
- package/dist/server/cors.test.js +0 -77
- package/dist/server/documentReviewRoutes.test.d.ts +0 -1
- package/dist/server/documentReviewRoutes.test.js +0 -190
- package/dist/server/email.test.d.ts +0 -1
- package/dist/server/email.test.js +0 -113
- package/dist/server/index.cookieProxy.test.d.ts +0 -1
- package/dist/server/index.cookieProxy.test.js +0 -67
- package/dist/server/index.rateLimit.test.d.ts +0 -1
- package/dist/server/index.rateLimit.test.js +0 -22
- package/dist/server/index.test.d.ts +0 -1
- package/dist/server/index.test.js +0 -283
- package/dist/server/rateLimit.test.d.ts +0 -1
- package/dist/server/rateLimit.test.js +0 -107
- package/dist/server/realtimeSync.auth.test.d.ts +0 -1
- package/dist/server/realtimeSync.auth.test.js +0 -62
- package/dist/server/realtimeSync.replay.test.d.ts +0 -1
- package/dist/server/realtimeSync.replay.test.js +0 -192
- package/dist/server/realtimeSync.workspaceIsolation.test.d.ts +0 -1
- package/dist/server/realtimeSync.workspaceIsolation.test.js +0 -101
- package/dist/server/routes/billing.test.d.ts +0 -1
- package/dist/server/routes/billing.test.js +0 -3515
- package/dist/server/routes/shared.test.d.ts +0 -1
- package/dist/server/routes/shared.test.js +0 -32
- package/dist/server/routes/sync.integration.test.d.ts +0 -1
- package/dist/server/routes/sync.integration.test.js +0 -2932
- package/dist/server/routes/syncAuxRoutes.test.d.ts +0 -1
- package/dist/server/routes/syncAuxRoutes.test.js +0 -158
- package/dist/server/routes/syncRouteGuards.test.d.ts +0 -1
- package/dist/server/routes/syncRouteGuards.test.js +0 -94
- package/dist/server/routes.test.d.ts +0 -1
- package/dist/server/routes.test.js +0 -15612
- package/dist/server/runtimeMode.test.d.ts +0 -1
- package/dist/server/runtimeMode.test.js +0 -26
- package/dist/server/securityHeaders.test.d.ts +0 -1
- package/dist/server/securityHeaders.test.js +0 -70
- package/dist/services/templateEngine.test.d.ts +0 -1
- package/dist/services/templateEngine.test.js +0 -150
- package/dist/services/templates.test.d.ts +0 -1
- package/dist/services/templates.test.js +0 -45
- package/dist/services/workflowDocumentFixtures.test.d.ts +0 -1
- package/dist/services/workflowDocumentFixtures.test.js +0 -78
- package/dist/services/workflowExportMatrix.test.d.ts +0 -1
- package/dist/services/workflowExportMatrix.test.js +0 -113
- package/dist/services/workflowExportSnapshots.test.d.ts +0 -1
- package/dist/services/workflowExportSnapshots.test.js +0 -30
- package/dist/services/workflowGeneration.test.d.ts +0 -1
- package/dist/services/workflowGeneration.test.js +0 -12
- package/dist/services/workflowSimulation.test.d.ts +0 -1
- package/dist/services/workflowSimulation.test.js +0 -113
- package/dist/services/workflowV2Policy.test.d.ts +0 -1
- package/dist/services/workflowV2Policy.test.js +0 -80
- package/dist/shared/customTaxonomyLibrary.test.d.ts +0 -1
- package/dist/shared/customTaxonomyLibrary.test.js +0 -20
- package/dist/shared/passwordPolicy.test.d.ts +0 -1
- package/dist/shared/passwordPolicy.test.js +0 -34
- package/dist/shared/runtimeContract.test.d.ts +0 -1
- package/dist/shared/runtimeContract.test.js +0 -23
- package/dist/shared/taxonomyLibrary.test.d.ts +0 -1
- package/dist/shared/taxonomyLibrary.test.js +0 -26
- package/dist/shared/taxonomyState.test.d.ts +0 -1
- package/dist/shared/taxonomyState.test.js +0 -71
- package/dist/soak/preflight.cli.d.ts +0 -1
- package/dist/soak/preflight.cli.js +0 -28
- package/dist/soak/preflight.d.ts +0 -26
- package/dist/soak/preflight.js +0 -113
- package/dist/soak/preflight.test.d.ts +0 -1
- package/dist/soak/preflight.test.js +0 -39
- package/dist/storage/objectStorageClient.test.d.ts +0 -1
- package/dist/storage/objectStorageClient.test.js +0 -82
- package/dist/storage/objectStorageConfig.test.d.ts +0 -1
- package/dist/storage/objectStorageConfig.test.js +0 -50
- package/dist/storage/postgresAdapter.test.d.ts +0 -1
- package/dist/storage/postgresAdapter.test.js +0 -29
- package/dist/storage/workspaceAssetStore.test.d.ts +0 -1
- package/dist/storage/workspaceAssetStore.test.js +0 -588
- package/dist/sync/cloudSyncApi.test.d.ts +0 -1
- package/dist/sync/cloudSyncApi.test.js +0 -111
- package/dist/sync/collaborationSyncPayload.test.d.ts +0 -1
- package/dist/sync/collaborationSyncPayload.test.js +0 -125
- package/dist/sync/contentSyncPayload.test.d.ts +0 -1
- package/dist/sync/contentSyncPayload.test.js +0 -143
- package/dist/sync/encryptionService.test.d.ts +0 -1
- package/dist/sync/encryptionService.test.js +0 -52
- package/dist/sync/planningSyncPayload.test.d.ts +0 -1
- package/dist/sync/planningSyncPayload.test.js +0 -92
- package/dist/sync/realtimeFeature.test.d.ts +0 -1
- package/dist/sync/realtimeFeature.test.js +0 -30
- package/dist/sync/realtimeReconcile.test.d.ts +0 -1
- package/dist/sync/realtimeReconcile.test.js +0 -43
- package/dist/sync/syncApplyHandlers.test.d.ts +0 -1
- package/dist/sync/syncApplyHandlers.test.js +0 -626
- package/dist/sync/syncService.test.d.ts +0 -1
- package/dist/sync/syncService.test.js +0 -903
- package/dist/sync/taskSyncPayload.test.d.ts +0 -1
- package/dist/sync/taskSyncPayload.test.js +0 -54
- package/dist/sync/workspacePullFeed.test.d.ts +0 -1
- package/dist/sync/workspacePullFeed.test.js +0 -438
- package/dist/sync/workspaceSyncModel.test.d.ts +0 -1
- package/dist/sync/workspaceSyncModel.test.js +0 -1442
- package/dist/test/setup.d.ts +0 -1
- package/dist/test/setup.js +0 -15
- package/dist/ui/assets/documentReferences-BPWp6ce0.js +0 -1
- package/dist/ui/assets/index-zvbo2Jse.js +0 -5
- package/dist/utils/accountProfileSummaryCache.test.d.ts +0 -1
- package/dist/utils/accountProfileSummaryCache.test.js +0 -63
- package/dist/utils/annotatedAttachments.test.d.ts +0 -1
- package/dist/utils/annotatedAttachments.test.js +0 -108
- package/dist/utils/assignees.test.d.ts +0 -1
- package/dist/utils/assignees.test.js +0 -25
- package/dist/utils/avatarUpload.test.d.ts +0 -1
- package/dist/utils/avatarUpload.test.js +0 -40
- package/dist/utils/canonicalAssetKind.test.d.ts +0 -1
- package/dist/utils/canonicalAssetKind.test.js +0 -24
- package/dist/utils/coalescedRefresh.test.d.ts +0 -1
- package/dist/utils/coalescedRefresh.test.js +0 -30
- package/dist/utils/constants.icons.test.d.ts +0 -1
- package/dist/utils/constants.icons.test.js +0 -41
- package/dist/utils/planParser.test.d.ts +0 -1
- package/dist/utils/planParser.test.js +0 -183
- package/dist/utils/planningReferences.test.d.ts +0 -1
- package/dist/utils/planningReferences.test.js +0 -17
- package/dist/utils/supportContact.test.d.ts +0 -1
- package/dist/utils/supportContact.test.js +0 -19
- package/dist/utils/syncEventDetails.test.d.ts +0 -1
- package/dist/utils/syncEventDetails.test.js +0 -23
- package/dist/utils/syncEventPresentation.test.d.ts +0 -1
- package/dist/utils/syncEventPresentation.test.js +0 -64
- package/dist/utils/syncStatusPresentation.test.d.ts +0 -1
- package/dist/utils/syncStatusPresentation.test.js +0 -164
- package/dist/utils/taskActivity.test.d.ts +0 -1
- package/dist/utils/taskActivity.test.js +0 -218
- package/dist/utils/taskDraftDefaults.test.d.ts +0 -1
- package/dist/utils/taskDraftDefaults.test.js +0 -34
- package/dist/utils/taskDragZones.test.d.ts +0 -1
- package/dist/utils/taskDragZones.test.js +0 -14
- package/dist/utils/taskNormalization.test.d.ts +0 -1
- package/dist/utils/taskNormalization.test.js +0 -158
- package/dist/utils/taskSearch.test.d.ts +0 -1
- package/dist/utils/taskSearch.test.js +0 -69
- package/dist/utils/taskUtils.test.d.ts +0 -1
- package/dist/utils/taskUtils.test.js +0 -19
- package/dist/utils/taskforceApiClient.test.d.ts +0 -1
- package/dist/utils/taskforceApiClient.test.js +0 -44
- package/dist/utils/taxonomyFormDefaults.test.d.ts +0 -1
- package/dist/utils/taxonomyFormDefaults.test.js +0 -63
- package/dist/utils/uiNotice.test.d.ts +0 -1
- package/dist/utils/uiNotice.test.js +0 -18
- package/dist/utils/workspaceIdentity.test.d.ts +0 -1
- package/dist/utils/workspaceIdentity.test.js +0 -61
- package/dist/utils/workspaceLifecycle.test.d.ts +0 -1
- package/dist/utils/workspaceLifecycle.test.js +0 -64
- package/dist/utils/workspaceSyncPresentation.test.d.ts +0 -1
- package/dist/utils/workspaceSyncPresentation.test.js +0 -71
- package/scripts/bootstrap-playwright-auth.mjs +0 -155
- package/scripts/check-cloud-mcp.mjs +0 -83
- package/scripts/check-compat-boundaries.mjs +0 -41
- package/scripts/check-env.ts +0 -31
- package/scripts/check-localization-strings.mjs +0 -49
- package/scripts/check-runtime-boundaries.mjs +0 -44
- package/scripts/debug-global.mjs +0 -34
- package/scripts/debug-login.mjs +0 -32
- package/scripts/debug-server.mjs +0 -36
- package/scripts/deploy-prod.sh +0 -41
- package/scripts/deploy-staging.sh +0 -23
- package/scripts/export-sqlite-to-postgres.mjs +0 -123
- package/scripts/generate-env-example.ts +0 -8
- package/scripts/mcp-stdio-adapter.mjs +0 -160
- package/scripts/migrate-task-data-assets.mjs +0 -408
- package/scripts/playwright-auth.sh +0 -19
- package/scripts/qa-open-lib.mjs +0 -175
- package/scripts/qa-open-lib.mjs.d.ts +0 -49
- package/scripts/qa-open.mjs +0 -352
- package/scripts/release-version-lib.mjs +0 -88
- package/scripts/release-version.mjs +0 -72
- package/scripts/run-billing-performance-smoke.sh +0 -24
- package/scripts/run-dev-proxy.sh +0 -51
- package/scripts/run-e2e-realtime.sh +0 -30
- package/scripts/run-smoke.sh +0 -35
- package/scripts/run-soak.sh +0 -41
- package/scripts/test-global.js +0 -143
- package/scripts/update-homebrew-formula.sh +0 -108
- package/scripts/with-esbuild.sh +0 -11
|
@@ -1,903 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { runWorkspacePullSyncService, runWorkspacePushSyncService, ensureCloudWorkspaceReadyForSyncService, syncUserGlobalSettingsService } from './syncService';
|
|
3
|
-
vi.mock('./cloudSyncApi', () => ({
|
|
4
|
-
pullWorkspaceChanges: vi.fn(),
|
|
5
|
-
pushWorkspaceChanges: vi.fn(),
|
|
6
|
-
applyLocalWorkspaceChanges: vi.fn(),
|
|
7
|
-
handshakeWorkspace: vi.fn(),
|
|
8
|
-
provisionWorkspace: vi.fn(),
|
|
9
|
-
pullUserSettings: vi.fn(),
|
|
10
|
-
pushUserSettings: vi.fn()
|
|
11
|
-
}));
|
|
12
|
-
import { pullWorkspaceChanges, pushWorkspaceChanges, applyLocalWorkspaceChanges, handshakeWorkspace, provisionWorkspace, pullUserSettings, pushUserSettings } from './cloudSyncApi';
|
|
13
|
-
const mockResolveCloudAuthUrl = (p) => p;
|
|
14
|
-
function buildPayload(overrides = {}) {
|
|
15
|
-
return {
|
|
16
|
-
changes: [],
|
|
17
|
-
currentTaskIds: new Set(),
|
|
18
|
-
deleteTaskIds: new Set(),
|
|
19
|
-
currentInitiativeIds: new Set(),
|
|
20
|
-
currentInitiativeWatermarks: new Map(),
|
|
21
|
-
currentWorkstreamIds: new Set(),
|
|
22
|
-
currentWorkstreamWatermarks: new Map(),
|
|
23
|
-
currentAiProfileIds: new Set(),
|
|
24
|
-
currentAiProfileWatermarks: new Map(),
|
|
25
|
-
currentDocumentPaths: new Set(),
|
|
26
|
-
deleteDocumentPaths: new Set(),
|
|
27
|
-
currentDocumentWatermarks: new Map(),
|
|
28
|
-
currentAssetPaths: new Set(),
|
|
29
|
-
deleteAssetPaths: new Set(),
|
|
30
|
-
currentAssetWatermarks: new Map(),
|
|
31
|
-
currentDocumentReviewSessionIds: new Set(),
|
|
32
|
-
deleteDocumentReviewSessionIds: new Set(),
|
|
33
|
-
currentDocumentReviewSessionWatermarks: new Map(),
|
|
34
|
-
currentDocumentReviewCommentIds: new Set(),
|
|
35
|
-
deleteDocumentReviewCommentIds: new Set(),
|
|
36
|
-
currentDocumentReviewCommentWatermarks: new Map(),
|
|
37
|
-
currentAnnotatedAttachmentSessionIds: new Set(),
|
|
38
|
-
deleteAnnotatedAttachmentSessionIds: new Set(),
|
|
39
|
-
currentAnnotatedAttachmentSessionWatermarks: new Map(),
|
|
40
|
-
currentTaskEventWatermarks: new Map(),
|
|
41
|
-
pushedWatermarks: new Map(),
|
|
42
|
-
...overrides
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
const baseHandshakeInput = {
|
|
46
|
-
cloudAuthConfigured: true,
|
|
47
|
-
runtimeMode: 'local',
|
|
48
|
-
isAuthenticated: true,
|
|
49
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
50
|
-
workspaceId: 'ws-test',
|
|
51
|
-
workspaceName: 'Test Workspace'
|
|
52
|
-
};
|
|
53
|
-
describe('syncService', () => {
|
|
54
|
-
describe('runWorkspacePushSyncService', () => {
|
|
55
|
-
beforeEach(() => {
|
|
56
|
-
vi.mocked(pushWorkspaceChanges).mockReset();
|
|
57
|
-
});
|
|
58
|
-
it('returns current/delete document path sets from payload', async () => {
|
|
59
|
-
vi.mocked(pushWorkspaceChanges).mockResolvedValueOnce({
|
|
60
|
-
ok: true,
|
|
61
|
-
status: 200,
|
|
62
|
-
data: { success: true, emittedEventIds: ['epoch-1:1', 'epoch-1:1', 'epoch-1:2', ''] }
|
|
63
|
-
});
|
|
64
|
-
const result = await runWorkspacePushSyncService({
|
|
65
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
66
|
-
workspaceId: 'ws-1',
|
|
67
|
-
payload: buildPayload({
|
|
68
|
-
changes: [{ op: 'document-delete', path: 'docs/remove.md' }],
|
|
69
|
-
currentTaskIds: new Set(['task-1']),
|
|
70
|
-
currentDocumentPaths: new Set(['docs/keep.md']),
|
|
71
|
-
deleteDocumentPaths: new Set(['docs/remove.md']),
|
|
72
|
-
currentDocumentWatermarks: new Map([['docs/keep.md', '2026-02-01T00:00:00.000Z']]),
|
|
73
|
-
pushedWatermarks: new Map([['task-1', 'wm-1']])
|
|
74
|
-
}),
|
|
75
|
-
ensureCloudWorkspaceReadyForSync: async () => ({ success: true })
|
|
76
|
-
});
|
|
77
|
-
expect(result.success).toBe(true);
|
|
78
|
-
expect(Array.from(result.currentDocumentPaths)).toEqual(['docs/keep.md']);
|
|
79
|
-
expect(Array.from(result.deleteDocumentPaths)).toEqual(['docs/remove.md']);
|
|
80
|
-
expect(result.changeCount).toBe(1);
|
|
81
|
-
expect(result.emittedEventIds).toEqual(['epoch-1:1', 'epoch-1:2']);
|
|
82
|
-
});
|
|
83
|
-
it('uses deterministic fallback idempotency key when crypto.subtle is unavailable', async () => {
|
|
84
|
-
const payload = buildPayload({
|
|
85
|
-
changes: [{ op: 'document-delete', path: 'docs/remove.md' }],
|
|
86
|
-
deleteDocumentPaths: new Set(['docs/remove.md']),
|
|
87
|
-
});
|
|
88
|
-
vi.mocked(pushWorkspaceChanges)
|
|
89
|
-
.mockResolvedValue({
|
|
90
|
-
ok: true,
|
|
91
|
-
status: 200,
|
|
92
|
-
data: { success: true }
|
|
93
|
-
});
|
|
94
|
-
vi.stubGlobal('crypto', {});
|
|
95
|
-
try {
|
|
96
|
-
await runWorkspacePushSyncService({
|
|
97
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
98
|
-
workspaceId: 'ws-fallback',
|
|
99
|
-
payload,
|
|
100
|
-
ensureCloudWorkspaceReadyForSync: async () => ({ success: true })
|
|
101
|
-
});
|
|
102
|
-
await runWorkspacePushSyncService({
|
|
103
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
104
|
-
workspaceId: 'ws-fallback',
|
|
105
|
-
payload,
|
|
106
|
-
ensureCloudWorkspaceReadyForSync: async () => ({ success: true })
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
finally {
|
|
110
|
-
vi.unstubAllGlobals();
|
|
111
|
-
}
|
|
112
|
-
expect(pushWorkspaceChanges).toHaveBeenCalledTimes(2);
|
|
113
|
-
const firstKey = vi.mocked(pushWorkspaceChanges).mock.calls[0]?.[1]?.idempotencyKey;
|
|
114
|
-
const secondKey = vi.mocked(pushWorkspaceChanges).mock.calls[1]?.[1]?.idempotencyKey;
|
|
115
|
-
expect(firstKey).toEqual(secondKey);
|
|
116
|
-
expect(String(firstKey || '')).toMatch(/^ws-fallback:fallback:[0-9a-f]{8}$/);
|
|
117
|
-
});
|
|
118
|
-
it('reuses the same idempotency key when retrying push after ensure succeeds', async () => {
|
|
119
|
-
vi.mocked(pushWorkspaceChanges)
|
|
120
|
-
.mockResolvedValueOnce({
|
|
121
|
-
ok: false,
|
|
122
|
-
status: 403,
|
|
123
|
-
data: { error: 'forbidden' }
|
|
124
|
-
})
|
|
125
|
-
.mockResolvedValueOnce({
|
|
126
|
-
ok: true,
|
|
127
|
-
status: 200,
|
|
128
|
-
data: { success: true }
|
|
129
|
-
});
|
|
130
|
-
const ensureCloudWorkspaceReadyForSync = vi.fn().mockResolvedValue({ success: true });
|
|
131
|
-
const result = await runWorkspacePushSyncService({
|
|
132
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
133
|
-
workspaceId: 'ws-retry',
|
|
134
|
-
payload: buildPayload({
|
|
135
|
-
changes: [{ op: 'delete', taskId: 'task-1' }],
|
|
136
|
-
deleteTaskIds: new Set(['task-1']),
|
|
137
|
-
}),
|
|
138
|
-
ensureCloudWorkspaceReadyForSync
|
|
139
|
-
});
|
|
140
|
-
expect(result.success).toBe(true);
|
|
141
|
-
expect(ensureCloudWorkspaceReadyForSync).toHaveBeenCalledTimes(1);
|
|
142
|
-
expect(pushWorkspaceChanges).toHaveBeenCalledTimes(2);
|
|
143
|
-
const firstKey = vi.mocked(pushWorkspaceChanges).mock.calls[0]?.[1]?.idempotencyKey;
|
|
144
|
-
const secondKey = vi.mocked(pushWorkspaceChanges).mock.calls[1]?.[1]?.idempotencyKey;
|
|
145
|
-
expect(firstKey).toEqual(secondKey);
|
|
146
|
-
});
|
|
147
|
-
it('surfaces push error details from non-ok cloud responses', async () => {
|
|
148
|
-
vi.mocked(pushWorkspaceChanges).mockResolvedValueOnce({
|
|
149
|
-
ok: false,
|
|
150
|
-
status: 500,
|
|
151
|
-
data: {
|
|
152
|
-
error: 'Failed to apply workspace deltas',
|
|
153
|
-
code: 'SQLITE_BUSY'
|
|
154
|
-
}
|
|
155
|
-
});
|
|
156
|
-
const result = await runWorkspacePushSyncService({
|
|
157
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
158
|
-
workspaceId: 'ws-error',
|
|
159
|
-
payload: buildPayload({
|
|
160
|
-
changes: [{ op: 'delete', taskId: 'task-1' }],
|
|
161
|
-
deleteTaskIds: new Set(['task-1']),
|
|
162
|
-
}),
|
|
163
|
-
ensureCloudWorkspaceReadyForSync: async () => ({ success: false })
|
|
164
|
-
});
|
|
165
|
-
expect(result.success).toBe(false);
|
|
166
|
-
expect(result.status).toBe(500);
|
|
167
|
-
expect(result.error).toBe('Failed to apply workspace deltas');
|
|
168
|
-
expect(result.code).toBe('SQLITE_BUSY');
|
|
169
|
-
});
|
|
170
|
-
});
|
|
171
|
-
describe('runWorkspacePullSyncService', () => {
|
|
172
|
-
beforeEach(() => {
|
|
173
|
-
vi.mocked(pullWorkspaceChanges).mockReset();
|
|
174
|
-
vi.mocked(applyLocalWorkspaceChanges).mockReset();
|
|
175
|
-
});
|
|
176
|
-
it('halts pagination correctly when hasMore is false', async () => {
|
|
177
|
-
vi.mocked(pullWorkspaceChanges).mockResolvedValueOnce({
|
|
178
|
-
ok: true,
|
|
179
|
-
status: 200,
|
|
180
|
-
data: {
|
|
181
|
-
success: true,
|
|
182
|
-
changes: [],
|
|
183
|
-
nextCursor: null,
|
|
184
|
-
hasMore: false
|
|
185
|
-
}
|
|
186
|
-
});
|
|
187
|
-
const res = await runWorkspacePullSyncService({
|
|
188
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
189
|
-
workspaceId: 'ws-1',
|
|
190
|
-
cursor: null,
|
|
191
|
-
bootstrap: false
|
|
192
|
-
});
|
|
193
|
-
expect(pullWorkspaceChanges).toHaveBeenCalledTimes(1);
|
|
194
|
-
expect(res.cursor).toBeNull();
|
|
195
|
-
expect(res.success).toBe(true);
|
|
196
|
-
});
|
|
197
|
-
it('correctly advances cursor across multiple pages', async () => {
|
|
198
|
-
vi.mocked(pullWorkspaceChanges)
|
|
199
|
-
.mockResolvedValueOnce({
|
|
200
|
-
ok: true,
|
|
201
|
-
data: {
|
|
202
|
-
success: true,
|
|
203
|
-
changes: [],
|
|
204
|
-
nextCursor: 'page-2-cursor',
|
|
205
|
-
hasMore: true
|
|
206
|
-
}
|
|
207
|
-
})
|
|
208
|
-
.mockResolvedValueOnce({
|
|
209
|
-
ok: true,
|
|
210
|
-
data: {
|
|
211
|
-
success: true,
|
|
212
|
-
changes: [],
|
|
213
|
-
nextCursor: null,
|
|
214
|
-
hasMore: false
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
const res = await runWorkspacePullSyncService({
|
|
218
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
219
|
-
workspaceId: 'ws-1',
|
|
220
|
-
cursor: null,
|
|
221
|
-
bootstrap: false
|
|
222
|
-
});
|
|
223
|
-
expect(pullWorkspaceChanges).toHaveBeenCalledTimes(2);
|
|
224
|
-
expect(res.cursor).toBeNull();
|
|
225
|
-
expect(res.success).toBe(true);
|
|
226
|
-
});
|
|
227
|
-
it('forwards workspace members from pull into local apply', async () => {
|
|
228
|
-
vi.mocked(pullWorkspaceChanges).mockResolvedValueOnce({
|
|
229
|
-
ok: true,
|
|
230
|
-
status: 200,
|
|
231
|
-
data: {
|
|
232
|
-
success: true,
|
|
233
|
-
workspaceMembers: [
|
|
234
|
-
{
|
|
235
|
-
userId: 'user-1',
|
|
236
|
-
workspaceId: 'ws-1',
|
|
237
|
-
email: 'member@example.com',
|
|
238
|
-
displayName: 'Member One',
|
|
239
|
-
role: 'member',
|
|
240
|
-
permissionMode: 'read-write',
|
|
241
|
-
betaAccess: true,
|
|
242
|
-
status: 'active',
|
|
243
|
-
disabled: false
|
|
244
|
-
}
|
|
245
|
-
],
|
|
246
|
-
changes: [{ op: 'upsert', task: { id: 't-1', title: 'Task', assignee: 'user-1' }, archived: false }],
|
|
247
|
-
nextCursor: null,
|
|
248
|
-
hasMore: false
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
vi.mocked(applyLocalWorkspaceChanges).mockResolvedValueOnce({
|
|
252
|
-
ok: true,
|
|
253
|
-
status: 200,
|
|
254
|
-
failures: [],
|
|
255
|
-
data: { success: true }
|
|
256
|
-
});
|
|
257
|
-
const res = await runWorkspacePullSyncService({
|
|
258
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
259
|
-
workspaceId: 'ws-1',
|
|
260
|
-
cursor: null,
|
|
261
|
-
bootstrap: false
|
|
262
|
-
});
|
|
263
|
-
expect(res.success).toBe(true);
|
|
264
|
-
expect(applyLocalWorkspaceChanges).toHaveBeenCalledWith('ws-1', expect.any(Array), expect.objectContaining({
|
|
265
|
-
workspaceMembers: [
|
|
266
|
-
expect.objectContaining({
|
|
267
|
-
userId: 'user-1',
|
|
268
|
-
email: 'member@example.com'
|
|
269
|
-
})
|
|
270
|
-
]
|
|
271
|
-
}));
|
|
272
|
-
});
|
|
273
|
-
it('applies members-only pull pages even when no entity changes are returned', async () => {
|
|
274
|
-
vi.mocked(pullWorkspaceChanges).mockResolvedValueOnce({
|
|
275
|
-
ok: true,
|
|
276
|
-
status: 200,
|
|
277
|
-
data: {
|
|
278
|
-
success: true,
|
|
279
|
-
workspaceMembers: [
|
|
280
|
-
{
|
|
281
|
-
userId: 'user-1',
|
|
282
|
-
workspaceId: 'ws-1',
|
|
283
|
-
email: 'member@example.com',
|
|
284
|
-
displayName: 'Member One',
|
|
285
|
-
role: 'member',
|
|
286
|
-
permissionMode: 'read-write',
|
|
287
|
-
betaAccess: true,
|
|
288
|
-
status: 'active',
|
|
289
|
-
disabled: false
|
|
290
|
-
}
|
|
291
|
-
],
|
|
292
|
-
changes: [],
|
|
293
|
-
nextCursor: null,
|
|
294
|
-
hasMore: false
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
vi.mocked(applyLocalWorkspaceChanges).mockResolvedValueOnce({
|
|
298
|
-
ok: true,
|
|
299
|
-
status: 200,
|
|
300
|
-
failures: [],
|
|
301
|
-
data: { success: true }
|
|
302
|
-
});
|
|
303
|
-
const res = await runWorkspacePullSyncService({
|
|
304
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
305
|
-
workspaceId: 'ws-1',
|
|
306
|
-
cursor: null,
|
|
307
|
-
bootstrap: false
|
|
308
|
-
});
|
|
309
|
-
expect(res.success).toBe(true);
|
|
310
|
-
expect(applyLocalWorkspaceChanges).toHaveBeenCalledWith('ws-1', [], expect.objectContaining({
|
|
311
|
-
workspaceMembers: [
|
|
312
|
-
expect.objectContaining({
|
|
313
|
-
userId: 'user-1'
|
|
314
|
-
})
|
|
315
|
-
]
|
|
316
|
-
}));
|
|
317
|
-
});
|
|
318
|
-
it('surfaces retryAfterMs when cloud returns 429', async () => {
|
|
319
|
-
vi.mocked(pullWorkspaceChanges).mockResolvedValueOnce({
|
|
320
|
-
ok: false,
|
|
321
|
-
status: 429,
|
|
322
|
-
retryAfterMs: 30_000,
|
|
323
|
-
data: { error: 'Rate limited' }
|
|
324
|
-
});
|
|
325
|
-
const res = await runWorkspacePullSyncService({
|
|
326
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
327
|
-
workspaceId: 'ws-1',
|
|
328
|
-
cursor: null,
|
|
329
|
-
bootstrap: false
|
|
330
|
-
});
|
|
331
|
-
expect(res.success).toBe(false);
|
|
332
|
-
expect(res.kind).toBe('pull_http');
|
|
333
|
-
expect(res.status).toBe(429);
|
|
334
|
-
expect(res.retryAfterMs).toBe(30_000);
|
|
335
|
-
});
|
|
336
|
-
it('surfaces thrown pull exceptions as exception errors', async () => {
|
|
337
|
-
vi.mocked(pullWorkspaceChanges).mockRejectedValueOnce(new Error('duplicate key value violates unique constraint'));
|
|
338
|
-
const res = await runWorkspacePullSyncService({
|
|
339
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
340
|
-
workspaceId: 'ws-1',
|
|
341
|
-
cursor: null,
|
|
342
|
-
bootstrap: false
|
|
343
|
-
});
|
|
344
|
-
expect(res.success).toBe(false);
|
|
345
|
-
expect(res.kind).toBe('exception');
|
|
346
|
-
expect(res.status).toBe(0);
|
|
347
|
-
expect(res.error).toContain('duplicate key value violates unique constraint');
|
|
348
|
-
});
|
|
349
|
-
it('retries pull once after 403 when ensure succeeds', async () => {
|
|
350
|
-
const ensureCloudWorkspaceReadyForSync = vi.fn().mockResolvedValue({ success: true });
|
|
351
|
-
vi.mocked(pullWorkspaceChanges)
|
|
352
|
-
.mockResolvedValueOnce({
|
|
353
|
-
ok: false,
|
|
354
|
-
status: 403,
|
|
355
|
-
data: { error: 'Forbidden' }
|
|
356
|
-
})
|
|
357
|
-
.mockResolvedValueOnce({
|
|
358
|
-
ok: true,
|
|
359
|
-
status: 200,
|
|
360
|
-
data: {
|
|
361
|
-
success: true,
|
|
362
|
-
changes: [],
|
|
363
|
-
nextCursor: null,
|
|
364
|
-
hasMore: false
|
|
365
|
-
}
|
|
366
|
-
});
|
|
367
|
-
const res = await runWorkspacePullSyncService({
|
|
368
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
369
|
-
workspaceId: 'ws-1',
|
|
370
|
-
cursor: null,
|
|
371
|
-
bootstrap: false,
|
|
372
|
-
ensureCloudWorkspaceReadyForSync
|
|
373
|
-
});
|
|
374
|
-
expect(res.success).toBe(true);
|
|
375
|
-
expect(ensureCloudWorkspaceReadyForSync).toHaveBeenCalledTimes(1);
|
|
376
|
-
expect(pullWorkspaceChanges).toHaveBeenCalledTimes(2);
|
|
377
|
-
});
|
|
378
|
-
it('does not retry pull when ensure after 403 fails', async () => {
|
|
379
|
-
const ensureCloudWorkspaceReadyForSync = vi.fn().mockResolvedValue({ success: false, statusCode: 403 });
|
|
380
|
-
vi.mocked(pullWorkspaceChanges).mockResolvedValueOnce({
|
|
381
|
-
ok: false,
|
|
382
|
-
status: 403,
|
|
383
|
-
data: { error: 'Forbidden' }
|
|
384
|
-
});
|
|
385
|
-
const res = await runWorkspacePullSyncService({
|
|
386
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
387
|
-
workspaceId: 'ws-1',
|
|
388
|
-
cursor: null,
|
|
389
|
-
bootstrap: false,
|
|
390
|
-
ensureCloudWorkspaceReadyForSync
|
|
391
|
-
});
|
|
392
|
-
expect(res.success).toBe(false);
|
|
393
|
-
expect(res.kind).toBe('pull_http');
|
|
394
|
-
expect(res.status).toBe(403);
|
|
395
|
-
expect(ensureCloudWorkspaceReadyForSync).toHaveBeenCalledTimes(1);
|
|
396
|
-
expect(pullWorkspaceChanges).toHaveBeenCalledTimes(1);
|
|
397
|
-
});
|
|
398
|
-
it('returns pull_http kind with status 401 on auth failure', async () => {
|
|
399
|
-
vi.mocked(pullWorkspaceChanges).mockResolvedValueOnce({
|
|
400
|
-
ok: false,
|
|
401
|
-
status: 401,
|
|
402
|
-
data: { error: 'Unauthorized' }
|
|
403
|
-
});
|
|
404
|
-
const res = await runWorkspacePullSyncService({
|
|
405
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
406
|
-
workspaceId: 'ws-1',
|
|
407
|
-
cursor: null,
|
|
408
|
-
bootstrap: false
|
|
409
|
-
});
|
|
410
|
-
expect(res.success).toBe(false);
|
|
411
|
-
expect(res.kind).toBe('pull_http');
|
|
412
|
-
expect(res.status).toBe(401);
|
|
413
|
-
});
|
|
414
|
-
it('returns apply_auth kind when apply-local returns 401', async () => {
|
|
415
|
-
vi.mocked(pullWorkspaceChanges).mockResolvedValueOnce({
|
|
416
|
-
ok: true,
|
|
417
|
-
status: 200,
|
|
418
|
-
data: {
|
|
419
|
-
success: true,
|
|
420
|
-
changes: [{ op: 'upsert', task: { id: 't1', title: 'Task 1', updatedAt: '2026-01-01T00:00:00Z' } }],
|
|
421
|
-
nextCursor: null,
|
|
422
|
-
hasMore: false
|
|
423
|
-
}
|
|
424
|
-
});
|
|
425
|
-
vi.mocked(applyLocalWorkspaceChanges).mockResolvedValueOnce({
|
|
426
|
-
ok: false,
|
|
427
|
-
failures: ['apply:401'],
|
|
428
|
-
appliedCount: 0
|
|
429
|
-
});
|
|
430
|
-
const res = await runWorkspacePullSyncService({
|
|
431
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
432
|
-
workspaceId: 'ws-1',
|
|
433
|
-
cursor: null,
|
|
434
|
-
bootstrap: false
|
|
435
|
-
});
|
|
436
|
-
expect(res.success).toBe(false);
|
|
437
|
-
expect(res.kind).toBe('apply_auth');
|
|
438
|
-
expect(res.status).toBe(401);
|
|
439
|
-
});
|
|
440
|
-
it('surfaces apply-local error details from non-ok local apply responses', async () => {
|
|
441
|
-
vi.mocked(pullWorkspaceChanges).mockResolvedValueOnce({
|
|
442
|
-
ok: true,
|
|
443
|
-
status: 200,
|
|
444
|
-
data: {
|
|
445
|
-
success: true,
|
|
446
|
-
changes: [{ op: 'upsert', task: { id: 'task-apply-error', title: 'Apply error', status: 'done', updatedAt: '2026-03-15T20:27:08.000Z' } }],
|
|
447
|
-
nextCursor: null,
|
|
448
|
-
hasMore: false
|
|
449
|
-
}
|
|
450
|
-
});
|
|
451
|
-
vi.mocked(applyLocalWorkspaceChanges).mockResolvedValueOnce({
|
|
452
|
-
ok: false,
|
|
453
|
-
status: 400,
|
|
454
|
-
failures: ['/api/taskforce/sync/workspace/apply-local:400'],
|
|
455
|
-
data: { error: 'Task apply rejected by local validation' }
|
|
456
|
-
});
|
|
457
|
-
const res = await runWorkspacePullSyncService({
|
|
458
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
459
|
-
workspaceId: 'ws-1',
|
|
460
|
-
cursor: null,
|
|
461
|
-
bootstrap: false
|
|
462
|
-
});
|
|
463
|
-
expect(res.success).toBe(false);
|
|
464
|
-
expect(res.kind).toBe('apply_all_candidates');
|
|
465
|
-
expect(res.status).toBe(400);
|
|
466
|
-
expect(res.error).toBe('Task apply rejected by local validation');
|
|
467
|
-
});
|
|
468
|
-
it('surfaces document decryption failures without failing pull', async () => {
|
|
469
|
-
const previousKey = process.env.TASKFORCE_SYNC_KEY;
|
|
470
|
-
process.env.TASKFORCE_SYNC_KEY = 'test-sync-key';
|
|
471
|
-
vi.mocked(pullWorkspaceChanges).mockResolvedValueOnce({
|
|
472
|
-
ok: true,
|
|
473
|
-
status: 200,
|
|
474
|
-
data: {
|
|
475
|
-
success: true,
|
|
476
|
-
changes: [{ op: 'document-upsert', path: 'docs/secret.md', content: 'V1:AESGCM:malformed' }],
|
|
477
|
-
nextCursor: null,
|
|
478
|
-
hasMore: false
|
|
479
|
-
}
|
|
480
|
-
});
|
|
481
|
-
vi.mocked(applyLocalWorkspaceChanges).mockResolvedValueOnce({
|
|
482
|
-
ok: true,
|
|
483
|
-
failures: [],
|
|
484
|
-
appliedCount: 1,
|
|
485
|
-
data: { success: true }
|
|
486
|
-
});
|
|
487
|
-
try {
|
|
488
|
-
const res = await runWorkspacePullSyncService({
|
|
489
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
490
|
-
workspaceId: 'ws-1',
|
|
491
|
-
cursor: null,
|
|
492
|
-
bootstrap: false
|
|
493
|
-
});
|
|
494
|
-
expect(res.success).toBe(true);
|
|
495
|
-
expect(res.documentDecryptFailures).toEqual(['docs/secret.md']);
|
|
496
|
-
}
|
|
497
|
-
finally {
|
|
498
|
-
if (typeof previousKey === 'string')
|
|
499
|
-
process.env.TASKFORCE_SYNC_KEY = previousKey;
|
|
500
|
-
else
|
|
501
|
-
delete process.env.TASKFORCE_SYNC_KEY;
|
|
502
|
-
}
|
|
503
|
-
});
|
|
504
|
-
it('tracks event-only task pulls so callers can refresh visible task history', async () => {
|
|
505
|
-
vi.mocked(pullWorkspaceChanges).mockResolvedValueOnce({
|
|
506
|
-
ok: true,
|
|
507
|
-
status: 200,
|
|
508
|
-
data: {
|
|
509
|
-
success: true,
|
|
510
|
-
changes: [{
|
|
511
|
-
op: 'task-event-upsert',
|
|
512
|
-
event: {
|
|
513
|
-
id: 'task-event-1',
|
|
514
|
-
taskId: 'task-1',
|
|
515
|
-
workspaceId: 'ws-1',
|
|
516
|
-
action: 'task-status-changed',
|
|
517
|
-
actor: 'ai-profile-1',
|
|
518
|
-
actorType: 'ai',
|
|
519
|
-
createdAt: '2026-04-13T10:05:00.000Z',
|
|
520
|
-
details: {
|
|
521
|
-
changes: {
|
|
522
|
-
status: {
|
|
523
|
-
from: 'in-progress',
|
|
524
|
-
to: 'done'
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
}],
|
|
530
|
-
nextCursor: null,
|
|
531
|
-
hasMore: false
|
|
532
|
-
}
|
|
533
|
-
});
|
|
534
|
-
vi.mocked(applyLocalWorkspaceChanges).mockResolvedValueOnce({
|
|
535
|
-
ok: true,
|
|
536
|
-
failures: [],
|
|
537
|
-
appliedCount: 1,
|
|
538
|
-
data: { success: true }
|
|
539
|
-
});
|
|
540
|
-
const res = await runWorkspacePullSyncService({
|
|
541
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
542
|
-
workspaceId: 'ws-1',
|
|
543
|
-
cursor: null,
|
|
544
|
-
bootstrap: false
|
|
545
|
-
});
|
|
546
|
-
expect(res.success).toBe(true);
|
|
547
|
-
expect(res.pulledTaskEventUpserts).toBe(true);
|
|
548
|
-
expect(res.pulledActiveUpserts).toBe(false);
|
|
549
|
-
expect(res.pulledArchivedUpserts).toBe(false);
|
|
550
|
-
});
|
|
551
|
-
it('marks planning upserts when the pull contains initiative or workstream changes', async () => {
|
|
552
|
-
vi.mocked(pullWorkspaceChanges).mockResolvedValueOnce({
|
|
553
|
-
ok: true,
|
|
554
|
-
status: 200,
|
|
555
|
-
data: {
|
|
556
|
-
success: true,
|
|
557
|
-
changes: [{
|
|
558
|
-
op: 'workstream-upsert',
|
|
559
|
-
updatedAt: '2026-04-27T22:00:00.000Z',
|
|
560
|
-
workstream: {
|
|
561
|
-
id: 'ws-123',
|
|
562
|
-
title: 'Planning sync workstream',
|
|
563
|
-
description: 'Contains planning attachments',
|
|
564
|
-
createdAt: '2026-04-27T21:00:00.000Z',
|
|
565
|
-
updatedAt: '2026-04-27T22:00:00.000Z',
|
|
566
|
-
attachments: []
|
|
567
|
-
}
|
|
568
|
-
}],
|
|
569
|
-
nextCursor: null,
|
|
570
|
-
hasMore: false
|
|
571
|
-
}
|
|
572
|
-
});
|
|
573
|
-
vi.mocked(applyLocalWorkspaceChanges).mockResolvedValueOnce({
|
|
574
|
-
ok: true,
|
|
575
|
-
failures: [],
|
|
576
|
-
appliedCount: 1,
|
|
577
|
-
data: { success: true }
|
|
578
|
-
});
|
|
579
|
-
const res = await runWorkspacePullSyncService({
|
|
580
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
581
|
-
workspaceId: 'ws-1',
|
|
582
|
-
cursor: null,
|
|
583
|
-
bootstrap: false
|
|
584
|
-
});
|
|
585
|
-
expect(res.success).toBe(true);
|
|
586
|
-
expect(res.pulledPlanningUpserts).toBe(true);
|
|
587
|
-
expect(res.pulledActiveUpserts).toBe(false);
|
|
588
|
-
expect(res.pulledArchivedUpserts).toBe(false);
|
|
589
|
-
});
|
|
590
|
-
it('zero-change bootstrap pull (no changes, hasMore false) returns success true', async () => {
|
|
591
|
-
vi.mocked(pullWorkspaceChanges).mockResolvedValueOnce({
|
|
592
|
-
ok: true,
|
|
593
|
-
status: 200,
|
|
594
|
-
data: {
|
|
595
|
-
success: true,
|
|
596
|
-
changes: [],
|
|
597
|
-
nextCursor: null,
|
|
598
|
-
hasMore: false
|
|
599
|
-
}
|
|
600
|
-
});
|
|
601
|
-
vi.mocked(applyLocalWorkspaceChanges).mockResolvedValueOnce({
|
|
602
|
-
ok: true,
|
|
603
|
-
status: 200,
|
|
604
|
-
data: { success: true },
|
|
605
|
-
failures: []
|
|
606
|
-
});
|
|
607
|
-
const res = await runWorkspacePullSyncService({
|
|
608
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
609
|
-
workspaceId: 'ws-bootstrap',
|
|
610
|
-
cursor: null,
|
|
611
|
-
bootstrap: true
|
|
612
|
-
});
|
|
613
|
-
expect(res.success).toBe(true);
|
|
614
|
-
expect(res.appliedChanges).toBe(0);
|
|
615
|
-
expect(res.cursor).toBeNull();
|
|
616
|
-
expect(applyLocalWorkspaceChanges).toHaveBeenCalledWith('ws-bootstrap', [], {
|
|
617
|
-
bootstrapSnapshot: {
|
|
618
|
-
currentAnnotatedAttachmentSessionIds: []
|
|
619
|
-
}
|
|
620
|
-
});
|
|
621
|
-
});
|
|
622
|
-
it('sends pulled annotated attachment session ids during bootstrap reconciliation', async () => {
|
|
623
|
-
vi.mocked(pullWorkspaceChanges).mockResolvedValueOnce({
|
|
624
|
-
ok: true,
|
|
625
|
-
status: 200,
|
|
626
|
-
data: {
|
|
627
|
-
success: true,
|
|
628
|
-
changes: [{
|
|
629
|
-
op: 'annotated-attachment-session-upsert',
|
|
630
|
-
session: {
|
|
631
|
-
id: 'session-1',
|
|
632
|
-
workspaceId: 'ws-annotated',
|
|
633
|
-
taskId: 'task-1',
|
|
634
|
-
baseImageAssetId: 'asset-1',
|
|
635
|
-
title: 'Session 1',
|
|
636
|
-
globalInstruction: null,
|
|
637
|
-
annotations: [],
|
|
638
|
-
createdByActorId: null,
|
|
639
|
-
updatedByActorId: null,
|
|
640
|
-
createdAt: '2026-03-26T00:00:00.000Z',
|
|
641
|
-
updatedAt: '2026-03-26T00:00:00.000Z',
|
|
642
|
-
deletedAt: null
|
|
643
|
-
}
|
|
644
|
-
}],
|
|
645
|
-
nextCursor: null,
|
|
646
|
-
hasMore: false
|
|
647
|
-
}
|
|
648
|
-
});
|
|
649
|
-
vi.mocked(applyLocalWorkspaceChanges)
|
|
650
|
-
.mockResolvedValueOnce({
|
|
651
|
-
ok: true,
|
|
652
|
-
status: 200,
|
|
653
|
-
data: { success: true },
|
|
654
|
-
failures: []
|
|
655
|
-
})
|
|
656
|
-
.mockResolvedValueOnce({
|
|
657
|
-
ok: true,
|
|
658
|
-
status: 200,
|
|
659
|
-
data: { success: true },
|
|
660
|
-
failures: []
|
|
661
|
-
});
|
|
662
|
-
const res = await runWorkspacePullSyncService({
|
|
663
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
664
|
-
workspaceId: 'ws-annotated',
|
|
665
|
-
cursor: null,
|
|
666
|
-
bootstrap: true
|
|
667
|
-
});
|
|
668
|
-
expect(res.success).toBe(true);
|
|
669
|
-
expect(applyLocalWorkspaceChanges).toHaveBeenNthCalledWith(1, 'ws-annotated', expect.arrayContaining([
|
|
670
|
-
expect.objectContaining({
|
|
671
|
-
op: 'annotated-attachment-session-upsert',
|
|
672
|
-
session: expect.objectContaining({ id: 'session-1' })
|
|
673
|
-
})
|
|
674
|
-
]), expect.objectContaining({ repairMode: false }));
|
|
675
|
-
expect(applyLocalWorkspaceChanges).toHaveBeenNthCalledWith(2, 'ws-annotated', [], {
|
|
676
|
-
bootstrapSnapshot: {
|
|
677
|
-
currentAnnotatedAttachmentSessionIds: ['session-1']
|
|
678
|
-
}
|
|
679
|
-
});
|
|
680
|
-
});
|
|
681
|
-
it('stops at maxPages and returns partial success', async () => {
|
|
682
|
-
// Always returns hasMore=true so the loop would run forever without maxPages
|
|
683
|
-
vi.mocked(pullWorkspaceChanges).mockResolvedValue({
|
|
684
|
-
ok: true,
|
|
685
|
-
data: {
|
|
686
|
-
success: true,
|
|
687
|
-
changes: [],
|
|
688
|
-
nextCursor: 'cursor-next',
|
|
689
|
-
hasMore: true
|
|
690
|
-
}
|
|
691
|
-
});
|
|
692
|
-
const res = await runWorkspacePullSyncService({
|
|
693
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
694
|
-
workspaceId: 'ws-1',
|
|
695
|
-
cursor: null,
|
|
696
|
-
bootstrap: false,
|
|
697
|
-
maxPages: 3
|
|
698
|
-
});
|
|
699
|
-
expect(pullWorkspaceChanges).toHaveBeenCalledTimes(3);
|
|
700
|
-
expect(res.success).toBe(true);
|
|
701
|
-
expect(res.pages).toBe(3);
|
|
702
|
-
});
|
|
703
|
-
});
|
|
704
|
-
describe('ensureCloudWorkspaceReadyForSyncService', () => {
|
|
705
|
-
beforeEach(() => {
|
|
706
|
-
vi.mocked(handshakeWorkspace).mockReset();
|
|
707
|
-
vi.mocked(provisionWorkspace).mockReset();
|
|
708
|
-
});
|
|
709
|
-
it('returns success when handshake succeeds', async () => {
|
|
710
|
-
vi.mocked(handshakeWorkspace).mockResolvedValueOnce({
|
|
711
|
-
ok: true, status: 200, data: {}
|
|
712
|
-
});
|
|
713
|
-
const res = await ensureCloudWorkspaceReadyForSyncService(baseHandshakeInput);
|
|
714
|
-
expect(res.success).toBe(true);
|
|
715
|
-
expect(res.provisioned).toBe(false);
|
|
716
|
-
});
|
|
717
|
-
it('propagates 401 from handshake as auth failure', async () => {
|
|
718
|
-
vi.mocked(handshakeWorkspace).mockResolvedValueOnce({
|
|
719
|
-
ok: false, status: 401, data: { error: 'Invalid session' }
|
|
720
|
-
});
|
|
721
|
-
const res = await ensureCloudWorkspaceReadyForSyncService(baseHandshakeInput);
|
|
722
|
-
expect(res.success).toBe(false);
|
|
723
|
-
expect(res.statusCode).toBe(401);
|
|
724
|
-
expect(res.error).toContain('Invalid session');
|
|
725
|
-
});
|
|
726
|
-
it('propagates 429 from handshake with retryAfterMs', async () => {
|
|
727
|
-
vi.mocked(handshakeWorkspace).mockResolvedValueOnce({
|
|
728
|
-
ok: false, status: 429, retryAfterMs: 45_000, data: { error: 'Rate limited' }
|
|
729
|
-
});
|
|
730
|
-
const res = await ensureCloudWorkspaceReadyForSyncService(baseHandshakeInput);
|
|
731
|
-
expect(res.success).toBe(false);
|
|
732
|
-
expect(res.statusCode).toBe(429);
|
|
733
|
-
expect(res.retryAfterMs).toBe(45_000);
|
|
734
|
-
});
|
|
735
|
-
it('marks status 0 handshake failures as transient', async () => {
|
|
736
|
-
vi.mocked(handshakeWorkspace).mockResolvedValueOnce({
|
|
737
|
-
ok: false, status: 0, data: {}
|
|
738
|
-
});
|
|
739
|
-
const res = await ensureCloudWorkspaceReadyForSyncService(baseHandshakeInput);
|
|
740
|
-
expect(res.success).toBe(false);
|
|
741
|
-
expect(res.statusCode).toBe(0);
|
|
742
|
-
expect(res.transient).toBe(true);
|
|
743
|
-
});
|
|
744
|
-
it('recovers from missing cloud workspace selection by provisioning and retrying handshake', async () => {
|
|
745
|
-
vi.mocked(handshakeWorkspace)
|
|
746
|
-
.mockResolvedValueOnce({
|
|
747
|
-
ok: false,
|
|
748
|
-
status: 400,
|
|
749
|
-
data: {
|
|
750
|
-
code: 'WORKSPACE_ID_REQUIRED',
|
|
751
|
-
error: 'No cloud workspace is selected. Complete workspace setup first.'
|
|
752
|
-
}
|
|
753
|
-
})
|
|
754
|
-
.mockResolvedValueOnce({
|
|
755
|
-
ok: true,
|
|
756
|
-
status: 200,
|
|
757
|
-
data: {}
|
|
758
|
-
});
|
|
759
|
-
vi.mocked(provisionWorkspace).mockResolvedValueOnce({
|
|
760
|
-
ok: true,
|
|
761
|
-
status: 200,
|
|
762
|
-
data: {
|
|
763
|
-
success: true,
|
|
764
|
-
existing: true
|
|
765
|
-
}
|
|
766
|
-
});
|
|
767
|
-
const res = await ensureCloudWorkspaceReadyForSyncService(baseHandshakeInput);
|
|
768
|
-
expect(res.success).toBe(true);
|
|
769
|
-
expect(res.provisioned).toBe(true);
|
|
770
|
-
expect(provisionWorkspace).toHaveBeenCalledWith(mockResolveCloudAuthUrl, {
|
|
771
|
-
workspaceId: 'ws-test',
|
|
772
|
-
name: 'Test Workspace'
|
|
773
|
-
});
|
|
774
|
-
expect(handshakeWorkspace).toHaveBeenCalledTimes(2);
|
|
775
|
-
});
|
|
776
|
-
it('surfaces provisioning failure when recovering missing cloud workspace selection', async () => {
|
|
777
|
-
vi.mocked(handshakeWorkspace).mockResolvedValueOnce({
|
|
778
|
-
ok: false,
|
|
779
|
-
status: 400,
|
|
780
|
-
data: {
|
|
781
|
-
code: 'WORKSPACE_ID_REQUIRED',
|
|
782
|
-
error: 'No cloud workspace is selected. Complete workspace setup first.'
|
|
783
|
-
}
|
|
784
|
-
});
|
|
785
|
-
vi.mocked(provisionWorkspace).mockResolvedValueOnce({
|
|
786
|
-
ok: false,
|
|
787
|
-
status: 409,
|
|
788
|
-
data: {
|
|
789
|
-
code: 'WORKSPACE_ID_ALREADY_EXISTS',
|
|
790
|
-
error: 'Workspace ID already exists'
|
|
791
|
-
}
|
|
792
|
-
});
|
|
793
|
-
const res = await ensureCloudWorkspaceReadyForSyncService(baseHandshakeInput);
|
|
794
|
-
expect(res.success).toBe(false);
|
|
795
|
-
expect(res.statusCode).toBe(409);
|
|
796
|
-
expect(res.error).toContain('already linked to another cloud account');
|
|
797
|
-
});
|
|
798
|
-
it('returns failure when cloudAuthConfigured is false', async () => {
|
|
799
|
-
const res = await ensureCloudWorkspaceReadyForSyncService({
|
|
800
|
-
...baseHandshakeInput,
|
|
801
|
-
cloudAuthConfigured: false
|
|
802
|
-
});
|
|
803
|
-
expect(res.success).toBe(false);
|
|
804
|
-
expect(handshakeWorkspace).not.toHaveBeenCalled();
|
|
805
|
-
});
|
|
806
|
-
it('returns failure when runtimeMode is not local', async () => {
|
|
807
|
-
const res = await ensureCloudWorkspaceReadyForSyncService({
|
|
808
|
-
...baseHandshakeInput,
|
|
809
|
-
runtimeMode: 'cloud'
|
|
810
|
-
});
|
|
811
|
-
expect(res.success).toBe(false);
|
|
812
|
-
expect(handshakeWorkspace).not.toHaveBeenCalled();
|
|
813
|
-
});
|
|
814
|
-
it('returns failure when not authenticated', async () => {
|
|
815
|
-
const res = await ensureCloudWorkspaceReadyForSyncService({
|
|
816
|
-
...baseHandshakeInput,
|
|
817
|
-
isAuthenticated: false
|
|
818
|
-
});
|
|
819
|
-
expect(res.success).toBe(false);
|
|
820
|
-
expect(handshakeWorkspace).not.toHaveBeenCalled();
|
|
821
|
-
});
|
|
822
|
-
it('maps workspace access conflicts to user-facing guidance', async () => {
|
|
823
|
-
vi.mocked(handshakeWorkspace).mockResolvedValueOnce({
|
|
824
|
-
ok: false,
|
|
825
|
-
status: 409,
|
|
826
|
-
data: { code: 'WORKSPACE_ID_MISMATCH', error: 'Workspace mismatch' }
|
|
827
|
-
});
|
|
828
|
-
vi.mocked(provisionWorkspace).mockResolvedValueOnce({
|
|
829
|
-
ok: false,
|
|
830
|
-
status: 409,
|
|
831
|
-
data: { code: 'WORKSPACE_ID_ALREADY_EXISTS', error: 'Workspace ID already exists' }
|
|
832
|
-
});
|
|
833
|
-
const res = await ensureCloudWorkspaceReadyForSyncService(baseHandshakeInput);
|
|
834
|
-
expect(res.success).toBe(false);
|
|
835
|
-
expect(res.statusCode).toBe(409);
|
|
836
|
-
expect(res.error).toContain('already linked to another cloud account');
|
|
837
|
-
expect(res.error).toContain('grant you access');
|
|
838
|
-
});
|
|
839
|
-
it('does not provision a new cloud workspace during attach-cloud mismatch handling', async () => {
|
|
840
|
-
vi.mocked(handshakeWorkspace).mockResolvedValueOnce({
|
|
841
|
-
ok: false,
|
|
842
|
-
status: 409,
|
|
843
|
-
data: { code: 'WORKSPACE_ID_MISMATCH', error: 'Workspace mismatch' }
|
|
844
|
-
});
|
|
845
|
-
const res = await ensureCloudWorkspaceReadyForSyncService({
|
|
846
|
-
...baseHandshakeInput,
|
|
847
|
-
allowProvisionOnMismatch: false
|
|
848
|
-
});
|
|
849
|
-
expect(res.success).toBe(false);
|
|
850
|
-
expect(res.statusCode).toBe(409);
|
|
851
|
-
expect(provisionWorkspace).not.toHaveBeenCalled();
|
|
852
|
-
});
|
|
853
|
-
});
|
|
854
|
-
describe('syncUserGlobalSettingsService transient metadata', () => {
|
|
855
|
-
beforeEach(() => {
|
|
856
|
-
vi.mocked(pullUserSettings).mockReset();
|
|
857
|
-
vi.mocked(pushUserSettings).mockReset();
|
|
858
|
-
});
|
|
859
|
-
it('propagates retryAfterMs + transient for pull 429 failure', async () => {
|
|
860
|
-
vi.mocked(pullUserSettings).mockResolvedValueOnce({
|
|
861
|
-
ok: false,
|
|
862
|
-
status: 429,
|
|
863
|
-
retryAfterMs: 30_000,
|
|
864
|
-
data: { error: 'Rate limited' }
|
|
865
|
-
});
|
|
866
|
-
const res = await syncUserGlobalSettingsService({
|
|
867
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
868
|
-
userId: 'user-1',
|
|
869
|
-
preferCloudOnFirstSync: true,
|
|
870
|
-
getLocalUpdatedAt: () => null,
|
|
871
|
-
buildLocalSettings: () => ({ theme: 'dark' }),
|
|
872
|
-
applyRemoteSettings: async () => { }
|
|
873
|
-
});
|
|
874
|
-
expect(res.success).toBe(false);
|
|
875
|
-
expect(res.statusCode).toBe(429);
|
|
876
|
-
expect(res.retryAfterMs).toBe(30_000);
|
|
877
|
-
expect(res.transient).toBe(true);
|
|
878
|
-
});
|
|
879
|
-
it('propagates transient=true for push status 0 failure', async () => {
|
|
880
|
-
vi.mocked(pullUserSettings).mockResolvedValueOnce({
|
|
881
|
-
ok: true,
|
|
882
|
-
status: 200,
|
|
883
|
-
data: { settings: {}, updatedAt: null }
|
|
884
|
-
});
|
|
885
|
-
vi.mocked(pushUserSettings).mockResolvedValueOnce({
|
|
886
|
-
ok: false,
|
|
887
|
-
status: 0,
|
|
888
|
-
data: {}
|
|
889
|
-
});
|
|
890
|
-
const res = await syncUserGlobalSettingsService({
|
|
891
|
-
resolveCloudAuthUrl: mockResolveCloudAuthUrl,
|
|
892
|
-
userId: 'user-1',
|
|
893
|
-
preferCloudOnFirstSync: false,
|
|
894
|
-
getLocalUpdatedAt: () => null,
|
|
895
|
-
buildLocalSettings: () => ({ theme: 'dark' }),
|
|
896
|
-
applyRemoteSettings: async () => { }
|
|
897
|
-
});
|
|
898
|
-
expect(res.success).toBe(false);
|
|
899
|
-
expect(res.statusCode).toBe(0);
|
|
900
|
-
expect(res.transient).toBe(true);
|
|
901
|
-
});
|
|
902
|
-
});
|
|
903
|
-
});
|