Skip to content

Commit

Permalink
chore(misc): update dependancies / clean (#3769)
Browse files Browse the repository at this point in the history
* chore(misc): update dependancies /  clean lint
  • Loading branch information
achorein authored Apr 15, 2024
1 parent 7d5b2e3 commit 60d7564
Show file tree
Hide file tree
Showing 27 changed files with 673 additions and 382 deletions.
9 changes: 9 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,15 @@
"cwd": "./"
}
},
{
"label": "Clean dependencies",
"command": "npm run clean",
"type": "shell",
"problemMatcher": [],
"options": {
"cwd": "./"
}
},
{
"label": "Start Admin Applications",
"dependsOn": ["Start Lib", "Start DS", "Start Api", "Start Admin"],
Expand Down
13 changes: 12 additions & 1 deletion admin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"copy:dsfr": "copy-dsfr-to-public && only-include-used-icons",
"lint": "eslint src --ext .js,.jsx",
"lint:fix": "eslint src --ext .js --fix",
"lint:report": "eslint src --ext .js --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif"
"lint:report": "eslint src --ext .js --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif",
"clean": "rm -fr node_modules .turbo build .swc"
},
"dependencies": {
"@codegouvfr/react-dsfr": "^1.9.2",
Expand Down Expand Up @@ -85,5 +86,15 @@
"node": "^18.16.0",
"npm": "^9.5.1",
"yarn": "🍎 This project uses NPM, please do not use YARN. 🍎"
},
"optionalDependencies": {
"@swc/core": "^1.3.95",
"@swc/core-darwin-arm64": "^1.4.14",
"@swc/core-darwin-x64": "^1.4.14",
"@swc/core-linux-arm-gnueabihf": "^1.4.14",
"@swc/core-linux-arm64-gnu": "^1.4.14",
"@swc/core-linux-arm64-musl": "^1.4.14",
"@swc/core-linux-x64-gnu": "^1.4.14",
"@swc/core-linux-x64-musl": "^1.4.14"
}
}
3 changes: 2 additions & 1 deletion analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"dev": "nodemon --watch src src/index.js",
"lint": "eslint . --ext .js,.jsx",
"lint:fix": "eslint --ext .js --fix src",
"lint:report": "eslint src --ext .js --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif"
"lint:report": "eslint src --ext .js --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif",
"clean": "rm -fr node_modules .turbo"
},
"engines": {
"node": "^18.16.0",
Expand Down
3 changes: 2 additions & 1 deletion antivirus/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"start": "node index.js",
"lint": "eslint . --ext .js,.jsx",
"lint:fix": "eslint . --ext .js --fix",
"lint:report": "eslint . --ext .js --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif"
"lint:report": "eslint . --ext .js --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif",
"clean": "rm -fr .turbo"
},
"author": "SNU",
"license": "MIT",
Expand Down
1 change: 1 addition & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"lint:fix": "eslint src --ext .js --fix",
"lint:report": "eslint src --ext .js --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif",
"doc": "node ./src/utils/generate-models-documentation.js",
"clean": "rm -fr node_modules .turbo",
"build": "tsc -b ./tsconfig.json"
},
"author": "SELEGO",
Expand Down
7 changes: 0 additions & 7 deletions api/src/SNUpport.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,4 @@ const api = async (path, options = {}) => {
return await res.text();
};

function getEnvironment() {
if (process.env.STAGING === "true") return "staging";
else if (process.env.PRODUCTION === "true") return "production";
else if (process.env.TESTING === "true" || process.env.NODE_ENV === "test") return "testing";
return "development";
}

module.exports = { api, getCustomerIdByEmail };
2 changes: 0 additions & 2 deletions api/src/__tests__/__mocks__/redis.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
const redis = jest.createMockFromModule("redis");

const data = {};

