diff --git a/facade-app/src/Components/Header.tsx b/facade-app/src/Components/Header.tsx index 6665232..9c3ec16 100644 --- a/facade-app/src/Components/Header.tsx +++ b/facade-app/src/Components/Header.tsx @@ -65,15 +65,15 @@ export default class Header extends React.Component { About Us - - - DAST - + + + DAST + - - SAST - + + SAST + diff --git a/facade-app/src/test/App.test.tsx b/facade-app/src/test/App.test.tsx index a50cccf..5d1c5fa 100644 --- a/facade-app/src/test/App.test.tsx +++ b/facade-app/src/test/App.test.tsx @@ -1,92 +1,92 @@ -import React from "react"; -import { render, screen, fireEvent } from "@testing-library/react"; -import { getResource } from "../Utilities/Utils"; -import testFixture from "./fixtures"; - -import App from "../App"; - -jest.mock("../Utilities/Utils"); - -describe("App", () => { - const _renderAppFully = () => { - //mock getResource since it will not work during testing - (getResource as jest.Mock).mockImplementation( - (uri: string, callback: Function, isJson: boolean) => { - //testFixture structure does not match the web response. - //so, we restructure it - const response = { - VulnerableApp: - testFixture.applicationData[0].vulnerabilityDefinitions, - "VulnerableApp-jsp": - testFixture.applicationData[1].vulnerabilityDefinitions, - "VulnerableApp-php": - testFixture.applicationData[2].vulnerabilityDefinitions, - }; - - callback({ isSuccessful: true, data: response }); - } - ); - - return render(); - }; - - const _renderAppFail = () => { - (getResource as jest.Mock).mockImplementation( - (uri: string, callback: Function, isJson: boolean) => { - callback({ isSuccessful: false, error: "error" }); - } - ); - - return render(); - }; - - const _renderAppNull = () => { - (getResource as jest.Mock).mockImplementation( - (uri: string, callback: Function, isJson: boolean) => { - callback({ isSuccessful: true, data: null }); - } - ); - - return render(); - }; - - const _renderAppEmpty = () => { - (getResource as jest.Mock).mockImplementation( - (uri: string, callback: Function, isJson: boolean) => { - callback({ isSuccessful: true, data: {} }); - } - ); - - return render(); - }; - - it("renders correctly", async () => { - expect(_renderAppFully().container).toMatchSnapshot(); - }); - - it("renders content on nav item click", () => { - _renderAppFully(); - - fireEvent( - screen.getByTestId("VulnerableApp.CommandInjection.LEVEL_1"), - new MouseEvent("click", { bubbles: true, cancelable: true }) - ); - const content = screen.getByTestId("VULNERABILITY_CONTENT_DESCRIPTION"); - expect(content).toBeInTheDocument(); - }); - - it("does not render nav when data is null", async () => { - _renderAppNull(); - expect(screen.queryByTestId(/LEFT_NAV_CONTAINER/i)).toBeNull(); - }); - - it("does not render nav when getResource failed", async () => { - _renderAppFail(); - expect(screen.queryByTestId(/LEFT_NAV_CONTAINER/i)).toBeNull(); - }); - - it("does not render nav items when empty", async () => { - _renderAppEmpty(); - expect(screen.queryByTestId(/VulnerableApp.CommandInjection/i)).toBeNull(); - }); -}); +import React from "react"; +import { render, screen, fireEvent } from "@testing-library/react"; +import { getResource } from "../Utilities/Utils"; +import testFixture from "./fixtures"; + +import App from "../App"; + +jest.mock("../Utilities/Utils"); + +describe("App", () => { + const _renderAppFully = () => { + //mock getResource since it will not work during testing + (getResource as jest.Mock).mockImplementation( + (uri: string, callback: Function, isJson: boolean) => { + //testFixture structure does not match the web response. + //so, we restructure it + const response = { + VulnerableApp: + testFixture.applicationData[0].vulnerabilityDefinitions, + "VulnerableApp-jsp": + testFixture.applicationData[1].vulnerabilityDefinitions, + "VulnerableApp-php": + testFixture.applicationData[2].vulnerabilityDefinitions, + }; + + callback({ isSuccessful: true, data: response }); + } + ); + + return render(); + }; + + const _renderAppFail = () => { + (getResource as jest.Mock).mockImplementation( + (uri: string, callback: Function, isJson: boolean) => { + callback({ isSuccessful: false, error: "error" }); + } + ); + + return render(); + }; + + const _renderAppNull = () => { + (getResource as jest.Mock).mockImplementation( + (uri: string, callback: Function, isJson: boolean) => { + callback({ isSuccessful: true, data: null }); + } + ); + + return render(); + }; + + const _renderAppEmpty = () => { + (getResource as jest.Mock).mockImplementation( + (uri: string, callback: Function, isJson: boolean) => { + callback({ isSuccessful: true, data: {} }); + } + ); + + return render(); + }; + + it("renders correctly", async () => { + expect(_renderAppFully().container).toMatchSnapshot(); + }); + + it("renders content on nav item click", () => { + _renderAppFully(); + + fireEvent( + screen.getByTestId("VulnerableApp.CommandInjection.LEVEL_1"), + new MouseEvent("click", { bubbles: true, cancelable: true }) + ); + const content = screen.getByTestId("VULNERABILITY_CONTENT_DESCRIPTION"); + expect(content).toBeInTheDocument(); + }); + + it("does not render nav when data is null", async () => { + _renderAppNull(); + expect(screen.queryByTestId(/LEFT_NAV_CONTAINER/i)).toBeNull(); + }); + + it("does not render nav when getResource failed", async () => { + _renderAppFail(); + expect(screen.queryByTestId(/LEFT_NAV_CONTAINER/i)).toBeNull(); + }); + + it("does not render nav items when empty", async () => { + _renderAppEmpty(); + expect(screen.queryByTestId(/VulnerableApp.CommandInjection/i)).toBeNull(); + }); +}); diff --git a/facade-app/src/test/Utils.test.tsx b/facade-app/src/test/Utils.test.tsx index 2ff1b5e..a512f3e 100644 --- a/facade-app/src/test/Utils.test.tsx +++ b/facade-app/src/test/Utils.test.tsx @@ -26,27 +26,27 @@ describe("appendStaticResourcesToDocument()", () => { hints: [ { vulnerabilityTypes: [{ identifierType: "CWE", value: "WASC-1" }], - description: "vulnerability hint 1" + description: "vulnerability hint 1", }, ], resourceInformation: { htmlResource: { resourceType: ResourceType.HTML, isAbsolute: false, - uri: "/" + uri: "/", }, staticResources: [ { resourceType: ResourceType.JAVASCRIPT, isAbsolute: false, - uri: "/dummy_javascript_uri" + uri: "/dummy_javascript_uri", }, { resourceType: ResourceType.CSS, isAbsolute: false, - uri: "/dummy_css_uri" - } - ] + uri: "/dummy_css_uri", + }, + ], }, }; it("should modify the content of an element.", () => {