mirror of
https://github.com/harivansh-afk/sandbox-agent.git
synced 2026-04-20 02:03:19 +00:00
38 lines
995 B
TypeScript
38 lines
995 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import type { TaskWorkbenchSnapshot } from "@sandbox-agent/factory-shared";
|
|
import { resolveRepoRouteTaskId } from "./workbench-routing";
|
|
|
|
const snapshot: TaskWorkbenchSnapshot = {
|
|
workspaceId: "default",
|
|
repos: [
|
|
{ id: "repo-a", label: "acme/repo-a" },
|
|
{ id: "repo-b", label: "acme/repo-b" },
|
|
],
|
|
repoSections: [],
|
|
tasks: [
|
|
{
|
|
id: "task-a",
|
|
repoId: "repo-a",
|
|
title: "Alpha",
|
|
status: "idle",
|
|
repoName: "acme/repo-a",
|
|
updatedAtMs: 20,
|
|
branch: "feature/alpha",
|
|
pullRequest: null,
|
|
tabs: [],
|
|
fileChanges: [],
|
|
diffs: {},
|
|
fileTree: [],
|
|
},
|
|
],
|
|
};
|
|
|
|
describe("resolveRepoRouteTaskId", () => {
|
|
it("finds the active task for a repo route", () => {
|
|
expect(resolveRepoRouteTaskId(snapshot, "repo-a")).toBe("task-a");
|
|
});
|
|
|
|
it("returns null when a repo has no task yet", () => {
|
|
expect(resolveRepoRouteTaskId(snapshot, "repo-b")).toBeNull();
|
|
});
|
|
});
|