@jiggai/kitchen 0.3.1 → 0.3.3
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/.next/BUILD_ID +1 -1
- package/.next/build-manifest.json +2 -2
- package/.next/server/app/_global-error.html +2 -2
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/channels.html +2 -2
- package/.next/server/app/channels.rsc +1 -1
- package/.next/server/app/channels.segments/_full.segment.rsc +1 -1
- package/.next/server/app/channels.segments/_head.segment.rsc +1 -1
- package/.next/server/app/channels.segments/_index.segment.rsc +1 -1
- package/.next/server/app/channels.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/channels.segments/channels/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/channels.segments/channels.segment.rsc +1 -1
- package/.next/server/app/cron-jobs.html +1 -1
- package/.next/server/app/cron-jobs.rsc +1 -1
- package/.next/server/app/cron-jobs.segments/_full.segment.rsc +1 -1
- package/.next/server/app/cron-jobs.segments/_head.segment.rsc +1 -1
- package/.next/server/app/cron-jobs.segments/_index.segment.rsc +1 -1
- package/.next/server/app/cron-jobs.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/cron-jobs.segments/cron-jobs/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/cron-jobs.segments/cron-jobs.segment.rsc +1 -1
- package/.next/server/app/goals/new.html +2 -2
- package/.next/server/app/goals/new.rsc +1 -1
- package/.next/server/app/goals/new.segments/_full.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/_head.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/_index.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/goals/new/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/goals/new.segment.rsc +1 -1
- package/.next/server/app/goals/new.segments/goals.segment.rsc +1 -1
- package/.next/server/app/goals.html +1 -1
- package/.next/server/app/goals.rsc +1 -1
- package/.next/server/app/goals.segments/_full.segment.rsc +1 -1
- package/.next/server/app/goals.segments/_head.segment.rsc +1 -1
- package/.next/server/app/goals.segments/_index.segment.rsc +1 -1
- package/.next/server/app/goals.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/goals.segments/goals/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/goals.segments/goals.segment.rsc +1 -1
- package/.next/server/app/settings.html +1 -1
- package/.next/server/app/settings.rsc +1 -1
- package/.next/server/app/settings.segments/_full.segment.rsc +1 -1
- package/.next/server/app/settings.segments/_head.segment.rsc +1 -1
- package/.next/server/app/settings.segments/_index.segment.rsc +1 -1
- package/.next/server/app/settings.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/settings.segments/settings/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/settings.segments/settings.segment.rsc +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +2 -2
- package/package.json +1 -2
- package/src/app/HomeClient.tsx +0 -207
- package/src/app/agents/[agentId]/agent-editor-tabs.tsx +0 -298
- package/src/app/agents/[agentId]/agent-editor.tsx +0 -468
- package/src/app/agents/[agentId]/page.tsx +0 -32
- package/src/app/api/__tests__/agents-add-route.test.ts +0 -143
- package/src/app/api/__tests__/agents-file-route.test.ts +0 -117
- package/src/app/api/__tests__/agents-files-route.test.ts +0 -61
- package/src/app/api/__tests__/agents-id-route.test.ts +0 -104
- package/src/app/api/__tests__/agents-identity-route.test.ts +0 -92
- package/src/app/api/__tests__/agents-route.test.ts +0 -54
- package/src/app/api/__tests__/agents-skills-install-route.test.ts +0 -131
- package/src/app/api/__tests__/agents-skills-route.test.ts +0 -64
- package/src/app/api/__tests__/agents-update-route.test.ts +0 -95
- package/src/app/api/__tests__/channels-bindings-route.test.ts +0 -143
- package/src/app/api/__tests__/cron-delete-route.test.ts +0 -93
- package/src/app/api/__tests__/cron-job-route.test.ts +0 -78
- package/src/app/api/__tests__/cron-jobs-route.test.ts +0 -116
- package/src/app/api/__tests__/cron-recipe-installed-route.test.ts +0 -114
- package/src/app/api/__tests__/gateway-restart-route.test.ts +0 -36
- package/src/app/api/__tests__/goals-promote-route.test.ts +0 -200
- package/src/app/api/__tests__/goals-route.test.ts +0 -184
- package/src/app/api/__tests__/ids-check-route.test.ts +0 -188
- package/src/app/api/__tests__/marketplace-recipes-route.test.ts +0 -123
- package/src/app/api/__tests__/recipes-clone-route.test.ts +0 -221
- package/src/app/api/__tests__/recipes-delete-route.test.ts +0 -248
- package/src/app/api/__tests__/recipes-id-route.test.ts +0 -166
- package/src/app/api/__tests__/recipes-route.test.ts +0 -57
- package/src/app/api/__tests__/recipes-team-agents-route.test.ts +0 -135
- package/src/app/api/__tests__/scaffold-route.test.ts +0 -173
- package/src/app/api/__tests__/settings-cron-installation-route.test.ts +0 -82
- package/src/app/api/__tests__/skills-available-route.test.ts +0 -47
- package/src/app/api/__tests__/swarms-start-route.test.ts +0 -79
- package/src/app/api/__tests__/swarms-status-route.test.ts +0 -42
- package/src/app/api/__tests__/teams-file-route.test.ts +0 -129
- package/src/app/api/__tests__/teams-files-route.test.ts +0 -57
- package/src/app/api/__tests__/teams-meta-route.test.ts +0 -113
- package/src/app/api/__tests__/teams-orchestrator-install-route.test.ts +0 -66
- package/src/app/api/__tests__/teams-orchestrator-route.test.ts +0 -59
- package/src/app/api/__tests__/teams-remove-team-route.test.ts +0 -122
- package/src/app/api/__tests__/teams-skills-install-route.test.ts +0 -78
- package/src/app/api/__tests__/teams-skills-route.test.ts +0 -73
- package/src/app/api/__tests__/teams-workflow-runs-route.test.ts +0 -85
- package/src/app/api/__tests__/teams-workflows-route.test.ts +0 -110
- package/src/app/api/__tests__/tickets-move-route.test.ts +0 -60
- package/src/app/api/agents/[id]/route.ts +0 -83
- package/src/app/api/agents/add/route.ts +0 -114
- package/src/app/api/agents/file/route.ts +0 -45
- package/src/app/api/agents/files/route.ts +0 -23
- package/src/app/api/agents/identity/route.ts +0 -41
- package/src/app/api/agents/route.ts +0 -22
- package/src/app/api/agents/skills/install/route.ts +0 -34
- package/src/app/api/agents/skills/route.ts +0 -39
- package/src/app/api/agents/update/route.ts +0 -52
- package/src/app/api/channels/bindings/route.ts +0 -63
- package/src/app/api/cron/__tests__/helpers.test.ts +0 -164
- package/src/app/api/cron/delete/route.ts +0 -23
- package/src/app/api/cron/helpers.ts +0 -172
- package/src/app/api/cron/job/route.ts +0 -22
- package/src/app/api/cron/jobs/route.ts +0 -52
- package/src/app/api/cron/recipe-installed/route.ts +0 -65
- package/src/app/api/gateway/restart/route.ts +0 -20
- package/src/app/api/goals/[id]/promote/route.ts +0 -119
- package/src/app/api/goals/[id]/route.ts +0 -54
- package/src/app/api/goals/route.ts +0 -44
- package/src/app/api/ids/check/route.ts +0 -113
- package/src/app/api/marketplace/recipes/[slug]/route.ts +0 -16
- package/src/app/api/marketplace/recipes/route.ts +0 -22
- package/src/app/api/recipes/[id]/route.ts +0 -62
- package/src/app/api/recipes/clone/route.ts +0 -106
- package/src/app/api/recipes/custom-team/route.ts +0 -193
- package/src/app/api/recipes/delete/helpers.ts +0 -65
- package/src/app/api/recipes/delete/route.ts +0 -73
- package/src/app/api/recipes/route.ts +0 -21
- package/src/app/api/recipes/team-agents/__tests__/helpers.test.ts +0 -156
- package/src/app/api/recipes/team-agents/helpers.ts +0 -151
- package/src/app/api/recipes/team-agents/route.ts +0 -80
- package/src/app/api/scaffold/__tests__/helpers.test.ts +0 -186
- package/src/app/api/scaffold/helpers.ts +0 -214
- package/src/app/api/scaffold/route.ts +0 -95
- package/src/app/api/settings/cron-installation/route.ts +0 -58
- package/src/app/api/skills/available/route.ts +0 -23
- package/src/app/api/swarms/start/route.ts +0 -100
- package/src/app/api/swarms/status/route.ts +0 -31
- package/src/app/api/teams/[teamId]/tickets/assign/route.ts +0 -105
- package/src/app/api/teams/[teamId]/tickets/assignees/route.ts +0 -27
- package/src/app/api/teams/[teamId]/tickets/delete/route.ts +0 -55
- package/src/app/api/teams/[teamId]/tickets/move/route.ts +0 -70
- package/src/app/api/teams/[teamId]/tickets/move-to-goals/route.ts +0 -56
- package/src/app/api/teams/file/route.ts +0 -46
- package/src/app/api/teams/files/route.ts +0 -63
- package/src/app/api/teams/memory/route.ts +0 -250
- package/src/app/api/teams/meta/route.ts +0 -43
- package/src/app/api/teams/orchestrator/install/route.ts +0 -129
- package/src/app/api/teams/orchestrator/route.ts +0 -216
- package/src/app/api/teams/remove-team/route.ts +0 -37
- package/src/app/api/teams/skills/install/route.ts +0 -18
- package/src/app/api/teams/skills/route.ts +0 -25
- package/src/app/api/teams/workflow-runs/route.ts +0 -534
- package/src/app/api/teams/workflow-templates/route.ts +0 -71
- package/src/app/api/teams/workflows/route.ts +0 -55
- package/src/app/api/tickets/assign/route.ts +0 -94
- package/src/app/api/tickets/assignees/route.ts +0 -24
- package/src/app/api/tickets/move/route.ts +0 -69
- package/src/app/channels/channels-client.tsx +0 -271
- package/src/app/channels/page.tsx +0 -5
- package/src/app/cron-jobs/cron-jobs-client.tsx +0 -243
- package/src/app/cron-jobs/page.tsx +0 -34
- package/src/app/favicon.ico +0 -0
- package/src/app/global-error.tsx +0 -50
- package/src/app/globals.css +0 -153
- package/src/app/goals/[id]/goal-editor.tsx +0 -162
- package/src/app/goals/[id]/page.tsx +0 -6
- package/src/app/goals/goals-client.tsx +0 -201
- package/src/app/goals/new/page.tsx +0 -81
- package/src/app/goals/page.tsx +0 -10
- package/src/app/layout.tsx +0 -53
- package/src/app/manifest.ts +0 -15
- package/src/app/not-found.tsx +0 -8
- package/src/app/page.tsx +0 -33
- package/src/app/recipes/CreateAgentModal.tsx +0 -156
- package/src/app/recipes/CreateCustomTeamModal.tsx +0 -375
- package/src/app/recipes/CreateModalShell.tsx +0 -55
- package/src/app/recipes/CreateTeamModal.tsx +0 -91
- package/src/app/recipes/[id]/RecipeEditor/RecipeEditorCreateModal.tsx +0 -72
- package/src/app/recipes/[id]/RecipeEditor/RecipeEditorPanel.tsx +0 -216
- package/src/app/recipes/[id]/RecipeEditor/index.tsx +0 -271
- package/src/app/recipes/[id]/RecipeEditor/recipe-editor-utils.ts +0 -46
- package/src/app/recipes/[id]/RecipeEditor/types.ts +0 -52
- package/src/app/recipes/[id]/page.tsx +0 -37
- package/src/app/recipes/page.tsx +0 -101
- package/src/app/recipes/recipes-client.tsx +0 -620
- package/src/app/settings/page.tsx +0 -26
- package/src/app/settings/settings-client.tsx +0 -91
- package/src/app/teams/[teamId]/CloneTeamModal.tsx +0 -116
- package/src/app/teams/[teamId]/OrchestratorPanel.tsx +0 -255
- package/src/app/teams/[teamId]/OrchestratorSetupModal.tsx +0 -184
- package/src/app/teams/[teamId]/PublishChangesModal.tsx +0 -43
- package/src/app/teams/[teamId]/page.tsx +0 -49
- package/src/app/teams/[teamId]/team-editor/TeamAgentsTab.tsx +0 -145
- package/src/app/teams/[teamId]/team-editor/TeamCronTab.tsx +0 -72
- package/src/app/teams/[teamId]/team-editor/TeamFilesTab.tsx +0 -74
- package/src/app/teams/[teamId]/team-editor/TeamMemoryTab.tsx +0 -349
- package/src/app/teams/[teamId]/team-editor/TeamRecipeTab.tsx +0 -151
- package/src/app/teams/[teamId]/team-editor/TeamSkillsTab.tsx +0 -68
- package/src/app/teams/[teamId]/team-editor/index.tsx +0 -558
- package/src/app/teams/[teamId]/team-editor/team-editor-data.ts +0 -255
- package/src/app/teams/[teamId]/team-editor/team-editor-utils.ts +0 -78
- package/src/app/teams/[teamId]/team-editor/types.ts +0 -34
- package/src/app/teams/[teamId]/tickets/[ticket]/page.tsx +0 -35
- package/src/app/teams/[teamId]/tickets/page.tsx +0 -15
- package/src/app/teams/[teamId]/workflows/[workflowId]/WorkflowCanvas.tsx +0 -111
- package/src/app/teams/[teamId]/workflows/[workflowId]/page.tsx +0 -27
- package/src/app/teams/[teamId]/workflows/[workflowId]/workflows-editor-client.tsx +0 -1608
- package/src/app/teams/[teamId]/workflows/page.tsx +0 -40
- package/src/app/teams/[teamId]/workflows/workflows-client.tsx +0 -494
- package/src/app/tickets/TicketDetailClient.tsx +0 -147
- package/src/app/tickets/TicketsBoardClient.tsx +0 -200
- package/src/app/tickets/[ticket]/TicketAssignControl.tsx +0 -112
- package/src/app/tickets/[ticket]/page.tsx +0 -36
- package/src/app/tickets/page.tsx +0 -10
- package/src/components/AppShell.tsx +0 -286
- package/src/components/ConfirmationModal.tsx +0 -81
- package/src/components/DeleteEntityModal.tsx +0 -41
- package/src/components/ErrorBoundary.tsx +0 -70
- package/src/components/FileListWithOptionalToggle.tsx +0 -86
- package/src/components/GoalFormFields.tsx +0 -163
- package/src/components/ScaffoldOverlay.tsx +0 -78
- package/src/components/ThemeToggle.tsx +0 -53
- package/src/components/ToastProvider.tsx +0 -163
- package/src/components/__tests__/ConfirmationModal.test.tsx +0 -109
- package/src/components/__tests__/ErrorBoundary.test.tsx +0 -39
- package/src/components/__tests__/FileListWithOptionalToggle.test.tsx +0 -109
- package/src/components/__tests__/GoalFormFields.test.tsx +0 -117
- package/src/components/delete-modals.tsx +0 -59
- package/src/components/icons.tsx +0 -48
- package/src/lib/__tests__/agent-workspace.test.ts +0 -44
- package/src/lib/__tests__/agents.test.ts +0 -36
- package/src/lib/__tests__/api-route-helpers.test.ts +0 -188
- package/src/lib/__tests__/cron.test.ts +0 -45
- package/src/lib/__tests__/editor-utils.test.ts +0 -38
- package/src/lib/__tests__/errors.test.ts +0 -15
- package/src/lib/__tests__/exec.test.ts +0 -13
- package/src/lib/__tests__/fetch-json.test.ts +0 -118
- package/src/lib/__tests__/gateway.test.ts +0 -234
- package/src/lib/__tests__/goal-promote.test.ts +0 -39
- package/src/lib/__tests__/goals-client.test.ts +0 -26
- package/src/lib/__tests__/goals.test.ts +0 -275
- package/src/lib/__tests__/json.test.ts +0 -15
- package/src/lib/__tests__/kitchen-api.test.ts +0 -32
- package/src/lib/__tests__/marketplace.test.ts +0 -116
- package/src/lib/__tests__/openclaw.test.ts +0 -129
- package/src/lib/__tests__/paths.test.ts +0 -136
- package/src/lib/__tests__/poll.test.ts +0 -26
- package/src/lib/__tests__/recipe-clone.test.ts +0 -85
- package/src/lib/__tests__/recipe-team-agents.test.ts +0 -70
- package/src/lib/__tests__/recipes.test.ts +0 -199
- package/src/lib/__tests__/scaffold-client.test.ts +0 -106
- package/src/lib/__tests__/scaffold.test.ts +0 -64
- package/src/lib/__tests__/slugify.test.ts +0 -23
- package/src/lib/__tests__/tickets.test.ts +0 -158
- package/src/lib/__tests__/type-guards.test.ts +0 -18
- package/src/lib/__tests__/use-slugified-id.test.tsx +0 -120
- package/src/lib/agent-workspace.ts +0 -14
- package/src/lib/agents.ts +0 -17
- package/src/lib/api-route-helpers.ts +0 -157
- package/src/lib/cron.ts +0 -40
- package/src/lib/editor-utils.ts +0 -18
- package/src/lib/errors.ts +0 -7
- package/src/lib/exec.ts +0 -4
- package/src/lib/fetch-json.ts +0 -29
- package/src/lib/gateway.ts +0 -100
- package/src/lib/goal-promote.ts +0 -27
- package/src/lib/goals-client.ts +0 -69
- package/src/lib/goals.ts +0 -171
- package/src/lib/json.ts +0 -10
- package/src/lib/kitchen-api.ts +0 -19
- package/src/lib/marketplace.ts +0 -46
- package/src/lib/openclaw.ts +0 -59
- package/src/lib/paths.ts +0 -69
- package/src/lib/poll.ts +0 -18
- package/src/lib/recipe-clone.ts +0 -42
- package/src/lib/recipe-team-agents.ts +0 -30
- package/src/lib/recipes.ts +0 -95
- package/src/lib/scaffold-client.ts +0 -31
- package/src/lib/scaffold.ts +0 -37
- package/src/lib/slugify.ts +0 -25
- package/src/lib/swarms.ts +0 -25
- package/src/lib/tickets.ts +0 -192
- package/src/lib/type-guards.ts +0 -3
- package/src/lib/use-slugified-id.ts +0 -35
- package/src/lib/workflows/README.md +0 -11
- package/src/lib/workflows/__tests__/storage.test.ts +0 -129
- package/src/lib/workflows/__tests__/validate.test.ts +0 -92
- package/src/lib/workflows/api-handlers.ts +0 -35
- package/src/lib/workflows/readdir.ts +0 -23
- package/src/lib/workflows/runs-storage.ts +0 -59
- package/src/lib/workflows/runs-types.ts +0 -42
- package/src/lib/workflows/storage.ts +0 -70
- package/src/lib/workflows/templates/index.ts +0 -1
- package/src/lib/workflows/templates/marketing-cadence-v1.ts +0 -142
- package/src/lib/workflows/types.ts +0 -48
- package/src/lib/workflows/validate.ts +0 -92
- package/src/proxy.ts +0 -28
- /package/.next/static/{z86RoqzzXXrWnpi229zP6 → Jrrrm9HH5bKkSrQhe1j93}/_buildManifest.js +0 -0
- /package/.next/static/{z86RoqzzXXrWnpi229zP6 → Jrrrm9HH5bKkSrQhe1j93}/_clientMiddlewareManifest.json +0 -0
- /package/.next/static/{z86RoqzzXXrWnpi229zP6 → Jrrrm9HH5bKkSrQhe1j93}/_ssgManifest.js +0 -0
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
2
|
-
import { GET } from "../teams/files/route";
|
|
3
|
-
|
|
4
|
-
vi.mock("@/lib/paths", async (importOriginal) => {
|
|
5
|
-
const actual = await importOriginal<typeof import("@/lib/paths")>();
|
|
6
|
-
return { ...actual, readOpenClawConfig: vi.fn() };
|
|
7
|
-
});
|
|
8
|
-
vi.mock("node:fs/promises", () => ({
|
|
9
|
-
default: { stat: vi.fn() },
|
|
10
|
-
}));
|
|
11
|
-
|
|
12
|
-
import { readOpenClawConfig } from "@/lib/paths";
|
|
13
|
-
import fs from "node:fs/promises";
|
|
14
|
-
|
|
15
|
-
describe("api teams files route", () => {
|
|
16
|
-
const baseWorkspace = "/mock-workspace";
|
|
17
|
-
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
vi.mocked(readOpenClawConfig).mockReset();
|
|
20
|
-
vi.mocked(fs.stat).mockReset();
|
|
21
|
-
|
|
22
|
-
vi.mocked(readOpenClawConfig).mockResolvedValue({
|
|
23
|
-
agents: { defaults: { workspace: baseWorkspace } },
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("returns 400 when teamId missing", async () => {
|
|
28
|
-
const res = await GET(new Request("https://test/api/teams/files"));
|
|
29
|
-
expect(res.status).toBe(400);
|
|
30
|
-
const json = await res.json();
|
|
31
|
-
expect(json.error).toBe("teamId is required");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("returns 500 when workspace not set", async () => {
|
|
35
|
-
vi.mocked(readOpenClawConfig).mockResolvedValue({});
|
|
36
|
-
|
|
37
|
-
const res = await GET(new Request("https://test/api/teams/files?teamId=my-team"));
|
|
38
|
-
expect(res.status).toBe(500);
|
|
39
|
-
const json = await res.json();
|
|
40
|
-
expect(json.error).toBe("agents.defaults.workspace not set");
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("returns files with missing flags", async () => {
|
|
44
|
-
vi.mocked(fs.stat)
|
|
45
|
-
.mockResolvedValueOnce({ size: 100, mtimeMs: 123456 } as never)
|
|
46
|
-
.mockRejectedValueOnce(new Error("ENOENT"));
|
|
47
|
-
|
|
48
|
-
const res = await GET(new Request("https://test/api/teams/files?teamId=my-team"));
|
|
49
|
-
expect(res.status).toBe(200);
|
|
50
|
-
const json = await res.json();
|
|
51
|
-
expect(json.ok).toBe(true);
|
|
52
|
-
expect(json.teamId).toBe("my-team");
|
|
53
|
-
expect(json.files).toBeDefined();
|
|
54
|
-
expect(json.files.some((f: { name: string }) => f.name === "TEAM.md")).toBe(true);
|
|
55
|
-
expect(json.files.some((f: { missing: boolean }) => f.missing === true)).toBe(true);
|
|
56
|
-
});
|
|
57
|
-
});
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
2
|
-
import { GET, POST } from "../teams/meta/route";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
|
|
5
|
-
vi.mock("@/lib/paths", async (importOriginal) => {
|
|
6
|
-
const actual = await importOriginal<typeof import("@/lib/paths")>();
|
|
7
|
-
return { ...actual, readOpenClawConfig: vi.fn() };
|
|
8
|
-
});
|
|
9
|
-
vi.mock("node:fs/promises", () => ({
|
|
10
|
-
default: { readFile: vi.fn(), mkdir: vi.fn(), writeFile: vi.fn() },
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
import { readOpenClawConfig } from "@/lib/paths";
|
|
14
|
-
import fs from "node:fs/promises";
|
|
15
|
-
|
|
16
|
-
describe("api teams meta route", () => {
|
|
17
|
-
const baseWorkspace = "/mock-workspace";
|
|
18
|
-
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
vi.mocked(readOpenClawConfig).mockReset();
|
|
21
|
-
vi.mocked(fs.readFile).mockReset();
|
|
22
|
-
vi.mocked(fs.mkdir).mockReset();
|
|
23
|
-
vi.mocked(fs.writeFile).mockReset();
|
|
24
|
-
|
|
25
|
-
vi.mocked(readOpenClawConfig).mockResolvedValue({
|
|
26
|
-
agents: { defaults: { workspace: baseWorkspace } },
|
|
27
|
-
});
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
describe("GET", () => {
|
|
31
|
-
it("returns 400 when teamId missing", async () => {
|
|
32
|
-
const res = await GET(new Request("https://test/api/teams/meta"));
|
|
33
|
-
expect(res.status).toBe(400);
|
|
34
|
-
expect((await res.json()).error).toBe("teamId is required");
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("returns 500 when workspace not set", async () => {
|
|
38
|
-
vi.mocked(readOpenClawConfig).mockResolvedValue({});
|
|
39
|
-
const res = await GET(new Request("https://test/api/teams/meta?teamId=my-team"));
|
|
40
|
-
expect(res.status).toBe(500);
|
|
41
|
-
expect((await res.json()).error).toBe("agents.defaults.workspace not set");
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it("returns meta when file exists", async () => {
|
|
45
|
-
vi.mocked(fs.readFile).mockResolvedValue(
|
|
46
|
-
JSON.stringify({ teamId: "my-team", recipeId: "r1" })
|
|
47
|
-
);
|
|
48
|
-
const res = await GET(new Request("https://test/api/teams/meta?teamId=my-team"));
|
|
49
|
-
expect(res.status).toBe(200);
|
|
50
|
-
const json = await res.json();
|
|
51
|
-
expect(json.ok).toBe(true);
|
|
52
|
-
expect(json.meta).toEqual({ teamId: "my-team", recipeId: "r1" });
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
it("returns missing true when file not found", async () => {
|
|
56
|
-
vi.mocked(fs.readFile).mockRejectedValue(new Error("ENOENT"));
|
|
57
|
-
const res = await GET(new Request("https://test/api/teams/meta?teamId=my-team"));
|
|
58
|
-
expect(res.status).toBe(200);
|
|
59
|
-
const json = await res.json();
|
|
60
|
-
expect(json.ok).toBe(true);
|
|
61
|
-
expect(json.meta).toBeNull();
|
|
62
|
-
expect(json.missing).toBe(true);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
describe("POST", () => {
|
|
67
|
-
it("returns 400 when teamId or recipeId missing", async () => {
|
|
68
|
-
const res1 = await POST(
|
|
69
|
-
new Request("https://test", {
|
|
70
|
-
method: "POST",
|
|
71
|
-
body: JSON.stringify({ recipeId: "r1" }),
|
|
72
|
-
})
|
|
73
|
-
);
|
|
74
|
-
expect(res1.status).toBe(400);
|
|
75
|
-
expect((await res1.json()).error).toBe("teamId is required");
|
|
76
|
-
|
|
77
|
-
const res2 = await POST(
|
|
78
|
-
new Request("https://test", {
|
|
79
|
-
method: "POST",
|
|
80
|
-
body: JSON.stringify({ teamId: "t1" }),
|
|
81
|
-
})
|
|
82
|
-
);
|
|
83
|
-
expect(res2.status).toBe(400);
|
|
84
|
-
expect((await res2.json()).error).toBe("recipeId is required");
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("writes meta and returns ok", async () => {
|
|
88
|
-
vi.mocked(fs.mkdir).mockResolvedValue(undefined);
|
|
89
|
-
vi.mocked(fs.writeFile).mockResolvedValue(undefined);
|
|
90
|
-
|
|
91
|
-
const res = await POST(
|
|
92
|
-
new Request("https://test", {
|
|
93
|
-
method: "POST",
|
|
94
|
-
body: JSON.stringify({
|
|
95
|
-
teamId: "my-team",
|
|
96
|
-
recipeId: "my-recipe",
|
|
97
|
-
recipeName: "My Recipe",
|
|
98
|
-
}),
|
|
99
|
-
})
|
|
100
|
-
);
|
|
101
|
-
expect(res.status).toBe(200);
|
|
102
|
-
const json = await res.json();
|
|
103
|
-
expect(json.ok).toBe(true);
|
|
104
|
-
expect(json.meta.teamId).toBe("my-team");
|
|
105
|
-
expect(json.meta.recipeId).toBe("my-recipe");
|
|
106
|
-
expect(fs.writeFile).toHaveBeenCalledWith(
|
|
107
|
-
path.join(path.resolve(baseWorkspace, "..", "workspace-my-team"), "team.json"),
|
|
108
|
-
expect.stringContaining("my-team"),
|
|
109
|
-
"utf8"
|
|
110
|
-
);
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
});
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
2
|
-
import { POST } from "../teams/orchestrator/install/route";
|
|
3
|
-
|
|
4
|
-
vi.mock("@/lib/openclaw", () => ({ runOpenClaw: vi.fn() }));
|
|
5
|
-
vi.mock("node:fs/promises", () => ({
|
|
6
|
-
default: {
|
|
7
|
-
readFile: vi.fn(),
|
|
8
|
-
writeFile: vi.fn(),
|
|
9
|
-
mkdir: vi.fn(),
|
|
10
|
-
readdir: vi.fn(),
|
|
11
|
-
chmod: vi.fn(),
|
|
12
|
-
},
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
import { runOpenClaw } from "@/lib/openclaw";
|
|
16
|
-
|
|
17
|
-
describe("api teams orchestrator install route", () => {
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
vi.mocked(runOpenClaw).mockReset();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("returns 400 when teamId missing", async () => {
|
|
23
|
-
const res = await POST(
|
|
24
|
-
new Request("https://test", {
|
|
25
|
-
method: "POST",
|
|
26
|
-
body: JSON.stringify({
|
|
27
|
-
orchestratorAgentId: "team1-swarm-orchestrator",
|
|
28
|
-
repoDir: "/home/test/repo",
|
|
29
|
-
}),
|
|
30
|
-
})
|
|
31
|
-
);
|
|
32
|
-
expect(res.status).toBe(400);
|
|
33
|
-
const json = await res.json();
|
|
34
|
-
expect(json.error).toMatch(/teamId.*required/i);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it("returns 400 when orchestratorAgentId missing", async () => {
|
|
38
|
-
const res = await POST(
|
|
39
|
-
new Request("https://test", {
|
|
40
|
-
method: "POST",
|
|
41
|
-
body: JSON.stringify({
|
|
42
|
-
teamId: "team1",
|
|
43
|
-
repoDir: "/home/test/repo",
|
|
44
|
-
}),
|
|
45
|
-
})
|
|
46
|
-
);
|
|
47
|
-
expect(res.status).toBe(400);
|
|
48
|
-
const json = await res.json();
|
|
49
|
-
expect(json.error).toMatch(/orchestratorAgentId.*required/i);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
it("returns 400 when repoDir missing", async () => {
|
|
53
|
-
const res = await POST(
|
|
54
|
-
new Request("https://test", {
|
|
55
|
-
method: "POST",
|
|
56
|
-
body: JSON.stringify({
|
|
57
|
-
teamId: "team1",
|
|
58
|
-
orchestratorAgentId: "team1-swarm-orchestrator",
|
|
59
|
-
}),
|
|
60
|
-
})
|
|
61
|
-
);
|
|
62
|
-
expect(res.status).toBe(400);
|
|
63
|
-
const json = await res.json();
|
|
64
|
-
expect(json.error).toMatch(/repoDir.*required/i);
|
|
65
|
-
});
|
|
66
|
-
});
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
2
|
-
import { GET } from "../teams/orchestrator/route";
|
|
3
|
-
|
|
4
|
-
vi.mock("@/lib/openclaw", () => ({ runOpenClaw: vi.fn() }));
|
|
5
|
-
vi.mock("@/lib/kitchen-api", () => ({
|
|
6
|
-
getKitchenApi: vi.fn(() => ({
|
|
7
|
-
runtime: {
|
|
8
|
-
system: {
|
|
9
|
-
runCommandWithTimeout: vi.fn().mockResolvedValue({ stdout: "", stderr: "" }),
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
})),
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
import { runOpenClaw } from "@/lib/openclaw";
|
|
16
|
-
|
|
17
|
-
describe("api teams orchestrator route", () => {
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
vi.mocked(runOpenClaw).mockReset();
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("returns 400 when teamId missing", async () => {
|
|
23
|
-
const res = await GET(new Request("https://test"));
|
|
24
|
-
expect(res.status).toBe(400);
|
|
25
|
-
const json = await res.json();
|
|
26
|
-
expect(json.error).toBe("teamId is required");
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it("returns 200 with present:false when no orchestrator agent found", async () => {
|
|
30
|
-
vi.mocked(runOpenClaw).mockResolvedValue({
|
|
31
|
-
ok: true,
|
|
32
|
-
stdout: JSON.stringify([{ id: "other-agent", workspace: "/home" }]),
|
|
33
|
-
stderr: "",
|
|
34
|
-
exitCode: 0,
|
|
35
|
-
});
|
|
36
|
-
const res = await GET(new Request("https://test?teamId=team1"));
|
|
37
|
-
expect(res.status).toBe(200);
|
|
38
|
-
const json = await res.json();
|
|
39
|
-
expect(json.ok).toBe(true);
|
|
40
|
-
expect(json.present).toBe(false);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("returns 200 with present:true when orchestrator agent found", async () => {
|
|
44
|
-
vi.mocked(runOpenClaw).mockResolvedValue({
|
|
45
|
-
ok: true,
|
|
46
|
-
stdout: JSON.stringify([
|
|
47
|
-
{ id: "team1-swarm-orchestrator", workspace: "/home/workspace-team1" },
|
|
48
|
-
]),
|
|
49
|
-
stderr: "",
|
|
50
|
-
exitCode: 0,
|
|
51
|
-
});
|
|
52
|
-
const res = await GET(new Request("https://test?teamId=team1"));
|
|
53
|
-
expect(res.status).toBe(200);
|
|
54
|
-
const json = await res.json();
|
|
55
|
-
expect(json.ok).toBe(true);
|
|
56
|
-
expect(json.present).toBe(true);
|
|
57
|
-
expect(json.agent.id).toBe("team1-swarm-orchestrator");
|
|
58
|
-
});
|
|
59
|
-
});
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
2
|
-
import { POST } from "../teams/remove-team/route";
|
|
3
|
-
|
|
4
|
-
vi.mock("@/lib/openclaw", () => ({ runOpenClaw: vi.fn() }));
|
|
5
|
-
|
|
6
|
-
import { runOpenClaw } from "@/lib/openclaw";
|
|
7
|
-
|
|
8
|
-
describe("api teams remove-team route", () => {
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
vi.mocked(runOpenClaw).mockReset();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it("returns 400 when teamId missing", async () => {
|
|
14
|
-
const res = await POST(
|
|
15
|
-
new Request("https://test", { method: "POST", body: JSON.stringify({}) })
|
|
16
|
-
);
|
|
17
|
-
expect(res.status).toBe(400);
|
|
18
|
-
const json = await res.json();
|
|
19
|
-
expect(json.error).toBe("teamId is required");
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it("returns 403 when team is builtin", async () => {
|
|
23
|
-
vi.mocked(runOpenClaw).mockResolvedValue({
|
|
24
|
-
ok: true,
|
|
25
|
-
exitCode: 0,
|
|
26
|
-
stdout: JSON.stringify([
|
|
27
|
-
{ id: "builtin-team", kind: "team", source: "builtin" },
|
|
28
|
-
]),
|
|
29
|
-
stderr: "",
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
const res = await POST(
|
|
33
|
-
new Request("https://test", {
|
|
34
|
-
method: "POST",
|
|
35
|
-
body: JSON.stringify({ teamId: "builtin-team" }),
|
|
36
|
-
})
|
|
37
|
-
);
|
|
38
|
-
expect(res.status).toBe(403);
|
|
39
|
-
const json = await res.json();
|
|
40
|
-
expect(json.error).toContain("Refusing to delete builtin team");
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it("returns 500 when runOpenClaw fails", async () => {
|
|
44
|
-
vi.mocked(runOpenClaw)
|
|
45
|
-
.mockResolvedValueOnce({
|
|
46
|
-
ok: true,
|
|
47
|
-
exitCode: 0,
|
|
48
|
-
stdout: JSON.stringify([{ id: "my-team", kind: "team", source: "workspace" }]),
|
|
49
|
-
stderr: "",
|
|
50
|
-
})
|
|
51
|
-
.mockResolvedValueOnce({
|
|
52
|
-
ok: false,
|
|
53
|
-
exitCode: 1,
|
|
54
|
-
stdout: "",
|
|
55
|
-
stderr: "Team in use",
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
const res = await POST(
|
|
59
|
-
new Request("https://test", {
|
|
60
|
-
method: "POST",
|
|
61
|
-
body: JSON.stringify({ teamId: "my-team" }),
|
|
62
|
-
})
|
|
63
|
-
);
|
|
64
|
-
expect(res.status).toBe(500);
|
|
65
|
-
const json = await res.json();
|
|
66
|
-
expect(json.error).toContain("Team in use");
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it("returns ok on success", async () => {
|
|
70
|
-
vi.mocked(runOpenClaw)
|
|
71
|
-
.mockResolvedValueOnce({
|
|
72
|
-
ok: true,
|
|
73
|
-
exitCode: 0,
|
|
74
|
-
stdout: JSON.stringify([{ id: "my-team", kind: "team", source: "workspace" }]),
|
|
75
|
-
stderr: "",
|
|
76
|
-
})
|
|
77
|
-
.mockResolvedValueOnce({
|
|
78
|
-
ok: true,
|
|
79
|
-
exitCode: 0,
|
|
80
|
-
stdout: JSON.stringify({ removed: true }),
|
|
81
|
-
stderr: "",
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
const res = await POST(
|
|
85
|
-
new Request("https://test", {
|
|
86
|
-
method: "POST",
|
|
87
|
-
body: JSON.stringify({ teamId: "my-team" }),
|
|
88
|
-
})
|
|
89
|
-
);
|
|
90
|
-
expect(res.status).toBe(200);
|
|
91
|
-
const json = await res.json();
|
|
92
|
-
expect(json.ok).toBe(true);
|
|
93
|
-
expect(json.result).toEqual({ removed: true });
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it("includes includeAmbiguous when specified", async () => {
|
|
97
|
-
vi.mocked(runOpenClaw)
|
|
98
|
-
.mockResolvedValueOnce({
|
|
99
|
-
ok: true,
|
|
100
|
-
exitCode: 0,
|
|
101
|
-
stdout: JSON.stringify([{ id: "t", kind: "team", source: "workspace" }]),
|
|
102
|
-
stderr: "",
|
|
103
|
-
})
|
|
104
|
-
.mockResolvedValueOnce({
|
|
105
|
-
ok: true,
|
|
106
|
-
exitCode: 0,
|
|
107
|
-
stdout: "{}",
|
|
108
|
-
stderr: "",
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
await POST(
|
|
112
|
-
new Request("https://test", {
|
|
113
|
-
method: "POST",
|
|
114
|
-
body: JSON.stringify({ teamId: "t", includeAmbiguous: true }),
|
|
115
|
-
})
|
|
116
|
-
);
|
|
117
|
-
expect(runOpenClaw).toHaveBeenNthCalledWith(
|
|
118
|
-
2,
|
|
119
|
-
expect.arrayContaining(["--include-ambiguous"])
|
|
120
|
-
);
|
|
121
|
-
});
|
|
122
|
-
});
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
2
|
-
import { POST } from "../teams/skills/install/route";
|
|
3
|
-
|
|
4
|
-
vi.mock("@/lib/openclaw", () => ({ runOpenClaw: vi.fn() }));
|
|
5
|
-
import { runOpenClaw } from "@/lib/openclaw";
|
|
6
|
-
|
|
7
|
-
describe("api teams skills install route", () => {
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
vi.mocked(runOpenClaw).mockReset();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it("returns 400 when teamId missing", async () => {
|
|
13
|
-
const res = await POST(
|
|
14
|
-
new Request("https://test", { method: "POST", body: JSON.stringify({ skill: "foo" }) })
|
|
15
|
-
);
|
|
16
|
-
expect(res.status).toBe(400);
|
|
17
|
-
const json = await res.json();
|
|
18
|
-
expect(json.error).toBe("teamId is required");
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("returns 400 when skill missing", async () => {
|
|
22
|
-
const res = await POST(
|
|
23
|
-
new Request("https://test", { method: "POST", body: JSON.stringify({ teamId: "t1" }) })
|
|
24
|
-
);
|
|
25
|
-
expect(res.status).toBe(400);
|
|
26
|
-
const json = await res.json();
|
|
27
|
-
expect(json.error).toBe("skill is required");
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it("returns 200 and installs skill for team", async () => {
|
|
31
|
-
vi.mocked(runOpenClaw).mockResolvedValue({
|
|
32
|
-
ok: true,
|
|
33
|
-
exitCode: 0,
|
|
34
|
-
stdout: "installed",
|
|
35
|
-
stderr: "",
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
const res = await POST(
|
|
39
|
-
new Request("https://test", {
|
|
40
|
-
method: "POST",
|
|
41
|
-
body: JSON.stringify({ teamId: "t1", skill: "my-skill" }),
|
|
42
|
-
})
|
|
43
|
-
);
|
|
44
|
-
expect(res.status).toBe(200);
|
|
45
|
-
const json = await res.json();
|
|
46
|
-
expect(json.ok).toBe(true);
|
|
47
|
-
expect(json.teamId).toBe("t1");
|
|
48
|
-
expect(json.skill).toBe("my-skill");
|
|
49
|
-
expect(runOpenClaw).toHaveBeenCalledWith([
|
|
50
|
-
"recipes",
|
|
51
|
-
"install-skill",
|
|
52
|
-
"my-skill",
|
|
53
|
-
"--team-id",
|
|
54
|
-
"t1",
|
|
55
|
-
"--yes",
|
|
56
|
-
]);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it("returns 500 when runOpenClaw fails", async () => {
|
|
60
|
-
vi.mocked(runOpenClaw).mockResolvedValue({
|
|
61
|
-
ok: false,
|
|
62
|
-
exitCode: 1,
|
|
63
|
-
stdout: "stdout msg",
|
|
64
|
-
stderr: "stderr msg",
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
const res = await POST(
|
|
68
|
-
new Request("https://test", {
|
|
69
|
-
method: "POST",
|
|
70
|
-
body: JSON.stringify({ teamId: "t1", skill: "bad-skill" }),
|
|
71
|
-
})
|
|
72
|
-
);
|
|
73
|
-
expect(res.status).toBe(500);
|
|
74
|
-
const json = await res.json();
|
|
75
|
-
expect(json.ok).toBe(false);
|
|
76
|
-
expect(json.error).toBe("stderr msg");
|
|
77
|
-
});
|
|
78
|
-
});
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
2
|
-
import { GET } from "../teams/skills/route";
|
|
3
|
-
|
|
4
|
-
vi.mock("@/lib/paths", async (importOriginal) => {
|
|
5
|
-
const actual = await importOriginal<typeof import("@/lib/paths")>();
|
|
6
|
-
return { ...actual, readOpenClawConfig: vi.fn() };
|
|
7
|
-
});
|
|
8
|
-
vi.mock("node:fs/promises", () => ({
|
|
9
|
-
default: { readdir: vi.fn() },
|
|
10
|
-
}));
|
|
11
|
-
|
|
12
|
-
import { readOpenClawConfig } from "@/lib/paths";
|
|
13
|
-
import fs from "node:fs/promises";
|
|
14
|
-
|
|
15
|
-
describe("api teams skills route", () => {
|
|
16
|
-
const baseWorkspace = "/mock-workspace";
|
|
17
|
-
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
vi.mocked(readOpenClawConfig).mockReset();
|
|
20
|
-
vi.mocked(fs.readdir).mockReset();
|
|
21
|
-
|
|
22
|
-
vi.mocked(readOpenClawConfig).mockResolvedValue({
|
|
23
|
-
agents: { defaults: { workspace: baseWorkspace } },
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("returns 400 when teamId missing", async () => {
|
|
28
|
-
const res = await GET(new Request("https://test"));
|
|
29
|
-
expect(res.status).toBe(400);
|
|
30
|
-
const json = await res.json();
|
|
31
|
-
expect(json.error).toBe("teamId is required");
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it("returns 500 when workspace not set", async () => {
|
|
35
|
-
vi.mocked(readOpenClawConfig).mockResolvedValue({});
|
|
36
|
-
|
|
37
|
-
const res = await GET(
|
|
38
|
-
new Request("https://test?teamId=my-team")
|
|
39
|
-
);
|
|
40
|
-
expect(res.status).toBe(500);
|
|
41
|
-
const json = await res.json();
|
|
42
|
-
expect(json.error).toBe("agents.defaults.workspace not set");
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
it("returns sorted skills on success", async () => {
|
|
46
|
-
vi.mocked(fs.readdir).mockResolvedValue([
|
|
47
|
-
{ name: "skill-b", isDirectory: () => true } as never,
|
|
48
|
-
{ name: "skill-a", isDirectory: () => true } as never,
|
|
49
|
-
{ name: "README.md", isDirectory: () => false } as never,
|
|
50
|
-
]);
|
|
51
|
-
|
|
52
|
-
const res = await GET(
|
|
53
|
-
new Request("https://test?teamId=my-team")
|
|
54
|
-
);
|
|
55
|
-
expect(res.status).toBe(200);
|
|
56
|
-
const json = await res.json();
|
|
57
|
-
expect(json.ok).toBe(true);
|
|
58
|
-
expect(json.skills).toEqual(["skill-a", "skill-b"]);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it("returns empty skills with note when skills dir missing", async () => {
|
|
62
|
-
vi.mocked(fs.readdir).mockRejectedValue(new Error("ENOENT"));
|
|
63
|
-
|
|
64
|
-
const res = await GET(
|
|
65
|
-
new Request("https://test?teamId=my-team")
|
|
66
|
-
);
|
|
67
|
-
expect(res.status).toBe(200);
|
|
68
|
-
const json = await res.json();
|
|
69
|
-
expect(json.ok).toBe(true);
|
|
70
|
-
expect(json.skills).toEqual([]);
|
|
71
|
-
expect(json.note).toBe("ENOENT");
|
|
72
|
-
});
|
|
73
|
-
});
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi, beforeEach } from "vitest";
|
|
2
|
-
import { GET, POST } from "../teams/workflow-runs/route";
|
|
3
|
-
|
|
4
|
-
vi.mock("@/lib/workflows/runs-storage", () => ({
|
|
5
|
-
listWorkflowRuns: vi.fn(),
|
|
6
|
-
readWorkflowRun: vi.fn(),
|
|
7
|
-
writeWorkflowRun: vi.fn(),
|
|
8
|
-
}));
|
|
9
|
-
vi.mock("@/lib/workflows/storage", () => ({
|
|
10
|
-
readWorkflow: vi.fn(),
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
import { listWorkflowRuns, readWorkflowRun } from "@/lib/workflows/runs-storage";
|
|
14
|
-
|
|
15
|
-
describe("api teams workflow-runs route", () => {
|
|
16
|
-
beforeEach(() => {
|
|
17
|
-
vi.mocked(listWorkflowRuns).mockReset();
|
|
18
|
-
vi.mocked(readWorkflowRun).mockReset();
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it("GET returns 400 when teamId missing", async () => {
|
|
22
|
-
const res = await GET(new Request("https://test"));
|
|
23
|
-
expect(res.status).toBe(400);
|
|
24
|
-
const json = await res.json();
|
|
25
|
-
expect(json.error).toBe("teamId is required");
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("GET returns 400 when workflowId missing", async () => {
|
|
29
|
-
const res = await GET(new Request("https://test?teamId=team1"));
|
|
30
|
-
expect(res.status).toBe(400);
|
|
31
|
-
const json = await res.json();
|
|
32
|
-
expect(json.error).toBe("workflowId is required");
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it("GET returns 200 with list when no runId", async () => {
|
|
36
|
-
vi.mocked(listWorkflowRuns).mockResolvedValue({
|
|
37
|
-
ok: true,
|
|
38
|
-
dir: "/home/test",
|
|
39
|
-
files: ["run-1.run.json"],
|
|
40
|
-
});
|
|
41
|
-
const res = await GET(new Request("https://test?teamId=team1&workflowId=wf1"));
|
|
42
|
-
expect(res.status).toBe(200);
|
|
43
|
-
const json = await res.json();
|
|
44
|
-
expect(json.ok).toBe(true);
|
|
45
|
-
expect(json.files).toEqual(["run-1.run.json"]);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
it("GET returns 200 with run when runId provided", async () => {
|
|
49
|
-
const run = { id: "run-1", status: "running", nodes: [] };
|
|
50
|
-
vi.mocked(readWorkflowRun).mockResolvedValue({
|
|
51
|
-
ok: true,
|
|
52
|
-
path: "/home/test/run-1.run.json",
|
|
53
|
-
run,
|
|
54
|
-
});
|
|
55
|
-
const res = await GET(new Request("https://test?teamId=team1&workflowId=wf1&runId=run-1"));
|
|
56
|
-
expect(res.status).toBe(200);
|
|
57
|
-
const json = await res.json();
|
|
58
|
-
expect(json.ok).toBe(true);
|
|
59
|
-
expect(json.run).toEqual(run);
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it("POST returns 400 when teamId missing", async () => {
|
|
63
|
-
const res = await POST(
|
|
64
|
-
new Request("https://test", {
|
|
65
|
-
method: "POST",
|
|
66
|
-
body: JSON.stringify({ workflowId: "wf1", mode: "create" }),
|
|
67
|
-
})
|
|
68
|
-
);
|
|
69
|
-
expect(res.status).toBe(400);
|
|
70
|
-
const json = await res.json();
|
|
71
|
-
expect(json.error).toBe("teamId is required");
|
|
72
|
-
});
|
|
73
|
-
|
|
74
|
-
it("POST returns 400 when workflowId missing", async () => {
|
|
75
|
-
const res = await POST(
|
|
76
|
-
new Request("https://test", {
|
|
77
|
-
method: "POST",
|
|
78
|
-
body: JSON.stringify({ teamId: "team1", mode: "create" }),
|
|
79
|
-
})
|
|
80
|
-
);
|
|
81
|
-
expect(res.status).toBe(400);
|
|
82
|
-
const json = await res.json();
|
|
83
|
-
expect(json.error).toBe("workflowId is required");
|
|
84
|
-
});
|
|
85
|
-
});
|