(
options: { archived?: boolean; archive?: ReturnType<typeof mock> } = {}
)
| 641 | } |
| 642 | |
| 643 | async function createWorkspaceLifecycleHarness( |
| 644 | options: { archived?: boolean; archive?: ReturnType<typeof mock> } = {} |
| 645 | ) { |
| 646 | const config = await createTestConfig(rootDir); |
| 647 | const { parentId, projectPath } = await saveLocalParentWorkspace(config, rootDir); |
| 648 | await config.editConfig((cfg) => { |
| 649 | const project = cfg.projects.get(projectPath); |
| 650 | assert(project, "test project must exist"); |
| 651 | project.workspaces.push({ |
| 652 | path: path.join(projectPath, "child"), |
| 653 | id: "childworkspace", |
| 654 | name: "child", |
| 655 | title: "Child workspace", |
| 656 | createdAt: new Date().toISOString(), |
| 657 | runtimeConfig: { type: "local" }, |
| 658 | ...(options.archived ? { archivedAt: new Date().toISOString() } : {}), |
| 659 | }); |
| 660 | project.workspaces.push({ |
| 661 | path: path.join(projectPath, "unowned"), |
| 662 | id: "unownedworkspace", |
| 663 | name: "unowned", |
| 664 | createdAt: new Date().toISOString(), |
| 665 | runtimeConfig: { type: "local" }, |
| 666 | }); |
| 667 | return cfg; |
| 668 | }); |
| 669 | |
| 670 | const workspaceMocks = createWorkspaceServiceMocks({ archive: options.archive }); |
| 671 | const { taskService } = createTaskServiceHarness(config, { |
| 672 | workspaceService: workspaceMocks.workspaceService, |
| 673 | }); |
| 674 | const taskHandleStore = (taskService as unknown as { taskHandleStore: TaskHandleStore }) |
| 675 | .taskHandleStore; |
| 676 | await taskHandleStore.upsertWorkspaceTurn({ |
| 677 | kind: "workspace_turn", |
| 678 | handleId: "wst_created", |
| 679 | ownerWorkspaceId: parentId, |
| 680 | workspaceId: "childworkspace", |
| 681 | turnId: "turn-created", |
| 682 | status: "completed", |
| 683 | createdAt: new Date().toISOString(), |
| 684 | updatedAt: new Date().toISOString(), |
| 685 | createdWorkspace: true, |
| 686 | disposableWorkspace: false, |
| 687 | title: "Created child", |
| 688 | }); |
| 689 | return { config, parentId, projectPath, taskService, taskHandleStore, ...workspaceMocks }; |
| 690 | } |
| 691 | |
| 692 | test("workspace lifecycle archives only parent-owned created workspace turns", async () => { |
| 693 | const { parentId, taskService, archive } = await createWorkspaceLifecycleHarness(); |
no test coverage detected