mirror of
https://github.com/mgeeky/decode-spam-headers.git
synced 2026-02-22 05:23:31 +01:00
MAESTRO: validate JSON export content
This commit is contained in:
@@ -53,7 +53,7 @@ ReportContainer
|
|||||||
- [x] Hop chain displays as a vertical visual flow with server details and connecting arrows
|
- [x] Hop chain displays as a vertical visual flow with server details and connecting arrows
|
||||||
- [x] Security appliances show as badges; empty state handled gracefully
|
- [x] Security appliances show as badges; empty state handled gracefully
|
||||||
- [x] Search filters results in real-time across test name, header name, and analysis text
|
- [x] Search filters results in real-time across test name, header name, and analysis text
|
||||||
- [ ] Export JSON produces a valid JSON file containing all results
|
- [x] Export JSON produces a valid JSON file containing all results
|
||||||
- [ ] Export HTML produces a styled standalone page viewable in any browser
|
- [ ] Export HTML produces a styled standalone page viewable in any browser
|
||||||
- [ ] All report components are keyboard accessible
|
- [ ] All report components are keyboard accessible
|
||||||
- [ ] Linting passes (`npx eslint src/`, `npx prettier --check src/`)
|
- [ ] Linting passes (`npx eslint src/`, `npx prettier --check src/`)
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ const report: AnalysisReport = {
|
|||||||
let createObjectUrlSpy: ReturnType<typeof vi.spyOn> | null = null;
|
let createObjectUrlSpy: ReturnType<typeof vi.spyOn> | null = null;
|
||||||
let revokeObjectUrlSpy: ReturnType<typeof vi.spyOn> | null = null;
|
let revokeObjectUrlSpy: ReturnType<typeof vi.spyOn> | null = null;
|
||||||
let clickSpy: ReturnType<typeof vi.spyOn> | null = null;
|
let clickSpy: ReturnType<typeof vi.spyOn> | null = null;
|
||||||
|
let lastBlob: Blob | null = null;
|
||||||
|
|
||||||
const originalUrlStatics: UrlStatics = {
|
const originalUrlStatics: UrlStatics = {
|
||||||
createObjectURL: (URL as unknown as UrlStatics).createObjectURL,
|
createObjectURL: (URL as unknown as UrlStatics).createObjectURL,
|
||||||
@@ -90,9 +91,13 @@ beforeEach(() => {
|
|||||||
urlStatics.revokeObjectURL = () => undefined;
|
urlStatics.revokeObjectURL = () => undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lastBlob = null;
|
||||||
createObjectUrlSpy = vi
|
createObjectUrlSpy = vi
|
||||||
.spyOn(URL, "createObjectURL")
|
.spyOn(URL, "createObjectURL")
|
||||||
.mockReturnValue("blob:report");
|
.mockImplementation((blob: Blob) => {
|
||||||
|
lastBlob = blob;
|
||||||
|
return "blob:report";
|
||||||
|
});
|
||||||
revokeObjectUrlSpy = vi.spyOn(URL, "revokeObjectURL").mockImplementation(() => {
|
revokeObjectUrlSpy = vi.spyOn(URL, "revokeObjectURL").mockImplementation(() => {
|
||||||
return undefined;
|
return undefined;
|
||||||
});
|
});
|
||||||
@@ -119,7 +124,7 @@ afterEach(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe("ReportExport", () => {
|
describe("ReportExport", () => {
|
||||||
it("triggers a JSON download", () => {
|
it("triggers a JSON download", async () => {
|
||||||
const { container } = render(<ReportExport report={report} />);
|
const { container } = render(<ReportExport report={report} />);
|
||||||
|
|
||||||
const jsonButton = getByTestId(container, "report-export-json");
|
const jsonButton = getByTestId(container, "report-export-json");
|
||||||
@@ -130,6 +135,13 @@ describe("ReportExport", () => {
|
|||||||
|
|
||||||
expect(createObjectUrlSpy).toHaveBeenCalled();
|
expect(createObjectUrlSpy).toHaveBeenCalled();
|
||||||
expect(clickSpy).toHaveBeenCalled();
|
expect(clickSpy).toHaveBeenCalled();
|
||||||
|
expect(lastBlob).not.toBeNull();
|
||||||
|
expect(lastBlob?.type).toBe("application/json");
|
||||||
|
|
||||||
|
const text = await lastBlob?.text();
|
||||||
|
const parsed = JSON.parse(text ?? "{}") as AnalysisReport;
|
||||||
|
expect(parsed.results).toHaveLength(1);
|
||||||
|
expect(parsed.results[0]?.testId).toBe(101);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("triggers an HTML download", () => {
|
it("triggers an HTML download", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user