const mockRedis = {
Expand Down
170 changes: 85 additions & 85 deletions api/src/__tests__/application.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,95 +25,95 @@ afterAll(dbClose);

describe("Application", () => {
describe("POST /application", () => {
// it("should return 404 when young is not found", async () => {
// const application = getNewApplicationFixture();
// const res = await request(getAppHelper())
// .post("/application")
// .send({ ...application, youngId: notExistingYoungId, missionId: notExisitingMissionId });
// expect(res.status).toBe(404);
// });
// it("should return 404 when mission is not found", async () => {
// const young = await createYoungHelper(getNewYoungFixture());
// const application = getNewApplicationFixture();
// const res = await request(getAppHelper())
// .post("/application")
// .send({ ...application, youngId: young._id, missionId: notExisitingMissionId });
// expect(res.status).toBe(404);
// });
// it("should only allow young to apply for themselves", async () => {
// const lastYear = new Date().getFullYear() - 1;
// const cohort = await createCohortHelper(getNewCohortFixture({ name: "Test", dateEnd: `${lastYear}-07-15T00:00:00.000Z` }));
// const young = await createYoungHelper(getNewYoungFixture({ cohort: cohort.name, statusPhase1: YOUNG_STATUS_PHASE1.DONE }));
// const secondYoung = await createYoungHelper(getNewYoungFixture({ cohort: cohort.name, statusPhase1: YOUNG_STATUS_PHASE1.DONE }));
// const passport = require("passport");
// const previous = passport.user;
// passport.user = young;
// const mission = await createMissionHelper(getNewMissionFixture());
// const application = getNewApplicationFixture();
it.skip("should return 404 when young is not found", async () => {

Check warning on line 28 in api/src/__tests__/application.test.js

View workflow job for this annotation

GitHub Actions / run_tests_api / test

Disabled test
const application = getNewApplicationFixture();
const res = await request(getAppHelper())
.post("/application")
.send({ ...application, youngId: notExistingYoungId, missionId: notExisitingMissionId });
expect(res.status).toBe(404);
});
it("should return 404 when mission is not found", async () => {
const young = await createYoungHelper(getNewYoungFixture());
const application = getNewApplicationFixture();
const res = await request(getAppHelper())
.post("/application")
.send({ ...application, youngId: young._id, missionId: notExisitingMissionId });
expect(res.status).toBe(404);
});
it.skip("should only allow young to apply for themselves", async () => {

Check warning on line 43 in api/src/__tests__/application.test.js

View workflow job for this annotation

GitHub Actions / run_tests_api / test

Disabled test
const lastYear = new Date().getFullYear() - 1;
const cohort = await createCohortHelper(getNewCohortFixture({ name: "Test", dateEnd: `${lastYear}-07-15T00:00:00.000Z` }));
const young = await createYoungHelper(getNewYoungFixture({ cohort: cohort.name, statusPhase1: YOUNG_STATUS_PHASE1.DONE }));
const secondYoung = await createYoungHelper(getNewYoungFixture({ cohort: cohort.name, statusPhase1: YOUNG_STATUS_PHASE1.DONE }));
const passport = require("passport");
const previous = passport.user;
passport.user = young;
const mission = await createMissionHelper(getNewMissionFixture());
const application = getNewApplicationFixture();

// // Successful application
// let res = await request(getAppHelper())
// .post("/application")
// .send({ ...application, youngId: young._id, missionId: mission._id });
// expect(res.status).toBe(200);
// expect(res.body.data.youngId).toBe(young._id.toString());
// Successful application
let res = await request(getAppHelper())
.post("/application")
.send({ ...application, youngId: young._id, missionId: mission._id });
expect(res.status).toBe(200);
expect(res.body.data.youngId).toBe(young._id.toString());

// // Failed application
// res = await request(getAppHelper())
// .post("/application")
// .send({ ...application, youngId: secondYoung._id, missionId: mission._id });
// expect(res.status).toBe(400);
// Failed application
res = await request(getAppHelper())
.post("/application")
.send({ ...application, youngId: secondYoung._id, missionId: mission._id });
expect(res.status).toBe(400);

// passport.user = previous;
// });
// it("should create an application when priority is given", async () => {
// const young = await createYoungHelper(getNewYoungFixture({ cohort: "Test", statusPhase1: YOUNG_STATUS_PHASE1.DONE }));
// const mission = await createMissionHelper(getNewMissionFixture());
// const application = getNewApplicationFixture();
// const res = await request(getAppHelper())
// .post("/application")
// .send({ ...application, youngId: young._id, missionId: mission._id });
// expect(res.status).toBe(200);
// expect(res.body.data.youngId).toBe(young._id.toString());
// });
// it("should create an application when no priority is given", async () => {
// const young = await createYoungHelper(getNewYoungFixture({ cohort: "Test", statusPhase1: YOUNG_STATUS_PHASE1.DONE }));
// const mission1 = await createMissionHelper(getNewMissionFixture());
// await createApplication({ ...getNewApplicationFixture(), youngId: young._id, missionId: mission1._id });
// const mission2 = await createMissionHelper(getNewMissionFixture());
// const { priority, ...application } = getNewApplicationFixture();
// const res = await request(getAppHelper())
// .post("/application")
// .send({ ...application, youngId: young._id, missionId: mission2._id });
// expect(res.status).toBe(200);
// expect(res.body.data.priority).toBe("2");
// expect(res.body.data.youngId).toBe(young._id.toString());
// });
// it("should update young status", async () => {
// const young = await createYoungHelper(getNewYoungFixture({ cohort: "Test", statusPhase1: YOUNG_STATUS_PHASE1.DONE }));
// const mission = await createMissionHelper(getNewMissionFixture());
// const application = getNewApplicationFixture();
// const res = await request(getAppHelper())
// .post("/application")
// .send({ ...application, youngId: young._id, missionId: mission._id, status: "WAITING_VALIDATION" });
// expect(res.status).toBe(200);
passport.user = previous;
});
it.skip("should create an application when priority is given", async () => {

Check warning on line 69 in api/src/__tests__/application.test.js

View workflow job for this annotation

GitHub Actions / run_tests_api / test

Disabled test
const young = await createYoungHelper(getNewYoungFixture({ cohort: "Test", statusPhase1: YOUNG_STATUS_PHASE1.DONE }));
const mission = await createMissionHelper(getNewMissionFixture());
const application = getNewApplicationFixture();
const res = await request(getAppHelper())
.post("/application")
.send({ ...application, youngId: young._id, missionId: mission._id });
expect(res.status).toBe(200);
expect(res.body.data.youngId).toBe(young._id.toString());
});
it.skip("should create an application when no priority is given", async () => {

Check warning on line 79 in api/src/__tests__/application.test.js

View workflow job for this annotation

GitHub Actions / run_tests_api / test

Disabled test
const young = await createYoungHelper(getNewYoungFixture({ cohort: "Test", statusPhase1: YOUNG_STATUS_PHASE1.DONE }));
const mission1 = await createMissionHelper(getNewMissionFixture());
await createApplication({ ...getNewApplicationFixture(), youngId: young._id, missionId: mission1._id });
const mission2 = await createMissionHelper(getNewMissionFixture());
const { ...application } = getNewApplicationFixture();
const res = await request(getAppHelper())
.post("/application")
.send({ ...application, youngId: young._id, missionId: mission2._id });
expect(res.status).toBe(200);
expect(res.body.data.priority).toBe("2");
expect(res.body.data.youngId).toBe(young._id.toString());
});
it.skip("should update young status", async () => {

Check warning on line 92 in api/src/__tests__/application.test.js

View workflow job for this annotation

GitHub Actions / run_tests_api / test

Disabled test
const young = await createYoungHelper(getNewYoungFixture({ cohort: "Test", statusPhase1: YOUNG_STATUS_PHASE1.DONE }));
const mission = await createMissionHelper(getNewMissionFixture());
const application = getNewApplicationFixture();
const res = await request(getAppHelper())
.post("/application")
.send({ ...application, youngId: young._id, missionId: mission._id, status: "WAITING_VALIDATION" });
expect(res.status).toBe(200);

// const updatedYoung = await getYoungByIdHelper(young._id);
// expect(updatedYoung.statusPhase2).toBe("IN_PROGRESS");
// expect([...updatedYoung.phase2ApplicationStatus]).toStrictEqual(["WAITING_VALIDATION"]);
// });
// it("should update mission places left status", async () => {
// const young = await createYoungHelper(getNewYoungFixture({ cohort: "Test", statusPhase1: YOUNG_STATUS_PHASE1.DONE }));
// const mission = await createMissionHelper({ ...getNewMissionFixture(), placesLeft: 100, placesTotal: 100 });
// const application = getNewApplicationFixture();
// const res = await request(getAppHelper())
// .post("/application")
// .send({ ...application, youngId: young._id, missionId: mission._id, status: "DONE" });
// expect(res.status).toBe(200);
const updatedYoung = await getYoungByIdHelper(young._id);
expect(updatedYoung.statusPhase2).toBe("IN_PROGRESS");
expect([...updatedYoung.phase2ApplicationStatus]).toStrictEqual(["WAITING_VALIDATION"]);
});
it.skip("should update mission places left status", async () => {

Check warning on line 105 in api/src/__tests__/application.test.js

View workflow job for this annotation

GitHub Actions / run_tests_api / test

Disabled test
const young = await createYoungHelper(getNewYoungFixture({ cohort: "Test", statusPhase1: YOUNG_STATUS_PHASE1.DONE }));
const mission = await createMissionHelper({ ...getNewMissionFixture(), placesLeft: 100, placesTotal: 100 });
const application = getNewApplicationFixture();
const res = await request(getAppHelper())
.post("/application")
.send({ ...application, youngId: young._id, missionId: mission._id, status: "DONE" });
expect(res.status).toBe(200);

// const updatedMission = await getMissionByIdHelper(mission._id);
// expect(updatedMission.placesLeft).toBe(99);
// });
const updatedMission = await getMissionByIdHelper(mission._id);
expect(updatedMission.placesLeft).toBe(99);
});
it("should return 403 when young is under 15 years old", async () => {
const year = new Date().getFullYear();
const cohort = await createCohortHelper(getNewCohortFixture({ name: "Test", endDate: `${year - 1}-12-31T00:00:00.000Z` }));
Expand Down Expand Up @@ -204,7 +204,7 @@ describe("Application", () => {
missionId: mission._id,
missionDuration: "1",
});
const res = await request(getAppHelper()).put("/application").send({ priority: "1", status, _id: application._id.toString() });
await request(getAppHelper()).put("/application").send({ priority: "1", status, _id: application._id.toString() });
}
const updatedYoung = await getYoungByIdHelper(young._id);
expect(updatedYoung.phase2NumberHoursEstimated).toBe("5");
Expand Down
9 changes: 2 additions & 7 deletions api/src/__tests__/cohesion-center.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
const request = require("supertest");
const getNewBusFixture = require("./fixtures/bus");
const { getNewCohesionCenterFixture, getNewCohesionCenterFixtureV2 } = require("./fixtures/cohesionCenter");
const { getNewSessionPhase1Fixture } = require("./fixtures/sessionPhase1");
const { createSessionPhase1, getSessionPhase1ById } = require("./helpers/sessionPhase1");

const getNewMeetingPointFixture = require("./fixtures/meetingPoint");
const getNewReferentFixture = require("./fixtures/referent");
const getNewYoungFixture = require("./fixtures/young");
const getAppHelper = require("./helpers/app");
const { createBusHelper, getBusByIdHelper } = require("./helpers/bus");
const { notExistingCohesionCenterId, createCohesionCenter, getCohesionCenterById, createCohesionCenterWithSession } = require("./helpers/cohesionCenter");
const { notExistingCohesionCenterId, createCohesionCenter, createCohesionCenterWithSession } = require("./helpers/cohesionCenter");
const { dbConnect, dbClose } = require("./helpers/db");
const { createMeetingPointHelper, getMeetingPointByIdHelper } = require("./helpers/meetingPoint");
const { createYoungHelper, getYoungByIdHelper } = require("./helpers/young");
const { createYoungHelper } = require("./helpers/young");
const { ROLES } = require("snu-lib");

jest.mock("../sendinblue", () => ({
Expand Down
2 changes: 0 additions & 2 deletions api/src/__tests__/department-service.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const request = require("supertest");
const getNewReferentFixture = require("./fixtures/referent");
const getNewDepartmentServiceFixture = require("./fixtures/departmentService");
const { deleteReferentByIdHelper, createReferentHelper } = require("./helpers/referent");
const {
getDepartmentServicesHelper,
deleteDepartmentServiceByIdHelper,
Expand Down
8 changes: 2 additions & 6 deletions api/src/__tests__/ligne-de-bus.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ describe("Meeting point", () => {

it("should return 500 when there's an error", async () => {
const passport = require("passport");
const previous = passport.user;
passport.user = null;
jest.spyOn(LigneBusModel, "find").mockImplementation(() => {
throw new Error("test error");
Expand Down Expand Up @@ -372,7 +371,7 @@ describe("Meeting point", () => {
},
});

const schemaRepartition = await SchemaRepartitionModel.create({
await SchemaRepartitionModel.create({
centerId: center._id,
name: "Schema 1",
fromRegion: "Île-de-France",
Expand All @@ -381,7 +380,7 @@ describe("Meeting point", () => {
gatheringPlaces: [pdr1._id, pdr2._id],
});

const young = await YoungModel.create({
await YoungModel.create({
firstName: "John",
lastName: "Doe",
email: "[email protected]",
Expand Down Expand Up @@ -416,7 +415,6 @@ describe("Meeting point", () => {
it("should return 403 when user is not authorized", async () => {
const young = await createYoungHelper({ ...getNewYoungFixture() });
const passport = require("passport");
const previous = passport.user;
passport.user = young;
const center = await CohesionCenterModel.create({
name: "Center 1",
Expand Down Expand Up @@ -455,7 +453,6 @@ describe("Meeting point", () => {

it("should return 500 when there's an error", async () => {
const passport = require("passport");
const previous = passport.user;
passport.user = null;
jest.spyOn(LigneBusModel, "findById").mockImplementation(() => {
throw new Error("test error");
Expand Down Expand Up @@ -522,7 +519,6 @@ describe("Meeting point", () => {

it("should return 500 when there's an error", async () => {
const passport = require("passport");
const previous = passport.user;
passport.user = null;
jest.spyOn(LigneBusModel, "findById").mockImplementation(() => {
throw new Error("test error");
Expand Down
6 changes: 1 addition & 5 deletions api/src/__tests__/ligne-to-point.test.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
const request = require("supertest");
const getAppHelper = require("./helpers/app");
const { dbConnect, dbClose } = require("./helpers/db");
const { createPointDeRassemblementHelper, createPointDeRassemblementWithBus, notExistingMeetingPointId } = require("./helpers/PlanDeTransport/pointDeRassemblement");
const { createPointDeRassemblementWithBus, notExistingMeetingPointId } = require("./helpers/PlanDeTransport/pointDeRassemblement");
const { createSessionPhase1 } = require("./helpers/sessionPhase1");
const { createCohesionCenter } = require("./helpers/cohesionCenter");
const getNewPointDeRassemblementFixture = require("./fixtures/PlanDeTransport/pointDeRassemblement");
const { createMeetingPointHelper } = require("./helpers/meetingPoint");
const { getNewCohesionCenterFixture } = require("./fixtures/cohesionCenter");
const { getNewSessionPhase1Fixture } = require("./fixtures/sessionPhase1");
const PointDeRassemblementModel = require("../models/PlanDeTransport/pointDeRassemblement");
Expand All @@ -19,15 +18,12 @@ afterAll(dbClose);
describe("Meeting Point", () => {
let res;
let ligneToPoint;
let meetingPoint;

beforeEach(async () => {
// const pdr = await createPointDeRassemblementHelper();
const cohesionCenter = await createCohesionCenter(getNewCohesionCenterFixture());
const sessionPhase1 = await createSessionPhase1({ ...getNewSessionPhase1Fixture(), cohesionCenterId: cohesionCenter._id });
const result = await createPointDeRassemblementWithBus(getNewPointDeRassemblementFixture(), cohesionCenter._id, sessionPhase1._id);
ligneToPoint = result.ligneToPoint;
meetingPoint = result.pdr;
});

afterEach(async () => {
Expand Down
Loading

0 comments on commit 60d7564

Please sign in to comment.