Skip to content

Commit

Permalink
feat(lbac-2110): image optimization (#1628)
Browse files Browse the repository at this point in the history
* feat: webp assets

* fix: bundler analyser

* feat: yarnlock

* fix: yarnlock

* feat: migrate to webp image

* feat: logo opco

* feat: update a-propos & logo partenaire

* refactor: single opco logo source

* fix: lint (?)

* fix: import

* fix: lint

* fix: test using type declaration

* fix: prettier

* fix: lint

* fix: img size
  • Loading branch information
kevbarns authored Dec 11, 2024
1 parent 087fae6 commit 2eff28a
Show file tree
Hide file tree
Showing 191 changed files with 3,127 additions and 4,975 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useMongo } from "@tests/utils/mongo.test.utils"
import { ObjectId } from "mongodb"
import nock from "nock"
import { describe, expect, it, vi } from "vitest"

import { getDbCollection } from "@/common/utils/mongodbUtils"
import { sentryCaptureException } from "@/common/utils/sentryUtils"
import { useMongo } from "@tests/utils/mongo.test.utils"

import { getRomeoPredictions, searchForFtJobs } from "./franceTravail.client"
import {
Expand Down
4 changes: 2 additions & 2 deletions server/src/http/controllers/application.controller.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { ObjectId } from "mongodb"
import { generateLbaCompanyFixture } from "shared/fixtures/recruteurLba.fixture"
import { beforeEach, describe, expect, it, vi } from "vitest"

import { s3Write } from "@/common/utils/awsUtils"
import { getDbCollection } from "@/common/utils/mongodbUtils"
import { isInfected } from "@/services/clamav.service"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"

vi.mock("@/common/utils/awsUtils", () => {
return {
Expand Down
20 changes: 10 additions & 10 deletions server/src/http/controllers/etablissement.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@ export default (server: Server) => {
replyTo: `${config.publicEmail}?subject=Email%20CFA%20Premium%20invite%20-%20MAJ%20contact%20formation`,
images: {
logoLba: `${config.publicUrl}/images/emails/logo_LBA.png?raw=true`,
logoFooter: `${config.publicUrl}/assets/logo-republique-francaise.png?raw=true`,
peopleLaptop: `${config.publicUrl}/assets/people-laptop.png?raw=true`,
logoFooter: `${config.publicUrl}/assets/logo-republique-francaise.webp?raw=true`,
peopleLaptop: `${config.publicUrl}/assets/people-laptop.webp?raw=true`,
},
etablissement: {
email,
Expand Down Expand Up @@ -208,8 +208,8 @@ export default (server: Server) => {
replyTo: `${config.publicEmail}?subject=Email%20CFA%20Premium%20invite%20-%20MAJ%20contact%20formation`,
images: {
logoLba: `${config.publicUrl}/images/emails/logo_LBA.png?raw=true`,
logoFooter: `${config.publicUrl}/assets/logo-republique-francaise.png?raw=true`,
peopleLaptop: `${config.publicUrl}/assets/people-laptop.png?raw=true`,
logoFooter: `${config.publicUrl}/assets/logo-republique-francaise.webp?raw=true`,
peopleLaptop: `${config.publicUrl}/assets/people-laptop.webp?raw=true`,
},
etablissement: {
email,
Expand Down Expand Up @@ -283,9 +283,9 @@ export default (server: Server) => {
data: {
isAffelnet: true,
images: {
informationIcon: `${config.publicUrl}/assets/icon-information-blue.png?raw=true`,
informationIcon: `${config.publicUrl}/assets/icon-information-blue.webp?raw=true`,
logoLba: `${config.publicUrl}/images/emails/logo_LBA.png?raw=true`,
logoFooter: `${config.publicUrl}/assets/logo-republique-francaise.png?raw=true`,
logoFooter: `${config.publicUrl}/assets/logo-republique-francaise.webp?raw=true`,
},
etablissement: {
raison_sociale: etablissement.raison_sociale,
Expand Down Expand Up @@ -349,9 +349,9 @@ export default (server: Server) => {
data: {
isParcoursup: true,
images: {
informationIcon: `${config.publicUrl}/assets/icon-information-blue.png?raw=true`,
informationIcon: `${config.publicUrl}/assets/icon-information-blue.webp?raw=true`,
logoLba: `${config.publicUrl}/images/emails/logo_LBA.png?raw=true`,
logoFooter: `${config.publicUrl}/assets/logo-republique-francaise.png?raw=true`,
logoFooter: `${config.publicUrl}/assets/logo-republique-francaise.webp?raw=true`,
},
etablissement: {
raison_sociale: etablissement.raison_sociale,
Expand Down Expand Up @@ -410,7 +410,7 @@ export default (server: Server) => {
data: {
images: {
logoLba: `${config.publicUrl}/images/emails/logo_LBA.png?raw=true`,
logoFooter: `${config.publicUrl}/assets/logo-republique-francaise.png?raw=true`,
logoFooter: `${config.publicUrl}/assets/logo-republique-francaise.webp?raw=true`,
},
etablissement: {
name: etablissement.raison_sociale,
Expand Down Expand Up @@ -462,7 +462,7 @@ export default (server: Server) => {
data: {
images: {
logoLba: `${config.publicUrl}/images/emails/logo_LBA.png?raw=true`,
logoFooter: `${config.publicUrl}/assets/logo-republique-francaise.png?raw=true`,
logoFooter: `${config.publicUrl}/assets/logo-republique-francaise.webp?raw=true`,
},
etablissement: {
name: etablissement.raison_sociale,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { saveUserWithAccount } from "@tests/utils/user.test.utils"
import omit from "lodash/omit"
import nock from "nock"
import { CFA, ENTREPRISE, OPCOS_LABEL } from "shared/constants"
Expand All @@ -11,6 +8,9 @@ import { beforeEach, describe, expect, it } from "vitest"

import { apiEntrepriseEtablissementFixture } from "@/common/apis/apiEntreprise/apiEntreprise.client.fixture"
import { getDbCollection } from "@/common/utils/mongodbUtils"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { saveUserWithAccount } from "@tests/utils/user.test.utils"

describe("POST /etablissement/creation", () => {
useMongo()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { saveDbEntity } from "@tests/utils/user.test.utils"
import { IFormationCatalogue, zFormationCatalogueSchema } from "shared/models"
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"

import { getDbCollection } from "@/common/utils/mongodbUtils"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { saveDbEntity } from "@tests/utils/user.test.utils"

useMongo()

Expand Down
3 changes: 2 additions & 1 deletion server/src/http/controllers/formationV1.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import assert from "assert"

import { describe, expect, it } from "vitest"

import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { describe, expect, it } from "vitest"

describe("formationV1", () => {
useMongo()
Expand Down
6 changes: 3 additions & 3 deletions server/src/http/controllers/formulaire.controller.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { givenAConnectedOpcoUser } from "@tests/fixture/connectedUser.fixture"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { OPCOS_LABEL } from "shared/constants"
import { generateJobFixture, generateRecruiterFixture } from "shared/fixtures/recruiter.fixture"
import { generateReferentielRome } from "shared/fixtures/rome.fixture"
import { AccessEntityType, JOB_STATUS } from "shared/models"
import { describe, expect, it } from "vitest"

import { getDbCollection } from "@/common/utils/mongodbUtils"
import { givenAConnectedOpcoUser } from "@tests/fixture/connectedUser.fixture"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"

import { generateEntrepriseFixture } from "../../../../shared/fixtures/entreprise.fixture"

Expand Down
3 changes: 2 additions & 1 deletion server/src/http/controllers/jobs.controller.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import assert from "assert"

import { describe, expect, it } from "vitest"

import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { describe, expect, it } from "vitest"

describe.skip("jobV1", () => {
useMongo()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import assert from "assert"

import { describe, expect, it } from "vitest"

import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { describe, expect, it } from "vitest"

describe("jobEtFormationV1", () => {
useMongo()
Expand Down
3 changes: 2 additions & 1 deletion server/src/http/controllers/metiers.controller.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import assert from "assert"

import { describe, expect, it } from "vitest"

import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { describe, expect, it } from "vitest"

describe.skip("romesFromCatalogue", () => {
useMongo()
Expand Down
3 changes: 2 additions & 1 deletion server/src/http/controllers/partners.controller.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import assert from "assert"

import { describe, expect, it } from "vitest"

import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { describe, expect, it } from "vitest"

describe("partnersRoutes", () => {
useMongo()
Expand Down
3 changes: 2 additions & 1 deletion server/src/http/controllers/rolesRoutes.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import assert from "assert"

import { describe, expect, it } from "vitest"

import { createAndLogUser } from "@tests/utils/login.test.utils"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { describe, expect, it } from "vitest"

describe("rolesRoutes", () => {
useMongo()
Expand Down
8 changes: 4 additions & 4 deletions server/src/http/controllers/user.controller.test.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { createAndLogUser, logUser } from "@tests/utils/login.test.utils"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { saveAdminUserTest, saveEntrepriseUserTest, saveOpcoUserTest } from "@tests/utils/user.test.utils"
import { OPCOS_LABEL } from "shared/constants"
import { beforeEach, describe, expect, it } from "vitest"

import { getDbCollection } from "@/common/utils/mongodbUtils"
import { createAndLogUser, logUser } from "@tests/utils/login.test.utils"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { saveAdminUserTest, saveEntrepriseUserTest, saveOpcoUserTest } from "@tests/utils/user.test.utils"

describe("Modification des utilisateurs par ADMIN et par utilisateur OPCO ", () => {
beforeEach(async () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { ObjectId } from "mongodb"
import { IApplicationApiPayload, JOB_STATUS } from "shared"
import { NIVEAUX_POUR_LBA, RECRUITER_STATUS } from "shared/constants"
Expand All @@ -13,6 +11,8 @@ import { describe, expect, it, vi } from "vitest"

import { s3Write } from "@/common/utils/awsUtils"
import { getDbCollection } from "@/common/utils/mongodbUtils"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"

import { getApiApprentissageTestingToken, getApiApprentissageTestingTokenFromInvalidPrivateKey } from "../../../../tests/utils/jwt.test.utils"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { getApiApprentissageTestingToken, getApiApprentissageTestingTokenFromInvalidPrivateKey } from "@tests/utils/jwt.test.utils"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { ObjectId } from "mongodb"
import nock from "nock"
import { generateFeaturePropertyFixture } from "shared/fixtures/geolocation.fixture"
Expand All @@ -17,6 +14,9 @@ import { apiEntrepriseEtablissementFixture } from "@/common/apis/apiEntreprise/a
import { searchForFtJobs } from "@/common/apis/franceTravail/franceTravail.client"
import { getDbCollection } from "@/common/utils/mongodbUtils"
import { certificationFixtures } from "@/services/external/api-alternance/certification.fixture"
import { getApiApprentissageTestingToken, getApiApprentissageTestingTokenFromInvalidPrivateKey } from "@tests/utils/jwt.test.utils"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"

vi.mock("@/common/apis/franceTravail/franceTravail.client")
vi.mock("@/common/apis/apiEntreprise/apiEntreprise.client")
Expand Down
5 changes: 3 additions & 2 deletions server/src/http/controllers/version.controller.test.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import assert from "assert"

import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import isSemver from "is-semver"
import { describe, expect, it } from "vitest"

import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"

describe("version", () => {
useMongo()
const httpClient = useServer()
Expand Down
4 changes: 2 additions & 2 deletions server/src/http/healthcheck.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"
import { describe, expect, it } from "vitest"

import { setupJobProcessor } from "@/jobs/jobs"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { useServer } from "@tests/utils/server.test.utils"

import config from "../config"

Expand Down
4 changes: 1 addition & 3 deletions server/src/jobs/franceTravail/generateFranceTravailAccess.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { ACCESS_PARAMS, IAccessParams } from "@/common/apis/franceTravail/franceTravail.client"

import { getFranceTravailTokenFromAPI } from "../../common/apis/franceTravail/franceTravail.client"
import { ACCESS_PARAMS, IAccessParams, getFranceTravailTokenFromAPI } from "@/common/apis/franceTravail/franceTravail.client"

export const generateFranceTravailAccess = async () => {
await Promise.all(Object.keys(ACCESS_PARAMS).map(async (access) => await getFranceTravailTokenFromAPI(access as IAccessParams)))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createComputedJobPartner, createJobPartner } from "@tests/utils/jobsPartners.test.utils"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { JOB_STATUS_ENGLISH } from "shared/models"
import { beforeEach, describe, expect, it } from "vitest"

import { getDbCollection } from "@/common/utils/mongodbUtils"
import { createComputedJobPartner, createJobPartner } from "@tests/utils/jobsPartners.test.utils"
import { useMongo } from "@tests/utils/mongo.test.utils"

import { cancelRemovedJobsPartners } from "./cancelRemovedJobsPartners"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { givenSomeComputedJobPartners } from "@tests/fixture/givenSomeComputedJobPartners"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { saveRecruiter } from "@tests/utils/user.test.utils"
import { ObjectId } from "bson"
import { RECRUITER_STATUS } from "shared/constants"
import { generateJobFixture, generateRecruiterFixture } from "shared/fixtures/recruiter.fixture"
Expand All @@ -11,6 +8,9 @@ import { beforeEach, describe, expect, it } from "vitest"

import { getPairs } from "@/common/utils/array"
import { getDbCollection } from "@/common/utils/mongodbUtils"
import { givenSomeComputedJobPartners } from "@tests/fixture/givenSomeComputedJobPartners"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { saveRecruiter } from "@tests/utils/user.test.utils"

import { checkSimilarity, detectDuplicateJobPartners, isCanonicalForDuplicate, OfferRef } from "./detectDuplicateJobPartners"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { givenSomeComputedJobPartners } from "@tests/fixture/givenSomeComputedJobPartners"
import { useMongo } from "@tests/utils/mongo.test.utils"
import { ObjectId } from "mongodb"
import nock from "nock"
import { OPCOS_LABEL } from "shared/constants"
Expand All @@ -9,6 +7,8 @@ import { entriesToTypedRecord } from "shared/utils"
import { beforeEach, describe, expect, it, vi } from "vitest"

import { getDbCollection } from "@/common/utils/mongodbUtils"
import { givenSomeComputedJobPartners } from "@tests/fixture/givenSomeComputedJobPartners"
import { useMongo } from "@tests/utils/mongo.test.utils"

import { fillComputedJobsPartners } from "./fillComputedJobsPartners"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { givenSomeComputedJobPartners } from "@tests/fixture/givenSomeComputedJobPartners"
import { useMongo } from "@tests/utils/mongo.test.utils"
import nock from "nock"
import { generateFeaturePropertyFixture } from "shared/fixtures/geolocation.fixture"
import { clichyFixture, parisFixture } from "shared/fixtures/referentiel/commune.fixture"
import { beforeEach, describe, expect, it } from "vitest"

import { getDbCollection } from "@/common/utils/mongodbUtils"
import { saveGeolocationInCache } from "@/services/cacheGeolocation.service"
import { givenSomeComputedJobPartners } from "@tests/fixture/givenSomeComputedJobPartners"
import { useMongo } from "@tests/utils/mongo.test.utils"

import { fillLocationInfosForPartners } from "./fillLocationInfosForPartners"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { givenSomeComputedJobPartners } from "@tests/fixture/givenSomeComputedJobPartners"
import { useMongo } from "@tests/utils/mongo.test.utils"
import pick from "lodash-es/pick"
import { ObjectId } from "mongodb"
import nock from "nock"
import { OPCOS_LABEL } from "shared/constants"
import { beforeEach, describe, expect, it, vi } from "vitest"

import { getDbCollection } from "@/common/utils/mongodbUtils"
import { givenSomeComputedJobPartners } from "@tests/fixture/givenSomeComputedJobPartners"
import { useMongo } from "@tests/utils/mongo.test.utils"

import { fillOpcoInfosForPartners } from "./fillOpcoInfosForPartners"

Expand Down
7 changes: 3 additions & 4 deletions server/src/jobs/offrePartenaire/fillRomeForPartners.test.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { givenSomeComputedJobPartners } from "@tests/fixture/givenSomeComputedJobPartners"
import { useMongo } from "@tests/utils/mongo.test.utils"
import nock from "nock"
import { IRomeoAPIResponse } from "shared/models/cacheRomeo.model"
import { beforeEach, describe, expect, it, vi } from "vitest"

import { nockFranceTravailRomeo } from "@/common/apis/franceTravail/franceTravail.client.fixture"
import { nockFranceTravailRomeo, nockFranceTravailTokenAccessRomeo } from "@/common/apis/franceTravail/franceTravail.client.fixture"
import { getDbCollection } from "@/common/utils/mongodbUtils"
import { givenSomeComputedJobPartners } from "@tests/fixture/givenSomeComputedJobPartners"
import { useMongo } from "@tests/utils/mongo.test.utils"

import { cacheRomeFixture, cacheRomeResultFixture } from "../../../../shared/fixtures/cacheRome.fixture"
import { nockFranceTravailTokenAccessRomeo } from "../../common/apis/franceTravail/franceTravail.client.fixture"

import { fillRomeForPartners } from "./fillRomeForPartners"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { givenSomeComputedJobPartners } from "@tests/fixture/givenSomeComputedJobPartners"
import { useMongo } from "@tests/utils/mongo.test.utils"
import pick from "lodash-es/pick"
import nock from "nock"
import { generateCacheInfoSiretForSiret } from "shared/fixtures/cacheInfoSiret.fixture"
Expand All @@ -8,6 +6,8 @@ import { entriesToTypedRecord } from "shared/utils"
import { beforeEach, describe, expect, it, vi } from "vitest"

import { getDbCollection } from "@/common/utils/mongodbUtils"
import { givenSomeComputedJobPartners } from "@tests/fixture/givenSomeComputedJobPartners"
import { useMongo } from "@tests/utils/mongo.test.utils"

import { fillSiretInfosForPartners } from "./fillSiretInfosForPartners"

Expand Down
Loading

0 comments on commit 2eff28a

Please sign in to comment.