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