@taskforcehq/taskforce 0.3.305 → 0.3.307
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 +0 -2
- package/dist/Taskforce.module.css +603 -107
- package/dist/TaskforceCore.js +216 -43
- package/dist/TaskforceCore.test.js +611 -28
- package/dist/assets/fonts/CourierPrime-Bold.woff2 +0 -0
- package/dist/assets/fonts/CourierPrime-BoldItalic.woff2 +0 -0
- package/dist/assets/fonts/CourierPrime-Italic.woff2 +0 -0
- package/dist/assets/fonts/CourierPrime-Regular.woff2 +0 -0
- package/dist/assets/fonts/Noir_medium.woff2 +0 -0
- package/dist/assets/fonts/Noir_regular.woff2 +0 -0
- package/dist/assets/fonts/RussoOne-Regular.woff2 +0 -0
- package/dist/assets/fonts/SpecialElite-Regular.woff2 +0 -0
- package/dist/compat/workspaceSyncCompat.js +46 -2
- package/dist/compat/workspaceSyncCompat.test.js +38 -1
- package/dist/components/activity/EntityActivityTimeline.d.ts +34 -0
- package/dist/components/activity/EntityActivityTimeline.js +81 -0
- package/dist/components/context/ContextAttachmentManager.d.ts +14 -0
- package/dist/components/context/ContextAttachmentManager.js +561 -0
- package/dist/components/features/AgentsModule.d.ts +14 -1
- package/dist/components/features/AgentsModule.js +366 -18
- package/dist/components/features/AgentsModule.test.js +507 -8
- package/dist/components/features/AnnotatedAttachmentWorkspace.d.ts +3 -1
- package/dist/components/features/AnnotatedAttachmentWorkspace.js +118 -4
- package/dist/components/features/AnnotatedAttachmentWorkspace.test.js +52 -0
- package/dist/components/features/DocumentIndex.d.ts +2 -2
- package/dist/components/features/DocumentIndex.js +3 -4
- package/dist/components/features/DocumentViewer.d.ts +7 -1
- package/dist/components/features/DocumentViewer.js +62 -4
- package/dist/components/features/DocumentWorkspace.d.ts +10 -2
- package/dist/components/features/DocumentWorkspace.js +15 -4
- package/dist/components/features/DocumentWorkspace.test.js +51 -1
- package/dist/components/features/TaskSettings.d.ts +2 -0
- package/dist/components/features/TaskSettings.js +83 -78
- package/dist/components/features/TaskSettings.test.js +171 -82
- package/dist/components/features/documentWorkspaceModel.d.ts +1 -1
- package/dist/components/task/TaskActionHeader.js +11 -5
- package/dist/components/task/TaskActionHeader.test.js +10 -0
- package/dist/components/task/TaskCard.js +24 -29
- package/dist/components/task/TaskCard.test.js +38 -3
- package/dist/components/task/TaskContextUpload.js +4 -526
- package/dist/components/task/TaskContextUpload.test.js +3 -3
- package/dist/components/task/TaskForm.js +61 -116
- package/dist/components/task/TaskForm.test.js +110 -8
- package/dist/components/task/TaskKanban.d.ts +2 -1
- package/dist/components/task/TaskKanban.js +94 -21
- package/dist/components/task/TaskKanban.test.js +36 -0
- package/dist/components/task/TaskList.js +5 -1
- package/dist/components/task/TaskList.test.js +4 -0
- package/dist/components/ui/EditableAvatarButton.d.ts +18 -0
- package/dist/components/ui/EditableAvatarButton.js +18 -0
- package/dist/components/ui/HierarchyActionBadge.d.ts +10 -0
- package/dist/components/ui/HierarchyActionBadge.js +5 -0
- package/dist/components/views/AppShellHeader.d.ts +3 -1
- package/dist/components/views/AppShellHeader.js +27 -11
- package/dist/components/views/AppShellHeader.test.js +18 -1
- package/dist/components/views/PlanComparisonPage.d.ts +9 -1
- package/dist/components/views/PlanComparisonPage.js +78 -14
- package/dist/components/views/PlanComparisonPage.test.js +257 -0
- package/dist/components/views/PlansPage.js +127 -36
- package/dist/components/views/PlansPage.test.js +294 -12
- package/dist/components/views/StandaloneLayout.js +529 -592
- package/dist/components/views/WidgetView.js +10 -8
- package/dist/components/views/panels/PlanningDrawer.d.ts +25 -5
- package/dist/components/views/panels/PlanningDrawer.js +270 -55
- package/dist/components/views/panels/PlanningDrawer.test.d.ts +1 -0
- package/dist/components/views/panels/PlanningDrawer.test.js +529 -0
- package/dist/components/views/planningScope.d.ts +20 -0
- package/dist/components/views/planningScope.js +25 -0
- package/dist/components/views/planningScope.test.d.ts +1 -0
- package/dist/components/views/planningScope.test.js +60 -0
- package/dist/components/views/standalone/modals/AccountHubModal.d.ts +26 -1
- package/dist/components/views/standalone/modals/AccountHubModal.js +76 -2
- package/dist/components/views/standalone/modals/AccountHubModal.test.js +20 -3
- package/dist/components/views/standalone/modals/AvatarImageManagerModal.d.ts +20 -0
- package/dist/components/views/standalone/modals/AvatarImageManagerModal.js +127 -0
- package/dist/components/views/standalone/modals/EditProfileModal.d.ts +2 -9
- package/dist/components/views/standalone/modals/EditProfileModal.js +3 -2
- package/dist/components/views/standalone/modals/SyncEnableWarningModal.d.ts +9 -0
- package/dist/components/views/standalone/modals/SyncEnableWarningModal.js +6 -0
- package/dist/components/views/standalone/modals/SyncEnableWarningModal.test.d.ts +1 -0
- package/dist/components/views/standalone/modals/SyncEnableWarningModal.test.js +24 -0
- package/dist/components/views/standalone/modals/SyncStatusModal.d.ts +2 -1
- package/dist/components/views/standalone/modals/SyncStatusModal.js +2 -2
- package/dist/config/envSchema.js +1 -0
- package/dist/core/AiProfileService.d.ts +46 -2
- package/dist/core/AiProfileService.js +1073 -82
- package/dist/core/AiProfileService.test.js +19 -1
- package/dist/core/AiProfiles.test.js +1249 -44
- package/dist/core/AttachmentLinkService.d.ts +3 -0
- package/dist/core/AttachmentLinkService.js +110 -23
- package/dist/core/AuthIdentityService.d.ts +107 -0
- package/dist/core/AuthIdentityService.js +284 -0
- package/dist/core/AuthTokenService.d.ts +4 -0
- package/dist/core/AuthTokenService.js +34 -6
- package/dist/core/AuthTokenService.test.js +3 -3
- package/dist/core/EntitlementsPolicy.test.js +2 -2
- package/dist/core/GlobalSettingsService.js +127 -6
- package/dist/core/McpTokenService.d.ts +12 -0
- package/dist/core/McpTokenService.js +44 -1
- package/dist/core/PlanEntitlementService.d.ts +23 -2
- package/dist/core/PlanEntitlementService.js +343 -57
- package/dist/core/PlanFeatureCatalog.test.d.ts +1 -0
- package/dist/core/PlanFeatureCatalog.test.js +84 -0
- package/dist/core/PlanVersionPolicy.test.js +35 -2
- package/dist/core/PlanningEntities.test.js +418 -4
- package/dist/core/SignupMonetizationSettings.test.js +199 -27
- package/dist/core/SyncReconciliationService.js +2 -65
- package/dist/core/SystemAdmin.test.js +42 -42
- package/dist/core/TaskActivityService.d.ts +28 -1
- package/dist/core/TaskActivityService.js +227 -46
- package/dist/core/TaskActivitySync.test.d.ts +1 -0
- package/dist/core/TaskActivitySync.test.js +90 -0
- package/dist/core/TaskAttachmentsCanonical.test.js +51 -1
- package/dist/core/TaskAuditTimeline.test.js +96 -0
- package/dist/core/Taskforce.d.ts +415 -40
- package/dist/core/Taskforce.ids.test.js +58 -0
- package/dist/core/Taskforce.js +1543 -266
- package/dist/core/Taskforce.listTasksSlim.test.d.ts +1 -0
- package/dist/core/Taskforce.listTasksSlim.test.js +91 -0
- package/dist/core/Taskforce.mcpAuth.test.js +109 -0
- package/dist/core/UserProfileAvatarDrafts.test.js +30 -3
- package/dist/core/WorkspaceLifecycleService.js +0 -5
- package/dist/core/WorkspacePermissions.test.js +25 -1
- package/dist/core/WorkspacePlanMode.test.js +117 -16
- package/dist/core/shared.d.ts +1 -1
- package/dist/core/shared.js +5 -1
- package/dist/core/types.d.ts +75 -2
- package/dist/hooks/auth/useTaskforceAuthBootstrap.js +28 -2
- package/dist/hooks/bootstrapTimeouts.d.ts +4 -0
- package/dist/hooks/bootstrapTimeouts.js +8 -0
- package/dist/hooks/bootstrapTimeouts.test.d.ts +1 -0
- package/dist/hooks/bootstrapTimeouts.test.js +12 -0
- package/dist/hooks/sync/bootstrap.js +2 -0
- package/dist/hooks/sync/controlPlane.d.ts +37 -0
- package/dist/hooks/sync/controlPlane.js +78 -0
- package/dist/hooks/sync/controlPlane.test.d.ts +1 -0
- package/dist/hooks/sync/controlPlane.test.js +121 -0
- package/dist/hooks/sync/lifecyclePolicy.d.ts +45 -0
- package/dist/hooks/sync/lifecyclePolicy.js +93 -0
- package/dist/hooks/sync/lifecyclePolicy.test.d.ts +1 -0
- package/dist/hooks/sync/lifecyclePolicy.test.js +124 -0
- package/dist/hooks/sync/orchestratorShared.d.ts +13 -4
- package/dist/hooks/sync/orchestratorShared.js +129 -48
- package/dist/hooks/sync/orchestratorShared.test.js +50 -1
- package/dist/hooks/sync/pullLifecycle.d.ts +31 -0
- package/dist/hooks/sync/pullLifecycle.js +24 -0
- package/dist/hooks/sync/pullLifecycle.test.d.ts +1 -0
- package/dist/hooks/sync/pullLifecycle.test.js +80 -0
- package/dist/hooks/sync/recovery.d.ts +16 -2
- package/dist/hooks/sync/recovery.js +179 -53
- package/dist/hooks/sync/recovery.test.d.ts +1 -0
- package/dist/hooks/sync/recovery.test.js +292 -0
- package/dist/hooks/sync/transfers.d.ts +16 -3
- package/dist/hooks/sync/transfers.js +210 -66
- package/dist/hooks/sync/transfers.test.d.ts +1 -0
- package/dist/hooks/sync/transfers.test.js +928 -0
- package/dist/hooks/sync/useRecentSyncEvents.d.ts +21 -0
- package/dist/hooks/sync/useRecentSyncEvents.js +92 -0
- package/dist/hooks/sync/useRecentSyncEvents.test.d.ts +1 -0
- package/dist/hooks/sync/useRecentSyncEvents.test.js +124 -0
- package/dist/hooks/sync/useSyncStatusActions.d.ts +30 -0
- package/dist/hooks/sync/useSyncStatusActions.js +88 -0
- package/dist/hooks/sync/useSyncStatusActions.test.d.ts +1 -0
- package/dist/hooks/sync/useSyncStatusActions.test.js +133 -0
- package/dist/hooks/sync/useSyncStatusControls.d.ts +25 -0
- package/dist/hooks/sync/useSyncStatusControls.js +60 -0
- package/dist/hooks/sync/useSyncStatusControls.test.d.ts +1 -0
- package/dist/hooks/sync/useSyncStatusControls.test.js +88 -0
- package/dist/hooks/useFilterSort.js +13 -13
- package/dist/hooks/useFilterSort.test.js +87 -1
- package/dist/hooks/useSyncOrchestrator.aiProfiles.test.js +12 -0
- package/dist/hooks/useSyncOrchestrator.d.ts +9 -2
- package/dist/hooks/useSyncOrchestrator.js +409 -183
- package/dist/hooks/useSyncOrchestrator.retry-closure.test.js +407 -0
- package/dist/hooks/useTaskData.js +8 -3
- package/dist/hooks/useTaskData.test.js +45 -0
- package/dist/hooks/useTaskforce.d.ts +145 -52
- package/dist/hooks/useTaskforce.js +592 -253
- package/dist/hooks/useTaskforce.runtime-routing.test.d.ts +1 -0
- package/dist/hooks/useTaskforce.runtime-routing.test.js +246 -0
- package/dist/hooks/useTaskforce.sync-behavior.test.js +2468 -201
- package/dist/hooks/useWorkspaceSyncController.d.ts +1 -0
- package/dist/hooks/useWorkspaceSyncController.js +13 -2
- package/dist/hooks/useWorkspaceSyncController.test.js +48 -0
- package/dist/hooks/workspace/useTaskforceWorkspaceBootstrap.d.ts +16 -0
- package/dist/hooks/workspace/useTaskforceWorkspaceBootstrap.js +328 -40
- package/dist/localization/locales/en-US.d.ts +0 -1
- package/dist/localization/locales/en-US.js +0 -1
- package/dist/localization/locales/es-419.js +0 -1
- package/dist/localization/locales/pt-BR.js +0 -1
- package/dist/mcp/canonicalAssetHelpers.d.ts +16 -4
- package/dist/mcp/canonicalAssetHelpers.js +18 -10
- package/dist/mcp/canonicalAssetHelpers.test.d.ts +1 -0
- package/dist/mcp/canonicalAssetHelpers.test.js +67 -0
- package/dist/mcp/clientIntegrations.d.ts +1 -0
- package/dist/mcp/clientIntegrations.js +25 -0
- package/dist/mcp/clientIntegrations.test.js +14 -3
- package/dist/mcp/clientProfileDefaults.js +3 -3
- package/dist/mcp/collaborationRegistrar.js +7 -7
- package/dist/mcp/documentAssetRegistrar.js +116 -10
- package/dist/mcp/runtime.d.ts +3 -0
- package/dist/mcp/runtime.js +1099 -185
- package/dist/mcp/runtime.test.js +1491 -140
- package/dist/mcp/taskAttachmentTypes.d.ts +1 -1
- package/dist/mcp/taskPlanningRegistrar.js +48 -0
- package/dist/mcp/toolRegistry.d.ts +56 -0
- package/dist/mcp/toolRegistry.js +8 -0
- package/dist/mcp/toolRegistry.test.js +4 -0
- package/dist/migrations/taskSchemaMigrations.d.ts +1 -1
- package/dist/migrations/taskSchemaMigrations.js +192 -61
- package/dist/migrations/taskSchemaMigrations.test.js +15 -0
- package/dist/resources/templates/workflow-sources/workflowDocs.mjs +6 -6
- package/dist/resources/templates/workflows/collaborate.yaml +1 -1
- package/dist/resources/templates/workflows/evaluate.yaml +2 -2
- package/dist/resources/templates/workflows/plan.yaml +1 -1
- package/dist/resources/templates/workflows/review.yaml +2 -2
- package/dist/server/aiProfileAvatarAssets.d.ts +49 -0
- package/dist/server/aiProfileAvatarAssets.js +319 -0
- package/dist/server/aiProfileAvatarAssets.test.d.ts +1 -0
- package/dist/server/aiProfileAvatarAssets.test.js +213 -0
- package/dist/server/annotatedAttachmentsRoutes.test.js +69 -10
- package/dist/server/auth/providers/apple.d.ts +33 -0
- package/dist/server/auth/providers/apple.js +82 -0
- package/dist/server/auth/providers/appleClientSecret.d.ts +37 -0
- package/dist/server/auth/providers/appleClientSecret.js +65 -0
- package/dist/server/auth/providers/github.d.ts +26 -0
- package/dist/server/auth/providers/github.js +86 -0
- package/dist/server/auth/providers/google.d.ts +21 -0
- package/dist/server/auth/providers/google.js +56 -0
- package/dist/server/auth/providers/types.d.ts +21 -0
- package/dist/server/auth/providers/types.js +1 -0
- package/dist/server/auth.d.ts +2 -0
- package/dist/server/auth.js +6 -3
- package/dist/server/documentReviewRoutes.test.js +36 -3
- package/dist/server/index.cookieProxy.test.js +1 -0
- package/dist/server/index.d.ts +12 -0
- package/dist/server/index.js +124 -9
- package/dist/server/index.rateLimit.test.js +3 -0
- package/dist/server/index.test.js +111 -3
- package/dist/server/routes/admin.d.ts +3 -0
- package/dist/server/routes/admin.js +459 -28
- package/dist/server/routes/annotatedAttachments.js +51 -0
- package/dist/server/routes/auth.d.ts +26 -2
- package/dist/server/routes/auth.js +1170 -71
- package/dist/server/routes/authSupport.d.ts +5 -1
- package/dist/server/routes/authSupport.js +13 -2
- package/dist/server/routes/billing.js +372 -35
- package/dist/server/routes/billing.test.js +595 -12
- package/dist/server/routes/documents.d.ts +1 -0
- package/dist/server/routes/documents.js +182 -70
- package/dist/server/routes/shared.d.ts +28 -2
- package/dist/server/routes/shared.js +69 -14
- package/dist/server/routes/sync.integration.test.js +658 -39
- package/dist/server/routes/sync.js +74 -608
- package/dist/server/routes/syncAuxRoutes.d.ts +15 -0
- package/dist/server/routes/syncAuxRoutes.js +91 -0
- package/dist/server/routes/syncAuxRoutes.test.d.ts +1 -0
- package/dist/server/routes/syncAuxRoutes.test.js +158 -0
- package/dist/server/routes/syncPullApplyRoutes.d.ts +36 -0
- package/dist/server/routes/syncPullApplyRoutes.js +204 -0
- package/dist/server/routes/syncPushRoutes.d.ts +24 -0
- package/dist/server/routes/syncPushRoutes.js +212 -0
- package/dist/server/routes/syncRouteGuards.d.ts +36 -0
- package/dist/server/routes/syncRouteGuards.js +67 -0
- package/dist/server/routes/syncRouteGuards.test.d.ts +1 -0
- package/dist/server/routes/syncRouteGuards.test.js +94 -0
- package/dist/server/routes/syncRouteTypes.d.ts +13 -0
- package/dist/server/routes/syncRouteTypes.js +1 -0
- package/dist/server/routes/syncSnapshotRoutes.d.ts +66 -0
- package/dist/server/routes/syncSnapshotRoutes.js +182 -0
- package/dist/server/routes/tasks.js +55 -10
- package/dist/server/routes/workspaces.js +36 -5
- package/dist/server/routes.js +147 -11
- package/dist/server/routes.test.js +2704 -183
- package/dist/services/workflowExportSnapshots.test.js +2 -0
- package/dist/shared/aiProfileSeatScope.d.ts +5 -0
- package/dist/shared/aiProfileSeatScope.js +21 -0
- package/dist/shared/aiProfileSurfaceType.d.ts +1 -1
- package/dist/shared/aiProfileSurfaceType.js +10 -8
- package/dist/shared/passwordPolicy.d.ts +13 -0
- package/dist/shared/passwordPolicy.js +84 -0
- package/dist/shared/passwordPolicy.test.d.ts +1 -0
- package/dist/shared/passwordPolicy.test.js +34 -0
- package/dist/storage/objectStorage.d.ts +1 -0
- package/dist/storage/objectStorage.js +2 -1
- package/dist/storage/objectStorageClient.d.ts +1 -0
- package/dist/storage/objectStorageClient.js +41 -8
- package/dist/storage/objectStorageClient.test.js +26 -1
- package/dist/storage/objectStorageConfig.js +3 -1
- package/dist/storage/objectStorageConfig.test.js +13 -1
- package/dist/storage/workspaceAssetStore.d.ts +15 -3
- package/dist/storage/workspaceAssetStore.js +132 -44
- package/dist/storage/workspaceAssetStore.test.js +93 -6
- package/dist/styles/fonts.css +70 -0
- package/dist/sync/collaborationSyncPayload.d.ts +6 -1
- package/dist/sync/collaborationSyncPayload.js +19 -11
- package/dist/sync/collaborationSyncPayload.test.js +14 -1
- package/dist/sync/collaborationSyncState.d.ts +3 -3
- package/dist/sync/collaborationSyncState.js +19 -12
- package/dist/sync/contentSyncPayload.d.ts +5 -1
- package/dist/sync/contentSyncPayload.js +9 -0
- package/dist/sync/contentSyncPayload.test.js +39 -0
- package/dist/sync/contentSyncState.d.ts +9 -9
- package/dist/sync/contentSyncState.js +248 -107
- package/dist/sync/planningSyncPayload.js +5 -0
- package/dist/sync/planningSyncPayload.test.js +24 -0
- package/dist/sync/syncApplyHandlers.d.ts +11 -4
- package/dist/sync/syncApplyHandlers.js +115 -42
- package/dist/sync/syncApplyHandlers.test.js +251 -4
- package/dist/sync/syncFieldSemantics.d.ts +12 -0
- package/dist/sync/syncFieldSemantics.js +55 -0
- package/dist/sync/syncResourceAdapters.d.ts +46 -0
- package/dist/sync/syncResourceAdapters.js +79 -0
- package/dist/sync/syncService.d.ts +6 -0
- package/dist/sync/syncService.js +65 -1
- package/dist/sync/syncService.test.js +96 -3
- package/dist/sync/taskSyncChangeKey.d.ts +2 -0
- package/dist/sync/taskSyncChangeKey.js +143 -0
- package/dist/sync/taskSyncPayload.js +3 -8
- package/dist/sync/workspacePullFeed.d.ts +4 -0
- package/dist/sync/workspacePullFeed.js +132 -72
- package/dist/sync/workspacePullFeed.test.js +92 -0
- package/dist/sync/workspaceRepair.js +5 -2
- package/dist/sync/workspaceSyncModel.d.ts +73 -6
- package/dist/sync/workspaceSyncModel.js +342 -73
- package/dist/sync/workspaceSyncModel.test.js +559 -14
- package/dist/sync/workspaceSyncState.d.ts +17 -0
- package/dist/sync/workspaceSyncState.js +2 -1
- package/dist/sync/workspaceSyncSurface.js +3 -8
- package/dist/types.d.ts +50 -2
- package/dist/ui/assets/AgentsModule-2y82_3DO.js +1 -0
- package/dist/ui/assets/AnnotatedAttachmentWorkspace-BTLZZCiQ.js +3 -0
- package/dist/ui/assets/AnnotatedAttachmentWorkspace-BVKew-mH.css +1 -0
- package/dist/ui/assets/ContextAttachmentManager-D2epuNnG.js +3 -0
- package/dist/ui/assets/CourierPrime-Bold-BuLj_dpw.woff2 +0 -0
- package/dist/ui/assets/CourierPrime-BoldItalic-BrK2pUkZ.woff2 +0 -0
- package/dist/ui/assets/CourierPrime-Italic-DFUZK5Ey.woff2 +0 -0
- package/dist/ui/assets/CourierPrime-Regular-BsKphzVf.woff2 +0 -0
- package/dist/ui/assets/DocumentWorkspace-D4rJKXzd.css +1 -0
- package/dist/ui/assets/DocumentWorkspace-sVa-3Do6.js +252 -0
- package/dist/ui/assets/EntityActivityTimeline-DyqvvhuF.css +1 -0
- package/dist/ui/assets/EntityActivityTimeline-Zods27y_.js +1 -0
- package/dist/ui/assets/{InitiativesModule-Dhm7M8e7.js → InitiativesModule-D4XseTwW.js} +1 -1
- package/dist/ui/assets/Noir_medium-bxQwKGzB.woff2 +0 -0
- package/dist/ui/assets/Noir_regular-ojf2kxlG.woff2 +0 -0
- package/dist/ui/assets/PlansPage-D5AcbO0L.js +1 -0
- package/dist/ui/assets/PlansPage-Dvqsz5zc.css +1 -0
- package/dist/ui/assets/RussoOne-Regular-Cu_qq_qC.woff2 +0 -0
- package/dist/ui/assets/SpecialElite-Regular-Di6gSvAS.woff2 +0 -0
- package/dist/ui/assets/TaskContextUpload-uC5qx4Bv.js +1 -0
- package/dist/ui/assets/TaskSettings-CqvPAsTv.js +9 -0
- package/dist/ui/assets/{WorkflowsModule-BcS4afRn.js → WorkflowsModule-oOA9bcdK.js} +4 -4
- package/dist/ui/assets/documentReferences-DPZuTgHh.js +1 -0
- package/dist/ui/assets/index-607WPo_X.js +4 -0
- package/dist/ui/assets/index-CYyodXsg.css +1 -0
- package/dist/ui/assets/{vendor-icons-BSUaRwF8.js → vendor-icons-B32hGuF2.js} +1 -1
- package/dist/ui/fonts/CourierPrime-Bold.ttf +0 -0
- package/dist/ui/fonts/CourierPrime-Bold.woff2 +0 -0
- package/dist/ui/fonts/CourierPrime-BoldItalic.ttf +0 -0
- package/dist/ui/fonts/CourierPrime-BoldItalic.woff2 +0 -0
- package/dist/ui/fonts/CourierPrime-Italic.ttf +0 -0
- package/dist/ui/fonts/CourierPrime-Italic.woff2 +0 -0
- package/dist/ui/fonts/CourierPrime-Regular.ttf +0 -0
- package/dist/ui/fonts/CourierPrime-Regular.woff2 +0 -0
- package/dist/ui/fonts/Noir_medium.otf +0 -0
- package/dist/ui/fonts/Noir_medium.woff2 +0 -0
- package/dist/ui/fonts/Noir_regular.otf +0 -0
- package/dist/ui/fonts/Noir_regular.woff2 +0 -0
- package/dist/ui/fonts/RussoOne-Regular.woff2 +0 -0
- package/dist/ui/fonts/SpecialElite-Regular.ttf +0 -0
- package/dist/ui/fonts/SpecialElite-Regular.woff2 +0 -0
- package/dist/ui/index.html +3 -3
- package/dist/ui/product/agent manager.png +0 -0
- package/dist/ui/product/agent_manager_02.png +0 -0
- package/dist/utils/accountProfileSummaryCache.d.ts +5 -0
- package/dist/utils/aiProfileEvents.d.ts +7 -0
- package/dist/utils/aiProfileEvents.js +6 -0
- package/dist/utils/assignees.d.ts +8 -0
- package/dist/utils/assignees.js +10 -1
- package/dist/utils/assignees.test.d.ts +1 -0
- package/dist/utils/assignees.test.js +25 -0
- package/dist/utils/avatarDisplay.d.ts +1 -0
- package/dist/utils/avatarDisplay.js +15 -0
- package/dist/utils/avatarUpload.d.ts +27 -0
- package/dist/utils/avatarUpload.js +132 -0
- package/dist/utils/avatarUpload.test.d.ts +1 -0
- package/dist/utils/avatarUpload.test.js +40 -0
- package/dist/utils/bootstrapTrace.d.ts +7 -0
- package/dist/utils/bootstrapTrace.js +29 -0
- package/dist/utils/commercialLifecyclePresentation.js +3 -0
- package/dist/utils/contextAssetEvents.d.ts +2 -0
- package/dist/utils/contextFiles.d.ts +3 -1
- package/dist/utils/contextFiles.js +2 -1
- package/dist/utils/syncEventDetails.d.ts +3 -0
- package/dist/utils/syncEventDetails.js +64 -0
- package/dist/utils/syncEventDetails.test.d.ts +1 -0
- package/dist/utils/syncEventDetails.test.js +23 -0
- package/dist/utils/syncEventPresentation.d.ts +15 -0
- package/dist/utils/syncEventPresentation.js +129 -0
- package/dist/utils/syncEventPresentation.test.d.ts +1 -0
- package/dist/utils/syncEventPresentation.test.js +64 -0
- package/dist/utils/syncStatusPresentation.d.ts +72 -0
- package/dist/utils/syncStatusPresentation.js +217 -0
- package/dist/utils/syncStatusPresentation.test.d.ts +1 -0
- package/dist/utils/syncStatusPresentation.test.js +164 -0
- package/dist/utils/taskActivity.d.ts +9 -1
- package/dist/utils/taskActivity.js +290 -22
- package/dist/utils/taskActivity.test.js +141 -8
- package/dist/utils/taskSearch.d.ts +22 -0
- package/dist/utils/taskSearch.js +87 -0
- package/dist/utils/taskSearch.test.d.ts +1 -0
- package/dist/utils/taskSearch.test.js +69 -0
- package/dist/utils/taskUtils.js +10 -3
- package/dist/utils/taskUtils.test.d.ts +1 -0
- package/dist/utils/taskUtils.test.js +19 -0
- package/dist/utils/workspaceSyncPresentation.d.ts +4 -0
- package/dist/utils/workspaceSyncPresentation.js +68 -2
- package/dist/utils/workspaceSyncPresentation.test.js +36 -1
- package/package.json +3 -2
- package/scripts/export-sqlite-to-postgres.mjs +7 -9
- package/scripts/run-e2e-realtime.sh +17 -3
- package/scripts/run-smoke.sh +17 -5
- package/scripts/run-soak.sh +17 -5
- package/src/resources/templates/workflow-sources/workflowDocs.mjs +6 -6
- package/src/resources/templates/workflows/collaborate.yaml +1 -1
- package/src/resources/templates/workflows/evaluate.yaml +2 -2
- package/src/resources/templates/workflows/plan.yaml +1 -1
- package/src/resources/templates/workflows/review.yaml +2 -2
- package/dist/ui/assets/AgentsModule-N2MnQBZk.js +0 -1
- package/dist/ui/assets/AnnotatedAttachmentWorkspace-BG6P_GVW.js +0 -3
- package/dist/ui/assets/AnnotatedAttachmentWorkspace-BaS2VwIr.css +0 -1
- package/dist/ui/assets/DocumentWorkspace-B3nV_Gc5.css +0 -1
- package/dist/ui/assets/DocumentWorkspace-DRbDMwh8.js +0 -252
- package/dist/ui/assets/PlansPage-C2dd2n1X.css +0 -1
- package/dist/ui/assets/PlansPage-Cq0zXj3I.js +0 -1
- package/dist/ui/assets/RussoOne-Regular-C3BxZIj7.ttf +0 -0
- package/dist/ui/assets/TaskSettings-ln0aF7xc.js +0 -9
- package/dist/ui/assets/index-C2-OXZV7.css +0 -1
- package/dist/ui/assets/index-DcSI5F86.js +0 -6
- package/scripts/migrate-planning-model.ts +0 -233
|
@@ -186,8 +186,49 @@ describe('useTaskforce sync behavior', () => {
|
|
|
186
186
|
expect(childTask?.status).toBe('in-progress');
|
|
187
187
|
});
|
|
188
188
|
});
|
|
189
|
-
it('keeps
|
|
190
|
-
const
|
|
189
|
+
it('keeps a created workstream visible even if the follow-up planning refresh is stale', async () => {
|
|
190
|
+
const initialInitiative = {
|
|
191
|
+
id: 'initiative-1',
|
|
192
|
+
title: 'AI & MCP',
|
|
193
|
+
description: 'Planning initiative',
|
|
194
|
+
ownerId: null,
|
|
195
|
+
createdAt: '2026-03-15T10:00:00.000Z',
|
|
196
|
+
updatedAt: '2026-03-15T10:00:00.000Z',
|
|
197
|
+
referenceNumber: 5,
|
|
198
|
+
referenceLabel: 'IN-5',
|
|
199
|
+
isArchived: false,
|
|
200
|
+
comments: [],
|
|
201
|
+
attachments: []
|
|
202
|
+
};
|
|
203
|
+
const initialWorkstream = {
|
|
204
|
+
id: 'workstream-1',
|
|
205
|
+
title: 'MCP Tools',
|
|
206
|
+
description: 'Existing workstream',
|
|
207
|
+
ownerId: null,
|
|
208
|
+
initiativeId: 'initiative-1',
|
|
209
|
+
createdAt: '2026-03-15T10:05:00.000Z',
|
|
210
|
+
updatedAt: '2026-03-15T10:05:00.000Z',
|
|
211
|
+
referenceNumber: 640,
|
|
212
|
+
referenceLabel: 'WS-640',
|
|
213
|
+
isArchived: false,
|
|
214
|
+
comments: [],
|
|
215
|
+
attachments: []
|
|
216
|
+
};
|
|
217
|
+
const createdWorkstream = {
|
|
218
|
+
id: 'workstream-2',
|
|
219
|
+
title: 'Agent Manager',
|
|
220
|
+
description: 'New workstream',
|
|
221
|
+
ownerId: null,
|
|
222
|
+
initiativeId: 'initiative-1',
|
|
223
|
+
createdAt: '2026-03-15T10:10:00.000Z',
|
|
224
|
+
updatedAt: '2026-03-15T10:10:00.000Z',
|
|
225
|
+
referenceNumber: 641,
|
|
226
|
+
referenceLabel: 'WS-641',
|
|
227
|
+
isArchived: false,
|
|
228
|
+
comments: [],
|
|
229
|
+
attachments: []
|
|
230
|
+
};
|
|
231
|
+
vi.stubGlobal('fetch', vi.fn((url, init) => {
|
|
191
232
|
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
192
233
|
return jsonResponse({ config: { runtimeMode: 'local', workspaceMode: 'single-local', authSource: 'cloud' } });
|
|
193
234
|
}
|
|
@@ -212,9 +253,6 @@ describe('useTaskforce sync behavior', () => {
|
|
|
212
253
|
}
|
|
213
254
|
if (url.includes('/api/taskforce/config')) {
|
|
214
255
|
return jsonResponse({
|
|
215
|
-
theme: 'dawn',
|
|
216
|
-
globalTheme: 'dawn',
|
|
217
|
-
themeUseGlobalDefault: true,
|
|
218
256
|
projectName: 'Test Project',
|
|
219
257
|
workspaceId: 'workspace-local-active',
|
|
220
258
|
runtimeMode: 'local',
|
|
@@ -241,38 +279,78 @@ describe('useTaskforce sync behavior', () => {
|
|
|
241
279
|
return jsonResponse({ tasks: [activeTask] });
|
|
242
280
|
if (url.includes('/api/taskforce/archive'))
|
|
243
281
|
return jsonResponse({ archived: [] });
|
|
244
|
-
if (url.includes('/api/taskforce/
|
|
282
|
+
if (url.includes('/api/taskforce/planning/bootstrap')) {
|
|
283
|
+
return jsonResponse({
|
|
284
|
+
initiatives: [initialInitiative],
|
|
285
|
+
workstreams: [initialWorkstream],
|
|
286
|
+
workstreamTaskSummaries: [{
|
|
287
|
+
workstreamId: initialWorkstream.id,
|
|
288
|
+
taskCount: 1,
|
|
289
|
+
completedTaskCount: 0,
|
|
290
|
+
tasks: [{
|
|
291
|
+
id: activeTask.id,
|
|
292
|
+
title: activeTask.title,
|
|
293
|
+
status: activeTask.status,
|
|
294
|
+
}],
|
|
295
|
+
}],
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
if (url.includes('/api/taskforce/workstream') && String(init?.method || '').toUpperCase() === 'POST') {
|
|
299
|
+
return jsonResponse(createdWorkstream, 201);
|
|
300
|
+
}
|
|
301
|
+
if (url.includes('/api/taskforce/data-version')) {
|
|
245
302
|
return jsonResponse({ dataVersion: 1 });
|
|
303
|
+
}
|
|
246
304
|
return jsonResponse({});
|
|
247
|
-
});
|
|
248
|
-
vi.stubGlobal('fetch', fetchMock);
|
|
305
|
+
}));
|
|
249
306
|
const { result } = renderHook(() => useTaskforce({ config: {} }), { wrapper });
|
|
250
307
|
await waitFor(() => {
|
|
251
|
-
expect(result.current.
|
|
308
|
+
expect(result.current.tasks.some((task) => task.id === activeTask.id)).toBe(true);
|
|
252
309
|
});
|
|
253
310
|
await act(async () => {
|
|
254
|
-
result.current.
|
|
255
|
-
|
|
311
|
+
await result.current.createWorkstream({
|
|
312
|
+
title: createdWorkstream.title,
|
|
313
|
+
description: createdWorkstream.description,
|
|
314
|
+
initiativeId: createdWorkstream.initiativeId
|
|
315
|
+
});
|
|
256
316
|
});
|
|
257
317
|
await waitFor(() => {
|
|
258
|
-
expect(
|
|
259
|
-
expect(result.current.currentTheme).toBe('dawn');
|
|
318
|
+
expect(result.current.workstreams.some((workstream) => workstream.id === createdWorkstream.id)).toBe(true);
|
|
260
319
|
});
|
|
261
320
|
});
|
|
262
|
-
it('
|
|
263
|
-
|
|
321
|
+
it('falls back to legacy planning endpoints when bootstrap is unavailable during startup', async () => {
|
|
322
|
+
const initiative = {
|
|
323
|
+
id: 'initiative-fallback-1',
|
|
324
|
+
title: 'Fallback initiative',
|
|
325
|
+
description: null,
|
|
326
|
+
createdAt: '2026-03-15T10:00:00.000Z',
|
|
327
|
+
};
|
|
328
|
+
const workstream = {
|
|
329
|
+
id: 'workstream-fallback-1',
|
|
330
|
+
title: 'Fallback workstream',
|
|
331
|
+
description: null,
|
|
332
|
+
initiativeId: initiative.id,
|
|
333
|
+
createdAt: '2026-03-15T10:05:00.000Z',
|
|
334
|
+
};
|
|
335
|
+
vi.stubGlobal('fetch', vi.fn((url) => {
|
|
264
336
|
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
265
337
|
return jsonResponse({ config: { runtimeMode: 'local', workspaceMode: 'single-local', authSource: 'cloud' } });
|
|
266
338
|
}
|
|
267
|
-
if (url.includes('/api/taskforce/
|
|
268
|
-
return jsonResponse({ success: true, state: {} });
|
|
269
|
-
}
|
|
270
|
-
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
339
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
271
340
|
return jsonResponse({
|
|
272
|
-
|
|
273
|
-
|
|
341
|
+
authenticated: false,
|
|
342
|
+
authRequiredForApi: false,
|
|
343
|
+
betaAccess: true,
|
|
344
|
+
userId: 'anonymous',
|
|
345
|
+
email: '',
|
|
346
|
+
workspaceId: 'workspace-local-active'
|
|
274
347
|
});
|
|
275
348
|
}
|
|
349
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
350
|
+
return jsonResponse({ success: true, state: {} });
|
|
351
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
352
|
+
return jsonResponse({ success: true, state: { version: 2, enabled: false, phase: 'idle', pullCursor: null } });
|
|
353
|
+
}
|
|
276
354
|
if (url.includes('/api/taskforce/config')) {
|
|
277
355
|
return jsonResponse({
|
|
278
356
|
projectName: 'Test Project',
|
|
@@ -285,72 +363,75 @@ describe('useTaskforce sync behavior', () => {
|
|
|
285
363
|
}
|
|
286
364
|
});
|
|
287
365
|
}
|
|
288
|
-
if (url.includes('/api/taskforce/global-settings'))
|
|
366
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
289
367
|
return jsonResponse({});
|
|
290
|
-
|
|
291
|
-
if (url.includes('/api/taskforce/categories')) {
|
|
368
|
+
if (url.includes('/api/taskforce/categories'))
|
|
292
369
|
return jsonResponse({ categories: [{ value: 'general', label: 'General' }] });
|
|
293
|
-
|
|
294
|
-
if (url.includes('/api/taskforce/types')) {
|
|
370
|
+
if (url.includes('/api/taskforce/types'))
|
|
295
371
|
return jsonResponse({ types: [] });
|
|
296
|
-
|
|
297
|
-
if (url.includes('/api/taskforce/priorities')) {
|
|
372
|
+
if (url.includes('/api/taskforce/priorities'))
|
|
298
373
|
return jsonResponse({ priorities: [] });
|
|
299
|
-
|
|
300
|
-
if (url.includes('/api/taskforce/approaches')) {
|
|
374
|
+
if (url.includes('/api/taskforce/approaches'))
|
|
301
375
|
return jsonResponse({ approaches: [] });
|
|
302
|
-
|
|
303
|
-
if (url.includes('/api/taskforce/specialists')) {
|
|
376
|
+
if (url.includes('/api/taskforce/specialists'))
|
|
304
377
|
return jsonResponse({ specialists: [] });
|
|
305
|
-
|
|
306
|
-
if (url.includes('/api/taskforce/tasks')) {
|
|
378
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
307
379
|
return jsonResponse({ tasks: [activeTask] });
|
|
308
|
-
|
|
309
|
-
if (url.includes('/api/taskforce/archive')) {
|
|
380
|
+
if (url.includes('/api/taskforce/archive'))
|
|
310
381
|
return jsonResponse({ archived: [] });
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
updatedAt: '2026-03-15T10:20:00.000Z'
|
|
319
|
-
});
|
|
320
|
-
}
|
|
321
|
-
if (url.includes('/api/taskforce/data-version')) {
|
|
382
|
+
if (url.includes('/api/taskforce/planning/bootstrap'))
|
|
383
|
+
return jsonResponse({ error: 'missing' }, 404);
|
|
384
|
+
if (url.includes('/api/taskforce/initiatives'))
|
|
385
|
+
return jsonResponse([initiative]);
|
|
386
|
+
if (url.includes('/api/taskforce/workstreams'))
|
|
387
|
+
return jsonResponse([workstream]);
|
|
388
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
322
389
|
return jsonResponse({ dataVersion: 1 });
|
|
323
|
-
}
|
|
324
390
|
return jsonResponse({});
|
|
325
391
|
}));
|
|
326
392
|
const { result } = renderHook(() => useTaskforce({ config: {} }), { wrapper });
|
|
327
393
|
await waitFor(() => {
|
|
328
|
-
expect(result.current.tasks.some((task) => task.id ===
|
|
329
|
-
});
|
|
330
|
-
await act(async () => {
|
|
331
|
-
await result.current.handleArchiveTask(activeTask);
|
|
394
|
+
expect(result.current.tasks.some((task) => task.id === activeTask.id)).toBe(true);
|
|
332
395
|
});
|
|
333
396
|
await waitFor(() => {
|
|
334
|
-
expect(result.current.
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
expect(archived?.status).toBe('done');
|
|
338
|
-
});
|
|
397
|
+
expect(result.current.initiatives.some((item) => item.id === initiative.id)).toBe(true);
|
|
398
|
+
expect(result.current.workstreams.some((item) => item.id === workstream.id)).toBe(true);
|
|
399
|
+
}, { timeout: 3000 });
|
|
339
400
|
});
|
|
340
|
-
it('
|
|
341
|
-
|
|
401
|
+
it('retries planning bootstrap after a transient startup failure', async () => {
|
|
402
|
+
const initiative = {
|
|
403
|
+
id: 'initiative-retry-1',
|
|
404
|
+
title: 'Retry initiative',
|
|
405
|
+
description: null,
|
|
406
|
+
createdAt: '2026-03-15T10:00:00.000Z',
|
|
407
|
+
};
|
|
408
|
+
const workstream = {
|
|
409
|
+
id: 'workstream-retry-1',
|
|
410
|
+
title: 'Retry workstream',
|
|
411
|
+
description: null,
|
|
412
|
+
initiativeId: initiative.id,
|
|
413
|
+
createdAt: '2026-03-15T10:05:00.000Z',
|
|
414
|
+
};
|
|
415
|
+
let planningBootstrapCalls = 0;
|
|
416
|
+
vi.stubGlobal('fetch', vi.fn((url) => {
|
|
342
417
|
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
343
418
|
return jsonResponse({ config: { runtimeMode: 'local', workspaceMode: 'single-local', authSource: 'cloud' } });
|
|
344
419
|
}
|
|
345
|
-
if (url.includes('/api/taskforce/
|
|
346
|
-
return jsonResponse({ success: true, state: {} });
|
|
347
|
-
}
|
|
348
|
-
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
420
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
349
421
|
return jsonResponse({
|
|
350
|
-
|
|
351
|
-
|
|
422
|
+
authenticated: false,
|
|
423
|
+
authRequiredForApi: false,
|
|
424
|
+
betaAccess: true,
|
|
425
|
+
userId: 'anonymous',
|
|
426
|
+
email: '',
|
|
427
|
+
workspaceId: 'workspace-local-active'
|
|
352
428
|
});
|
|
353
429
|
}
|
|
430
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
431
|
+
return jsonResponse({ success: true, state: {} });
|
|
432
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
433
|
+
return jsonResponse({ success: true, state: { version: 2, enabled: false, phase: 'idle', pullCursor: null } });
|
|
434
|
+
}
|
|
354
435
|
if (url.includes('/api/taskforce/config')) {
|
|
355
436
|
return jsonResponse({
|
|
356
437
|
projectName: 'Test Project',
|
|
@@ -363,71 +444,85 @@ describe('useTaskforce sync behavior', () => {
|
|
|
363
444
|
}
|
|
364
445
|
});
|
|
365
446
|
}
|
|
366
|
-
if (url.includes('/api/taskforce/global-settings'))
|
|
447
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
367
448
|
return jsonResponse({});
|
|
368
|
-
|
|
369
|
-
if (url.includes('/api/taskforce/categories')) {
|
|
449
|
+
if (url.includes('/api/taskforce/categories'))
|
|
370
450
|
return jsonResponse({ categories: [{ value: 'general', label: 'General' }] });
|
|
371
|
-
|
|
372
|
-
if (url.includes('/api/taskforce/types')) {
|
|
451
|
+
if (url.includes('/api/taskforce/types'))
|
|
373
452
|
return jsonResponse({ types: [] });
|
|
374
|
-
|
|
375
|
-
if (url.includes('/api/taskforce/priorities')) {
|
|
453
|
+
if (url.includes('/api/taskforce/priorities'))
|
|
376
454
|
return jsonResponse({ priorities: [] });
|
|
377
|
-
|
|
378
|
-
if (url.includes('/api/taskforce/approaches')) {
|
|
455
|
+
if (url.includes('/api/taskforce/approaches'))
|
|
379
456
|
return jsonResponse({ approaches: [] });
|
|
380
|
-
|
|
381
|
-
if (url.includes('/api/taskforce/specialists')) {
|
|
457
|
+
if (url.includes('/api/taskforce/specialists'))
|
|
382
458
|
return jsonResponse({ specialists: [] });
|
|
383
|
-
|
|
384
|
-
if (url.includes('/api/taskforce/tasks')) {
|
|
459
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
385
460
|
return jsonResponse({ tasks: [activeTask] });
|
|
386
|
-
|
|
387
|
-
if (url.includes('/api/taskforce/archive')) {
|
|
461
|
+
if (url.includes('/api/taskforce/archive'))
|
|
388
462
|
return jsonResponse({ archived: [] });
|
|
389
|
-
|
|
390
|
-
|
|
463
|
+
if (url.includes('/api/taskforce/planning/bootstrap')) {
|
|
464
|
+
planningBootstrapCalls += 1;
|
|
465
|
+
if (planningBootstrapCalls === 1) {
|
|
466
|
+
return Promise.reject(new Error('temporary failure'));
|
|
467
|
+
}
|
|
391
468
|
return jsonResponse({
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
updatedAt: '2026-03-15T10:25:00.000Z'
|
|
469
|
+
initiatives: [initiative],
|
|
470
|
+
workstreams: [workstream],
|
|
471
|
+
workstreamTaskSummaries: [],
|
|
396
472
|
});
|
|
397
473
|
}
|
|
398
|
-
if (url.includes('/api/taskforce/data-version'))
|
|
474
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
399
475
|
return jsonResponse({ dataVersion: 1 });
|
|
400
|
-
}
|
|
401
476
|
return jsonResponse({});
|
|
402
477
|
}));
|
|
403
478
|
const { result } = renderHook(() => useTaskforce({ config: {} }), { wrapper });
|
|
404
479
|
await waitFor(() => {
|
|
405
|
-
expect(
|
|
406
|
-
});
|
|
407
|
-
await act(async () => {
|
|
408
|
-
await result.current.handleToggleComplete(activeTask);
|
|
480
|
+
expect(planningBootstrapCalls).toBeGreaterThanOrEqual(1);
|
|
409
481
|
});
|
|
410
482
|
await waitFor(() => {
|
|
411
|
-
|
|
412
|
-
expect(completed?.status).toBe('done');
|
|
413
|
-
expect(completed?.completedAt).toBe('2026-03-15T10:25:00.000Z');
|
|
483
|
+
expect(result.current.tasks.some((task) => task.id === activeTask.id)).toBe(true);
|
|
414
484
|
});
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
485
|
+
await waitFor(() => {
|
|
486
|
+
expect(result.current.initiatives.some((item) => item.id === initiative.id)).toBe(true);
|
|
487
|
+
expect(result.current.workstreams.some((item) => item.id === workstream.id)).toBe(true);
|
|
488
|
+
}, { timeout: 7000 });
|
|
489
|
+
}, 10000);
|
|
490
|
+
it('retries a timed-out planning bootstrap without falling back to legacy endpoints during startup', async () => {
|
|
491
|
+
const initiative = {
|
|
492
|
+
id: 'initiative-timeout-1',
|
|
493
|
+
title: 'Timeout initiative',
|
|
494
|
+
description: null,
|
|
495
|
+
createdAt: '2026-03-15T10:00:00.000Z',
|
|
496
|
+
};
|
|
497
|
+
const workstream = {
|
|
498
|
+
id: 'workstream-timeout-1',
|
|
499
|
+
title: 'Timeout workstream',
|
|
500
|
+
description: null,
|
|
501
|
+
initiativeId: initiative.id,
|
|
502
|
+
createdAt: '2026-03-15T10:05:00.000Z',
|
|
503
|
+
};
|
|
504
|
+
let planningBootstrapCalls = 0;
|
|
505
|
+
let initiativesCalls = 0;
|
|
506
|
+
let workstreamsCalls = 0;
|
|
507
|
+
vi.stubGlobal('fetch', vi.fn((url) => {
|
|
419
508
|
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
420
509
|
return jsonResponse({ config: { runtimeMode: 'local', workspaceMode: 'single-local', authSource: 'cloud' } });
|
|
421
510
|
}
|
|
422
|
-
if (url.includes('/api/taskforce/
|
|
423
|
-
return jsonResponse({ success: true, state: {} });
|
|
424
|
-
}
|
|
425
|
-
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
511
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
426
512
|
return jsonResponse({
|
|
427
|
-
|
|
428
|
-
|
|
513
|
+
authenticated: false,
|
|
514
|
+
authRequiredForApi: false,
|
|
515
|
+
betaAccess: true,
|
|
516
|
+
userId: 'anonymous',
|
|
517
|
+
email: '',
|
|
518
|
+
workspaceId: 'workspace-local-active'
|
|
429
519
|
});
|
|
430
520
|
}
|
|
521
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
522
|
+
return jsonResponse({ success: true, state: {} });
|
|
523
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
524
|
+
return jsonResponse({ success: true, state: { version: 2, enabled: false, phase: 'idle', pullCursor: null } });
|
|
525
|
+
}
|
|
431
526
|
if (url.includes('/api/taskforce/config')) {
|
|
432
527
|
return jsonResponse({
|
|
433
528
|
projectName: 'Test Project',
|
|
@@ -440,80 +535,82 @@ describe('useTaskforce sync behavior', () => {
|
|
|
440
535
|
}
|
|
441
536
|
});
|
|
442
537
|
}
|
|
443
|
-
if (url.includes('/api/taskforce/global-settings'))
|
|
538
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
444
539
|
return jsonResponse({});
|
|
445
|
-
|
|
446
|
-
if (url.includes('/api/taskforce/categories')) {
|
|
540
|
+
if (url.includes('/api/taskforce/categories'))
|
|
447
541
|
return jsonResponse({ categories: [{ value: 'general', label: 'General' }] });
|
|
448
|
-
|
|
449
|
-
if (url.includes('/api/taskforce/types')) {
|
|
542
|
+
if (url.includes('/api/taskforce/types'))
|
|
450
543
|
return jsonResponse({ types: [] });
|
|
451
|
-
|
|
452
|
-
if (url.includes('/api/taskforce/priorities')) {
|
|
544
|
+
if (url.includes('/api/taskforce/priorities'))
|
|
453
545
|
return jsonResponse({ priorities: [] });
|
|
454
|
-
|
|
455
|
-
if (url.includes('/api/taskforce/approaches')) {
|
|
546
|
+
if (url.includes('/api/taskforce/approaches'))
|
|
456
547
|
return jsonResponse({ approaches: [] });
|
|
457
|
-
|
|
458
|
-
if (url.includes('/api/taskforce/specialists')) {
|
|
548
|
+
if (url.includes('/api/taskforce/specialists'))
|
|
459
549
|
return jsonResponse({ specialists: [] });
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
}
|
|
464
|
-
if (url.includes('/api/taskforce/archive')) {
|
|
550
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
551
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
552
|
+
if (url.includes('/api/taskforce/archive'))
|
|
465
553
|
return jsonResponse({ archived: [] });
|
|
466
|
-
|
|
467
|
-
|
|
554
|
+
if (url.includes('/api/taskforce/planning/bootstrap')) {
|
|
555
|
+
planningBootstrapCalls += 1;
|
|
556
|
+
if (planningBootstrapCalls === 1) {
|
|
557
|
+
return Promise.reject(new DOMException('timed out', 'AbortError'));
|
|
558
|
+
}
|
|
468
559
|
return jsonResponse({
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
{
|
|
473
|
-
...doneTask,
|
|
474
|
-
isArchived: true
|
|
475
|
-
}
|
|
476
|
-
]
|
|
477
|
-
},
|
|
478
|
-
errors: []
|
|
560
|
+
initiatives: [initiative],
|
|
561
|
+
workstreams: [workstream],
|
|
562
|
+
workstreamTaskSummaries: [],
|
|
479
563
|
});
|
|
480
564
|
}
|
|
481
|
-
if (url.includes('/api/taskforce/
|
|
482
|
-
|
|
565
|
+
if (url.includes('/api/taskforce/initiatives')) {
|
|
566
|
+
initiativesCalls += 1;
|
|
567
|
+
return jsonResponse([initiative]);
|
|
568
|
+
}
|
|
569
|
+
if (url.includes('/api/taskforce/workstreams')) {
|
|
570
|
+
workstreamsCalls += 1;
|
|
571
|
+
return jsonResponse([workstream]);
|
|
483
572
|
}
|
|
573
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
574
|
+
return jsonResponse({ dataVersion: 1 });
|
|
484
575
|
return jsonResponse({});
|
|
485
576
|
}));
|
|
486
577
|
const { result } = renderHook(() => useTaskforce({ config: {} }), { wrapper });
|
|
487
578
|
await waitFor(() => {
|
|
488
|
-
expect(result.current.tasks.some((task) => task.id ===
|
|
489
|
-
});
|
|
490
|
-
await act(async () => {
|
|
491
|
-
await result.current.handleBulkArchive();
|
|
579
|
+
expect(result.current.tasks.some((task) => task.id === activeTask.id)).toBe(true);
|
|
492
580
|
});
|
|
493
581
|
await waitFor(() => {
|
|
494
|
-
expect(result.current.
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
582
|
+
expect(result.current.initiatives.some((item) => item.id === initiative.id)).toBe(true);
|
|
583
|
+
expect(result.current.workstreams.some((item) => item.id === workstream.id)).toBe(true);
|
|
584
|
+
}, { timeout: 7000 });
|
|
585
|
+
expect(planningBootstrapCalls).toBeGreaterThanOrEqual(2);
|
|
586
|
+
expect(initiativesCalls).toBe(0);
|
|
587
|
+
expect(workstreamsCalls).toBe(0);
|
|
588
|
+
}, 10000);
|
|
589
|
+
it('does not block cloud bootstrap readiness on a slow planning bootstrap response', async () => {
|
|
590
|
+
const delayedPlanningResponseMs = 1500;
|
|
501
591
|
vi.stubGlobal('fetch', vi.fn((url) => {
|
|
502
592
|
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
503
593
|
return jsonResponse({
|
|
504
594
|
config: {
|
|
505
|
-
runtimeMode: '
|
|
506
|
-
workspaceMode: 'single-
|
|
595
|
+
runtimeMode: 'cloud',
|
|
596
|
+
workspaceMode: 'single-cloud',
|
|
507
597
|
authSource: 'cloud',
|
|
508
|
-
|
|
509
|
-
apiBaseUrl: 'http://localhost:5174',
|
|
510
|
-
cloudAuthBaseUrl: 'http://localhost:5174'
|
|
598
|
+
workspaceSwitchingEnabled: false
|
|
511
599
|
}
|
|
512
600
|
});
|
|
513
601
|
}
|
|
514
|
-
if (url.includes('/api/taskforce/
|
|
515
|
-
return jsonResponse({
|
|
602
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
603
|
+
return jsonResponse({
|
|
604
|
+
authenticated: true,
|
|
605
|
+
authRequiredForApi: true,
|
|
606
|
+
betaAccess: true,
|
|
607
|
+
userId: 'user-1',
|
|
608
|
+
email: 'user@example.com',
|
|
609
|
+
workspaceId: 'workspace-cloud-1'
|
|
610
|
+
});
|
|
516
611
|
}
|
|
612
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
613
|
+
return jsonResponse({ success: true, state: {} });
|
|
517
614
|
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
518
615
|
return jsonResponse({
|
|
519
616
|
success: true,
|
|
@@ -522,63 +619,83 @@ describe('useTaskforce sync behavior', () => {
|
|
|
522
619
|
}
|
|
523
620
|
if (url.includes('/api/taskforce/config')) {
|
|
524
621
|
return jsonResponse({
|
|
525
|
-
projectName: '
|
|
526
|
-
workspaceId: 'workspace-
|
|
527
|
-
runtimeMode: '
|
|
622
|
+
projectName: 'Cloud Project',
|
|
623
|
+
workspaceId: 'workspace-cloud-1',
|
|
624
|
+
runtimeMode: 'cloud',
|
|
625
|
+
authRequiredForApi: true,
|
|
626
|
+
userId: 'user-1',
|
|
528
627
|
setupState: {
|
|
529
628
|
globalSetupState: 'complete',
|
|
530
629
|
workspaceSetupState: 'complete',
|
|
531
|
-
workspaceId: 'workspace-
|
|
630
|
+
workspaceId: 'workspace-cloud-1'
|
|
532
631
|
}
|
|
533
632
|
});
|
|
534
633
|
}
|
|
535
|
-
if (url.includes('/api/taskforce/
|
|
536
|
-
return jsonResponse({
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
return jsonResponse({ types: [] });
|
|
543
|
-
}
|
|
544
|
-
if (url.includes('/api/taskforce/priorities')) {
|
|
545
|
-
return jsonResponse({ priorities: [] });
|
|
546
|
-
}
|
|
547
|
-
if (url.includes('/api/taskforce/approaches')) {
|
|
548
|
-
return jsonResponse({ approaches: [] });
|
|
634
|
+
if (url.includes('/api/taskforce/taxonomy-state')) {
|
|
635
|
+
return jsonResponse({
|
|
636
|
+
categories: [{ value: 'general', label: 'General' }],
|
|
637
|
+
types: [{ value: 'feature', label: 'Feature' }],
|
|
638
|
+
priorities: [{ value: 2, label: 'Medium' }],
|
|
639
|
+
taxonomies: []
|
|
640
|
+
});
|
|
549
641
|
}
|
|
550
|
-
if (url.includes('/api/taskforce/
|
|
551
|
-
return jsonResponse({
|
|
642
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
643
|
+
return jsonResponse({});
|
|
644
|
+
if (url.includes('/api/taskforce/workspace/assignee-options'))
|
|
645
|
+
return jsonResponse({ assignees: [] });
|
|
646
|
+
if (url.includes('/api/taskforce/auth/workspace-members'))
|
|
647
|
+
return jsonResponse({ users: [] });
|
|
648
|
+
if (url.includes('/api/taskforce/planning/bootstrap')) {
|
|
649
|
+
return new Promise((resolve) => {
|
|
650
|
+
setTimeout(() => {
|
|
651
|
+
resolve({
|
|
652
|
+
ok: true,
|
|
653
|
+
status: 200,
|
|
654
|
+
json: () => Promise.resolve({
|
|
655
|
+
initiatives: [{
|
|
656
|
+
id: 'initiative-slow-1',
|
|
657
|
+
title: 'Slow initiative',
|
|
658
|
+
description: null,
|
|
659
|
+
createdAt: '2026-03-15T10:00:00.000Z',
|
|
660
|
+
}],
|
|
661
|
+
workstreams: [],
|
|
662
|
+
workstreamTaskSummaries: []
|
|
663
|
+
})
|
|
664
|
+
});
|
|
665
|
+
}, delayedPlanningResponseMs);
|
|
666
|
+
});
|
|
552
667
|
}
|
|
553
|
-
if (url.includes('/api/taskforce/tasks'))
|
|
668
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
554
669
|
return jsonResponse({ tasks: [activeTask] });
|
|
555
|
-
|
|
556
|
-
if (url.includes('/api/taskforce/archive')) {
|
|
670
|
+
if (url.includes('/api/taskforce/archive'))
|
|
557
671
|
return jsonResponse({ archived: [] });
|
|
558
|
-
|
|
559
|
-
if (url.includes('/api/taskforce/data-version')) {
|
|
672
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
560
673
|
return jsonResponse({ dataVersion: 1 });
|
|
561
|
-
|
|
674
|
+
if (url.includes('/api/taskforce/build-info'))
|
|
675
|
+
return jsonResponse({});
|
|
562
676
|
return jsonResponse({});
|
|
563
677
|
}));
|
|
564
|
-
const { result } = renderHook(() => useTaskforce({ config: {
|
|
678
|
+
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
565
679
|
await waitFor(() => {
|
|
566
|
-
expect(result.current.
|
|
567
|
-
|
|
680
|
+
expect(result.current.tasks.some((task) => task.id === activeTask.id)).toBe(true);
|
|
681
|
+
expect(result.current.bootstrapState.pending).toBe(false);
|
|
682
|
+
expect(result.current.bootstrapState.ready).toBe(true);
|
|
683
|
+
}, { timeout: 700 });
|
|
684
|
+
expect(result.current.initiatives).toEqual([]);
|
|
685
|
+
await waitFor(() => {
|
|
686
|
+
expect(result.current.initiatives.some((initiative) => initiative.id === 'initiative-slow-1')).toBe(true);
|
|
687
|
+
}, { timeout: 2500 });
|
|
568
688
|
});
|
|
569
|
-
it('
|
|
570
|
-
|
|
571
|
-
const archivedChildren = [
|
|
572
|
-
archivedTaskRecord('task-archived-child-1', 'Archived Task 1')
|
|
573
|
-
];
|
|
689
|
+
it('loads cloud assignee options only once during initial bootstrap', async () => {
|
|
690
|
+
let assigneeRequestCount = 0;
|
|
574
691
|
vi.stubGlobal('fetch', vi.fn((url) => {
|
|
575
692
|
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
576
693
|
return jsonResponse({
|
|
577
694
|
config: {
|
|
578
695
|
runtimeMode: 'cloud',
|
|
579
|
-
workspaceMode: '
|
|
696
|
+
workspaceMode: 'single-cloud',
|
|
580
697
|
authSource: 'cloud',
|
|
581
|
-
workspaceSwitchingEnabled:
|
|
698
|
+
workspaceSwitchingEnabled: false
|
|
582
699
|
}
|
|
583
700
|
});
|
|
584
701
|
}
|
|
@@ -592,9 +709,8 @@ describe('useTaskforce sync behavior', () => {
|
|
|
592
709
|
workspaceId: 'workspace-cloud-1'
|
|
593
710
|
});
|
|
594
711
|
}
|
|
595
|
-
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
712
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
596
713
|
return jsonResponse({ success: true, state: {} });
|
|
597
|
-
}
|
|
598
714
|
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
599
715
|
return jsonResponse({
|
|
600
716
|
success: true,
|
|
@@ -607,7 +723,6 @@ describe('useTaskforce sync behavior', () => {
|
|
|
607
723
|
workspaceId: 'workspace-cloud-1',
|
|
608
724
|
runtimeMode: 'cloud',
|
|
609
725
|
authRequiredForApi: true,
|
|
610
|
-
realtimeSyncEnabled: true,
|
|
611
726
|
userId: 'user-1',
|
|
612
727
|
setupState: {
|
|
613
728
|
globalSetupState: 'complete',
|
|
@@ -616,6 +731,83 @@ describe('useTaskforce sync behavior', () => {
|
|
|
616
731
|
}
|
|
617
732
|
});
|
|
618
733
|
}
|
|
734
|
+
if (url.includes('/api/taskforce/taxonomy-state')) {
|
|
735
|
+
return jsonResponse({
|
|
736
|
+
categories: [{ value: 'general', label: 'General' }],
|
|
737
|
+
types: [{ value: 'feature', label: 'Feature' }],
|
|
738
|
+
priorities: [{ value: 2, label: 'Medium' }],
|
|
739
|
+
taxonomies: []
|
|
740
|
+
});
|
|
741
|
+
}
|
|
742
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
743
|
+
return jsonResponse({});
|
|
744
|
+
if (url.includes('/api/taskforce/workspace/assignee-options')) {
|
|
745
|
+
assigneeRequestCount += 1;
|
|
746
|
+
return jsonResponse({ assignees: [] });
|
|
747
|
+
}
|
|
748
|
+
if (url.includes('/api/taskforce/auth/workspace-members'))
|
|
749
|
+
return jsonResponse({ users: [] });
|
|
750
|
+
if (url.includes('/api/taskforce/planning/bootstrap'))
|
|
751
|
+
return jsonResponse({ initiatives: [], workstreams: [], workstreamTaskSummaries: [] });
|
|
752
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
753
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
754
|
+
if (url.includes('/api/taskforce/archive'))
|
|
755
|
+
return jsonResponse({ archived: [] });
|
|
756
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
757
|
+
return jsonResponse({ dataVersion: 1 });
|
|
758
|
+
if (url.includes('/api/taskforce/build-info'))
|
|
759
|
+
return jsonResponse({});
|
|
760
|
+
return jsonResponse({});
|
|
761
|
+
}));
|
|
762
|
+
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
763
|
+
await waitFor(() => {
|
|
764
|
+
expect(result.current.tasks.some((task) => task.id === activeTask.id)).toBe(true);
|
|
765
|
+
expect(result.current.bootstrapState.pending).toBe(false);
|
|
766
|
+
expect(result.current.bootstrapState.ready).toBe(true);
|
|
767
|
+
}, { timeout: 2500 });
|
|
768
|
+
await waitFor(() => {
|
|
769
|
+
expect(assigneeRequestCount).toBe(1);
|
|
770
|
+
}, { timeout: 2500 });
|
|
771
|
+
});
|
|
772
|
+
it('keeps the dawn theme when settings re-fetch configuration', async () => {
|
|
773
|
+
const fetchMock = vi.fn((url) => {
|
|
774
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
775
|
+
return jsonResponse({ config: { runtimeMode: 'local', workspaceMode: 'single-local', authSource: 'cloud' } });
|
|
776
|
+
}
|
|
777
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
778
|
+
return jsonResponse({
|
|
779
|
+
authenticated: false,
|
|
780
|
+
authRequiredForApi: false,
|
|
781
|
+
betaAccess: true,
|
|
782
|
+
userId: 'anonymous',
|
|
783
|
+
email: '',
|
|
784
|
+
workspaceId: 'workspace-local-active'
|
|
785
|
+
});
|
|
786
|
+
}
|
|
787
|
+
if (url.includes('/api/taskforce/ui-state?key=app')) {
|
|
788
|
+
return jsonResponse({ success: true, state: {} });
|
|
789
|
+
}
|
|
790
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
791
|
+
return jsonResponse({
|
|
792
|
+
success: true,
|
|
793
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
794
|
+
});
|
|
795
|
+
}
|
|
796
|
+
if (url.includes('/api/taskforce/config')) {
|
|
797
|
+
return jsonResponse({
|
|
798
|
+
theme: 'dawn',
|
|
799
|
+
globalTheme: 'dawn',
|
|
800
|
+
themeUseGlobalDefault: true,
|
|
801
|
+
projectName: 'Test Project',
|
|
802
|
+
workspaceId: 'workspace-local-active',
|
|
803
|
+
runtimeMode: 'local',
|
|
804
|
+
setupState: {
|
|
805
|
+
globalSetupState: 'complete',
|
|
806
|
+
workspaceSetupState: 'complete',
|
|
807
|
+
workspaceId: 'workspace-local-active'
|
|
808
|
+
}
|
|
809
|
+
});
|
|
810
|
+
}
|
|
619
811
|
if (url.includes('/api/taskforce/global-settings'))
|
|
620
812
|
return jsonResponse({});
|
|
621
813
|
if (url.includes('/api/taskforce/categories'))
|
|
@@ -631,24 +823,2094 @@ describe('useTaskforce sync behavior', () => {
|
|
|
631
823
|
if (url.includes('/api/taskforce/tasks'))
|
|
632
824
|
return jsonResponse({ tasks: [activeTask] });
|
|
633
825
|
if (url.includes('/api/taskforce/archive'))
|
|
634
|
-
return jsonResponse({ archived:
|
|
826
|
+
return jsonResponse({ archived: [] });
|
|
635
827
|
if (url.includes('/api/taskforce/data-version'))
|
|
636
828
|
return jsonResponse({ dataVersion: 1 });
|
|
637
829
|
return jsonResponse({});
|
|
830
|
+
});
|
|
831
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
832
|
+
const { result } = renderHook(() => useTaskforce({ config: {} }), { wrapper });
|
|
833
|
+
await waitFor(() => {
|
|
834
|
+
expect(result.current.currentTheme).toBe('dawn');
|
|
835
|
+
});
|
|
836
|
+
await act(async () => {
|
|
837
|
+
result.current.setIsOpen(true);
|
|
838
|
+
result.current.setActiveTab('settings');
|
|
839
|
+
});
|
|
840
|
+
await waitFor(() => {
|
|
841
|
+
expect(fetchMock.mock.calls.filter(([url]) => String(url).includes('/api/taskforce/config'))).toHaveLength(2);
|
|
842
|
+
expect(result.current.currentTheme).toBe('dawn');
|
|
843
|
+
});
|
|
844
|
+
});
|
|
845
|
+
it('merges a server-returned archived task immediately instead of dropping it between collections', async () => {
|
|
846
|
+
vi.stubGlobal('fetch', vi.fn((url, init) => {
|
|
847
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
848
|
+
return jsonResponse({ config: { runtimeMode: 'local', workspaceMode: 'single-local', authSource: 'cloud' } });
|
|
849
|
+
}
|
|
850
|
+
if (url.includes('/api/taskforce/ui-state?key=app')) {
|
|
851
|
+
return jsonResponse({ success: true, state: {} });
|
|
852
|
+
}
|
|
853
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
854
|
+
return jsonResponse({
|
|
855
|
+
success: true,
|
|
856
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
857
|
+
});
|
|
858
|
+
}
|
|
859
|
+
if (url.includes('/api/taskforce/config')) {
|
|
860
|
+
return jsonResponse({
|
|
861
|
+
projectName: 'Test Project',
|
|
862
|
+
workspaceId: 'workspace-local-active',
|
|
863
|
+
runtimeMode: 'local',
|
|
864
|
+
setupState: {
|
|
865
|
+
globalSetupState: 'complete',
|
|
866
|
+
workspaceSetupState: 'complete',
|
|
867
|
+
workspaceId: 'workspace-local-active'
|
|
868
|
+
}
|
|
869
|
+
});
|
|
870
|
+
}
|
|
871
|
+
if (url.includes('/api/taskforce/global-settings')) {
|
|
872
|
+
return jsonResponse({});
|
|
873
|
+
}
|
|
874
|
+
if (url.includes('/api/taskforce/categories')) {
|
|
875
|
+
return jsonResponse({ categories: [{ value: 'general', label: 'General' }] });
|
|
876
|
+
}
|
|
877
|
+
if (url.includes('/api/taskforce/types')) {
|
|
878
|
+
return jsonResponse({ types: [] });
|
|
879
|
+
}
|
|
880
|
+
if (url.includes('/api/taskforce/priorities')) {
|
|
881
|
+
return jsonResponse({ priorities: [] });
|
|
882
|
+
}
|
|
883
|
+
if (url.includes('/api/taskforce/approaches')) {
|
|
884
|
+
return jsonResponse({ approaches: [] });
|
|
885
|
+
}
|
|
886
|
+
if (url.includes('/api/taskforce/specialists')) {
|
|
887
|
+
return jsonResponse({ specialists: [] });
|
|
888
|
+
}
|
|
889
|
+
if (url.includes('/api/taskforce/tasks')) {
|
|
890
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
891
|
+
}
|
|
892
|
+
if (url.includes('/api/taskforce/archive')) {
|
|
893
|
+
return jsonResponse({ archived: [] });
|
|
894
|
+
}
|
|
895
|
+
if (url.includes('/api/taskforce/task/task-parent/complete') && String(init?.method || '').toUpperCase() === 'POST') {
|
|
896
|
+
return jsonResponse({
|
|
897
|
+
...activeTask,
|
|
898
|
+
status: 'done',
|
|
899
|
+
isArchived: true,
|
|
900
|
+
completedAt: '2026-03-15T10:20:00.000Z',
|
|
901
|
+
updatedAt: '2026-03-15T10:20:00.000Z'
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
if (url.includes('/api/taskforce/data-version')) {
|
|
905
|
+
return jsonResponse({ dataVersion: 1 });
|
|
906
|
+
}
|
|
907
|
+
return jsonResponse({});
|
|
638
908
|
}));
|
|
639
|
-
const { result } = renderHook(() => useTaskforce({ config: {
|
|
909
|
+
const { result } = renderHook(() => useTaskforce({ config: {} }), { wrapper });
|
|
640
910
|
await waitFor(() => {
|
|
641
|
-
expect(result.current.
|
|
642
|
-
}
|
|
643
|
-
act(() => {
|
|
644
|
-
result.current.
|
|
911
|
+
expect(result.current.tasks.some((task) => task.id === 'task-parent')).toBe(true);
|
|
912
|
+
});
|
|
913
|
+
await act(async () => {
|
|
914
|
+
await result.current.handleArchiveTask(activeTask);
|
|
645
915
|
});
|
|
646
916
|
await waitFor(() => {
|
|
647
|
-
expect(result.current.
|
|
648
|
-
|
|
649
|
-
expect(
|
|
917
|
+
expect(result.current.tasks.some((task) => task.id === 'task-parent')).toBe(false);
|
|
918
|
+
const archived = result.current.archivedTasks.find((task) => task.id === 'task-parent');
|
|
919
|
+
expect(archived?.isArchived).toBe(true);
|
|
920
|
+
expect(archived?.status).toBe('done');
|
|
650
921
|
});
|
|
651
922
|
});
|
|
923
|
+
it('merges a server-returned completed task immediately when toggling done', async () => {
|
|
924
|
+
vi.stubGlobal('fetch', vi.fn((url, init) => {
|
|
925
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
926
|
+
return jsonResponse({ config: { runtimeMode: 'local', workspaceMode: 'single-local', authSource: 'cloud' } });
|
|
927
|
+
}
|
|
928
|
+
if (url.includes('/api/taskforce/ui-state?key=app')) {
|
|
929
|
+
return jsonResponse({ success: true, state: {} });
|
|
930
|
+
}
|
|
931
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
932
|
+
return jsonResponse({
|
|
933
|
+
success: true,
|
|
934
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
935
|
+
});
|
|
936
|
+
}
|
|
937
|
+
if (url.includes('/api/taskforce/config')) {
|
|
938
|
+
return jsonResponse({
|
|
939
|
+
projectName: 'Test Project',
|
|
940
|
+
workspaceId: 'workspace-local-active',
|
|
941
|
+
runtimeMode: 'local',
|
|
942
|
+
setupState: {
|
|
943
|
+
globalSetupState: 'complete',
|
|
944
|
+
workspaceSetupState: 'complete',
|
|
945
|
+
workspaceId: 'workspace-local-active'
|
|
946
|
+
}
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
if (url.includes('/api/taskforce/global-settings')) {
|
|
950
|
+
return jsonResponse({});
|
|
951
|
+
}
|
|
952
|
+
if (url.includes('/api/taskforce/categories')) {
|
|
953
|
+
return jsonResponse({ categories: [{ value: 'general', label: 'General' }] });
|
|
954
|
+
}
|
|
955
|
+
if (url.includes('/api/taskforce/types')) {
|
|
956
|
+
return jsonResponse({ types: [] });
|
|
957
|
+
}
|
|
958
|
+
if (url.includes('/api/taskforce/priorities')) {
|
|
959
|
+
return jsonResponse({ priorities: [] });
|
|
960
|
+
}
|
|
961
|
+
if (url.includes('/api/taskforce/approaches')) {
|
|
962
|
+
return jsonResponse({ approaches: [] });
|
|
963
|
+
}
|
|
964
|
+
if (url.includes('/api/taskforce/specialists')) {
|
|
965
|
+
return jsonResponse({ specialists: [] });
|
|
966
|
+
}
|
|
967
|
+
if (url.includes('/api/taskforce/tasks')) {
|
|
968
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
969
|
+
}
|
|
970
|
+
if (url.includes('/api/taskforce/archive')) {
|
|
971
|
+
return jsonResponse({ archived: [] });
|
|
972
|
+
}
|
|
973
|
+
if (url.includes('/api/taskforce/task/task-parent') && String(init?.method || '').toUpperCase() === 'PATCH') {
|
|
974
|
+
return jsonResponse({
|
|
975
|
+
...activeTask,
|
|
976
|
+
status: 'done',
|
|
977
|
+
completedAt: '2026-03-15T10:25:00.000Z',
|
|
978
|
+
updatedAt: '2026-03-15T10:25:00.000Z'
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
if (url.includes('/api/taskforce/data-version')) {
|
|
982
|
+
return jsonResponse({ dataVersion: 1 });
|
|
983
|
+
}
|
|
984
|
+
return jsonResponse({});
|
|
985
|
+
}));
|
|
986
|
+
const { result } = renderHook(() => useTaskforce({ config: {} }), { wrapper });
|
|
987
|
+
await waitFor(() => {
|
|
988
|
+
expect(result.current.tasks.some((task) => task.id === 'task-parent')).toBe(true);
|
|
989
|
+
});
|
|
990
|
+
await act(async () => {
|
|
991
|
+
await result.current.handleToggleComplete(activeTask);
|
|
992
|
+
});
|
|
993
|
+
await waitFor(() => {
|
|
994
|
+
const completed = result.current.tasks.find((task) => task.id === 'task-parent');
|
|
995
|
+
expect(completed?.status).toBe('done');
|
|
996
|
+
expect(completed?.completedAt).toBe('2026-03-15T10:25:00.000Z');
|
|
997
|
+
});
|
|
998
|
+
});
|
|
999
|
+
it('merges bulk-archived tasks immediately instead of relying on archive refresh timing', async () => {
|
|
1000
|
+
vi.stubGlobal('confirm', vi.fn(() => true));
|
|
1001
|
+
vi.stubGlobal('fetch', vi.fn((url, init) => {
|
|
1002
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
1003
|
+
return jsonResponse({ config: { runtimeMode: 'local', workspaceMode: 'single-local', authSource: 'cloud' } });
|
|
1004
|
+
}
|
|
1005
|
+
if (url.includes('/api/taskforce/ui-state?key=app')) {
|
|
1006
|
+
return jsonResponse({ success: true, state: {} });
|
|
1007
|
+
}
|
|
1008
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
1009
|
+
return jsonResponse({
|
|
1010
|
+
success: true,
|
|
1011
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
1012
|
+
});
|
|
1013
|
+
}
|
|
1014
|
+
if (url.includes('/api/taskforce/config')) {
|
|
1015
|
+
return jsonResponse({
|
|
1016
|
+
projectName: 'Test Project',
|
|
1017
|
+
workspaceId: 'workspace-local-active',
|
|
1018
|
+
runtimeMode: 'local',
|
|
1019
|
+
setupState: {
|
|
1020
|
+
globalSetupState: 'complete',
|
|
1021
|
+
workspaceSetupState: 'complete',
|
|
1022
|
+
workspaceId: 'workspace-local-active'
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
}
|
|
1026
|
+
if (url.includes('/api/taskforce/global-settings')) {
|
|
1027
|
+
return jsonResponse({});
|
|
1028
|
+
}
|
|
1029
|
+
if (url.includes('/api/taskforce/categories')) {
|
|
1030
|
+
return jsonResponse({ categories: [{ value: 'general', label: 'General' }] });
|
|
1031
|
+
}
|
|
1032
|
+
if (url.includes('/api/taskforce/types')) {
|
|
1033
|
+
return jsonResponse({ types: [] });
|
|
1034
|
+
}
|
|
1035
|
+
if (url.includes('/api/taskforce/priorities')) {
|
|
1036
|
+
return jsonResponse({ priorities: [] });
|
|
1037
|
+
}
|
|
1038
|
+
if (url.includes('/api/taskforce/approaches')) {
|
|
1039
|
+
return jsonResponse({ approaches: [] });
|
|
1040
|
+
}
|
|
1041
|
+
if (url.includes('/api/taskforce/specialists')) {
|
|
1042
|
+
return jsonResponse({ specialists: [] });
|
|
1043
|
+
}
|
|
1044
|
+
if (url.includes('/api/taskforce/tasks')) {
|
|
1045
|
+
return jsonResponse({ tasks: [activeTask, doneTask] });
|
|
1046
|
+
}
|
|
1047
|
+
if (url.includes('/api/taskforce/archive')) {
|
|
1048
|
+
return jsonResponse({ archived: [] });
|
|
1049
|
+
}
|
|
1050
|
+
if (url.includes('/api/taskforce/bulk-archive') && String(init?.method || '').toUpperCase() === 'POST') {
|
|
1051
|
+
return jsonResponse({
|
|
1052
|
+
success: true,
|
|
1053
|
+
results: {
|
|
1054
|
+
archived: [
|
|
1055
|
+
{
|
|
1056
|
+
...doneTask,
|
|
1057
|
+
isArchived: true
|
|
1058
|
+
}
|
|
1059
|
+
]
|
|
1060
|
+
},
|
|
1061
|
+
errors: []
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
if (url.includes('/api/taskforce/data-version')) {
|
|
1065
|
+
return jsonResponse({ dataVersion: 1 });
|
|
1066
|
+
}
|
|
1067
|
+
return jsonResponse({});
|
|
1068
|
+
}));
|
|
1069
|
+
const { result } = renderHook(() => useTaskforce({ config: {} }), { wrapper });
|
|
1070
|
+
await waitFor(() => {
|
|
1071
|
+
expect(result.current.tasks.some((task) => task.id === 'task-done')).toBe(true);
|
|
1072
|
+
});
|
|
1073
|
+
await act(async () => {
|
|
1074
|
+
await result.current.handleBulkArchive();
|
|
1075
|
+
});
|
|
1076
|
+
await waitFor(() => {
|
|
1077
|
+
expect(result.current.tasks.some((task) => task.id === 'task-done')).toBe(false);
|
|
1078
|
+
const archived = result.current.archivedTasks.find((task) => task.id === 'task-done');
|
|
1079
|
+
expect(archived?.isArchived).toBe(true);
|
|
1080
|
+
expect(archived?.status).toBe('done');
|
|
1081
|
+
});
|
|
1082
|
+
});
|
|
1083
|
+
it('preserves an explicit local api base url instead of letting runtime-config reset it to the app origin', async () => {
|
|
1084
|
+
vi.stubGlobal('fetch', vi.fn((url) => {
|
|
1085
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
1086
|
+
return jsonResponse({
|
|
1087
|
+
config: {
|
|
1088
|
+
runtimeMode: 'local',
|
|
1089
|
+
workspaceMode: 'single-local',
|
|
1090
|
+
authSource: 'cloud',
|
|
1091
|
+
baseUrl: 'http://localhost:5174',
|
|
1092
|
+
apiBaseUrl: 'http://localhost:5174',
|
|
1093
|
+
cloudAuthBaseUrl: 'http://localhost:5174'
|
|
1094
|
+
}
|
|
1095
|
+
});
|
|
1096
|
+
}
|
|
1097
|
+
if (url.includes('/api/taskforce/ui-state?key=app')) {
|
|
1098
|
+
return jsonResponse({ success: true, state: {} });
|
|
1099
|
+
}
|
|
1100
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
1101
|
+
return jsonResponse({
|
|
1102
|
+
success: true,
|
|
1103
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
1104
|
+
});
|
|
1105
|
+
}
|
|
1106
|
+
if (url.includes('/api/taskforce/config')) {
|
|
1107
|
+
return jsonResponse({
|
|
1108
|
+
projectName: 'Test Project',
|
|
1109
|
+
workspaceId: 'workspace-local-active',
|
|
1110
|
+
runtimeMode: 'local',
|
|
1111
|
+
setupState: {
|
|
1112
|
+
globalSetupState: 'complete',
|
|
1113
|
+
workspaceSetupState: 'complete',
|
|
1114
|
+
workspaceId: 'workspace-local-active'
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1117
|
+
}
|
|
1118
|
+
if (url.includes('/api/taskforce/global-settings')) {
|
|
1119
|
+
return jsonResponse({});
|
|
1120
|
+
}
|
|
1121
|
+
if (url.includes('/api/taskforce/categories')) {
|
|
1122
|
+
return jsonResponse({ categories: [{ value: 'general', label: 'General' }] });
|
|
1123
|
+
}
|
|
1124
|
+
if (url.includes('/api/taskforce/types')) {
|
|
1125
|
+
return jsonResponse({ types: [] });
|
|
1126
|
+
}
|
|
1127
|
+
if (url.includes('/api/taskforce/priorities')) {
|
|
1128
|
+
return jsonResponse({ priorities: [] });
|
|
1129
|
+
}
|
|
1130
|
+
if (url.includes('/api/taskforce/approaches')) {
|
|
1131
|
+
return jsonResponse({ approaches: [] });
|
|
1132
|
+
}
|
|
1133
|
+
if (url.includes('/api/taskforce/specialists')) {
|
|
1134
|
+
return jsonResponse({ specialists: [] });
|
|
1135
|
+
}
|
|
1136
|
+
if (url.includes('/api/taskforce/tasks')) {
|
|
1137
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
1138
|
+
}
|
|
1139
|
+
if (url.includes('/api/taskforce/archive')) {
|
|
1140
|
+
return jsonResponse({ archived: [] });
|
|
1141
|
+
}
|
|
1142
|
+
if (url.includes('/api/taskforce/data-version')) {
|
|
1143
|
+
return jsonResponse({ dataVersion: 1 });
|
|
1144
|
+
}
|
|
1145
|
+
return jsonResponse({});
|
|
1146
|
+
}));
|
|
1147
|
+
const { result } = renderHook(() => useTaskforce({ config: { apiBaseUrl: 'http://127.0.0.1:4280' } }), { wrapper });
|
|
1148
|
+
await waitFor(() => {
|
|
1149
|
+
expect(result.current.config.apiBaseUrl).toBe('http://127.0.0.1:4280');
|
|
1150
|
+
});
|
|
1151
|
+
});
|
|
1152
|
+
it('opens archived tasks by id and enables archive view', async () => {
|
|
1153
|
+
vi.stubGlobal('WebSocket', MockWebSocket);
|
|
1154
|
+
const archivedChildren = [
|
|
1155
|
+
archivedTaskRecord('task-archived-child-1', 'Archived Task 1')
|
|
1156
|
+
];
|
|
1157
|
+
vi.stubGlobal('fetch', vi.fn((url) => {
|
|
1158
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
1159
|
+
return jsonResponse({
|
|
1160
|
+
config: {
|
|
1161
|
+
runtimeMode: 'cloud',
|
|
1162
|
+
workspaceMode: 'multi-cloud',
|
|
1163
|
+
authSource: 'cloud',
|
|
1164
|
+
workspaceSwitchingEnabled: true
|
|
1165
|
+
}
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1168
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
1169
|
+
return jsonResponse({
|
|
1170
|
+
authenticated: true,
|
|
1171
|
+
authRequiredForApi: true,
|
|
1172
|
+
betaAccess: true,
|
|
1173
|
+
userId: 'user-1',
|
|
1174
|
+
email: 'user@example.com',
|
|
1175
|
+
workspaceId: 'workspace-cloud-1'
|
|
1176
|
+
});
|
|
1177
|
+
}
|
|
1178
|
+
if (url.includes('/api/taskforce/ui-state?key=app')) {
|
|
1179
|
+
return jsonResponse({ success: true, state: {} });
|
|
1180
|
+
}
|
|
1181
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
1182
|
+
return jsonResponse({
|
|
1183
|
+
success: true,
|
|
1184
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
1185
|
+
});
|
|
1186
|
+
}
|
|
1187
|
+
if (url.includes('/api/taskforce/config')) {
|
|
1188
|
+
return jsonResponse({
|
|
1189
|
+
projectName: 'Cloud Project',
|
|
1190
|
+
workspaceId: 'workspace-cloud-1',
|
|
1191
|
+
runtimeMode: 'cloud',
|
|
1192
|
+
authRequiredForApi: true,
|
|
1193
|
+
realtimeSyncEnabled: true,
|
|
1194
|
+
userId: 'user-1',
|
|
1195
|
+
setupState: {
|
|
1196
|
+
globalSetupState: 'complete',
|
|
1197
|
+
workspaceSetupState: 'complete',
|
|
1198
|
+
workspaceId: 'workspace-cloud-1'
|
|
1199
|
+
}
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
1203
|
+
return jsonResponse({});
|
|
1204
|
+
if (url.includes('/api/taskforce/categories'))
|
|
1205
|
+
return jsonResponse({ categories: [{ value: 'general', label: 'General' }] });
|
|
1206
|
+
if (url.includes('/api/taskforce/types'))
|
|
1207
|
+
return jsonResponse({ types: [] });
|
|
1208
|
+
if (url.includes('/api/taskforce/priorities'))
|
|
1209
|
+
return jsonResponse({ priorities: [] });
|
|
1210
|
+
if (url.includes('/api/taskforce/approaches'))
|
|
1211
|
+
return jsonResponse({ approaches: [] });
|
|
1212
|
+
if (url.includes('/api/taskforce/specialists'))
|
|
1213
|
+
return jsonResponse({ specialists: [] });
|
|
1214
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
1215
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
1216
|
+
if (url.includes('/api/taskforce/archive'))
|
|
1217
|
+
return jsonResponse({ archived: archivedChildren });
|
|
1218
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
1219
|
+
return jsonResponse({ dataVersion: 1 });
|
|
1220
|
+
return jsonResponse({});
|
|
1221
|
+
}));
|
|
1222
|
+
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
1223
|
+
await waitFor(() => {
|
|
1224
|
+
expect(result.current.archivedTasks.some((task) => task.id === 'task-archived-child-1')).toBe(true);
|
|
1225
|
+
}, { timeout: 2500 });
|
|
1226
|
+
act(() => {
|
|
1227
|
+
result.current.handleOpenTaskById('task-archived-child-1');
|
|
1228
|
+
});
|
|
1229
|
+
await waitFor(() => {
|
|
1230
|
+
expect(result.current.showArchive).toBe(true);
|
|
1231
|
+
expect(result.current.editingTaskId).toBe('task-archived-child-1');
|
|
1232
|
+
expect(result.current.currentTask?.isArchived).toBe(true);
|
|
1233
|
+
});
|
|
1234
|
+
});
|
|
1235
|
+
it('hydrates cloud taxonomy filters when commercial onboarding continues into the app', async () => {
|
|
1236
|
+
let configResolved = false;
|
|
1237
|
+
let allowResolvedTaxonomyState = false;
|
|
1238
|
+
vi.stubGlobal('fetch', vi.fn((url, init) => {
|
|
1239
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
1240
|
+
return jsonResponse({
|
|
1241
|
+
config: {
|
|
1242
|
+
runtimeMode: 'cloud',
|
|
1243
|
+
workspaceMode: 'multi-cloud',
|
|
1244
|
+
authSource: 'cloud',
|
|
1245
|
+
workspaceSwitchingEnabled: true
|
|
1246
|
+
}
|
|
1247
|
+
});
|
|
1248
|
+
}
|
|
1249
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
1250
|
+
return jsonResponse({
|
|
1251
|
+
authenticated: true,
|
|
1252
|
+
authRequiredForApi: true,
|
|
1253
|
+
betaAccess: true,
|
|
1254
|
+
userId: 'user-1',
|
|
1255
|
+
email: 'user@example.com',
|
|
1256
|
+
workspaceId: 'workspace-cloud-1'
|
|
1257
|
+
});
|
|
1258
|
+
}
|
|
1259
|
+
if (url.includes('/api/taskforce/ui-state?key=app')) {
|
|
1260
|
+
return jsonResponse({ success: true, state: {} });
|
|
1261
|
+
}
|
|
1262
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
1263
|
+
return jsonResponse({
|
|
1264
|
+
success: true,
|
|
1265
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
1266
|
+
});
|
|
1267
|
+
}
|
|
1268
|
+
if (url.includes('/api/taskforce/workspaces')) {
|
|
1269
|
+
if (String(init?.method || 'GET').toUpperCase() === 'POST') {
|
|
1270
|
+
return jsonResponse({ success: true });
|
|
1271
|
+
}
|
|
1272
|
+
return jsonResponse({
|
|
1273
|
+
success: true,
|
|
1274
|
+
currentWorkspaceId: 'workspace-cloud-1',
|
|
1275
|
+
workspaces: [
|
|
1276
|
+
{ id: 'workspace-cloud-1', name: 'Cloud Workspace', role: 'owner' }
|
|
1277
|
+
]
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1280
|
+
if (url.includes('/api/taskforce/session/workspace')) {
|
|
1281
|
+
return jsonResponse({ success: true });
|
|
1282
|
+
}
|
|
1283
|
+
if (url.includes('/api/taskforce/config')) {
|
|
1284
|
+
return new Promise((resolve) => {
|
|
1285
|
+
setTimeout(() => {
|
|
1286
|
+
configResolved = true;
|
|
1287
|
+
resolve({
|
|
1288
|
+
ok: true,
|
|
1289
|
+
status: 200,
|
|
1290
|
+
json: () => Promise.resolve({
|
|
1291
|
+
projectName: 'Cloud Project',
|
|
1292
|
+
workspaceId: 'workspace-cloud-1',
|
|
1293
|
+
runtimeMode: 'cloud',
|
|
1294
|
+
authRequiredForApi: true,
|
|
1295
|
+
userId: 'user-1',
|
|
1296
|
+
setupState: {
|
|
1297
|
+
globalSetupState: 'complete',
|
|
1298
|
+
workspaceSetupState: 'complete',
|
|
1299
|
+
workspaceId: 'workspace-cloud-1'
|
|
1300
|
+
}
|
|
1301
|
+
})
|
|
1302
|
+
});
|
|
1303
|
+
}, 25);
|
|
1304
|
+
});
|
|
1305
|
+
}
|
|
1306
|
+
if (url.includes('/api/taskforce/taxonomy-state')) {
|
|
1307
|
+
return jsonResponse(configResolved && allowResolvedTaxonomyState ? {
|
|
1308
|
+
categories: [{ value: 'cloud-ops', label: 'Cloud Ops' }],
|
|
1309
|
+
types: [{ value: 'incident', label: 'Incident' }],
|
|
1310
|
+
priorities: [{ value: 4, label: 'Critical' }],
|
|
1311
|
+
taxonomies: []
|
|
1312
|
+
} : {
|
|
1313
|
+
categories: [],
|
|
1314
|
+
types: [],
|
|
1315
|
+
priorities: [],
|
|
1316
|
+
taxonomies: []
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
1320
|
+
return jsonResponse({});
|
|
1321
|
+
if (url.includes('/api/taskforce/workspace/assignee-options'))
|
|
1322
|
+
return jsonResponse({ assignees: [] });
|
|
1323
|
+
if (url.includes('/api/taskforce/auth/workspace-members'))
|
|
1324
|
+
return jsonResponse({ users: [] });
|
|
1325
|
+
if (url.includes('/api/taskforce/planning/bootstrap'))
|
|
1326
|
+
return jsonResponse({ initiatives: [], workstreams: [], workstreamTaskSummaries: [] });
|
|
1327
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
1328
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
1329
|
+
if (url.includes('/api/taskforce/archive'))
|
|
1330
|
+
return jsonResponse({ archived: [] });
|
|
1331
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
1332
|
+
return jsonResponse({ dataVersion: 1 });
|
|
1333
|
+
if (url.includes('/api/taskforce/build-info'))
|
|
1334
|
+
return jsonResponse({});
|
|
1335
|
+
return jsonResponse({});
|
|
1336
|
+
}));
|
|
1337
|
+
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
1338
|
+
await waitFor(() => {
|
|
1339
|
+
expect(result.current.authSessionResolved).toBe(true);
|
|
1340
|
+
expect(result.current.isAuthenticated).toBe(true);
|
|
1341
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-cloud-1');
|
|
1342
|
+
}, { timeout: 2500 });
|
|
1343
|
+
expect(result.current.activeCategories.some((category) => category.value === 'cloud-ops')).toBe(false);
|
|
1344
|
+
allowResolvedTaxonomyState = true;
|
|
1345
|
+
await act(async () => {
|
|
1346
|
+
const outcome = await result.current.continueAfterCommercialOnboarding();
|
|
1347
|
+
expect(outcome).toEqual({ success: true, destination: 'app' });
|
|
1348
|
+
});
|
|
1349
|
+
await waitFor(() => {
|
|
1350
|
+
expect(result.current.activeCategories.some((category) => category.value === 'cloud-ops')).toBe(true);
|
|
1351
|
+
expect(result.current.activeTypes.some((type) => type.value === 'incident')).toBe(true);
|
|
1352
|
+
expect(result.current.priorities.some((priority) => priority.value === 4)).toBe(true);
|
|
1353
|
+
}, { timeout: 2500 });
|
|
1354
|
+
});
|
|
1355
|
+
it('uses unified taxonomy-state payloads without falling back to category endpoints during cloud bootstrap', async () => {
|
|
1356
|
+
const fetchMock = vi.fn((url, init) => {
|
|
1357
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
1358
|
+
return jsonResponse({
|
|
1359
|
+
config: {
|
|
1360
|
+
runtimeMode: 'cloud',
|
|
1361
|
+
workspaceMode: 'multi-cloud',
|
|
1362
|
+
authSource: 'cloud',
|
|
1363
|
+
workspaceSwitchingEnabled: true
|
|
1364
|
+
}
|
|
1365
|
+
});
|
|
1366
|
+
}
|
|
1367
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
1368
|
+
return jsonResponse({
|
|
1369
|
+
authenticated: true,
|
|
1370
|
+
authRequiredForApi: true,
|
|
1371
|
+
betaAccess: true,
|
|
1372
|
+
userId: 'user-1',
|
|
1373
|
+
email: 'user@example.com',
|
|
1374
|
+
workspaceId: 'workspace-cloud-1'
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
1378
|
+
return jsonResponse({ success: true, state: {} });
|
|
1379
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
1380
|
+
return jsonResponse({
|
|
1381
|
+
success: true,
|
|
1382
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
1383
|
+
});
|
|
1384
|
+
}
|
|
1385
|
+
if (url.includes('/api/taskforce/workspaces')) {
|
|
1386
|
+
if (String(init?.method || 'GET').toUpperCase() === 'POST') {
|
|
1387
|
+
return jsonResponse({ success: true });
|
|
1388
|
+
}
|
|
1389
|
+
return jsonResponse({
|
|
1390
|
+
success: true,
|
|
1391
|
+
currentWorkspaceId: 'workspace-cloud-1',
|
|
1392
|
+
workspaces: [{ id: 'workspace-cloud-1', name: 'Cloud Workspace', role: 'owner' }]
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
if (url.includes('/api/taskforce/session/workspace'))
|
|
1396
|
+
return jsonResponse({ success: true });
|
|
1397
|
+
if (url.includes('/api/taskforce/config')) {
|
|
1398
|
+
return jsonResponse({
|
|
1399
|
+
projectName: 'Cloud Project',
|
|
1400
|
+
workspaceId: 'workspace-cloud-1',
|
|
1401
|
+
runtimeMode: 'cloud',
|
|
1402
|
+
authRequiredForApi: true,
|
|
1403
|
+
userId: 'user-1',
|
|
1404
|
+
setupState: {
|
|
1405
|
+
globalSetupState: 'complete',
|
|
1406
|
+
workspaceSetupState: 'complete',
|
|
1407
|
+
workspaceId: 'workspace-cloud-1'
|
|
1408
|
+
}
|
|
1409
|
+
});
|
|
1410
|
+
}
|
|
1411
|
+
if (url.includes('/api/taskforce/taxonomy-state')) {
|
|
1412
|
+
return jsonResponse({
|
|
1413
|
+
categories: [{ value: 'cloud-ops', label: 'Cloud Ops' }],
|
|
1414
|
+
types: [{ value: 'incident', label: 'Incident' }],
|
|
1415
|
+
priorities: [{ value: 4, label: 'Critical' }],
|
|
1416
|
+
taxonomies: []
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
1420
|
+
return jsonResponse({});
|
|
1421
|
+
if (url.includes('/api/taskforce/workspace/assignee-options'))
|
|
1422
|
+
return jsonResponse({ assignees: [] });
|
|
1423
|
+
if (url.includes('/api/taskforce/auth/workspace-members'))
|
|
1424
|
+
return jsonResponse({ users: [] });
|
|
1425
|
+
if (url.includes('/api/taskforce/planning/bootstrap'))
|
|
1426
|
+
return jsonResponse({ initiatives: [], workstreams: [], workstreamTaskSummaries: [] });
|
|
1427
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
1428
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
1429
|
+
if (url.includes('/api/taskforce/archive'))
|
|
1430
|
+
return jsonResponse({ archived: [] });
|
|
1431
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
1432
|
+
return jsonResponse({ dataVersion: 1 });
|
|
1433
|
+
if (url.includes('/api/taskforce/build-info'))
|
|
1434
|
+
return jsonResponse({});
|
|
1435
|
+
return jsonResponse({});
|
|
1436
|
+
});
|
|
1437
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
1438
|
+
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
1439
|
+
await waitFor(() => {
|
|
1440
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-cloud-1');
|
|
1441
|
+
expect(result.current.activeCategories.some((category) => category.value === 'cloud-ops')).toBe(true);
|
|
1442
|
+
}, { timeout: 2500 });
|
|
1443
|
+
expect(fetchMock.mock.calls.some(([url]) => String(url).includes('/api/taskforce/categories'))).toBe(false);
|
|
1444
|
+
expect(fetchMock.mock.calls.some(([url]) => String(url).includes('/api/taskforce/types'))).toBe(false);
|
|
1445
|
+
expect(fetchMock.mock.calls.some(([url]) => String(url).includes('/api/taskforce/priorities'))).toBe(false);
|
|
1446
|
+
expect(fetchMock.mock.calls.some(([url]) => String(url).includes('/api/taskforce/taxonomies'))).toBe(false);
|
|
1447
|
+
});
|
|
1448
|
+
it('defers the initial cloud bootstrap on a real cloud host until auth resolves so taxonomy and planning data still load', async () => {
|
|
1449
|
+
const windowProxy = new Proxy(window, {
|
|
1450
|
+
get(target, prop, receiver) {
|
|
1451
|
+
if (prop === 'location') {
|
|
1452
|
+
return {
|
|
1453
|
+
...target.location,
|
|
1454
|
+
hostname: 'app.taskforce.test'
|
|
1455
|
+
};
|
|
1456
|
+
}
|
|
1457
|
+
return Reflect.get(target, prop, receiver);
|
|
1458
|
+
}
|
|
1459
|
+
});
|
|
1460
|
+
vi.stubGlobal('window', windowProxy);
|
|
1461
|
+
let runtimeConfigResolved = false;
|
|
1462
|
+
let authSessionResolved = false;
|
|
1463
|
+
const prematureProtectedCalls = [];
|
|
1464
|
+
const fetchMock = vi.fn((url, init) => {
|
|
1465
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
1466
|
+
return new Promise((resolve) => {
|
|
1467
|
+
window.setTimeout(() => {
|
|
1468
|
+
runtimeConfigResolved = true;
|
|
1469
|
+
resolve({
|
|
1470
|
+
ok: true,
|
|
1471
|
+
status: 200,
|
|
1472
|
+
json: () => Promise.resolve({
|
|
1473
|
+
config: {
|
|
1474
|
+
runtimeMode: 'cloud',
|
|
1475
|
+
workspaceMode: 'multi-cloud',
|
|
1476
|
+
authSource: 'cloud',
|
|
1477
|
+
workspaceSwitchingEnabled: true
|
|
1478
|
+
}
|
|
1479
|
+
})
|
|
1480
|
+
});
|
|
1481
|
+
}, 20);
|
|
1482
|
+
});
|
|
1483
|
+
}
|
|
1484
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
1485
|
+
return new Promise((resolve) => {
|
|
1486
|
+
window.setTimeout(() => {
|
|
1487
|
+
authSessionResolved = true;
|
|
1488
|
+
resolve({
|
|
1489
|
+
ok: true,
|
|
1490
|
+
status: 200,
|
|
1491
|
+
json: () => Promise.resolve({
|
|
1492
|
+
authenticated: true,
|
|
1493
|
+
authRequiredForApi: true,
|
|
1494
|
+
betaAccess: true,
|
|
1495
|
+
userId: 'user-1',
|
|
1496
|
+
email: 'user@example.com',
|
|
1497
|
+
workspaceId: 'workspace-cloud-1'
|
|
1498
|
+
})
|
|
1499
|
+
});
|
|
1500
|
+
}, runtimeConfigResolved ? 20 : 40);
|
|
1501
|
+
});
|
|
1502
|
+
}
|
|
1503
|
+
if ((url.includes('/api/taskforce/config')
|
|
1504
|
+
|| url.includes('/api/taskforce/taxonomy-state')
|
|
1505
|
+
|| url.includes('/api/taskforce/planning/bootstrap')
|
|
1506
|
+
|| url.includes('/api/taskforce/tasks'))
|
|
1507
|
+
&& !authSessionResolved) {
|
|
1508
|
+
prematureProtectedCalls.push(url);
|
|
1509
|
+
}
|
|
1510
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
1511
|
+
return jsonResponse({ success: true, state: {} });
|
|
1512
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
1513
|
+
return jsonResponse({
|
|
1514
|
+
success: true,
|
|
1515
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
if (url.includes('/api/taskforce/workspaces')) {
|
|
1519
|
+
if (String(init?.method || 'GET').toUpperCase() === 'POST') {
|
|
1520
|
+
return jsonResponse({ success: true });
|
|
1521
|
+
}
|
|
1522
|
+
return jsonResponse({
|
|
1523
|
+
success: true,
|
|
1524
|
+
currentWorkspaceId: 'workspace-cloud-1',
|
|
1525
|
+
workspaces: [{ id: 'workspace-cloud-1', name: 'Cloud Workspace', role: 'owner' }]
|
|
1526
|
+
});
|
|
1527
|
+
}
|
|
1528
|
+
if (url.includes('/api/taskforce/session/workspace'))
|
|
1529
|
+
return jsonResponse({ success: true });
|
|
1530
|
+
if (url.includes('/api/taskforce/config')) {
|
|
1531
|
+
return jsonResponse({
|
|
1532
|
+
projectName: 'Cloud Project',
|
|
1533
|
+
workspaceId: 'workspace-cloud-1',
|
|
1534
|
+
runtimeMode: 'cloud',
|
|
1535
|
+
authRequiredForApi: true,
|
|
1536
|
+
userId: 'user-1',
|
|
1537
|
+
setupState: {
|
|
1538
|
+
globalSetupState: 'complete',
|
|
1539
|
+
workspaceSetupState: 'complete',
|
|
1540
|
+
workspaceId: 'workspace-cloud-1'
|
|
1541
|
+
}
|
|
1542
|
+
});
|
|
1543
|
+
}
|
|
1544
|
+
if (url.includes('/api/taskforce/taxonomy-state')) {
|
|
1545
|
+
return jsonResponse({
|
|
1546
|
+
categories: [{ value: 'cloud-ops', label: 'Cloud Ops' }],
|
|
1547
|
+
types: [{ value: 'incident', label: 'Incident' }],
|
|
1548
|
+
priorities: [{ value: 4, label: 'Critical' }],
|
|
1549
|
+
taxonomies: []
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
1553
|
+
return jsonResponse({});
|
|
1554
|
+
if (url.includes('/api/taskforce/workspace/assignee-options')) {
|
|
1555
|
+
return jsonResponse({
|
|
1556
|
+
assignees: [
|
|
1557
|
+
{ userId: 'member-1', email: 'member1@example.com', displayName: 'Member One', status: 'active', disabled: false },
|
|
1558
|
+
{ value: 'ai-profile-codex', label: 'Codex', icon: 'Bot', color: '#0ea5e9', kind: 'agent' }
|
|
1559
|
+
]
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
if (url.includes('/api/taskforce/auth/workspace-members')) {
|
|
1563
|
+
return jsonResponse({
|
|
1564
|
+
users: [
|
|
1565
|
+
{
|
|
1566
|
+
userId: 'user-1',
|
|
1567
|
+
email: 'user@example.com',
|
|
1568
|
+
displayName: 'Signed In Owner',
|
|
1569
|
+
role: 'owner',
|
|
1570
|
+
status: 'active',
|
|
1571
|
+
disabled: false
|
|
1572
|
+
},
|
|
1573
|
+
{
|
|
1574
|
+
userId: 'member-1',
|
|
1575
|
+
email: 'member1@example.com',
|
|
1576
|
+
displayName: 'Member One',
|
|
1577
|
+
status: 'active',
|
|
1578
|
+
disabled: false
|
|
1579
|
+
}
|
|
1580
|
+
]
|
|
1581
|
+
});
|
|
1582
|
+
}
|
|
1583
|
+
if (url.includes('/api/taskforce/planning/bootstrap')) {
|
|
1584
|
+
return jsonResponse({
|
|
1585
|
+
initiatives: [{
|
|
1586
|
+
id: 'initiative-1',
|
|
1587
|
+
title: 'Cloud Initiative',
|
|
1588
|
+
description: '',
|
|
1589
|
+
ownerId: null,
|
|
1590
|
+
createdAt: '2026-03-15T10:00:00.000Z',
|
|
1591
|
+
updatedAt: '2026-03-15T10:00:00.000Z',
|
|
1592
|
+
referenceNumber: 5,
|
|
1593
|
+
referenceLabel: 'IN-5',
|
|
1594
|
+
isArchived: false,
|
|
1595
|
+
comments: [],
|
|
1596
|
+
attachments: []
|
|
1597
|
+
}],
|
|
1598
|
+
workstreams: [{
|
|
1599
|
+
id: 'workstream-1',
|
|
1600
|
+
title: 'Cloud Workstream',
|
|
1601
|
+
description: '',
|
|
1602
|
+
ownerId: null,
|
|
1603
|
+
initiativeId: 'initiative-1',
|
|
1604
|
+
createdAt: '2026-03-15T10:05:00.000Z',
|
|
1605
|
+
updatedAt: '2026-03-15T10:05:00.000Z',
|
|
1606
|
+
referenceNumber: 10,
|
|
1607
|
+
referenceLabel: 'WS-10',
|
|
1608
|
+
isArchived: false,
|
|
1609
|
+
comments: [],
|
|
1610
|
+
attachments: []
|
|
1611
|
+
}],
|
|
1612
|
+
workstreamTaskSummaries: []
|
|
1613
|
+
});
|
|
1614
|
+
}
|
|
1615
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
1616
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
1617
|
+
if (url.includes('/api/taskforce/archive'))
|
|
1618
|
+
return jsonResponse({ archived: [] });
|
|
1619
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
1620
|
+
return jsonResponse({ dataVersion: 1 });
|
|
1621
|
+
if (url.includes('/api/taskforce/build-info'))
|
|
1622
|
+
return jsonResponse({});
|
|
1623
|
+
return jsonResponse({});
|
|
1624
|
+
});
|
|
1625
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
1626
|
+
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
1627
|
+
await waitFor(() => {
|
|
1628
|
+
expect(result.current.authSessionResolved).toBe(true);
|
|
1629
|
+
expect(result.current.isAuthenticated).toBe(true);
|
|
1630
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-cloud-1');
|
|
1631
|
+
expect(result.current.activeCategories.some((category) => category.value === 'cloud-ops')).toBe(true);
|
|
1632
|
+
expect(result.current.initiatives.some((initiative) => initiative.id === 'initiative-1')).toBe(true);
|
|
1633
|
+
expect(result.current.workstreams.some((workstream) => workstream.id === 'workstream-1')).toBe(true);
|
|
1634
|
+
expect(result.current.assigneeOptions.some((option) => option.value === 'member-1' && option.label === 'Member One')).toBe(true);
|
|
1635
|
+
expect(result.current.assigneeOptions.some((option) => option.value === 'ai-profile-codex' && option.label === 'Codex')).toBe(true);
|
|
1636
|
+
}, { timeout: 2500 });
|
|
1637
|
+
expect(prematureProtectedCalls).toEqual([]);
|
|
1638
|
+
});
|
|
1639
|
+
it('falls back to category endpoints when taxonomy-state payload is unavailable during cloud bootstrap', async () => {
|
|
1640
|
+
const fetchMock = vi.fn((url, init) => {
|
|
1641
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
1642
|
+
return jsonResponse({
|
|
1643
|
+
config: {
|
|
1644
|
+
runtimeMode: 'cloud',
|
|
1645
|
+
workspaceMode: 'multi-cloud',
|
|
1646
|
+
authSource: 'cloud',
|
|
1647
|
+
workspaceSwitchingEnabled: true
|
|
1648
|
+
}
|
|
1649
|
+
});
|
|
1650
|
+
}
|
|
1651
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
1652
|
+
return jsonResponse({
|
|
1653
|
+
authenticated: true,
|
|
1654
|
+
authRequiredForApi: true,
|
|
1655
|
+
betaAccess: true,
|
|
1656
|
+
userId: 'user-1',
|
|
1657
|
+
email: 'user@example.com',
|
|
1658
|
+
workspaceId: 'workspace-cloud-1'
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1661
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
1662
|
+
return jsonResponse({ success: true, state: {} });
|
|
1663
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
1664
|
+
return jsonResponse({
|
|
1665
|
+
success: true,
|
|
1666
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
1667
|
+
});
|
|
1668
|
+
}
|
|
1669
|
+
if (url.includes('/api/taskforce/workspaces')) {
|
|
1670
|
+
if (String(init?.method || 'GET').toUpperCase() === 'POST') {
|
|
1671
|
+
return jsonResponse({ success: true });
|
|
1672
|
+
}
|
|
1673
|
+
return jsonResponse({
|
|
1674
|
+
success: true,
|
|
1675
|
+
currentWorkspaceId: 'workspace-cloud-1',
|
|
1676
|
+
workspaces: [{ id: 'workspace-cloud-1', name: 'Cloud Workspace', role: 'owner' }]
|
|
1677
|
+
});
|
|
1678
|
+
}
|
|
1679
|
+
if (url.includes('/api/taskforce/session/workspace'))
|
|
1680
|
+
return jsonResponse({ success: true });
|
|
1681
|
+
if (url.includes('/api/taskforce/config')) {
|
|
1682
|
+
return jsonResponse({
|
|
1683
|
+
projectName: 'Cloud Project',
|
|
1684
|
+
workspaceId: 'workspace-cloud-1',
|
|
1685
|
+
runtimeMode: 'cloud',
|
|
1686
|
+
authRequiredForApi: true,
|
|
1687
|
+
userId: 'user-1',
|
|
1688
|
+
setupState: {
|
|
1689
|
+
globalSetupState: 'complete',
|
|
1690
|
+
workspaceSetupState: 'complete',
|
|
1691
|
+
workspaceId: 'workspace-cloud-1'
|
|
1692
|
+
}
|
|
1693
|
+
});
|
|
1694
|
+
}
|
|
1695
|
+
if (url.includes('/api/taskforce/taxonomy-state'))
|
|
1696
|
+
return jsonResponse({});
|
|
1697
|
+
if (url.includes('/api/taskforce/categories'))
|
|
1698
|
+
return jsonResponse({ categories: [{ value: 'cloud-ops', label: 'Cloud Ops' }] });
|
|
1699
|
+
if (url.includes('/api/taskforce/types'))
|
|
1700
|
+
return jsonResponse({ types: [{ value: 'incident', label: 'Incident' }] });
|
|
1701
|
+
if (url.includes('/api/taskforce/priorities'))
|
|
1702
|
+
return jsonResponse({ priorities: [{ value: 4, label: 'Critical' }] });
|
|
1703
|
+
if (url.includes('/api/taskforce/taxonomies'))
|
|
1704
|
+
return jsonResponse({ taxonomies: [] });
|
|
1705
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
1706
|
+
return jsonResponse({});
|
|
1707
|
+
if (url.includes('/api/taskforce/workspace/assignee-options'))
|
|
1708
|
+
return jsonResponse({ assignees: [] });
|
|
1709
|
+
if (url.includes('/api/taskforce/auth/workspace-members'))
|
|
1710
|
+
return jsonResponse({ users: [] });
|
|
1711
|
+
if (url.includes('/api/taskforce/planning/bootstrap'))
|
|
1712
|
+
return jsonResponse({ initiatives: [], workstreams: [], workstreamTaskSummaries: [] });
|
|
1713
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
1714
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
1715
|
+
if (url.includes('/api/taskforce/archive'))
|
|
1716
|
+
return jsonResponse({ archived: [] });
|
|
1717
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
1718
|
+
return jsonResponse({ dataVersion: 1 });
|
|
1719
|
+
if (url.includes('/api/taskforce/build-info'))
|
|
1720
|
+
return jsonResponse({});
|
|
1721
|
+
return jsonResponse({});
|
|
1722
|
+
});
|
|
1723
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
1724
|
+
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
1725
|
+
await waitFor(() => {
|
|
1726
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-cloud-1');
|
|
1727
|
+
expect(result.current.activeCategories.some((category) => category.value === 'cloud-ops')).toBe(true);
|
|
1728
|
+
expect(result.current.activeTypes.some((type) => type.value === 'incident')).toBe(true);
|
|
1729
|
+
expect(result.current.priorities.some((priority) => priority.value === 4)).toBe(true);
|
|
1730
|
+
}, { timeout: 2500 });
|
|
1731
|
+
expect(fetchMock.mock.calls.some(([url]) => String(url).includes('/api/taskforce/categories'))).toBe(true);
|
|
1732
|
+
expect(fetchMock.mock.calls.some(([url]) => String(url).includes('/api/taskforce/types'))).toBe(true);
|
|
1733
|
+
expect(fetchMock.mock.calls.some(([url]) => String(url).includes('/api/taskforce/priorities'))).toBe(true);
|
|
1734
|
+
expect(fetchMock.mock.calls.some(([url]) => String(url).includes('/api/taskforce/taxonomies'))).toBe(true);
|
|
1735
|
+
});
|
|
1736
|
+
it('rehydrates taxonomy state for the newly selected workspace after a cloud workspace switch', async () => {
|
|
1737
|
+
let sessionWorkspaceId = 'workspace-cloud-1';
|
|
1738
|
+
const fetchMock = vi.fn((url, init) => {
|
|
1739
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
1740
|
+
return jsonResponse({
|
|
1741
|
+
config: {
|
|
1742
|
+
runtimeMode: 'cloud',
|
|
1743
|
+
workspaceMode: 'multi-cloud',
|
|
1744
|
+
authSource: 'cloud',
|
|
1745
|
+
workspaceSwitchingEnabled: true
|
|
1746
|
+
}
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
1750
|
+
return jsonResponse({
|
|
1751
|
+
authenticated: true,
|
|
1752
|
+
authRequiredForApi: true,
|
|
1753
|
+
betaAccess: true,
|
|
1754
|
+
userId: 'user-1',
|
|
1755
|
+
email: 'user@example.com',
|
|
1756
|
+
workspaceId: sessionWorkspaceId
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
1760
|
+
return jsonResponse({ success: true, state: {} });
|
|
1761
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
1762
|
+
return jsonResponse({
|
|
1763
|
+
success: true,
|
|
1764
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
1765
|
+
});
|
|
1766
|
+
}
|
|
1767
|
+
if (url.includes('/api/taskforce/workspaces')) {
|
|
1768
|
+
if (String(init?.method || 'GET').toUpperCase() === 'POST') {
|
|
1769
|
+
return jsonResponse({ success: true });
|
|
1770
|
+
}
|
|
1771
|
+
return jsonResponse({
|
|
1772
|
+
success: true,
|
|
1773
|
+
currentWorkspaceId: sessionWorkspaceId,
|
|
1774
|
+
workspaces: [
|
|
1775
|
+
{ id: 'workspace-cloud-1', name: 'Cloud Workspace 1', role: 'owner' },
|
|
1776
|
+
{ id: 'workspace-cloud-2', name: 'Cloud Workspace 2', role: 'owner' }
|
|
1777
|
+
]
|
|
1778
|
+
});
|
|
1779
|
+
}
|
|
1780
|
+
if (url.includes('/api/taskforce/session/workspace')) {
|
|
1781
|
+
const body = JSON.parse(String(init?.body || '{}'));
|
|
1782
|
+
sessionWorkspaceId = String(body.workspaceId || '').trim() || sessionWorkspaceId;
|
|
1783
|
+
return jsonResponse({ success: true });
|
|
1784
|
+
}
|
|
1785
|
+
if (url.includes('/api/taskforce/config')) {
|
|
1786
|
+
return jsonResponse({
|
|
1787
|
+
projectName: sessionWorkspaceId === 'workspace-cloud-2' ? 'Cloud Project 2' : 'Cloud Project 1',
|
|
1788
|
+
workspaceId: sessionWorkspaceId,
|
|
1789
|
+
runtimeMode: 'cloud',
|
|
1790
|
+
authRequiredForApi: true,
|
|
1791
|
+
userId: 'user-1',
|
|
1792
|
+
setupState: {
|
|
1793
|
+
globalSetupState: 'complete',
|
|
1794
|
+
workspaceSetupState: 'complete',
|
|
1795
|
+
workspaceId: sessionWorkspaceId
|
|
1796
|
+
}
|
|
1797
|
+
});
|
|
1798
|
+
}
|
|
1799
|
+
if (url.includes('/api/taskforce/taxonomy-state')) {
|
|
1800
|
+
if (sessionWorkspaceId === 'workspace-cloud-2') {
|
|
1801
|
+
return jsonResponse({
|
|
1802
|
+
categories: [{ value: 'workspace-two', label: 'Workspace Two' }],
|
|
1803
|
+
types: [{ value: 'incident', label: 'Incident' }],
|
|
1804
|
+
priorities: [{ value: 4, label: 'Critical' }],
|
|
1805
|
+
taxonomies: []
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1808
|
+
return jsonResponse({
|
|
1809
|
+
categories: [{ value: 'workspace-one', label: 'Workspace One' }],
|
|
1810
|
+
types: [{ value: 'feature', label: 'Feature' }],
|
|
1811
|
+
priorities: [{ value: 2, label: 'Medium' }],
|
|
1812
|
+
taxonomies: []
|
|
1813
|
+
});
|
|
1814
|
+
}
|
|
1815
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
1816
|
+
return jsonResponse({});
|
|
1817
|
+
if (url.includes('/api/taskforce/workspace/assignee-options'))
|
|
1818
|
+
return jsonResponse({ assignees: [] });
|
|
1819
|
+
if (url.includes('/api/taskforce/auth/workspace-members'))
|
|
1820
|
+
return jsonResponse({ users: [] });
|
|
1821
|
+
if (url.includes('/api/taskforce/planning/bootstrap'))
|
|
1822
|
+
return jsonResponse({ initiatives: [], workstreams: [], workstreamTaskSummaries: [] });
|
|
1823
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
1824
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
1825
|
+
if (url.includes('/api/taskforce/archive'))
|
|
1826
|
+
return jsonResponse({ archived: [] });
|
|
1827
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
1828
|
+
return jsonResponse({ dataVersion: 1 });
|
|
1829
|
+
if (url.includes('/api/taskforce/build-info'))
|
|
1830
|
+
return jsonResponse({});
|
|
1831
|
+
return jsonResponse({});
|
|
1832
|
+
});
|
|
1833
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
1834
|
+
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
1835
|
+
await waitFor(() => {
|
|
1836
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-cloud-1');
|
|
1837
|
+
expect(result.current.activeCategories.some((category) => category.value === 'workspace-one')).toBe(true);
|
|
1838
|
+
}, { timeout: 2500 });
|
|
1839
|
+
await act(async () => {
|
|
1840
|
+
const switched = await result.current.switchWorkspace('workspace-cloud-2');
|
|
1841
|
+
expect(switched).toEqual({ success: true });
|
|
1842
|
+
});
|
|
1843
|
+
await waitFor(() => {
|
|
1844
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-cloud-2');
|
|
1845
|
+
expect(result.current.activeCategories.some((category) => category.value === 'workspace-two')).toBe(true);
|
|
1846
|
+
expect(result.current.activeCategories.some((category) => category.value === 'workspace-one')).toBe(false);
|
|
1847
|
+
expect(result.current.activeTypes.some((type) => type.value === 'incident')).toBe(true);
|
|
1848
|
+
expect(result.current.activeTypes.some((type) => type.value === 'feature')).toBe(false);
|
|
1849
|
+
expect(result.current.priorities.some((priority) => priority.value === 4)).toBe(true);
|
|
1850
|
+
}, { timeout: 2500 });
|
|
1851
|
+
});
|
|
1852
|
+
it('rehydrates assignee options and workspace role for the newly selected cloud workspace after a workspace switch', async () => {
|
|
1853
|
+
let sessionWorkspaceId = 'workspace-cloud-1';
|
|
1854
|
+
vi.stubGlobal('fetch', vi.fn((url, init) => {
|
|
1855
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
1856
|
+
return jsonResponse({
|
|
1857
|
+
config: {
|
|
1858
|
+
runtimeMode: 'cloud',
|
|
1859
|
+
workspaceMode: 'multi-cloud',
|
|
1860
|
+
authSource: 'cloud',
|
|
1861
|
+
workspaceSwitchingEnabled: true
|
|
1862
|
+
}
|
|
1863
|
+
});
|
|
1864
|
+
}
|
|
1865
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
1866
|
+
return jsonResponse({
|
|
1867
|
+
authenticated: true,
|
|
1868
|
+
authRequiredForApi: true,
|
|
1869
|
+
betaAccess: true,
|
|
1870
|
+
userId: 'user-1',
|
|
1871
|
+
email: 'user@example.com',
|
|
1872
|
+
workspaceId: sessionWorkspaceId
|
|
1873
|
+
});
|
|
1874
|
+
}
|
|
1875
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
1876
|
+
return jsonResponse({ success: true, state: {} });
|
|
1877
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
1878
|
+
return jsonResponse({
|
|
1879
|
+
success: true,
|
|
1880
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
1881
|
+
});
|
|
1882
|
+
}
|
|
1883
|
+
if (url.includes('/api/taskforce/workspaces')) {
|
|
1884
|
+
if (String(init?.method || 'GET').toUpperCase() === 'POST') {
|
|
1885
|
+
return jsonResponse({ success: true });
|
|
1886
|
+
}
|
|
1887
|
+
return jsonResponse({
|
|
1888
|
+
success: true,
|
|
1889
|
+
currentWorkspaceId: sessionWorkspaceId,
|
|
1890
|
+
workspaces: [
|
|
1891
|
+
{ id: 'workspace-cloud-1', name: 'Cloud Workspace 1', role: 'owner' },
|
|
1892
|
+
{ id: 'workspace-cloud-2', name: 'Cloud Workspace 2', role: 'member' }
|
|
1893
|
+
]
|
|
1894
|
+
});
|
|
1895
|
+
}
|
|
1896
|
+
if (url.includes('/api/taskforce/session/workspace')) {
|
|
1897
|
+
const body = JSON.parse(String(init?.body || '{}'));
|
|
1898
|
+
sessionWorkspaceId = String(body.workspaceId || '').trim() || sessionWorkspaceId;
|
|
1899
|
+
return jsonResponse({ success: true });
|
|
1900
|
+
}
|
|
1901
|
+
if (url.includes('/api/taskforce/config')) {
|
|
1902
|
+
return jsonResponse({
|
|
1903
|
+
projectName: sessionWorkspaceId === 'workspace-cloud-2' ? 'Cloud Project 2' : 'Cloud Project 1',
|
|
1904
|
+
workspaceId: sessionWorkspaceId,
|
|
1905
|
+
runtimeMode: 'cloud',
|
|
1906
|
+
authRequiredForApi: true,
|
|
1907
|
+
userId: 'user-1',
|
|
1908
|
+
setupState: {
|
|
1909
|
+
globalSetupState: 'complete',
|
|
1910
|
+
workspaceSetupState: 'complete',
|
|
1911
|
+
workspaceId: sessionWorkspaceId
|
|
1912
|
+
}
|
|
1913
|
+
});
|
|
1914
|
+
}
|
|
1915
|
+
if (url.includes('/api/taskforce/taxonomy-state')) {
|
|
1916
|
+
return jsonResponse({
|
|
1917
|
+
categories: [{ value: sessionWorkspaceId === 'workspace-cloud-2' ? 'workspace-two' : 'workspace-one', label: 'Workspace' }],
|
|
1918
|
+
types: [{ value: 'feature', label: 'Feature' }],
|
|
1919
|
+
priorities: [{ value: 2, label: 'Medium' }],
|
|
1920
|
+
taxonomies: []
|
|
1921
|
+
});
|
|
1922
|
+
}
|
|
1923
|
+
if (url.includes('/api/taskforce/auth/workspace-members')) {
|
|
1924
|
+
if (sessionWorkspaceId === 'workspace-cloud-2') {
|
|
1925
|
+
return jsonResponse({
|
|
1926
|
+
users: [
|
|
1927
|
+
{
|
|
1928
|
+
userId: 'user-1',
|
|
1929
|
+
email: 'user@example.com',
|
|
1930
|
+
displayName: 'Signed In User',
|
|
1931
|
+
role: 'member',
|
|
1932
|
+
status: 'active',
|
|
1933
|
+
disabled: false
|
|
1934
|
+
},
|
|
1935
|
+
{
|
|
1936
|
+
userId: 'member-2',
|
|
1937
|
+
email: 'member2@example.com',
|
|
1938
|
+
displayName: 'Workspace Two Member',
|
|
1939
|
+
status: 'active',
|
|
1940
|
+
disabled: false
|
|
1941
|
+
}
|
|
1942
|
+
]
|
|
1943
|
+
});
|
|
1944
|
+
}
|
|
1945
|
+
return jsonResponse({
|
|
1946
|
+
users: [
|
|
1947
|
+
{
|
|
1948
|
+
userId: 'user-1',
|
|
1949
|
+
email: 'user@example.com',
|
|
1950
|
+
displayName: 'Signed In User',
|
|
1951
|
+
role: 'owner',
|
|
1952
|
+
status: 'active',
|
|
1953
|
+
disabled: false
|
|
1954
|
+
},
|
|
1955
|
+
{
|
|
1956
|
+
userId: 'member-1',
|
|
1957
|
+
email: 'member1@example.com',
|
|
1958
|
+
displayName: 'Workspace One Member',
|
|
1959
|
+
status: 'active',
|
|
1960
|
+
disabled: false
|
|
1961
|
+
}
|
|
1962
|
+
]
|
|
1963
|
+
});
|
|
1964
|
+
}
|
|
1965
|
+
if (url.includes('/api/taskforce/workspace/assignee-options')) {
|
|
1966
|
+
if (sessionWorkspaceId === 'workspace-cloud-2') {
|
|
1967
|
+
return jsonResponse({
|
|
1968
|
+
assignees: [
|
|
1969
|
+
{ userId: 'member-2', email: 'member2@example.com', displayName: 'Workspace Two Member', status: 'active', disabled: false },
|
|
1970
|
+
{ value: 'ai-profile-reviewer', label: 'Reviewer', icon: 'Bot', color: '#0ea5e9', kind: 'agent' }
|
|
1971
|
+
]
|
|
1972
|
+
});
|
|
1973
|
+
}
|
|
1974
|
+
return jsonResponse({
|
|
1975
|
+
assignees: [
|
|
1976
|
+
{ userId: 'member-1', email: 'member1@example.com', displayName: 'Workspace One Member', status: 'active', disabled: false },
|
|
1977
|
+
{ value: 'ai-profile-codex', label: 'Codex', icon: 'Bot', color: '#0ea5e9', kind: 'agent' }
|
|
1978
|
+
]
|
|
1979
|
+
});
|
|
1980
|
+
}
|
|
1981
|
+
if (url.includes('/api/taskforce/planning/bootstrap'))
|
|
1982
|
+
return jsonResponse({ initiatives: [], workstreams: [], workstreamTaskSummaries: [] });
|
|
1983
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
1984
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
1985
|
+
if (url.includes('/api/taskforce/archive'))
|
|
1986
|
+
return jsonResponse({ archived: [] });
|
|
1987
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
1988
|
+
return jsonResponse({ dataVersion: 1 });
|
|
1989
|
+
if (url.includes('/api/taskforce/build-info'))
|
|
1990
|
+
return jsonResponse({});
|
|
1991
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
1992
|
+
return jsonResponse({});
|
|
1993
|
+
return jsonResponse({});
|
|
1994
|
+
}));
|
|
1995
|
+
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
1996
|
+
await waitFor(() => {
|
|
1997
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-cloud-1');
|
|
1998
|
+
expect(result.current.currentWorkspaceRole).toBe('owner');
|
|
1999
|
+
expect(result.current.assigneeOptions.some((option) => option.value === 'member-1' && option.label === 'Workspace One Member')).toBe(true);
|
|
2000
|
+
expect(result.current.assigneeOptions.some((option) => option.value === 'ai-profile-codex' && option.label === 'Codex')).toBe(true);
|
|
2001
|
+
}, { timeout: 2500 });
|
|
2002
|
+
await act(async () => {
|
|
2003
|
+
const switched = await result.current.switchWorkspace('workspace-cloud-2');
|
|
2004
|
+
expect(switched).toEqual({ success: true });
|
|
2005
|
+
});
|
|
2006
|
+
await waitFor(() => {
|
|
2007
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-cloud-2');
|
|
2008
|
+
expect(result.current.currentWorkspaceRole).toBe('member');
|
|
2009
|
+
expect(result.current.assigneeOptions.some((option) => option.value === 'member-2' && option.label === 'Workspace Two Member')).toBe(true);
|
|
2010
|
+
expect(result.current.assigneeOptions.some((option) => option.value === 'member-1')).toBe(false);
|
|
2011
|
+
expect(result.current.assigneeOptions.some((option) => option.value === 'ai-profile-reviewer' && option.label === 'Reviewer')).toBe(true);
|
|
2012
|
+
expect(result.current.assigneeOptions.some((option) => option.value === 'ai-profile-codex')).toBe(false);
|
|
2013
|
+
}, { timeout: 2500 });
|
|
2014
|
+
});
|
|
2015
|
+
it('starts planning bootstrap before deferred assignee hydration after a cloud workspace switch', async () => {
|
|
2016
|
+
let sessionWorkspaceId = 'workspace-cloud-1';
|
|
2017
|
+
const requestOrder = [];
|
|
2018
|
+
let resolveWorkspaceTwoAssignees = null;
|
|
2019
|
+
vi.stubGlobal('fetch', vi.fn((url, init) => {
|
|
2020
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
2021
|
+
return jsonResponse({
|
|
2022
|
+
config: {
|
|
2023
|
+
runtimeMode: 'cloud',
|
|
2024
|
+
workspaceMode: 'multi-cloud',
|
|
2025
|
+
authSource: 'cloud',
|
|
2026
|
+
workspaceSwitchingEnabled: true
|
|
2027
|
+
}
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
2031
|
+
return jsonResponse({
|
|
2032
|
+
authenticated: true,
|
|
2033
|
+
authRequiredForApi: true,
|
|
2034
|
+
betaAccess: true,
|
|
2035
|
+
userId: 'user-1',
|
|
2036
|
+
email: 'user@example.com',
|
|
2037
|
+
workspaceId: sessionWorkspaceId
|
|
2038
|
+
});
|
|
2039
|
+
}
|
|
2040
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
2041
|
+
return jsonResponse({ success: true, state: {} });
|
|
2042
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
2043
|
+
return jsonResponse({
|
|
2044
|
+
success: true,
|
|
2045
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
2046
|
+
});
|
|
2047
|
+
}
|
|
2048
|
+
if (url.includes('/api/taskforce/workspaces')) {
|
|
2049
|
+
if (String(init?.method || 'GET').toUpperCase() === 'POST')
|
|
2050
|
+
return jsonResponse({ success: true });
|
|
2051
|
+
return jsonResponse({
|
|
2052
|
+
success: true,
|
|
2053
|
+
currentWorkspaceId: sessionWorkspaceId,
|
|
2054
|
+
workspaces: [
|
|
2055
|
+
{ id: 'workspace-cloud-1', name: 'Cloud Workspace 1', role: 'owner' },
|
|
2056
|
+
{ id: 'workspace-cloud-2', name: 'Cloud Workspace 2', role: 'member' }
|
|
2057
|
+
]
|
|
2058
|
+
});
|
|
2059
|
+
}
|
|
2060
|
+
if (url.includes('/api/taskforce/session/workspace')) {
|
|
2061
|
+
const body = JSON.parse(String(init?.body || '{}'));
|
|
2062
|
+
sessionWorkspaceId = String(body.workspaceId || '').trim() || sessionWorkspaceId;
|
|
2063
|
+
return jsonResponse({ success: true });
|
|
2064
|
+
}
|
|
2065
|
+
if (url.includes('/api/taskforce/config')) {
|
|
2066
|
+
return jsonResponse({
|
|
2067
|
+
projectName: sessionWorkspaceId === 'workspace-cloud-2' ? 'Cloud Project 2' : 'Cloud Project 1',
|
|
2068
|
+
workspaceId: sessionWorkspaceId,
|
|
2069
|
+
runtimeMode: 'cloud',
|
|
2070
|
+
authRequiredForApi: true,
|
|
2071
|
+
userId: 'user-1',
|
|
2072
|
+
setupState: {
|
|
2073
|
+
globalSetupState: 'complete',
|
|
2074
|
+
workspaceSetupState: 'complete',
|
|
2075
|
+
workspaceId: sessionWorkspaceId
|
|
2076
|
+
}
|
|
2077
|
+
});
|
|
2078
|
+
}
|
|
2079
|
+
if (url.includes('/api/taskforce/taxonomy-state')) {
|
|
2080
|
+
return jsonResponse({
|
|
2081
|
+
categories: [{ value: sessionWorkspaceId === 'workspace-cloud-2' ? 'workspace-two' : 'workspace-one', label: 'Workspace' }],
|
|
2082
|
+
types: [{ value: 'feature', label: 'Feature' }],
|
|
2083
|
+
priorities: [{ value: 2, label: 'Medium' }],
|
|
2084
|
+
taxonomies: []
|
|
2085
|
+
});
|
|
2086
|
+
}
|
|
2087
|
+
if (url.includes('/api/taskforce/auth/workspace-members'))
|
|
2088
|
+
return jsonResponse({ users: [] });
|
|
2089
|
+
if (url.includes('/api/taskforce/workspace/assignee-options')) {
|
|
2090
|
+
requestOrder.push(`assignee:${sessionWorkspaceId}`);
|
|
2091
|
+
if (sessionWorkspaceId === 'workspace-cloud-2') {
|
|
2092
|
+
return new Promise((resolve) => {
|
|
2093
|
+
resolveWorkspaceTwoAssignees = () => resolve({
|
|
2094
|
+
ok: true,
|
|
2095
|
+
status: 200,
|
|
2096
|
+
json: () => Promise.resolve({ assignees: [] })
|
|
2097
|
+
});
|
|
2098
|
+
});
|
|
2099
|
+
}
|
|
2100
|
+
return jsonResponse({ assignees: [] });
|
|
2101
|
+
}
|
|
2102
|
+
if (url.includes('/api/taskforce/planning/bootstrap')) {
|
|
2103
|
+
requestOrder.push(`planning:${sessionWorkspaceId}`);
|
|
2104
|
+
return jsonResponse({
|
|
2105
|
+
initiatives: [{ id: `initiative-${sessionWorkspaceId}`, title: `Initiative ${sessionWorkspaceId}` }],
|
|
2106
|
+
workstreams: [],
|
|
2107
|
+
workstreamTaskSummaries: []
|
|
2108
|
+
});
|
|
2109
|
+
}
|
|
2110
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
2111
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
2112
|
+
if (url.includes('/api/taskforce/archive'))
|
|
2113
|
+
return jsonResponse({ archived: [] });
|
|
2114
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
2115
|
+
return jsonResponse({ dataVersion: 1 });
|
|
2116
|
+
if (url.includes('/api/taskforce/build-info'))
|
|
2117
|
+
return jsonResponse({});
|
|
2118
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
2119
|
+
return jsonResponse({});
|
|
2120
|
+
return jsonResponse({});
|
|
2121
|
+
}));
|
|
2122
|
+
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
2123
|
+
await waitFor(() => {
|
|
2124
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-cloud-1');
|
|
2125
|
+
expect(result.current.initiatives.some((initiative) => initiative.id === 'initiative-workspace-cloud-1')).toBe(true);
|
|
2126
|
+
}, { timeout: 2500 });
|
|
2127
|
+
requestOrder.length = 0;
|
|
2128
|
+
await act(async () => {
|
|
2129
|
+
const switched = await result.current.switchWorkspace('workspace-cloud-2');
|
|
2130
|
+
expect(switched).toEqual({ success: true });
|
|
2131
|
+
});
|
|
2132
|
+
await waitFor(() => {
|
|
2133
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-cloud-2');
|
|
2134
|
+
expect(result.current.initiatives.some((initiative) => initiative.id === 'initiative-workspace-cloud-2')).toBe(true);
|
|
2135
|
+
}, { timeout: 2500 });
|
|
2136
|
+
await waitFor(() => {
|
|
2137
|
+
expect(requestOrder).toContain('planning:workspace-cloud-2');
|
|
2138
|
+
expect(requestOrder).toContain('assignee:workspace-cloud-2');
|
|
2139
|
+
}, { timeout: 2500 });
|
|
2140
|
+
expect(requestOrder.indexOf('planning:workspace-cloud-2')).toBeLessThan(requestOrder.indexOf('assignee:workspace-cloud-2'));
|
|
2141
|
+
await act(async () => {
|
|
2142
|
+
resolveWorkspaceTwoAssignees?.();
|
|
2143
|
+
});
|
|
2144
|
+
});
|
|
2145
|
+
it('rehydrates planning bootstrap outputs for the newly selected cloud workspace after a workspace switch', async () => {
|
|
2146
|
+
let sessionWorkspaceId = 'workspace-cloud-1';
|
|
2147
|
+
const planningBootstrapWorkspaces = [];
|
|
2148
|
+
const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => { });
|
|
2149
|
+
vi.stubGlobal('fetch', vi.fn((url, init) => {
|
|
2150
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
2151
|
+
return jsonResponse({
|
|
2152
|
+
config: {
|
|
2153
|
+
runtimeMode: 'cloud',
|
|
2154
|
+
workspaceMode: 'multi-cloud',
|
|
2155
|
+
authSource: 'cloud',
|
|
2156
|
+
workspaceSwitchingEnabled: true
|
|
2157
|
+
}
|
|
2158
|
+
});
|
|
2159
|
+
}
|
|
2160
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
2161
|
+
return jsonResponse({
|
|
2162
|
+
authenticated: true,
|
|
2163
|
+
authRequiredForApi: true,
|
|
2164
|
+
betaAccess: true,
|
|
2165
|
+
userId: 'user-1',
|
|
2166
|
+
email: 'user@example.com',
|
|
2167
|
+
workspaceId: sessionWorkspaceId
|
|
2168
|
+
});
|
|
2169
|
+
}
|
|
2170
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
2171
|
+
return jsonResponse({ success: true, state: {} });
|
|
2172
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
2173
|
+
return jsonResponse({
|
|
2174
|
+
success: true,
|
|
2175
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
2176
|
+
});
|
|
2177
|
+
}
|
|
2178
|
+
if (url.includes('/api/taskforce/workspaces')) {
|
|
2179
|
+
if (String(init?.method || 'GET').toUpperCase() === 'POST') {
|
|
2180
|
+
return jsonResponse({ success: true });
|
|
2181
|
+
}
|
|
2182
|
+
return jsonResponse({
|
|
2183
|
+
success: true,
|
|
2184
|
+
currentWorkspaceId: sessionWorkspaceId,
|
|
2185
|
+
workspaces: [
|
|
2186
|
+
{ id: 'workspace-cloud-1', name: 'Cloud Workspace 1', role: 'owner' },
|
|
2187
|
+
{ id: 'workspace-cloud-2', name: 'Cloud Workspace 2', role: 'member' }
|
|
2188
|
+
]
|
|
2189
|
+
});
|
|
2190
|
+
}
|
|
2191
|
+
if (url.includes('/api/taskforce/session/workspace')) {
|
|
2192
|
+
const body = JSON.parse(String(init?.body || '{}'));
|
|
2193
|
+
sessionWorkspaceId = String(body.workspaceId || '').trim() || sessionWorkspaceId;
|
|
2194
|
+
return jsonResponse({ success: true });
|
|
2195
|
+
}
|
|
2196
|
+
if (url.includes('/api/taskforce/config')) {
|
|
2197
|
+
return jsonResponse({
|
|
2198
|
+
projectName: sessionWorkspaceId === 'workspace-cloud-2' ? 'Cloud Project 2' : 'Cloud Project 1',
|
|
2199
|
+
workspaceId: sessionWorkspaceId,
|
|
2200
|
+
runtimeMode: 'cloud',
|
|
2201
|
+
authRequiredForApi: true,
|
|
2202
|
+
userId: 'user-1',
|
|
2203
|
+
setupState: {
|
|
2204
|
+
globalSetupState: 'complete',
|
|
2205
|
+
workspaceSetupState: 'complete',
|
|
2206
|
+
workspaceId: sessionWorkspaceId
|
|
2207
|
+
}
|
|
2208
|
+
});
|
|
2209
|
+
}
|
|
2210
|
+
if (url.includes('/api/taskforce/taxonomy-state')) {
|
|
2211
|
+
return jsonResponse({
|
|
2212
|
+
categories: [{ value: sessionWorkspaceId === 'workspace-cloud-2' ? 'workspace-two' : 'workspace-one', label: 'Workspace' }],
|
|
2213
|
+
types: [{ value: 'feature', label: 'Feature' }],
|
|
2214
|
+
priorities: [{ value: 2, label: 'Medium' }],
|
|
2215
|
+
taxonomies: []
|
|
2216
|
+
});
|
|
2217
|
+
}
|
|
2218
|
+
if (url.includes('/api/taskforce/auth/workspace-members'))
|
|
2219
|
+
return jsonResponse({ users: [] });
|
|
2220
|
+
if (url.includes('/api/taskforce/workspace/assignee-options'))
|
|
2221
|
+
return jsonResponse({ assignees: [] });
|
|
2222
|
+
if (url.includes('/api/taskforce/planning/bootstrap')) {
|
|
2223
|
+
planningBootstrapWorkspaces.push(sessionWorkspaceId);
|
|
2224
|
+
if (sessionWorkspaceId === 'workspace-cloud-2') {
|
|
2225
|
+
return jsonResponse({
|
|
2226
|
+
initiatives: [
|
|
2227
|
+
{
|
|
2228
|
+
id: 'initiative-2',
|
|
2229
|
+
title: 'Workspace Two Initiative',
|
|
2230
|
+
description: 'Workspace two planning initiative',
|
|
2231
|
+
ownerId: null,
|
|
2232
|
+
createdAt: '2026-03-15T10:20:00.000Z',
|
|
2233
|
+
updatedAt: '2026-03-15T10:20:00.000Z',
|
|
2234
|
+
referenceNumber: 12,
|
|
2235
|
+
referenceLabel: 'IN-12',
|
|
2236
|
+
isArchived: false,
|
|
2237
|
+
comments: [],
|
|
2238
|
+
attachments: []
|
|
2239
|
+
}
|
|
2240
|
+
],
|
|
2241
|
+
workstreams: [
|
|
2242
|
+
{
|
|
2243
|
+
id: 'workstream-2',
|
|
2244
|
+
title: 'Workspace Two Workstream',
|
|
2245
|
+
description: 'Workspace two workstream',
|
|
2246
|
+
ownerId: null,
|
|
2247
|
+
initiativeId: 'initiative-2',
|
|
2248
|
+
createdAt: '2026-03-15T10:25:00.000Z',
|
|
2249
|
+
updatedAt: '2026-03-15T10:25:00.000Z',
|
|
2250
|
+
referenceNumber: 102,
|
|
2251
|
+
referenceLabel: 'WS-102',
|
|
2252
|
+
isArchived: false,
|
|
2253
|
+
comments: [],
|
|
2254
|
+
attachments: []
|
|
2255
|
+
}
|
|
2256
|
+
],
|
|
2257
|
+
workstreamTaskSummaries: [{
|
|
2258
|
+
workstreamId: 'workstream-2',
|
|
2259
|
+
taskCount: 1,
|
|
2260
|
+
completedTaskCount: 0,
|
|
2261
|
+
tasks: [{
|
|
2262
|
+
id: 'task-workspace-2',
|
|
2263
|
+
title: 'Workspace Two Task',
|
|
2264
|
+
status: 'task'
|
|
2265
|
+
}]
|
|
2266
|
+
}]
|
|
2267
|
+
});
|
|
2268
|
+
}
|
|
2269
|
+
return jsonResponse({
|
|
2270
|
+
initiatives: [
|
|
2271
|
+
{
|
|
2272
|
+
id: 'initiative-1',
|
|
2273
|
+
title: 'Workspace One Initiative',
|
|
2274
|
+
description: 'Workspace one planning initiative',
|
|
2275
|
+
ownerId: null,
|
|
2276
|
+
createdAt: '2026-03-15T10:00:00.000Z',
|
|
2277
|
+
updatedAt: '2026-03-15T10:00:00.000Z',
|
|
2278
|
+
referenceNumber: 11,
|
|
2279
|
+
referenceLabel: 'IN-11',
|
|
2280
|
+
isArchived: false,
|
|
2281
|
+
comments: [],
|
|
2282
|
+
attachments: []
|
|
2283
|
+
}
|
|
2284
|
+
],
|
|
2285
|
+
workstreams: [
|
|
2286
|
+
{
|
|
2287
|
+
id: 'workstream-1',
|
|
2288
|
+
title: 'Workspace One Workstream',
|
|
2289
|
+
description: 'Workspace one workstream',
|
|
2290
|
+
ownerId: null,
|
|
2291
|
+
initiativeId: 'initiative-1',
|
|
2292
|
+
createdAt: '2026-03-15T10:05:00.000Z',
|
|
2293
|
+
updatedAt: '2026-03-15T10:05:00.000Z',
|
|
2294
|
+
referenceNumber: 101,
|
|
2295
|
+
referenceLabel: 'WS-101',
|
|
2296
|
+
isArchived: false,
|
|
2297
|
+
comments: [],
|
|
2298
|
+
attachments: []
|
|
2299
|
+
}
|
|
2300
|
+
],
|
|
2301
|
+
workstreamTaskSummaries: [{
|
|
2302
|
+
workstreamId: 'workstream-1',
|
|
2303
|
+
taskCount: 1,
|
|
2304
|
+
completedTaskCount: 0,
|
|
2305
|
+
tasks: [{
|
|
2306
|
+
id: 'task-workspace-1',
|
|
2307
|
+
title: 'Workspace One Task',
|
|
2308
|
+
status: 'task'
|
|
2309
|
+
}]
|
|
2310
|
+
}]
|
|
2311
|
+
});
|
|
2312
|
+
}
|
|
2313
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
2314
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
2315
|
+
if (url.includes('/api/taskforce/archive'))
|
|
2316
|
+
return jsonResponse({ archived: [] });
|
|
2317
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
2318
|
+
return jsonResponse({ dataVersion: 1 });
|
|
2319
|
+
if (url.includes('/api/taskforce/build-info'))
|
|
2320
|
+
return jsonResponse({});
|
|
2321
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
2322
|
+
return jsonResponse({});
|
|
2323
|
+
return jsonResponse({});
|
|
2324
|
+
}));
|
|
2325
|
+
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
2326
|
+
await waitFor(() => {
|
|
2327
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-cloud-1');
|
|
2328
|
+
expect(result.current.initiatives.some((initiative) => initiative.id === 'initiative-1')).toBe(true);
|
|
2329
|
+
expect(result.current.workstreams.some((workstream) => workstream.id === 'workstream-1')).toBe(true);
|
|
2330
|
+
}, { timeout: 2500 });
|
|
2331
|
+
await act(async () => {
|
|
2332
|
+
const switched = await result.current.switchWorkspace('workspace-cloud-2');
|
|
2333
|
+
expect(switched).toEqual({ success: true });
|
|
2334
|
+
});
|
|
2335
|
+
await waitFor(() => {
|
|
2336
|
+
expect(planningBootstrapWorkspaces).toContain('workspace-cloud-2');
|
|
2337
|
+
}, { timeout: 2500 });
|
|
2338
|
+
await waitFor(() => {
|
|
2339
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-cloud-2');
|
|
2340
|
+
expect(result.current.initiatives.map((initiative) => initiative.id)).toEqual(['initiative-2']);
|
|
2341
|
+
expect(result.current.workstreams.map((workstream) => workstream.id)).toEqual(['workstream-2']);
|
|
2342
|
+
}, { timeout: 2500 });
|
|
2343
|
+
expect(consoleErrorSpy).not.toHaveBeenCalledWith('[Taskforce] Failed to fetch planning entities:', 'superseded');
|
|
2344
|
+
});
|
|
2345
|
+
it('does not log expected workspace-transition aborts during cloud workspace switches', async () => {
|
|
2346
|
+
let sessionWorkspaceId = 'workspace-cloud-1';
|
|
2347
|
+
let deletedAbortSeen = false;
|
|
2348
|
+
const consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => { });
|
|
2349
|
+
const rejectOnAbort = (init, errorFactory) => new Promise((_resolve, reject) => {
|
|
2350
|
+
const signal = init?.signal;
|
|
2351
|
+
if (!signal)
|
|
2352
|
+
return;
|
|
2353
|
+
const onAbort = () => reject(errorFactory(signal));
|
|
2354
|
+
if (signal.aborted) {
|
|
2355
|
+
onAbort();
|
|
2356
|
+
return;
|
|
2357
|
+
}
|
|
2358
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
2359
|
+
});
|
|
2360
|
+
vi.stubGlobal('fetch', vi.fn((url, init) => {
|
|
2361
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
2362
|
+
return jsonResponse({
|
|
2363
|
+
config: {
|
|
2364
|
+
runtimeMode: 'cloud',
|
|
2365
|
+
workspaceMode: 'multi-cloud',
|
|
2366
|
+
authSource: 'cloud',
|
|
2367
|
+
workspaceSwitchingEnabled: true
|
|
2368
|
+
}
|
|
2369
|
+
});
|
|
2370
|
+
}
|
|
2371
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
2372
|
+
return jsonResponse({
|
|
2373
|
+
authenticated: true,
|
|
2374
|
+
authRequiredForApi: true,
|
|
2375
|
+
betaAccess: true,
|
|
2376
|
+
userId: 'user-1',
|
|
2377
|
+
email: 'user@example.com',
|
|
2378
|
+
workspaceId: sessionWorkspaceId
|
|
2379
|
+
});
|
|
2380
|
+
}
|
|
2381
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
2382
|
+
return jsonResponse({ success: true, state: {} });
|
|
2383
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
2384
|
+
return jsonResponse({
|
|
2385
|
+
success: true,
|
|
2386
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
2387
|
+
});
|
|
2388
|
+
}
|
|
2389
|
+
if (url.includes('/api/taskforce/workspaces')) {
|
|
2390
|
+
if (String(init?.method || 'GET').toUpperCase() === 'POST') {
|
|
2391
|
+
return jsonResponse({ success: true });
|
|
2392
|
+
}
|
|
2393
|
+
return jsonResponse({
|
|
2394
|
+
success: true,
|
|
2395
|
+
currentWorkspaceId: sessionWorkspaceId,
|
|
2396
|
+
workspaces: [
|
|
2397
|
+
{ id: 'workspace-cloud-1', name: 'Cloud Workspace 1', role: 'owner' },
|
|
2398
|
+
{ id: 'workspace-cloud-2', name: 'Cloud Workspace 2', role: 'member' }
|
|
2399
|
+
]
|
|
2400
|
+
});
|
|
2401
|
+
}
|
|
2402
|
+
if (url.includes('/api/taskforce/session/workspace')) {
|
|
2403
|
+
const body = JSON.parse(String(init?.body || '{}'));
|
|
2404
|
+
sessionWorkspaceId = String(body.workspaceId || '').trim() || sessionWorkspaceId;
|
|
2405
|
+
return jsonResponse({ success: true });
|
|
2406
|
+
}
|
|
2407
|
+
if (url.includes('/api/taskforce/config')) {
|
|
2408
|
+
return jsonResponse({
|
|
2409
|
+
projectName: 'Cloud Project',
|
|
2410
|
+
workspaceId: sessionWorkspaceId,
|
|
2411
|
+
runtimeMode: 'cloud',
|
|
2412
|
+
authRequiredForApi: true,
|
|
2413
|
+
userId: 'user-1',
|
|
2414
|
+
setupState: {
|
|
2415
|
+
globalSetupState: 'complete',
|
|
2416
|
+
workspaceSetupState: 'complete',
|
|
2417
|
+
workspaceId: sessionWorkspaceId
|
|
2418
|
+
}
|
|
2419
|
+
});
|
|
2420
|
+
}
|
|
2421
|
+
if (url.includes('/api/taskforce/taxonomy-state')) {
|
|
2422
|
+
return jsonResponse({
|
|
2423
|
+
categories: [{ value: 'general', label: 'General' }],
|
|
2424
|
+
types: [{ value: 'feature', label: 'Feature' }],
|
|
2425
|
+
priorities: [{ value: 2, label: 'Medium' }],
|
|
2426
|
+
taxonomies: []
|
|
2427
|
+
});
|
|
2428
|
+
}
|
|
2429
|
+
if (url.includes('/api/taskforce/auth/workspace-members'))
|
|
2430
|
+
return jsonResponse({ users: [] });
|
|
2431
|
+
if (url.includes('/api/taskforce/workspace/assignee-options'))
|
|
2432
|
+
return jsonResponse({ assignees: [] });
|
|
2433
|
+
if (url.includes('/api/taskforce/planning/bootstrap')) {
|
|
2434
|
+
if (sessionWorkspaceId === 'workspace-cloud-1') {
|
|
2435
|
+
return rejectOnAbort(init, (signal) => signal.reason || new TypeError('Failed to fetch'));
|
|
2436
|
+
}
|
|
2437
|
+
return jsonResponse({ initiatives: [], workstreams: [], workstreamTaskSummaries: [] });
|
|
2438
|
+
}
|
|
2439
|
+
if (url.includes('/api/taskforce/deleted')) {
|
|
2440
|
+
return rejectOnAbort(init, () => {
|
|
2441
|
+
deletedAbortSeen = true;
|
|
2442
|
+
return new TypeError('Failed to fetch');
|
|
2443
|
+
});
|
|
2444
|
+
}
|
|
2445
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
2446
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
2447
|
+
if (url.includes('/api/taskforce/archive'))
|
|
2448
|
+
return jsonResponse({ archived: [] });
|
|
2449
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
2450
|
+
return jsonResponse({ dataVersion: 1 });
|
|
2451
|
+
if (url.includes('/api/taskforce/build-info'))
|
|
2452
|
+
return jsonResponse({});
|
|
2453
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
2454
|
+
return jsonResponse({});
|
|
2455
|
+
return jsonResponse({});
|
|
2456
|
+
}));
|
|
2457
|
+
try {
|
|
2458
|
+
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
2459
|
+
await waitFor(() => {
|
|
2460
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-cloud-1');
|
|
2461
|
+
expect(result.current.bootstrapState.ready).toBe(true);
|
|
2462
|
+
}, { timeout: 2500 });
|
|
2463
|
+
act(() => {
|
|
2464
|
+
void result.current.fetchDeletedTasks(true);
|
|
2465
|
+
});
|
|
2466
|
+
await act(async () => {
|
|
2467
|
+
const switched = await result.current.switchWorkspace('workspace-cloud-2', { hydrate: false });
|
|
2468
|
+
expect(switched).toEqual({ success: true });
|
|
2469
|
+
});
|
|
2470
|
+
await waitFor(() => {
|
|
2471
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-cloud-2');
|
|
2472
|
+
expect(deletedAbortSeen).toBe(true);
|
|
2473
|
+
}, { timeout: 2500 });
|
|
2474
|
+
expect(consoleErrorSpy).not.toHaveBeenCalledWith('[Taskforce] Failed to fetch planning entities:', 'workspace-transition');
|
|
2475
|
+
expect(consoleErrorSpy).not.toHaveBeenCalledWith('[Taskforce] Failed to fetch deleted tasks:', expect.any(TypeError));
|
|
2476
|
+
}
|
|
2477
|
+
finally {
|
|
2478
|
+
consoleErrorSpy.mockRestore();
|
|
2479
|
+
}
|
|
2480
|
+
});
|
|
2481
|
+
it('uses the preferred workspace returned by invite join during cloud re-entry', async () => {
|
|
2482
|
+
let sessionWorkspaceId = 'workspace-home';
|
|
2483
|
+
const sessionWorkspacePosts = [];
|
|
2484
|
+
vi.stubGlobal('fetch', vi.fn((url, init) => {
|
|
2485
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
2486
|
+
return jsonResponse({
|
|
2487
|
+
config: {
|
|
2488
|
+
runtimeMode: 'cloud',
|
|
2489
|
+
workspaceMode: 'multi-cloud',
|
|
2490
|
+
authSource: 'cloud',
|
|
2491
|
+
workspaceSwitchingEnabled: true,
|
|
2492
|
+
cloudAuthBaseUrl: 'https://cloud.example.com'
|
|
2493
|
+
}
|
|
2494
|
+
});
|
|
2495
|
+
}
|
|
2496
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
2497
|
+
return jsonResponse({
|
|
2498
|
+
authenticated: true,
|
|
2499
|
+
authRequiredForApi: true,
|
|
2500
|
+
betaAccess: true,
|
|
2501
|
+
userId: 'user-1',
|
|
2502
|
+
email: 'user@example.com',
|
|
2503
|
+
workspaceId: sessionWorkspaceId
|
|
2504
|
+
});
|
|
2505
|
+
}
|
|
2506
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
2507
|
+
return jsonResponse({ success: true, state: {} });
|
|
2508
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
2509
|
+
return jsonResponse({
|
|
2510
|
+
success: true,
|
|
2511
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
2512
|
+
});
|
|
2513
|
+
}
|
|
2514
|
+
if (url.includes('/api/taskforce/workspaces')) {
|
|
2515
|
+
return jsonResponse({
|
|
2516
|
+
success: true,
|
|
2517
|
+
currentWorkspaceId: sessionWorkspaceId,
|
|
2518
|
+
workspaces: [
|
|
2519
|
+
{ id: 'workspace-home', name: 'Home Workspace', role: 'owner' },
|
|
2520
|
+
{ id: 'workspace-invite', name: 'Invited Workspace', role: 'member' }
|
|
2521
|
+
]
|
|
2522
|
+
});
|
|
2523
|
+
}
|
|
2524
|
+
if (url.includes('/api/taskforce/session/workspace')) {
|
|
2525
|
+
const body = JSON.parse(String(init?.body || '{}'));
|
|
2526
|
+
const nextWorkspaceId = String(body.workspaceId || '').trim();
|
|
2527
|
+
sessionWorkspacePosts.push(nextWorkspaceId);
|
|
2528
|
+
sessionWorkspaceId = nextWorkspaceId || sessionWorkspaceId;
|
|
2529
|
+
return jsonResponse({ success: true, workspaceId: sessionWorkspaceId });
|
|
2530
|
+
}
|
|
2531
|
+
if (url.includes('/api/taskforce/config')) {
|
|
2532
|
+
return jsonResponse({
|
|
2533
|
+
projectName: sessionWorkspaceId === 'workspace-invite' ? 'Invited Workspace' : 'Home Workspace',
|
|
2534
|
+
workspaceId: sessionWorkspaceId,
|
|
2535
|
+
runtimeMode: 'cloud',
|
|
2536
|
+
authRequiredForApi: true,
|
|
2537
|
+
userId: 'user-1',
|
|
2538
|
+
setupState: {
|
|
2539
|
+
globalSetupState: 'complete',
|
|
2540
|
+
workspaceSetupState: 'complete',
|
|
2541
|
+
workspaceId: sessionWorkspaceId
|
|
2542
|
+
}
|
|
2543
|
+
});
|
|
2544
|
+
}
|
|
2545
|
+
if (url.includes('/api/taskforce/taxonomy-state')) {
|
|
2546
|
+
return jsonResponse({
|
|
2547
|
+
categories: [{ value: sessionWorkspaceId === 'workspace-invite' ? 'invite' : 'home', label: 'Workspace' }],
|
|
2548
|
+
types: [{ value: 'feature', label: 'Feature' }],
|
|
2549
|
+
priorities: [{ value: 2, label: 'Medium' }],
|
|
2550
|
+
taxonomies: []
|
|
2551
|
+
});
|
|
2552
|
+
}
|
|
2553
|
+
if (url.includes('/api/taskforce/auth/invite/join')) {
|
|
2554
|
+
return jsonResponse({ success: true, workspaceId: 'workspace-invite' });
|
|
2555
|
+
}
|
|
2556
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
2557
|
+
return jsonResponse({});
|
|
2558
|
+
if (url.includes('/api/taskforce/workspace/assignee-options'))
|
|
2559
|
+
return jsonResponse({ assignees: [] });
|
|
2560
|
+
if (url.includes('/api/taskforce/auth/workspace-members'))
|
|
2561
|
+
return jsonResponse({ users: [] });
|
|
2562
|
+
if (url.includes('/api/taskforce/planning/bootstrap'))
|
|
2563
|
+
return jsonResponse({ initiatives: [], workstreams: [], workstreamTaskSummaries: [] });
|
|
2564
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
2565
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
2566
|
+
if (url.includes('/api/taskforce/archive'))
|
|
2567
|
+
return jsonResponse({ archived: [] });
|
|
2568
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
2569
|
+
return jsonResponse({ dataVersion: 1 });
|
|
2570
|
+
if (url.includes('/api/taskforce/build-info'))
|
|
2571
|
+
return jsonResponse({});
|
|
2572
|
+
return jsonResponse({});
|
|
2573
|
+
}));
|
|
2574
|
+
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
2575
|
+
await waitFor(() => {
|
|
2576
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-home');
|
|
2577
|
+
expect(result.current.runtimeMode).toBe('cloud');
|
|
2578
|
+
expect(result.current.workspaceSwitchingEnabled).toBe(true);
|
|
2579
|
+
}, { timeout: 2500 });
|
|
2580
|
+
await act(async () => {
|
|
2581
|
+
const joined = await result.current.joinInviteWithToken('invite-token');
|
|
2582
|
+
expect(joined).toEqual({ success: true, workspaceSetupRequired: false });
|
|
2583
|
+
});
|
|
2584
|
+
await waitFor(() => {
|
|
2585
|
+
expect(sessionWorkspacePosts).toContain('workspace-invite');
|
|
2586
|
+
}, { timeout: 2500 });
|
|
2587
|
+
await waitFor(() => {
|
|
2588
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-invite');
|
|
2589
|
+
}, { timeout: 2500 });
|
|
2590
|
+
});
|
|
2591
|
+
it('uses the preferred workspace returned by invite acceptance during cloud re-entry', async () => {
|
|
2592
|
+
let sessionWorkspaceId = 'workspace-home';
|
|
2593
|
+
const sessionWorkspacePosts = [];
|
|
2594
|
+
vi.stubGlobal('fetch', vi.fn((url, init) => {
|
|
2595
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
2596
|
+
return jsonResponse({
|
|
2597
|
+
config: {
|
|
2598
|
+
runtimeMode: 'cloud',
|
|
2599
|
+
workspaceMode: 'multi-cloud',
|
|
2600
|
+
authSource: 'cloud',
|
|
2601
|
+
workspaceSwitchingEnabled: true,
|
|
2602
|
+
cloudAuthBaseUrl: 'https://cloud.example.com'
|
|
2603
|
+
}
|
|
2604
|
+
});
|
|
2605
|
+
}
|
|
2606
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
2607
|
+
return jsonResponse({
|
|
2608
|
+
authenticated: true,
|
|
2609
|
+
authRequiredForApi: true,
|
|
2610
|
+
betaAccess: true,
|
|
2611
|
+
userId: 'user-1',
|
|
2612
|
+
email: 'new@example.com',
|
|
2613
|
+
workspaceId: sessionWorkspaceId
|
|
2614
|
+
});
|
|
2615
|
+
}
|
|
2616
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
2617
|
+
return jsonResponse({ success: true, state: {} });
|
|
2618
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
2619
|
+
return jsonResponse({
|
|
2620
|
+
success: true,
|
|
2621
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
2622
|
+
});
|
|
2623
|
+
}
|
|
2624
|
+
if (url.includes('/api/taskforce/workspaces')) {
|
|
2625
|
+
return jsonResponse({
|
|
2626
|
+
success: true,
|
|
2627
|
+
currentWorkspaceId: sessionWorkspaceId,
|
|
2628
|
+
workspaces: [
|
|
2629
|
+
{ id: 'workspace-home', name: 'Home Workspace', role: 'owner' },
|
|
2630
|
+
{ id: 'workspace-invite', name: 'Invited Workspace', role: 'member' }
|
|
2631
|
+
]
|
|
2632
|
+
});
|
|
2633
|
+
}
|
|
2634
|
+
if (url.includes('/api/taskforce/session/workspace')) {
|
|
2635
|
+
const body = JSON.parse(String(init?.body || '{}'));
|
|
2636
|
+
const nextWorkspaceId = String(body.workspaceId || '').trim();
|
|
2637
|
+
sessionWorkspacePosts.push(nextWorkspaceId);
|
|
2638
|
+
sessionWorkspaceId = nextWorkspaceId || sessionWorkspaceId;
|
|
2639
|
+
return jsonResponse({ success: true, workspaceId: sessionWorkspaceId });
|
|
2640
|
+
}
|
|
2641
|
+
if (url.includes('/api/taskforce/config')) {
|
|
2642
|
+
return jsonResponse({
|
|
2643
|
+
projectName: sessionWorkspaceId === 'workspace-invite' ? 'Invited Workspace' : 'Home Workspace',
|
|
2644
|
+
workspaceId: sessionWorkspaceId,
|
|
2645
|
+
runtimeMode: 'cloud',
|
|
2646
|
+
authRequiredForApi: true,
|
|
2647
|
+
userId: 'user-1',
|
|
2648
|
+
setupState: {
|
|
2649
|
+
globalSetupState: 'complete',
|
|
2650
|
+
workspaceSetupState: 'complete',
|
|
2651
|
+
workspaceId: sessionWorkspaceId
|
|
2652
|
+
}
|
|
2653
|
+
});
|
|
2654
|
+
}
|
|
2655
|
+
if (url.includes('/api/taskforce/taxonomy-state')) {
|
|
2656
|
+
return jsonResponse({
|
|
2657
|
+
categories: [{ value: sessionWorkspaceId === 'workspace-invite' ? 'invite' : 'home', label: 'Workspace' }],
|
|
2658
|
+
types: [{ value: 'feature', label: 'Feature' }],
|
|
2659
|
+
priorities: [{ value: 2, label: 'Medium' }],
|
|
2660
|
+
taxonomies: []
|
|
2661
|
+
});
|
|
2662
|
+
}
|
|
2663
|
+
if (url.includes('/api/taskforce/auth/invite/accept')) {
|
|
2664
|
+
return jsonResponse({ success: true, workspaceId: 'workspace-invite' });
|
|
2665
|
+
}
|
|
2666
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
2667
|
+
return jsonResponse({});
|
|
2668
|
+
if (url.includes('/api/taskforce/workspace/assignee-options'))
|
|
2669
|
+
return jsonResponse({ assignees: [] });
|
|
2670
|
+
if (url.includes('/api/taskforce/auth/workspace-members'))
|
|
2671
|
+
return jsonResponse({ users: [] });
|
|
2672
|
+
if (url.includes('/api/taskforce/planning/bootstrap'))
|
|
2673
|
+
return jsonResponse({ initiatives: [], workstreams: [], workstreamTaskSummaries: [] });
|
|
2674
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
2675
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
2676
|
+
if (url.includes('/api/taskforce/archive'))
|
|
2677
|
+
return jsonResponse({ archived: [] });
|
|
2678
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
2679
|
+
return jsonResponse({ dataVersion: 1 });
|
|
2680
|
+
if (url.includes('/api/taskforce/build-info'))
|
|
2681
|
+
return jsonResponse({});
|
|
2682
|
+
return jsonResponse({});
|
|
2683
|
+
}));
|
|
2684
|
+
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
2685
|
+
await waitFor(() => {
|
|
2686
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-home');
|
|
2687
|
+
expect(result.current.runtimeMode).toBe('cloud');
|
|
2688
|
+
expect(result.current.workspaceSwitchingEnabled).toBe(true);
|
|
2689
|
+
}, { timeout: 2500 });
|
|
2690
|
+
await act(async () => {
|
|
2691
|
+
const accepted = await result.current.acceptInviteWithToken('invite-token', 'NewUserPass123!');
|
|
2692
|
+
expect(accepted).toEqual({ success: true, workspaceSetupRequired: false });
|
|
2693
|
+
});
|
|
2694
|
+
await waitFor(() => {
|
|
2695
|
+
expect(sessionWorkspacePosts).toContain('workspace-invite');
|
|
2696
|
+
}, { timeout: 2500 });
|
|
2697
|
+
await waitFor(() => {
|
|
2698
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-invite');
|
|
2699
|
+
}, { timeout: 2500 });
|
|
2700
|
+
});
|
|
2701
|
+
it('rehydrates taxonomy state after retryBootstrapChecks resolves a transient empty cloud taxonomy response', async () => {
|
|
2702
|
+
let taxonomyReady = false;
|
|
2703
|
+
vi.stubGlobal('fetch', vi.fn((url, init) => {
|
|
2704
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
2705
|
+
return jsonResponse({
|
|
2706
|
+
config: {
|
|
2707
|
+
runtimeMode: 'cloud',
|
|
2708
|
+
workspaceMode: 'multi-cloud',
|
|
2709
|
+
authSource: 'cloud',
|
|
2710
|
+
workspaceSwitchingEnabled: true
|
|
2711
|
+
}
|
|
2712
|
+
});
|
|
2713
|
+
}
|
|
2714
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
2715
|
+
return jsonResponse({
|
|
2716
|
+
authenticated: true,
|
|
2717
|
+
authRequiredForApi: true,
|
|
2718
|
+
betaAccess: true,
|
|
2719
|
+
userId: 'user-1',
|
|
2720
|
+
email: 'user@example.com',
|
|
2721
|
+
workspaceId: 'workspace-cloud-1'
|
|
2722
|
+
});
|
|
2723
|
+
}
|
|
2724
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
2725
|
+
return jsonResponse({ success: true, state: {} });
|
|
2726
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
2727
|
+
return jsonResponse({
|
|
2728
|
+
success: true,
|
|
2729
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
2730
|
+
});
|
|
2731
|
+
}
|
|
2732
|
+
if (url.includes('/api/taskforce/workspaces')) {
|
|
2733
|
+
if (String(init?.method || 'GET').toUpperCase() === 'POST') {
|
|
2734
|
+
return jsonResponse({ success: true });
|
|
2735
|
+
}
|
|
2736
|
+
return jsonResponse({
|
|
2737
|
+
success: true,
|
|
2738
|
+
currentWorkspaceId: 'workspace-cloud-1',
|
|
2739
|
+
workspaces: [{ id: 'workspace-cloud-1', name: 'Cloud Workspace', role: 'owner' }]
|
|
2740
|
+
});
|
|
2741
|
+
}
|
|
2742
|
+
if (url.includes('/api/taskforce/session/workspace'))
|
|
2743
|
+
return jsonResponse({ success: true });
|
|
2744
|
+
if (url.includes('/api/taskforce/config')) {
|
|
2745
|
+
return jsonResponse({
|
|
2746
|
+
projectName: 'Cloud Project',
|
|
2747
|
+
workspaceId: 'workspace-cloud-1',
|
|
2748
|
+
runtimeMode: 'cloud',
|
|
2749
|
+
authRequiredForApi: true,
|
|
2750
|
+
userId: 'user-1',
|
|
2751
|
+
setupState: {
|
|
2752
|
+
globalSetupState: 'complete',
|
|
2753
|
+
workspaceSetupState: 'complete',
|
|
2754
|
+
workspaceId: 'workspace-cloud-1'
|
|
2755
|
+
}
|
|
2756
|
+
});
|
|
2757
|
+
}
|
|
2758
|
+
if (url.includes('/api/taskforce/taxonomy-state')) {
|
|
2759
|
+
return jsonResponse(taxonomyReady ? {
|
|
2760
|
+
categories: [{ value: 'cloud-ops', label: 'Cloud Ops' }],
|
|
2761
|
+
types: [{ value: 'incident', label: 'Incident' }],
|
|
2762
|
+
priorities: [{ value: 4, label: 'Critical' }],
|
|
2763
|
+
taxonomies: []
|
|
2764
|
+
} : {
|
|
2765
|
+
categories: [],
|
|
2766
|
+
types: [],
|
|
2767
|
+
priorities: [],
|
|
2768
|
+
taxonomies: []
|
|
2769
|
+
});
|
|
2770
|
+
}
|
|
2771
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
2772
|
+
return jsonResponse({});
|
|
2773
|
+
if (url.includes('/api/taskforce/workspace/assignee-options'))
|
|
2774
|
+
return jsonResponse({ assignees: [] });
|
|
2775
|
+
if (url.includes('/api/taskforce/auth/workspace-members'))
|
|
2776
|
+
return jsonResponse({ users: [] });
|
|
2777
|
+
if (url.includes('/api/taskforce/planning/bootstrap'))
|
|
2778
|
+
return jsonResponse({ initiatives: [], workstreams: [], workstreamTaskSummaries: [] });
|
|
2779
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
2780
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
2781
|
+
if (url.includes('/api/taskforce/archive'))
|
|
2782
|
+
return jsonResponse({ archived: [] });
|
|
2783
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
2784
|
+
return jsonResponse({ dataVersion: 1 });
|
|
2785
|
+
if (url.includes('/api/taskforce/build-info'))
|
|
2786
|
+
return jsonResponse({});
|
|
2787
|
+
return jsonResponse({});
|
|
2788
|
+
}));
|
|
2789
|
+
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
2790
|
+
await waitFor(() => {
|
|
2791
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-cloud-1');
|
|
2792
|
+
}, { timeout: 2500 });
|
|
2793
|
+
expect(result.current.activeCategories.some((category) => category.value === 'cloud-ops')).toBe(false);
|
|
2794
|
+
taxonomyReady = true;
|
|
2795
|
+
await act(async () => {
|
|
2796
|
+
await result.current.retryBootstrapChecks();
|
|
2797
|
+
});
|
|
2798
|
+
await waitFor(() => {
|
|
2799
|
+
expect(result.current.activeCategories.some((category) => category.value === 'cloud-ops')).toBe(true);
|
|
2800
|
+
expect(result.current.activeTypes.some((type) => type.value === 'incident')).toBe(true);
|
|
2801
|
+
expect(result.current.priorities.some((priority) => priority.value === 4)).toBe(true);
|
|
2802
|
+
}, { timeout: 2500 });
|
|
2803
|
+
});
|
|
2804
|
+
it('does not refetch assignee options during retryBootstrapChecks when they are already loaded', async () => {
|
|
2805
|
+
let taxonomyReady = false;
|
|
2806
|
+
const requestOrder = [];
|
|
2807
|
+
vi.stubGlobal('fetch', vi.fn((url, init) => {
|
|
2808
|
+
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
2809
|
+
return jsonResponse({
|
|
2810
|
+
config: {
|
|
2811
|
+
runtimeMode: 'cloud',
|
|
2812
|
+
workspaceMode: 'multi-cloud',
|
|
2813
|
+
authSource: 'cloud',
|
|
2814
|
+
workspaceSwitchingEnabled: true
|
|
2815
|
+
}
|
|
2816
|
+
});
|
|
2817
|
+
}
|
|
2818
|
+
if (url.includes('/api/taskforce/auth/session')) {
|
|
2819
|
+
return jsonResponse({
|
|
2820
|
+
authenticated: true,
|
|
2821
|
+
authRequiredForApi: true,
|
|
2822
|
+
betaAccess: true,
|
|
2823
|
+
userId: 'user-1',
|
|
2824
|
+
email: 'user@example.com',
|
|
2825
|
+
workspaceId: 'workspace-cloud-1'
|
|
2826
|
+
});
|
|
2827
|
+
}
|
|
2828
|
+
if (url.includes('/api/taskforce/ui-state?key=app'))
|
|
2829
|
+
return jsonResponse({ success: true, state: {} });
|
|
2830
|
+
if (url.includes('/api/taskforce/ui-state?key=workspace-sync')) {
|
|
2831
|
+
return jsonResponse({
|
|
2832
|
+
success: true,
|
|
2833
|
+
state: { version: 2, enabled: false, phase: 'idle', pullCursor: null }
|
|
2834
|
+
});
|
|
2835
|
+
}
|
|
2836
|
+
if (url.includes('/api/taskforce/workspaces')) {
|
|
2837
|
+
if (String(init?.method || 'GET').toUpperCase() === 'POST')
|
|
2838
|
+
return jsonResponse({ success: true });
|
|
2839
|
+
return jsonResponse({
|
|
2840
|
+
success: true,
|
|
2841
|
+
currentWorkspaceId: 'workspace-cloud-1',
|
|
2842
|
+
workspaces: [{ id: 'workspace-cloud-1', name: 'Cloud Workspace', role: 'owner' }]
|
|
2843
|
+
});
|
|
2844
|
+
}
|
|
2845
|
+
if (url.includes('/api/taskforce/session/workspace'))
|
|
2846
|
+
return jsonResponse({ success: true });
|
|
2847
|
+
if (url.includes('/api/taskforce/config')) {
|
|
2848
|
+
return jsonResponse({
|
|
2849
|
+
projectName: 'Cloud Project',
|
|
2850
|
+
workspaceId: 'workspace-cloud-1',
|
|
2851
|
+
runtimeMode: 'cloud',
|
|
2852
|
+
authRequiredForApi: true,
|
|
2853
|
+
userId: 'user-1',
|
|
2854
|
+
setupState: {
|
|
2855
|
+
globalSetupState: 'complete',
|
|
2856
|
+
workspaceSetupState: 'complete',
|
|
2857
|
+
workspaceId: 'workspace-cloud-1'
|
|
2858
|
+
}
|
|
2859
|
+
});
|
|
2860
|
+
}
|
|
2861
|
+
if (url.includes('/api/taskforce/taxonomy-state')) {
|
|
2862
|
+
return jsonResponse(taxonomyReady ? {
|
|
2863
|
+
categories: [{ value: 'cloud-ops', label: 'Cloud Ops' }],
|
|
2864
|
+
types: [{ value: 'incident', label: 'Incident' }],
|
|
2865
|
+
priorities: [{ value: 4, label: 'Critical' }],
|
|
2866
|
+
taxonomies: []
|
|
2867
|
+
} : {
|
|
2868
|
+
categories: [],
|
|
2869
|
+
types: [],
|
|
2870
|
+
priorities: [],
|
|
2871
|
+
taxonomies: []
|
|
2872
|
+
});
|
|
2873
|
+
}
|
|
2874
|
+
if (url.includes('/api/taskforce/global-settings'))
|
|
2875
|
+
return jsonResponse({});
|
|
2876
|
+
if (url.includes('/api/taskforce/workspace/assignee-options')) {
|
|
2877
|
+
requestOrder.push('assignee');
|
|
2878
|
+
return jsonResponse({ assignees: [] });
|
|
2879
|
+
}
|
|
2880
|
+
if (url.includes('/api/taskforce/auth/workspace-members'))
|
|
2881
|
+
return jsonResponse({ users: [] });
|
|
2882
|
+
if (url.includes('/api/taskforce/planning/bootstrap')) {
|
|
2883
|
+
requestOrder.push('planning');
|
|
2884
|
+
return jsonResponse({ initiatives: [], workstreams: [], workstreamTaskSummaries: [] });
|
|
2885
|
+
}
|
|
2886
|
+
if (url.includes('/api/taskforce/tasks'))
|
|
2887
|
+
return jsonResponse({ tasks: [activeTask] });
|
|
2888
|
+
if (url.includes('/api/taskforce/archive'))
|
|
2889
|
+
return jsonResponse({ archived: [] });
|
|
2890
|
+
if (url.includes('/api/taskforce/data-version'))
|
|
2891
|
+
return jsonResponse({ dataVersion: 1 });
|
|
2892
|
+
if (url.includes('/api/taskforce/build-info'))
|
|
2893
|
+
return jsonResponse({});
|
|
2894
|
+
return jsonResponse({});
|
|
2895
|
+
}));
|
|
2896
|
+
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
2897
|
+
await waitFor(() => {
|
|
2898
|
+
expect(result.current.currentWorkspaceId).toBe('workspace-cloud-1');
|
|
2899
|
+
}, { timeout: 2500 });
|
|
2900
|
+
await waitFor(() => {
|
|
2901
|
+
expect(requestOrder.filter((entry) => entry === 'assignee')).toHaveLength(1);
|
|
2902
|
+
}, { timeout: 2500 });
|
|
2903
|
+
taxonomyReady = true;
|
|
2904
|
+
requestOrder.length = 0;
|
|
2905
|
+
await act(async () => {
|
|
2906
|
+
await result.current.retryBootstrapChecks();
|
|
2907
|
+
});
|
|
2908
|
+
await waitFor(() => {
|
|
2909
|
+
expect(result.current.activeCategories.some((category) => category.value === 'cloud-ops')).toBe(true);
|
|
2910
|
+
expect(requestOrder).toContain('planning');
|
|
2911
|
+
}, { timeout: 2500 });
|
|
2912
|
+
expect(requestOrder).not.toContain('assignee');
|
|
2913
|
+
});
|
|
652
2914
|
it('hydrates merged human members and workspace ai assignees for a signed-in local workspace', async () => {
|
|
653
2915
|
vi.stubGlobal('fetch', vi.fn((url) => {
|
|
654
2916
|
if (url.includes('/api/taskforce/auth/runtime-config')) {
|
|
@@ -668,6 +2930,7 @@ describe('useTaskforce sync behavior', () => {
|
|
|
668
2930
|
betaAccess: true,
|
|
669
2931
|
userId: 'user-1',
|
|
670
2932
|
email: 'user@example.com',
|
|
2933
|
+
avatarUrl: '/api/taskforce/context/users%2Fuser-1%2Fprofile%2Favatar%2Fheadshot.webp',
|
|
671
2934
|
workspaceId: 'workspace-cloud-1'
|
|
672
2935
|
});
|
|
673
2936
|
}
|
|
@@ -745,6 +3008,10 @@ describe('useTaskforce sync behavior', () => {
|
|
|
745
3008
|
const { result } = renderHook(() => useTaskforce({ config: { cloudAuthBaseUrl: 'https://cloud.example.com' } }), { wrapper });
|
|
746
3009
|
await waitFor(() => {
|
|
747
3010
|
expect(result.current.assigneeOptions.some((option) => option.value === 'member-1' && option.label === 'Member One')).toBe(true);
|
|
3011
|
+
expect(result.current.assigneeOptions.find((option) => option.value === 'user-1')).toEqual(expect.objectContaining({
|
|
3012
|
+
label: 'Signed In Owner',
|
|
3013
|
+
avatarUrl: '/api/taskforce/context/users%2Fuser-1%2Fprofile%2Favatar%2Fheadshot.webp'
|
|
3014
|
+
}));
|
|
748
3015
|
expect(result.current.assigneeOptions.some((option) => option.value === 'ai-profile-codex' && option.label === 'Codex')).toBe(true);
|
|
749
3016
|
expect(result.current.currentWorkspaceRole).toBe('owner');
|
|
750
3017
|
});
|