postgresai 0.14.0-dev.70 → 0.14.0-dev.72
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/bin/postgres-ai.ts +403 -95
- package/dist/bin/postgres-ai.js +1126 -158
- package/lib/init.ts +76 -19
- package/lib/issues.ts +453 -7
- package/lib/mcp-server.ts +180 -3
- package/lib/metrics-embedded.ts +1 -1
- package/lib/supabase.ts +52 -0
- package/package.json +1 -1
- package/test/config-consistency.test.ts +36 -0
- package/test/init.integration.test.ts +78 -70
- package/test/init.test.ts +155 -0
- package/test/issues.cli.test.ts +224 -0
- package/test/mcp-server.test.ts +551 -12
package/test/init.test.ts
CHANGED
|
@@ -152,6 +152,42 @@ describe("init module", () => {
|
|
|
152
152
|
expect(plan.steps.some((s: { optional?: boolean }) => s.optional)).toBe(true);
|
|
153
153
|
});
|
|
154
154
|
|
|
155
|
+
test("buildInitPlan skips role creation for supabase provider", async () => {
|
|
156
|
+
const plan = await init.buildInitPlan({
|
|
157
|
+
database: "mydb",
|
|
158
|
+
monitoringUser: DEFAULT_MONITORING_USER,
|
|
159
|
+
monitoringPassword: "pw",
|
|
160
|
+
includeOptionalPermissions: false,
|
|
161
|
+
provider: "supabase",
|
|
162
|
+
});
|
|
163
|
+
expect(plan.steps.some((s) => s.name === "01.role")).toBe(false);
|
|
164
|
+
expect(plan.steps.some((s) => s.name === "02.permissions")).toBe(true);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
test("buildInitPlan removes ALTER USER for supabase provider", async () => {
|
|
168
|
+
const plan = await init.buildInitPlan({
|
|
169
|
+
database: "mydb",
|
|
170
|
+
monitoringUser: DEFAULT_MONITORING_USER,
|
|
171
|
+
monitoringPassword: "pw",
|
|
172
|
+
includeOptionalPermissions: false,
|
|
173
|
+
provider: "supabase",
|
|
174
|
+
});
|
|
175
|
+
const permStep = plan.steps.find((s) => s.name === "02.permissions");
|
|
176
|
+
expect(permStep).toBeDefined();
|
|
177
|
+
expect(permStep!.sql.toLowerCase()).not.toMatch(/alter user/);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test("buildInitPlan includes role creation for unknown provider", async () => {
|
|
181
|
+
const plan = await init.buildInitPlan({
|
|
182
|
+
database: "mydb",
|
|
183
|
+
monitoringUser: DEFAULT_MONITORING_USER,
|
|
184
|
+
monitoringPassword: "pw",
|
|
185
|
+
includeOptionalPermissions: false,
|
|
186
|
+
provider: "some-custom-provider",
|
|
187
|
+
});
|
|
188
|
+
expect(plan.steps.some((s) => s.name === "01.role")).toBe(true);
|
|
189
|
+
});
|
|
190
|
+
|
|
155
191
|
test("resolveAdminConnection accepts positional URI", () => {
|
|
156
192
|
const r = init.resolveAdminConnection({ conn: "postgresql://u:p@h:5432/d" });
|
|
157
193
|
expect(r.clientConfig.connectionString).toBeTruthy();
|
|
@@ -290,6 +326,91 @@ describe("init module", () => {
|
|
|
290
326
|
expect(calls[calls.length - 1].toLowerCase()).toBe("rollback;");
|
|
291
327
|
});
|
|
292
328
|
|
|
329
|
+
test("verifyInitSetup skips search_path check for supabase provider", async () => {
|
|
330
|
+
const calls: string[] = [];
|
|
331
|
+
const client = {
|
|
332
|
+
query: async (sql: string, params?: any) => {
|
|
333
|
+
calls.push(String(sql));
|
|
334
|
+
|
|
335
|
+
if (String(sql).toLowerCase().startsWith("begin isolation level repeatable read")) {
|
|
336
|
+
return { rowCount: 1, rows: [] };
|
|
337
|
+
}
|
|
338
|
+
if (String(sql).toLowerCase() === "rollback;") {
|
|
339
|
+
return { rowCount: 1, rows: [] };
|
|
340
|
+
}
|
|
341
|
+
// Return empty rolconfig - would fail without provider=supabase
|
|
342
|
+
if (String(sql).includes("select rolconfig")) {
|
|
343
|
+
return { rowCount: 1, rows: [{ rolconfig: null }] };
|
|
344
|
+
}
|
|
345
|
+
if (String(sql).includes("from pg_catalog.pg_roles")) {
|
|
346
|
+
return { rowCount: 1, rows: [{ rolname: DEFAULT_MONITORING_USER }] };
|
|
347
|
+
}
|
|
348
|
+
if (String(sql).includes("has_database_privilege")) {
|
|
349
|
+
return { rowCount: 1, rows: [{ ok: true }] };
|
|
350
|
+
}
|
|
351
|
+
if (String(sql).includes("pg_has_role")) {
|
|
352
|
+
return { rowCount: 1, rows: [{ ok: true }] };
|
|
353
|
+
}
|
|
354
|
+
if (String(sql).includes("has_table_privilege")) {
|
|
355
|
+
return { rowCount: 1, rows: [{ ok: true }] };
|
|
356
|
+
}
|
|
357
|
+
if (String(sql).includes("to_regclass")) {
|
|
358
|
+
return { rowCount: 1, rows: [{ ok: true }] };
|
|
359
|
+
}
|
|
360
|
+
if (String(sql).includes("has_function_privilege")) {
|
|
361
|
+
return { rowCount: 1, rows: [{ ok: true }] };
|
|
362
|
+
}
|
|
363
|
+
if (String(sql).includes("has_schema_privilege")) {
|
|
364
|
+
return { rowCount: 1, rows: [{ ok: true }] };
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
throw new Error(`unexpected sql: ${sql} params=${JSON.stringify(params)}`);
|
|
368
|
+
},
|
|
369
|
+
};
|
|
370
|
+
|
|
371
|
+
// With provider=supabase, should pass even without search_path
|
|
372
|
+
const r = await init.verifyInitSetup({
|
|
373
|
+
client: client as any,
|
|
374
|
+
database: "mydb",
|
|
375
|
+
monitoringUser: DEFAULT_MONITORING_USER,
|
|
376
|
+
includeOptionalPermissions: false,
|
|
377
|
+
provider: "supabase",
|
|
378
|
+
});
|
|
379
|
+
expect(r.ok).toBe(true);
|
|
380
|
+
expect(r.missingRequired.length).toBe(0);
|
|
381
|
+
// Should not have queried for rolconfig since we skip search_path check
|
|
382
|
+
expect(calls.some((c) => c.includes("select rolconfig"))).toBe(false);
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
test("buildInitPlan preserves comments when filtering ALTER USER", async () => {
|
|
386
|
+
const plan = await init.buildInitPlan({
|
|
387
|
+
database: "mydb",
|
|
388
|
+
monitoringUser: DEFAULT_MONITORING_USER,
|
|
389
|
+
monitoringPassword: "pw",
|
|
390
|
+
includeOptionalPermissions: false,
|
|
391
|
+
provider: "supabase",
|
|
392
|
+
});
|
|
393
|
+
const permStep = plan.steps.find((s) => s.name === "02.permissions");
|
|
394
|
+
expect(permStep).toBeDefined();
|
|
395
|
+
// Should have removed ALTER USER but kept comments
|
|
396
|
+
expect(permStep!.sql.toLowerCase()).not.toMatch(/^\s*alter\s+user/m);
|
|
397
|
+
// Should still have comment lines
|
|
398
|
+
expect(permStep!.sql).toMatch(/^--/m);
|
|
399
|
+
});
|
|
400
|
+
|
|
401
|
+
test("validateProvider returns null for known providers", () => {
|
|
402
|
+
expect(init.validateProvider(undefined)).toBe(null);
|
|
403
|
+
expect(init.validateProvider("self-managed")).toBe(null);
|
|
404
|
+
expect(init.validateProvider("supabase")).toBe(null);
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
test("validateProvider returns warning for unknown providers", () => {
|
|
408
|
+
const warning = init.validateProvider("unknown-provider");
|
|
409
|
+
expect(warning).not.toBe(null);
|
|
410
|
+
expect(warning).toMatch(/Unknown provider/);
|
|
411
|
+
expect(warning).toMatch(/unknown-provider/);
|
|
412
|
+
});
|
|
413
|
+
|
|
293
414
|
test("redactPasswordsInSql redacts password literals with embedded quotes", async () => {
|
|
294
415
|
const plan = await init.buildInitPlan({
|
|
295
416
|
database: "mydb",
|
|
@@ -319,6 +440,40 @@ describe("CLI commands", () => {
|
|
|
319
440
|
expect(r.stdout).toMatch(new RegExp(`grant connect on database "mydb" to "${DEFAULT_MONITORING_USER}"`, "i"));
|
|
320
441
|
});
|
|
321
442
|
|
|
443
|
+
test("cli: prepare-db --print-sql with --provider supabase skips role step", () => {
|
|
444
|
+
const r = runCli(["prepare-db", "--print-sql", "-d", "mydb", "--password", "monpw", "--provider", "supabase"]);
|
|
445
|
+
expect(r.status).toBe(0);
|
|
446
|
+
expect(r.stdout).toMatch(/provider: supabase/);
|
|
447
|
+
// Should not have 01.role step
|
|
448
|
+
expect(r.stdout).not.toMatch(/-- 01\.role/);
|
|
449
|
+
// Should have 02.permissions step
|
|
450
|
+
expect(r.stdout).toMatch(/-- 02\.permissions/);
|
|
451
|
+
});
|
|
452
|
+
|
|
453
|
+
test("cli: prepare-db warns about unknown provider", () => {
|
|
454
|
+
const r = runCli(["prepare-db", "--print-sql", "-d", "mydb", "--password", "monpw", "--provider", "unknown-cloud"]);
|
|
455
|
+
expect(r.status).toBe(0);
|
|
456
|
+
// Should warn about unknown provider
|
|
457
|
+
expect(r.stderr).toMatch(/Unknown provider.*unknown-cloud/);
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
test("cli: prepare-db --reset-password with supabase provider would have no role step", async () => {
|
|
461
|
+
// When using supabase provider, the role creation step is skipped.
|
|
462
|
+
// This means --reset-password (which only runs 01.role) would have no steps.
|
|
463
|
+
// The CLI should error in this case. We test the underlying plan logic here.
|
|
464
|
+
const plan = await (await import("../lib/init")).buildInitPlan({
|
|
465
|
+
database: "mydb",
|
|
466
|
+
monitoringUser: "mon",
|
|
467
|
+
monitoringPassword: "pw",
|
|
468
|
+
includeOptionalPermissions: false,
|
|
469
|
+
provider: "supabase",
|
|
470
|
+
});
|
|
471
|
+
// Simulate what --reset-password does: filter to only 01.role step
|
|
472
|
+
const resetPasswordSteps = plan.steps.filter((s) => s.name === "01.role");
|
|
473
|
+
// For supabase, this should be empty (role creation is skipped)
|
|
474
|
+
expect(resetPasswordSteps.length).toBe(0);
|
|
475
|
+
});
|
|
476
|
+
|
|
322
477
|
test("pgai wrapper forwards to postgresai CLI", () => {
|
|
323
478
|
const r = runPgai(["--help"]);
|
|
324
479
|
expect(r.status).toBe(0);
|
package/test/issues.cli.test.ts
CHANGED
|
@@ -133,6 +133,43 @@ async function startFakeApi() {
|
|
|
133
133
|
);
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
// Action Items endpoints
|
|
137
|
+
if (req.method === "GET" && url.pathname.endsWith("/issue_action_items")) {
|
|
138
|
+
const issueIdParam = url.searchParams.get("issue_id");
|
|
139
|
+
const idParam = url.searchParams.get("id");
|
|
140
|
+
if (issueIdParam) {
|
|
141
|
+
// list_action_items
|
|
142
|
+
return new Response(
|
|
143
|
+
JSON.stringify([
|
|
144
|
+
{ id: "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", issue_id: issueIdParam.replace("eq.", ""), title: "Action 1", is_done: false, status: "waiting_for_approval" },
|
|
145
|
+
{ id: "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb", issue_id: issueIdParam.replace("eq.", ""), title: "Action 2", is_done: true, status: "approved" },
|
|
146
|
+
]),
|
|
147
|
+
{ status: 200, headers: { "Content-Type": "application/json" } }
|
|
148
|
+
);
|
|
149
|
+
}
|
|
150
|
+
if (idParam) {
|
|
151
|
+
// view_action_item
|
|
152
|
+
const actionId = idParam.replace("eq.", "").replace("in.(", "").replace(")", "").split(",")[0];
|
|
153
|
+
return new Response(
|
|
154
|
+
JSON.stringify([
|
|
155
|
+
{ id: actionId, issue_id: "11111111-1111-1111-1111-111111111111", title: "Test Action", description: "Test description", is_done: false, status: "waiting_for_approval", sql_action: "SELECT 1;", configs: [] },
|
|
156
|
+
]),
|
|
157
|
+
{ status: 200, headers: { "Content-Type": "application/json" } }
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
if (req.method === "POST" && url.pathname.endsWith("/rpc/issue_action_item_create")) {
|
|
163
|
+
return new Response(
|
|
164
|
+
JSON.stringify("cccccccc-cccc-cccc-cccc-cccccccccccc"),
|
|
165
|
+
{ status: 200, headers: { "Content-Type": "application/json" } }
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (req.method === "POST" && url.pathname.endsWith("/rpc/issue_action_item_update")) {
|
|
170
|
+
return new Response("", { status: 200, headers: { "Content-Type": "application/json" } });
|
|
171
|
+
}
|
|
172
|
+
|
|
136
173
|
return new Response("not found", { status: 404 });
|
|
137
174
|
},
|
|
138
175
|
});
|
|
@@ -312,3 +349,190 @@ describe("CLI issues command group", () => {
|
|
|
312
349
|
});
|
|
313
350
|
});
|
|
314
351
|
|
|
352
|
+
describe("CLI action items commands", () => {
|
|
353
|
+
test("issues action-items fails fast when API key is missing", () => {
|
|
354
|
+
const r = runCli(["issues", "action-items", "00000000-0000-0000-0000-000000000000"], isolatedEnv());
|
|
355
|
+
expect(r.status).toBe(1);
|
|
356
|
+
expect(`${r.stdout}\n${r.stderr}`).toContain("API key is required");
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
test("issues action-items fails when issue_id is not a valid UUID", () => {
|
|
360
|
+
const r = runCli(["issues", "action-items", "invalid-id"], isolatedEnv({ PGAI_API_KEY: "test-key" }));
|
|
361
|
+
expect(r.status).toBe(1);
|
|
362
|
+
expect(`${r.stdout}\n${r.stderr}`).toContain("issueId must be a valid UUID");
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
test("issues action-items succeeds against a fake API", async () => {
|
|
366
|
+
const api = await startFakeApi();
|
|
367
|
+
try {
|
|
368
|
+
const r = await runCliAsync(
|
|
369
|
+
["issues", "action-items", "11111111-1111-1111-1111-111111111111"],
|
|
370
|
+
isolatedEnv({
|
|
371
|
+
PGAI_API_KEY: "test-key",
|
|
372
|
+
PGAI_API_BASE_URL: api.baseUrl,
|
|
373
|
+
})
|
|
374
|
+
);
|
|
375
|
+
expect(r.status).toBe(0);
|
|
376
|
+
|
|
377
|
+
const out = JSON.parse(r.stdout.trim());
|
|
378
|
+
expect(Array.isArray(out)).toBe(true);
|
|
379
|
+
expect(out.length).toBe(2);
|
|
380
|
+
expect(out[0].title).toBe("Action 1");
|
|
381
|
+
} finally {
|
|
382
|
+
api.stop();
|
|
383
|
+
}
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
test("issues view-action-item fails fast when API key is missing", () => {
|
|
387
|
+
const r = runCli(["issues", "view-action-item", "00000000-0000-0000-0000-000000000000"], isolatedEnv());
|
|
388
|
+
expect(r.status).toBe(1);
|
|
389
|
+
expect(`${r.stdout}\n${r.stderr}`).toContain("API key is required");
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
test("issues view-action-item fails when action_item_id is not a valid UUID", () => {
|
|
393
|
+
const r = runCli(["issues", "view-action-item", "invalid-id"], isolatedEnv({ PGAI_API_KEY: "test-key" }));
|
|
394
|
+
expect(r.status).toBe(1);
|
|
395
|
+
expect(`${r.stdout}\n${r.stderr}`).toContain("actionItemId is required and must be a valid UUID");
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
test("issues view-action-item succeeds against a fake API", async () => {
|
|
399
|
+
const api = await startFakeApi();
|
|
400
|
+
try {
|
|
401
|
+
const r = await runCliAsync(
|
|
402
|
+
["issues", "view-action-item", "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"],
|
|
403
|
+
isolatedEnv({
|
|
404
|
+
PGAI_API_KEY: "test-key",
|
|
405
|
+
PGAI_API_BASE_URL: api.baseUrl,
|
|
406
|
+
})
|
|
407
|
+
);
|
|
408
|
+
expect(r.status).toBe(0);
|
|
409
|
+
|
|
410
|
+
const out = JSON.parse(r.stdout.trim());
|
|
411
|
+
expect(out[0].title).toBe("Test Action");
|
|
412
|
+
expect(out[0].sql_action).toBe("SELECT 1;");
|
|
413
|
+
} finally {
|
|
414
|
+
api.stop();
|
|
415
|
+
}
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
test("issues create-action-item fails fast when API key is missing", () => {
|
|
419
|
+
const r = runCli(["issues", "create-action-item", "00000000-0000-0000-0000-000000000000", "Test title"], isolatedEnv());
|
|
420
|
+
expect(r.status).toBe(1);
|
|
421
|
+
expect(`${r.stdout}\n${r.stderr}`).toContain("API key is required");
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
test("issues create-action-item fails when issue_id is not a valid UUID", () => {
|
|
425
|
+
const r = runCli(["issues", "create-action-item", "invalid-id", "Test title"], isolatedEnv({ PGAI_API_KEY: "test-key" }));
|
|
426
|
+
expect(r.status).toBe(1);
|
|
427
|
+
expect(`${r.stdout}\n${r.stderr}`).toContain("issueId must be a valid UUID");
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
test("issues create-action-item succeeds against a fake API", async () => {
|
|
431
|
+
const api = await startFakeApi();
|
|
432
|
+
try {
|
|
433
|
+
const r = await runCliAsync(
|
|
434
|
+
["issues", "create-action-item", "11111111-1111-1111-1111-111111111111", "New action item", "--description", "Test description"],
|
|
435
|
+
isolatedEnv({
|
|
436
|
+
PGAI_API_KEY: "test-key",
|
|
437
|
+
PGAI_API_BASE_URL: api.baseUrl,
|
|
438
|
+
})
|
|
439
|
+
);
|
|
440
|
+
expect(r.status).toBe(0);
|
|
441
|
+
|
|
442
|
+
const out = JSON.parse(r.stdout.trim());
|
|
443
|
+
expect(out.id).toBe("cccccccc-cccc-cccc-cccc-cccccccccccc");
|
|
444
|
+
|
|
445
|
+
const req = api.requests.find((x) => x.pathname.endsWith("/rpc/issue_action_item_create"));
|
|
446
|
+
expect(req).toBeTruthy();
|
|
447
|
+
expect(req!.headers["access-token"]).toBe("test-key");
|
|
448
|
+
expect(req!.bodyJson.issue_id).toBe("11111111-1111-1111-1111-111111111111");
|
|
449
|
+
expect(req!.bodyJson.title).toBe("New action item");
|
|
450
|
+
expect(req!.bodyJson.description).toBe("Test description");
|
|
451
|
+
} finally {
|
|
452
|
+
api.stop();
|
|
453
|
+
}
|
|
454
|
+
});
|
|
455
|
+
|
|
456
|
+
test("issues create-action-item interprets escape sequences", async () => {
|
|
457
|
+
const api = await startFakeApi();
|
|
458
|
+
try {
|
|
459
|
+
const r = await runCliAsync(
|
|
460
|
+
["issues", "create-action-item", "11111111-1111-1111-1111-111111111111", "Title\\nwith newline", "--description", "Desc\\twith tab"],
|
|
461
|
+
isolatedEnv({
|
|
462
|
+
PGAI_API_KEY: "test-key",
|
|
463
|
+
PGAI_API_BASE_URL: api.baseUrl,
|
|
464
|
+
})
|
|
465
|
+
);
|
|
466
|
+
expect(r.status).toBe(0);
|
|
467
|
+
|
|
468
|
+
const req = api.requests.find((x) => x.pathname.endsWith("/rpc/issue_action_item_create"));
|
|
469
|
+
expect(req).toBeTruthy();
|
|
470
|
+
expect(req!.bodyJson.title).toBe("Title\nwith newline");
|
|
471
|
+
expect(req!.bodyJson.description).toBe("Desc\twith tab");
|
|
472
|
+
} finally {
|
|
473
|
+
api.stop();
|
|
474
|
+
}
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
test("issues update-action-item fails fast when API key is missing", () => {
|
|
478
|
+
const r = runCli(["issues", "update-action-item", "00000000-0000-0000-0000-000000000000", "--done"], isolatedEnv());
|
|
479
|
+
expect(r.status).toBe(1);
|
|
480
|
+
expect(`${r.stdout}\n${r.stderr}`).toContain("API key is required");
|
|
481
|
+
});
|
|
482
|
+
|
|
483
|
+
test("issues update-action-item fails when action_item_id is not a valid UUID", () => {
|
|
484
|
+
const r = runCli(["issues", "update-action-item", "invalid-id", "--done"], isolatedEnv({ PGAI_API_KEY: "test-key" }));
|
|
485
|
+
expect(r.status).toBe(1);
|
|
486
|
+
expect(`${r.stdout}\n${r.stderr}`).toContain("actionItemId must be a valid UUID");
|
|
487
|
+
});
|
|
488
|
+
|
|
489
|
+
test("issues update-action-item fails when no update fields provided", () => {
|
|
490
|
+
const r = runCli(["issues", "update-action-item", "00000000-0000-0000-0000-000000000000"], isolatedEnv({ PGAI_API_KEY: "test-key" }));
|
|
491
|
+
expect(r.status).toBe(1);
|
|
492
|
+
expect(`${r.stdout}\n${r.stderr}`).toContain("At least one update option is required");
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
test("issues update-action-item succeeds with --done flag", async () => {
|
|
496
|
+
const api = await startFakeApi();
|
|
497
|
+
try {
|
|
498
|
+
const r = await runCliAsync(
|
|
499
|
+
["issues", "update-action-item", "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "--done"],
|
|
500
|
+
isolatedEnv({
|
|
501
|
+
PGAI_API_KEY: "test-key",
|
|
502
|
+
PGAI_API_BASE_URL: api.baseUrl,
|
|
503
|
+
})
|
|
504
|
+
);
|
|
505
|
+
expect(r.status).toBe(0);
|
|
506
|
+
|
|
507
|
+
const req = api.requests.find((x) => x.pathname.endsWith("/rpc/issue_action_item_update"));
|
|
508
|
+
expect(req).toBeTruthy();
|
|
509
|
+
expect(req!.headers["access-token"]).toBe("test-key");
|
|
510
|
+
expect(req!.bodyJson.action_item_id).toBe("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa");
|
|
511
|
+
expect(req!.bodyJson.is_done).toBe(true);
|
|
512
|
+
} finally {
|
|
513
|
+
api.stop();
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
|
|
517
|
+
test("issues update-action-item succeeds with --status flag", async () => {
|
|
518
|
+
const api = await startFakeApi();
|
|
519
|
+
try {
|
|
520
|
+
const r = await runCliAsync(
|
|
521
|
+
["issues", "update-action-item", "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", "--status", "approved", "--status-reason", "LGTM"],
|
|
522
|
+
isolatedEnv({
|
|
523
|
+
PGAI_API_KEY: "test-key",
|
|
524
|
+
PGAI_API_BASE_URL: api.baseUrl,
|
|
525
|
+
})
|
|
526
|
+
);
|
|
527
|
+
expect(r.status).toBe(0);
|
|
528
|
+
|
|
529
|
+
const req = api.requests.find((x) => x.pathname.endsWith("/rpc/issue_action_item_update"));
|
|
530
|
+
expect(req).toBeTruthy();
|
|
531
|
+
expect(req!.bodyJson.status).toBe("approved");
|
|
532
|
+
expect(req!.bodyJson.status_reason).toBe("LGTM");
|
|
533
|
+
} finally {
|
|
534
|
+
api.stop();
|
|
535
|
+
}
|
|
536
|
+
});
|
|
537
|
+
});
|
|
538
|
+
|