diff --git a/CHANGELOG.md b/CHANGELOG.md index bcdd90a..71d2be5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## 1.2.1 + +- Added more status codes ([zecarrera](https://github.com/zecarrera) in [#65](https://github.com/boyney123/mockit/pull/65)) + +- Clean up markdown #64 ([lirantal](https://github.com/lirantal) in [#64](https://github.com/boyney123/mockit/pull/64)) + ## 1.2.0 - Prevent secrets from leaking to source control ([lirantal](https://github.com/lirantal) in [#59](https://github.com/boyney123/mockit/pull/59)) diff --git a/SECURITY.md b/SECURITY.md index 1af53bd..8191b66 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -40,4 +40,3 @@ sending the report over a secure medium. Your efforts to responsibly disclose your findings are sincerely appreciated and will be taken into account to acknowledge your contributions. -``` diff --git a/client/src/components/RouteModal/index.js b/client/src/components/RouteModal/index.js index 9ddc62e..b77a19e 100644 --- a/client/src/components/RouteModal/index.js +++ b/client/src/components/RouteModal/index.js @@ -18,7 +18,9 @@ const STATUS_CODES = [ StatusCodes.NOT_FOUND, StatusCodes.CONFLICT, StatusCodes.UNPROCESSABLE_ENTITY, - StatusCodes.INTERNAL_SERVER_ERROR + StatusCodes.INTERNAL_SERVER_ERROR, + StatusCodes.SERVICE_UNAVAILABLE, + StatusCodes.GATEWAY_TIMEOUT ]; /** @@ -83,6 +85,10 @@ const Modal = function(props) { } }; + const statusCodeStartingWith = startingNumber => { + return STATUS_CODES.filter(routeStatusCode => routeStatusCode.startsWith(startingNumber)); + }; + return ( <>
@@ -123,13 +129,29 @@ const Modal = function(props) {
- +
@@ -197,3 +219,4 @@ const Modal = function(props) { }; export default Modal; + diff --git a/client/src/components/RouteModal/spec.js b/client/src/components/RouteModal/spec.js index b5377c5..f5f7b46 100644 --- a/client/src/components/RouteModal/spec.js +++ b/client/src/components/RouteModal/spec.js @@ -60,25 +60,37 @@ describe("Route Modal", () => { expect(getByValue("PATCH", dropdownOptions)).toBeVisible(); }); + it("with a dropdown list with three groups", () => { + const route = buildRoute(); + const { getByLabelText } = render(); + const dropdown = getByLabelText("route-statuscode"); + const dropdownOptionGroups = dropdown.childNodes; + + expect(dropdownOptionGroups.length).toEqual(3); + expect(getByLabelText("2xx", dropdownOptionGroups)).toBeVisible(); + expect(getByLabelText("4xx", dropdownOptionGroups)).toBeVisible(); + expect(getByLabelText("5xx", dropdownOptionGroups)).toBeVisible(); + }); + it("with a dropdown list of all available status code", () => { const route = buildRoute(); const { getByLabelText, getByValue } = render(); const dropdown = getByLabelText("route-statuscode"); - const dropdownOptions = dropdown.children; - - expect(dropdownOptions.length).toEqual(11); - - expect(getByValue("200", dropdownOptions)).toBeVisible(); - expect(getByValue("201", dropdownOptions)).toBeVisible(); - expect(getByValue("202", dropdownOptions)).toBeVisible(); - expect(getByValue("204", dropdownOptions)).toBeVisible(); - expect(getByValue("400", dropdownOptions)).toBeVisible(); - expect(getByValue("401", dropdownOptions)).toBeVisible(); - expect(getByValue("403", dropdownOptions)).toBeVisible(); - expect(getByValue("404", dropdownOptions)).toBeVisible(); - expect(getByValue("409", dropdownOptions)).toBeVisible(); - expect(getByValue("422", dropdownOptions)).toBeVisible(); - expect(getByValue("500", dropdownOptions)).toBeVisible(); + const dropdownOptionGroups = dropdown.childNodes; + + expect(getByValue("200", dropdownOptionGroups[0].children)).toBeVisible(); + expect(getByValue("201", dropdownOptionGroups[0].children)).toBeVisible(); + expect(getByValue("202", dropdownOptionGroups[0].children)).toBeVisible(); + expect(getByValue("204", dropdownOptionGroups[0].children)).toBeVisible(); + expect(getByValue("400", dropdownOptionGroups[1].children)).toBeVisible(); + expect(getByValue("401", dropdownOptionGroups[1].children)).toBeVisible(); + expect(getByValue("403", dropdownOptionGroups[1].children)).toBeVisible(); + expect(getByValue("404", dropdownOptionGroups[1].children)).toBeVisible(); + expect(getByValue("409", dropdownOptionGroups[1].children)).toBeVisible(); + expect(getByValue("422", dropdownOptionGroups[1].children)).toBeVisible(); + expect(getByValue("500", dropdownOptionGroups[2].children)).toBeVisible(); + expect(getByValue("503", dropdownOptionGroups[2].children)).toBeVisible(); + expect(getByValue("504", dropdownOptionGroups[2].children)).toBeVisible(); }); it("with a dropdown list of all available delay values", () => { diff --git a/client/src/utils/consts/index.js b/client/src/utils/consts/index.js index a22d4e3..5b282eb 100644 --- a/client/src/utils/consts/index.js +++ b/client/src/utils/consts/index.js @@ -17,7 +17,9 @@ export const StatusCodes = { NOT_FOUND: "404", CONFLICT: "409", UNPROCESSABLE_ENTITY: "422", - INTERNAL_SERVER_ERROR: "500" + INTERNAL_SERVER_ERROR: "500", + SERVICE_UNAVAILABLE: "503", + GATEWAY_TIMEOUT: "504" }; export const MOCKIT_SERVER_URL = process.env.REACT_APP_MOCKIT_SERVER_URL || "localhost:3000";