Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions apps/web/__tests__/unit/loom-csv.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { describe, expect, it } from "vitest";
import { parseConciergeLoomCsv } from "@/lib/loom-csv";

describe("concierge Loom CSV", () => {
it("keeps quoted workspace names and source row numbers", () => {
const rows = parseConciergeLoomCsv(
"\uFEFFuser_email,space_name,loom_video_url\r\n" +
"owner@example.com," +
JSON.stringify("Sales, Europe") +
",https://www.loom.com/share/0123456789abcdef\r\n",
);
expect(rows).toEqual([
{
rowNumber: 2,
loomUrl: "https://www.loom.com/share/0123456789abcdef",
userEmail: "owner@example.com",
spaceName: "Sales, Europe",
},
]);
});

it("rejects a file without the mapping columns", () => {
expect(() => parseConciergeLoomCsv("url,email\nlink,person@x.com")).toThrow(
"loom_video_url and user_email",
);
});
});
8 changes: 8 additions & 0 deletions apps/web/__tests__/unit/loom-import-ui.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ vi.mock("next/link", () => ({
}: React.PropsWithChildren<Record<string, unknown>>) =>
React.createElement("a", props, children),
}));
vi.mock("@cap/env", () => ({
buildEnv: { NEXT_PUBLIC_IS_CAP: "true" },
}));
vi.mock("@/actions/loom", () => ({
getLoomImportFolders: mocks.folders,
importFromLoom: mocks.import,
Expand Down Expand Up @@ -186,6 +189,11 @@ describe("Loom importer component", () => {
it("shows the inherited subfolder and submits it then returns there", async () => {
await render({ folderId: Folder.FolderId.make("child") });
await ready();
expect(
Array.from(container.querySelectorAll("a")).find(
(link) => link.getAttribute("href") === "/dashboard/migrations/loom",
)?.textContent,
).toContain("Want Cap to move your whole Loom workspace for you?");
expect(
getByRole(container, "combobox", { name: "Import to" }).textContent,
).toContain("My Caps / Course / Live Calls - Two");
Expand Down
39 changes: 39 additions & 0 deletions apps/web/__tests__/unit/loom-migration-state.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { describe, expect, it } from "vitest";
import { validateOperatorMigrationUpdate } from "@/lib/loom-migration-state";

const base = {
currentStatus: "in_progress" as const,
nextStatus: "completed" as const,
message: "Migration finished",
verified: true,
expectedVideoCount: 12,
importedVideoCount: 12,
};

describe("Loom migration completion", () => {
it("requires a verified library and reconciled counts", () => {
expect(() =>
validateOperatorMigrationUpdate({ ...base, verified: false }),
).toThrow("Verify the migrated library");
expect(() =>
validateOperatorMigrationUpdate({ ...base, importedVideoCount: 11 }),
).toThrow("Reconcile the expected video count");
expect(() =>
validateOperatorMigrationUpdate({ ...base, expectedVideoCount: null }),
).toThrow("Enter the agreed source video count");
});

it("requires a useful message when Cap asks for information", () => {
expect(() =>
validateOperatorMigrationUpdate({
...base,
nextStatus: "needs_information",
message: " ",
}),
).toThrow("Tell the customer");
});

it("accepts completion after verification", () => {
expect(validateOperatorMigrationUpdate(base)).toBe("Migration finished");
});
});
Loading
Loading