taskSourceAttribution.test.ts 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { describe, expect, it } from "vitest";
  2. import {
  3. projectTaskSourceDisplayName,
  4. resolveTaskSourceLabel,
  5. } from "@/lib/taskSourceAttribution.js";
  6. describe("task Source attribution", () => {
  7. it("uses the projected Source display name without leaking a stable ID", () => {
  8. expect(
  9. resolveTaskSourceLabel({
  10. workspacePath: "/work/demo",
  11. workspaceIdentity: "remote:server:source-a:/work/demo",
  12. sourceServerId: "source-a",
  13. serverDisplayName: "Dev Server",
  14. }),
  15. ).toBe("Dev Server");
  16. expect(
  17. resolveTaskSourceLabel({
  18. workspacePath: "/work/demo",
  19. workspaceIdentity: "remote:server:source-a:/work/demo",
  20. }),
  21. ).toBeNull();
  22. expect(resolveTaskSourceLabel({ workspacePath: "/work/local" })).toBeNull();
  23. });
  24. it("projects the Source directory display name onto legacy remote-store rows", () => {
  25. const task = {
  26. workspacePath: "/repo",
  27. workspaceIdentity: "remote:server:source-a:/repo",
  28. };
  29. expect(projectTaskSourceDisplayName(task, new Map([["source-a", "Build Server"]]))).toEqual({
  30. ...task,
  31. serverDisplayName: "Build Server",
  32. });
  33. });
  34. });