|
| 1 | +import { resolve } from "node:path"; |
1 | 2 | import { describe, expect, it } from "vitest"; |
2 | 3 | import { |
3 | 4 | noEligibleDeepResourceNotes, |
|
7 | 8 | } from "../../src/commands/scan-command/helpers"; |
8 | 9 | import type { ScanCommandOptions } from "../../src/commands/scan-command"; |
9 | 10 | import type { CodeGateReport } from "../../src/types/report"; |
| 11 | +import { normalizeLines } from "../helpers/path"; |
10 | 12 |
|
11 | 13 | function emptyReport(): CodeGateReport { |
12 | 14 | return { |
@@ -65,8 +67,9 @@ describe("scan command helpers", () => { |
65 | 67 | }); |
66 | 68 |
|
67 | 69 | it("formats remediation summary lines with backup and action details", () => { |
| 70 | + const scanTarget = "/tmp/codegate-demo"; |
68 | 71 | const result = remediationSummaryLines({ |
69 | | - scanTarget: "/tmp/codegate-demo", |
| 72 | + scanTarget, |
70 | 73 | options: { remediate: true } satisfies ScanCommandOptions, |
71 | 74 | before: { |
72 | 75 | ...emptyReport(), |
@@ -95,13 +98,18 @@ describe("scan command helpers", () => { |
95 | 98 | ], |
96 | 99 | }, |
97 | 100 | }); |
| 101 | + const normalized = normalizeLines(result); |
98 | 102 |
|
99 | | - expect(result).toContain("Remediation summary:"); |
100 | | - expect(result).toContain("Mode: remediate"); |
101 | | - expect(result).toContain("Findings before remediation: 3"); |
102 | | - expect(result).toContain("Findings after remediation: 1"); |
103 | | - expect(result).toContain("Backup session: /tmp/codegate-demo/.codegate-backup/session-123"); |
104 | | - expect(result).toContain("- remove_field -> /tmp/codegate-demo/.mcp.json (F-1)"); |
| 103 | + expect(normalized).toContain("Remediation summary:"); |
| 104 | + expect(normalized).toContain("Mode: remediate"); |
| 105 | + expect(normalized).toContain("Findings before remediation: 3"); |
| 106 | + expect(normalized).toContain("Findings after remediation: 1"); |
| 107 | + expect(normalized).toContain( |
| 108 | + `Backup session: ${resolve(scanTarget, ".codegate-backup", "session-123").replaceAll("\\", "/")}`, |
| 109 | + ); |
| 110 | + expect(normalized).toContain( |
| 111 | + `- remove_field -> ${resolve(scanTarget, ".mcp.json").replaceAll("\\", "/")} (F-1)`, |
| 112 | + ); |
105 | 113 | }); |
106 | 114 |
|
107 | 115 | it("returns the stock no-resource deep scan notes", () => { |
|
0 commit comments