-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #197 from KoolTheba/feat/improve-mutable-payloads
Improve API Digestion stability and include discrepancies visualization
- Loading branch information
Showing
14 changed files
with
252 additions
and
50 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export const CHECKS_LIST_NAMES = [ | ||
"Binary-Artifacts", | ||
"Branch-Protection", | ||
"CI-Tests", | ||
"CII-Best-Practices", | ||
"Code-Review", | ||
"Contributors", | ||
"Dangerous-Workflow", | ||
"Dependency-Update-Tool", | ||
"Fuzzing", | ||
"License", | ||
"Maintained", | ||
"Packaging", | ||
"Pinned-Dependencies", | ||
"SAST", | ||
"Security-Policy", | ||
"Signed-Releases", | ||
"Token-Permissions", | ||
"Vulnerabilities", | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
export const GITHUB = 'github.com' | ||
export const GITHUB = "github.com"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { areEqualElements } from "./areEqualElements.tsx"; | ||
|
||
const baseScoreElement = { | ||
name: "foo", | ||
score: 0, | ||
reason: "sample reason", | ||
details: ["sample detail"], | ||
documentation: { | ||
short: "documentation short", | ||
url: "documentation url", | ||
}, | ||
}; | ||
|
||
describe("util: areEqualElements", () => { | ||
it("returns true if two elements are equal", () => { | ||
expect( | ||
areEqualElements( | ||
{ ...baseScoreElement, details: ["foo"], reason: "foo" }, | ||
{ ...baseScoreElement, details: ["foo"], reason: "foo" }, | ||
), | ||
).toBe(true); | ||
}); | ||
|
||
it("returns false if two elements are not equal", () => { | ||
expect( | ||
areEqualElements( | ||
{ ...baseScoreElement, details: ["foo"], reason: "foo" }, | ||
{ ...baseScoreElement, details: ["bar"], reason: "bar" }, | ||
), | ||
).toBe(false); | ||
expect( | ||
areEqualElements( | ||
{ ...baseScoreElement, details: ["foo"], reason: "foo" }, | ||
{ ...baseScoreElement, details: ["bar"], reason: "foo" }, | ||
), | ||
).toBe(false); | ||
expect( | ||
areEqualElements( | ||
{ ...baseScoreElement, details: ["foo"], reason: "foo" }, | ||
{ ...baseScoreElement, details: ["foo"], reason: "bar" }, | ||
), | ||
).toBe(false); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ScoreElement } from "../../types"; | ||
|
||
export const areEqualElements = ( | ||
currentElement: ScoreElement, | ||
previousElement: ScoreElement, | ||
) => | ||
JSON.stringify(currentElement.details) === | ||
JSON.stringify(previousElement.details) && | ||
JSON.stringify(currentElement.reason) === | ||
JSON.stringify(previousElement.reason); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { getRefinedChecks } from "./getRefinedChecks.tsx"; | ||
import { CHECKS_LIST_NAMES } from "../../constants/checks.ts"; | ||
import sample1 from "../../../cypress/fixtures/2ac5e9889aba461f5a54d320973d2574980d206b.json"; | ||
import sample2 from "../../../cypress/fixtures/077fd7d83d7d41695137c1af5b9be1d72250e69e.json"; | ||
|
||
describe("util: getRefinedChecks", () => { | ||
it("Should handle empty checks", () => { | ||
expect(getRefinedChecks([], [])).toEqual({ | ||
common: [], | ||
discrepancies: [], | ||
}); | ||
}); | ||
|
||
it("Should handle an empty check", () => { | ||
expect(getRefinedChecks(sample1.checks, [])).toEqual({ | ||
common: [], | ||
discrepancies: CHECKS_LIST_NAMES, | ||
}); | ||
|
||
expect(getRefinedChecks([], sample1.checks)).toEqual({ | ||
common: [], | ||
discrepancies: CHECKS_LIST_NAMES, | ||
}); | ||
}); | ||
|
||
it("Should generate a refined valid result", () => { | ||
expect(getRefinedChecks(sample1.checks, sample2.checks)).toEqual({ | ||
common: CHECKS_LIST_NAMES, | ||
discrepancies: [], | ||
}); | ||
}); | ||
|
||
it("Should handle discrepancies and provide a valid result", () => { | ||
const filteredList = sample1.checks.filter( | ||
(item) => item.name !== "Binary-Artifacts", | ||
); | ||
expect(getRefinedChecks(filteredList, sample2.checks)).toEqual({ | ||
common: filteredList.map((item) => item.name), | ||
discrepancies: ["Binary-Artifacts"], | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.