Skip to content
Merged
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
26 changes: 26 additions & 0 deletions __tests__/commands/artists.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,32 @@ describe("artists list", () => {
expect(get).toHaveBeenCalledWith("/api/artists", { org_id: "org-123" });
});

it("passes account_id when --account is provided", async () => {
vi.mocked(get).mockResolvedValue({
status: "success",
artists: [{ account_id: "a1", name: "Artist One", label: "Label A" }],
});

await artistsCommand.parseAsync(["list", "--account", "acc-123"], {
from: "user",
});

expect(get).toHaveBeenCalledWith("/api/artists", { account_id: "acc-123" });
});

it("combines --account and --org flags", async () => {
vi.mocked(get).mockResolvedValue({
status: "success",
artists: [{ account_id: "a1", name: "Artist One", label: "Label A" }],
});

await artistsCommand.parseAsync(["list", "--account", "acc-123", "--org", "org-456"], {
from: "user",
});

expect(get).toHaveBeenCalledWith("/api/artists", { account_id: "acc-123", org_id: "org-456" });
});

it("prints JSON with --json flag", async () => {
const artists = [{ account_id: "a1", name: "Artist One", label: "Label" }];
vi.mocked(get).mockResolvedValue({ status: "success", artists });
Expand Down
15 changes: 14 additions & 1 deletion __tests__/commands/orgs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,23 @@ describe("orgs list", () => {

await orgsCommand.parseAsync(["list"], { from: "user" });

expect(get).toHaveBeenCalledWith("/api/organizations");
expect(get).toHaveBeenCalledWith("/api/organizations", {});
expect(logSpy).toHaveBeenCalledTimes(4); // header + separator + 2 rows
});

it("passes account_id when --account is provided", async () => {
vi.mocked(get).mockResolvedValue({
status: "success",
organizations: [{ organization_id: "org-1", organization_name: "My Org" }],
});

await orgsCommand.parseAsync(["list", "--account", "acc-123"], {
from: "user",
});

expect(get).toHaveBeenCalledWith("/api/organizations", { account_id: "acc-123" });
});

it("prints JSON with --json flag", async () => {
const orgs = [{ organization_id: "org-1", organization_name: "My Org" }];
vi.mocked(get).mockResolvedValue({
Expand Down
2 changes: 2 additions & 0 deletions src/commands/artists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ const listCommand = new Command("list")
.description("List artists for the current account")
.option("--json", "Output as JSON")
.option("--org <orgId>", "Filter by organization ID")
.option("--account <accountId>", "Filter by account ID")
.action(async (opts) => {
try {
const params: Record<string, string> = {};
if (opts.org) params.org_id = opts.org;
if (opts.account) params.account_id = opts.account;
const data = await get("/api/artists", params);
const artists = (data.artists as Record<string, unknown>[]) || [];

Expand Down
5 changes: 4 additions & 1 deletion src/commands/orgs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import { printJson, printTable, printError } from "../output.js";
const listCommand = new Command("list")
.description("List organizations for the current account")
.option("--json", "Output as JSON")
.option("--account <accountId>", "Filter by account ID")
.action(async (opts) => {
try {
const data = await get("/api/organizations");
const params: Record<string, string> = {};
if (opts.account) params.account_id = opts.account;
const data = await get("/api/organizations", params);
const orgs = (data.organizations as Record<string, unknown>[]) || [];

if (opts.json) {
Expand Down