Skip to content

Commit

Permalink
Merge pull request #446 from seiu503/package-update-202409
Browse files Browse the repository at this point in the history
updated msw, all client tests passing
  • Loading branch information
rifkegribenes authored Oct 15, 2024
2 parents f2c21d4 + b7e2c63 commit bdf5f2e
Show file tree
Hide file tree
Showing 27 changed files with 400 additions and 640 deletions.
5 changes: 4 additions & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"jest-localstorage-mock": "^2.4.0",
"jest-mock-action-creators": "^1.2.1",
"jest-transform-stub": "^2.0.0",
"msw": "^1.2.1",
"msw": "^2.4.11",
"npm-run-all": "^4.1.5",
"postcss-cli": "^8.0.0",
"prop-types": "^15.8.1",
Expand Down Expand Up @@ -117,6 +117,9 @@
"<rootDir>"
],
"testEnvironment": "jsdom",
"testEnvironmentOptions": {
"customExportConditions": [""]
},
"collectCoverageFrom": [
"src/**/*.{js,jsx}",
"!src/index.jsx",
Expand Down
1 change: 1 addition & 0 deletions client/src/__tests__/App.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import { I18nextProvider } from "react-i18next";
import i18n from "../translations/i18n";
import { defaultWelcomeInfo } from "../utils/index";
import handlers from "../mocks/handlers";
import { http, HttpResponse } from 'msw'
import { setupServer } from "msw/node";

import { createTheme, adaptV4Theme } from "@mui/material/styles";
Expand Down
1 change: 0 additions & 1 deletion client/src/__tests__/App/App_createSFContact.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { employersPayload, storeFactory } from "../../utils/testUtils";
import { rest } from "msw";
import { setupServer } from "msw/node";
import { AppUnconnected, AppConnected } from "../../App";
import * as App from "../../App";
Expand Down
1 change: 0 additions & 1 deletion client/src/__tests__/App/App_createSubmission.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { employersPayload, storeFactory } from "../../utils/testUtils";
import { rest } from "msw";
import { setupServer } from "msw/node";
import { AppUnconnected } from "../../App";
import * as formElements from "../../components/SubmissionFormElements";
Expand Down
1 change: 0 additions & 1 deletion client/src/__tests__/App/App_lookupSFContact.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { employersPayload, storeFactory } from "../../utils/testUtils";
import { rest } from "msw";
import { setupServer } from "msw/node";
import * as formElements from "../../components/SubmissionFormElements";
import { createTheme, adaptV4Theme } from "@mui/material/styles";
Expand Down
1 change: 0 additions & 1 deletion client/src/__tests__/App/App_miscMethods.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { employersPayload, storeFactory } from "../../utils/testUtils";
import { rest } from "msw";
import { setupServer } from "msw/node";
import * as formElements from "../../components/SubmissionFormElements";
import { createTheme, adaptV4Theme } from "@mui/material/styles";
Expand Down
1 change: 0 additions & 1 deletion client/src/__tests__/App/App_miscMethods2.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { employersPayload, storeFactory } from "../../utils/testUtils";
import { rest } from "msw";
import { setupServer } from "msw/node";
import * as formElements from "../../components/SubmissionFormElements";
import { createTheme, adaptV4Theme } from "@mui/material/styles";
Expand Down
1 change: 0 additions & 1 deletion client/src/__tests__/App/App_prepForContact.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { employersPayload, storeFactory } from "../../utils/testUtils";
import { rest } from "msw";
import { setupServer } from "msw/node";
import * as formElements from "../../components/SubmissionFormElements";
import { createTheme, adaptV4Theme } from "@mui/material/styles";
Expand Down
1 change: 0 additions & 1 deletion client/src/__tests__/App/App_prepForSubmission.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import {
} from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { employersPayload, storeFactory } from "../../utils/testUtils";
import { rest } from "msw";
import { setupServer } from "msw/node";
import * as formElements from "../../components/SubmissionFormElements";
import { createTheme, adaptV4Theme } from "@mui/material/styles";
Expand Down
3 changes: 1 addition & 2 deletions client/src/__tests__/App/App_updateSFContact.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ import {
} from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { employersPayload, storeFactory } from "../../utils/testUtils";
import { rest } from "msw";
import { setupServer } from "msw/node";
import { setupServer } from 'msw/node';
import * as formElements from "../../components/SubmissionFormElements";
import { createTheme, adaptV4Theme } from "@mui/material/styles";
import { ThemeProvider } from "@mui/material/styles";
Expand Down
148 changes: 65 additions & 83 deletions client/src/__tests__/actions/apiSFActions.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { setupServer } from "msw/node";
import handlers from "../../mocks/handlers";
import { rest } from "msw";
import { http, HttpResponse } from "msw";
import { apiMiddleware } from "redux-api-middleware";
import configureMockStore from "redux-mock-store";
import * as actions from "../../store/actions/apiSFActions";
Expand Down Expand Up @@ -47,11 +47,10 @@ describe("apiSFActions", () => {

it("GET_SF_CONTACT: Dispatches failure action after failed GET", async () => {
server.use(
rest.get("http://localhost/undefined/api/sf/12345678", (req, res, ctx) => {
return res(
ctx.json({ message: "There was an error fetching the contact" }),
ctx.status(404)
);
http.get("http://localhost/undefined/api/sf/12345678", () => {
return new HttpResponse(JSON.stringify({"message": "There was an error fetching the contact" }), {
status: 404
})
})
);

Expand All @@ -67,11 +66,10 @@ describe("apiSFActions", () => {

it("GET_SF_CONTACT: Dispatches failure action after failed GET (generic error msg)", async () => {
server.use(
rest.get("http://localhost/undefined/api/sf/12345678", (req, res, ctx) => {
return res(
ctx.json({ message: "Sorry, something went wrong :(" }),
ctx.status(500)
);
http.get("http://localhost/undefined/api/sf/12345678", () => {
return new HttpResponse(JSON.stringify({"message": "Sorry, something went wrong :(" }), {
status: 500
})
})
);

Expand Down Expand Up @@ -108,11 +106,10 @@ describe("apiSFActions", () => {

it("GET_SF_CONTACT_DID: Dispatches failure action after failed GET", async () => {
server.use(
rest.get("http://localhost/undefined/api/sfdid/1/2", (req, res, ctx) => {
return res(
ctx.json({ message: "There was an error fetching the contact" }),
ctx.status(404)
);
http.get("http://localhost/undefined/api/sfdid/1/2", () => {
return new HttpResponse(JSON.stringify({"message": "There was an error fetching the contact" }), {
status: 404
});
})
);

Expand All @@ -130,11 +127,10 @@ describe("apiSFActions", () => {

it("GET_SF_CONTACT_DID: Dispatches failure action after failed GET (generic error msg)", async () => {
server.use(
rest.get("http://localhost/undefined/api/sfdid/1/2", (req, res, ctx) => {
return res(
ctx.json({ message: "Sorry, something went wrong :(" }),
ctx.status(500)
);
http.get("http://localhost/undefined/api/sfdid/1/2", () => {
return new HttpResponse(JSON.stringify({"message": "Sorry, something went wrong :(" }), {
status: 500
})
})
);

Expand Down Expand Up @@ -165,11 +161,10 @@ describe("apiSFActions", () => {

it("CREATE_SF_CONTACT: Dispatches failure action after failed POST", async () => {
server.use(
rest.post("http://localhost/undefined/api/sf", (req, res, ctx) => {
return res(
ctx.json({ message: "There was an error creating the contact" }),
ctx.status(404)
);
http.post("http://localhost/undefined/api/sf", () => {
return new HttpResponse(JSON.stringify({"message": "There was an error creating the contact" }), {
status: 404
});
})
);

Expand All @@ -187,11 +182,10 @@ describe("apiSFActions", () => {

it("CREATE_SF_CONTACT: Dispatches failure action after failed POST (generic error msg)", async () => {
server.use(
rest.post("http://localhost/undefined/api/sf", (req, res, ctx) => {
return res(
ctx.json({ message: "Sorry, something went wrong :(" }),
ctx.status(500)
);
http.post("http://localhost/undefined/api/sf", () => {
return new HttpResponse(JSON.stringify({"message": "Sorry, something went wrong :(" }), {
status: 500
});
})
);

Expand Down Expand Up @@ -222,11 +216,10 @@ describe("apiSFActions", () => {

it("UPDATE_SF_CONTACT: Dispatches failure action after failed PUT", async () => {
server.use(
rest.put("http://localhost/undefined/api/sf/12345678", (req, res, ctx) => {
return res(
ctx.json({ message: "There was an error updating the contact" }),
ctx.status(404)
);
http.put("http://localhost/undefined/api/sf/12345678", () => {
return new HttpResponse(JSON.stringify({"message": "There was an error updating the contact" }), {
status: 404
});
})
);

Expand All @@ -244,11 +237,10 @@ describe("apiSFActions", () => {

it("UPDATE_SF_CONTACT: Dispatches failure action after failed PUT (generic error msg)", async () => {
server.use(
rest.put("http://localhost/undefined/api/sf/12345678", (req, res, ctx) => {
return res(
ctx.json({ message: "Sorry, something went wrong :(" }),
ctx.status(500)
);
http.put("http://localhost/undefined/api/sf/12345678", () => {
return new HttpResponse(JSON.stringify({"message": "Sorry, something went wrong :(" }), {
status: 500
});
})
);

Expand Down Expand Up @@ -277,11 +269,10 @@ describe("apiSFActions", () => {

it("CREATE_SF_OMA: Dispatches failure action after failed POST", async () => {
server.use(
rest.post("http://localhost/undefined/api/sfOMA", (req, res, ctx) => {
return res(
ctx.json({ message: "There was an error creating the record" }),
ctx.status(404)
);
http.post("http://localhost/undefined/api/sfOMA", (req, res, ctx) => {
return new HttpResponse(JSON.stringify({"message": "There was an error creating the record" }), {
status: 404
});
})
);

Expand All @@ -297,11 +288,10 @@ describe("apiSFActions", () => {

it("CREATE_SF_OMA: Dispatches failure action after failed POST (generic error msg)", async () => {
server.use(
rest.post("http://localhost/undefined/api/sfOMA", (req, res, ctx) => {
return res(
ctx.json({ message: "Sorry, something went wrong :(" }),
ctx.status(500)
);
http.post("http://localhost/undefined/api/sfOMA", () => {
return new HttpResponse(JSON.stringify({"message": "Sorry, something went wrong :(" }), {
status: 500
});
})
);

Expand All @@ -328,11 +318,10 @@ describe("apiSFActions", () => {

it("GET_SF_EMPLOYERS: Dispatches failure action after failed GET", async () => {
server.use(
rest.get("http://localhost/undefined/api/sfaccts", (req, res, ctx) => {
return res(
ctx.json({ message: "There was an error fetching the employers" }),
ctx.status(404)
);
http.get("http://localhost/undefined/api/sfaccts", (req, res, ctx) => {
return new HttpResponse(JSON.stringify({"message": "There was an error fetching the employers" }), {
status: 404
});
})
);

Expand All @@ -348,11 +337,10 @@ describe("apiSFActions", () => {

it("GET_SF_EMPLOYERS: Dispatches failure action after failed GET (generic error msg)", async () => {
server.use(
rest.get("http://localhost/undefined/api/sfaccts", (req, res, ctx) => {
return res(
ctx.json({ message: "Sorry, something went wrong :(" }),
ctx.status(500)
);
http.get("http://localhost/undefined/api/sfaccts", () => {
return new HttpResponse(JSON.stringify({"message": "Sorry, something went wrong :(" }), {
status: 500
});
})
);

Expand Down Expand Up @@ -381,11 +369,10 @@ describe("apiSFActions", () => {

it("LOOKUP_SF_CONTACT: Dispatches failure action after failed PUT", async () => {
server.use(
rest.put("http://localhost/undefined/api/sflookup", (req, res, ctx) => {
return res(
ctx.json({ message: "There was an error fetching the contact" }),
ctx.status(404)
);
http.put("http://localhost/undefined/api/sflookup", (req, res, ctx) => {
return new HttpResponse(JSON.stringify({"message": "There was an error fetching the contact" }), {
status: 404
});
})
);

Expand All @@ -403,11 +390,10 @@ describe("apiSFActions", () => {

it("LOOKUP_SF_CONTACT: Dispatches failure action after failed PUT (generic error msg)", async () => {
server.use(
rest.put("http://localhost/undefined/api/sflookup", (req, res, ctx) => {
return res(
ctx.json({ message: "Sorry, something went wrong :(" }),
ctx.status(500)
);
http.put("http://localhost/undefined/api/sflookup", () => {
return new HttpResponse(JSON.stringify({"message": "Sorry, something went wrong :(" }), {
status: 500
});
})
);

Expand Down Expand Up @@ -436,13 +422,10 @@ describe("apiSFActions", () => {

it("CREATE_SF_CAPE: Dispatches failure action after failed POST", async () => {
server.use(
rest.post("http://localhost/undefined/api/sfCAPE", (req, res, ctx) => {
return res(
ctx.json({
message: "There was an error creating the CAPE record"
}),
ctx.status(404)
);
http.post("http://localhost/undefined/api/sfCAPE", () => {
return new HttpResponse(JSON.stringify({"message": "There was an error creating the CAPE record" }), {
status: 404
});
})
);

Expand All @@ -458,11 +441,10 @@ describe("apiSFActions", () => {

it("CREATE_SF_CAPE: Dispatches failure action after failed POST (generic error msg)", async () => {
server.use(
rest.post("http://localhost/undefined/api/sfCAPE", (req, res, ctx) => {
return res(
ctx.json({ message: "Sorry, something went wrong :(" }),
ctx.status(500)
);
http.post("http://localhost/undefined/api/sfCAPE", () => {
return new HttpResponse(JSON.stringify({"message": "Sorry, something went wrong :(" }), {
status: 500
});
})
);

Expand Down
Loading

0 comments on commit bdf5f2e

Please sign in to comment.