Skip to content

Commit

Permalink
refactor(common): add common in 'mon-domifa'
Browse files Browse the repository at this point in the history
  • Loading branch information
pYassine committed Nov 8, 2023
1 parent f5b7894 commit 905021c
Show file tree
Hide file tree
Showing 81 changed files with 1,018 additions and 665 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,18 @@ jobs:
- name: Set up Yarn cache
uses: c-hive/gha-yarn-cache@v2

- name: Build common dependencies
run: yarn workspace @domifa/common build

- name: Test common dependencies
run: yarn workspace @domifa/common test

- name: Create backend .env file
run: cp ./packages/backend/.env.backend.test.local.example.env ./packages/backend/.env

- name: Install backend dependencies
run: yarn workspaces focus @domifa/backend

- name: Build common dependencies
run: yarn workspace @domifa/common build

- name: Create Postgres service
run: docker-compose -f ./docker-compose.tests.yml up --build --detach

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"prepare": "husky install"
},
"devDependencies": {
"@babel/runtime": "^7.22.15",
"@babel/runtime": "^7.23.2",
"@commitlint/cli": "^18.2.0",
"@commitlint/config-conventional": "^18.1.0",
"@socialgouv/sre-secrets": "^1.14.5",
Expand Down
28 changes: 14 additions & 14 deletions packages/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
},
"dependencies": {
"@domifa/common": "workspace:^",
"@faker-js/faker": "^8.1.0",
"@faker-js/faker": "^8.2.0",
"@nestjs/axios": "^3.0.1",
"@nestjs/common": "^10.0.5",
"@nestjs/core": "^10.0.5",
Expand All @@ -56,8 +56,8 @@
"@opentelemetry/instrumentation-pg": "^0.36.0",
"@opentelemetry/sdk-node": "^0.44.0",
"@opentelemetry/semantic-conventions": "^1.17.0",
"@sentry/node": "^7.76.0",
"@sentry/opentelemetry-node": "^7.76.0",
"@sentry/node": "^7.77.0",
"@sentry/opentelemetry-node": "^7.77.0",
"@socialgouv/streaming-file-encryption": "^1.1.0",
"@types/source-map-support": "^0.5.4",
"axios": "^1.4.0",
Expand Down Expand Up @@ -90,7 +90,7 @@
"pino-std-serializers": "^6.1.0",
"pizzip": "^3.0.6",
"reflect-metadata": "^0.1.13",
"rimraf": "^5.0.0",
"rimraf": "^5.0.5",
"rxjs": "^7.6.0",
"sanitize-filename": "^1.6.3",
"sanitize-html": "^2.11.0",
Expand All @@ -108,17 +108,17 @@
"devDependencies": {
"@nestjs/cli": "^10.1.1",
"@socialgouv/eslint-config-typescript": "^1.131.0",
"@types/bcryptjs": "^2.4.5",
"@types/compression": "^1.7.4",
"@types/bcryptjs": "^2.4.6",
"@types/compression": "^1.7.5",
"@types/cron": "^2.0.1",
"@types/dotenv": "^8.2.0",
"@types/email-templates": "^10.0.2",
"@types/express": "4.17.20",
"@types/faker": "^6.6.8",
"@types/fs-extra": "^11.0.2",
"@types/geojson": "^7946.0.10",
"@types/jest": "^29.2.4",
"@types/lodash.isequal": "^4.5.6",
"@types/faker": "^6.6.9",
"@types/fs-extra": "^11.0.4",
"@types/geojson": "^7946.0.13",
"@types/jest": "^29.5.8",
"@types/lodash.isequal": "^4.5.8",
"@types/multer": "^1.4.6",
"@types/node": "^20.3.3",
"@types/node-pdftk": "^2.1.6",
Expand All @@ -134,10 +134,10 @@
"@types/uuid": "^9.0.4",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.50.0",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-prettier": "^5.0.0",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-promise": "^6.1.1",
"jest": "^29.7.0",
"lint-staged": "^15.0.0",
Expand Down
11 changes: 11 additions & 0 deletions packages/common/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import type { Config } from "jest";

const jestConfig: Config = {
collectCoverage: false,
coverageReporters: ["cobertura"],
coverageDirectory: "./coverage/",
modulePathIgnorePatterns: ["<rootDir>/dist/"],
preset: "ts-jest/presets/js-with-ts",
};

export default jestConfig;
17 changes: 9 additions & 8 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
},
"devDependencies": {
"@eslint/create-config": "^0.4.6",
"@types/jest": "^29.4.0",
"@types/jest": "^29.5.8",
"@types/rimraf": "^4.0.5",
"@typescript-eslint/eslint-plugin": "^6.0.0",
"@typescript-eslint/parser": "^6.0.0",
"eslint": "^8.50.0",
"eslint-config-standard-with-typescript": "^39.1.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-jest": "^27.4.0",
"eslint-plugin-n": "^16.1.0",
"eslint-plugin-prettier": "^5.0.0",
"eslint": "^8.53.0",
"eslint-config-standard-with-typescript": "^39.1.1",
"eslint-plugin-import": "^2.29.0",
"eslint-plugin-jest": "^27.6.0",
"eslint-plugin-n": "^16.3.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-promise": "^6.1.1",
"jest": "^29.7.0",
"license-check-and-add": "^4.0.5",
Expand All @@ -39,7 +39,8 @@
"typescript": "^4.3.5"
},
"dependencies": {
"rimraf": "^5.0.0"
"date-fns": "^2.30.0",
"rimraf": "^5.0.5"
},
"lint-staged": {
"*": "prettier --ignore-unknown -w",
Expand Down
129 changes: 129 additions & 0 deletions packages/common/src/mocks/USAGER_ACTIF.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
import { ETAPE_DOSSIER_COMPLET } from "../usager";

export const USAGER_ACTIF_MOCK = {
numeroDistribution: null,
decision: {
statut: "VALIDE",
dateDebut: new Date("2020-02-12T00:00:00.000Z"),
dateDecision: new Date("2020-02-12T00:00:00.000Z"),
dateFin: new Date("2021-02-12T00:00:00.000Z"),
motif: "LIEN_COMMUNE",
typeDom: "PREMIERE_DOM",
orientation: "other",
orientationDetails: "DETAILS",
motifDetails: "DETAILS",
userId: 30,
userName: "Testeur Robin",
},
lastInteraction: {
colisIn: 0,
courrierIn: 0,
enAttente: false,
recommandeIn: 0,
dateInteraction: new Date("2020-12-01T14:11:28.167Z"),
},
pinnedNote: null,
options: {
transfert: {
actif: false,
nom: null,
adresse: null,
dateDebut: null,
dateFin: null,
},
procurations: [
{
nom: null,
prenom: null,
dateFin: null,
dateDebut: null,
dateNaissance: null,
},
],
npai: {
actif: false,
dateDebut: null,
},
portailUsagerEnabled: false,
},
contactByPhone: false,
rdv: { dateRdv: null, userId: 0, userName: "" },
ayantsDroits: [
{
nom: "Karamoko",
prenom: "Mauricette",
dateNaissance: new Date("1978-12-20T00:00:00.000Z"),
lien: "CONJOINT",
},
],
datePremiereDom: new Date("2018-01-11T00:00:00.000Z"),

email: "[email protected]",
entretien: {
typeMenage: "COUPLE_AVEC_ENFANT",
domiciliation: false,
revenus: false,
orientation: true,
orientationDetail: "Test orientation",
raison: "PRESTATIONS_SOCIALES",
liencommune: "SOCIAL",
liencommuneDetail: "Suivi social",
residence: "DOMICILE_MOBILE",
cause: "EXPULSION",
commentaires: "Ceci est un commentaire",
revenusDetail: null,
residenceDetail: null,
causeDetail: null,
rattachement: null,
raisonDetail: null,
accompagnement: null,
accompagnementDetail: null,
},
etapeDemande: ETAPE_DOSSIER_COMPLET,
historique: [
{
statut: "VALIDE",
dateDebut: new Date("2020-02-12T00:00:00.000Z"),
dateDecision: new Date("2020-02-12T00:00:00.000Z"),
dateFin: new Date("2021-02-12T00:00:00.000Z"),
motif: null,
typeDom: "PREMIERE_DOM",
orientation: null,
orientationDetails: null,
motifDetails: "",
userId: 30,
userName: "Testeur Robin",
},
{
dateDebut: new Date("2020-12-01T10:00:24.980Z"),
dateDecision: new Date("2020-12-01T10:00:24.980Z"),
dateFin: new Date("2020-12-01T10:00:24.980Z"),
motif: null,
motifDetails: null,
statut: "INSTRUCTION",
orientation: null,
orientationDetails: null,
userId: 30,
userName: "Testeur Robin",
typeDom: "PREMIERE_DOM",
},
],
telephone: { countryCode: "FR", numero: "0606060606" },
surnom: "",
import: {
date: new Date("2020-12-01T10:00:24.980Z"),
userId: 30,
userName: "Testeur Robin",
},
typeDom: "RENOUVELLEMENT",
customRef: "5",
dateNaissance: new Date("1998-08-07T00:00:00.000Z"),
nom: "Martine",
prenom: "Sembat",
sexe: "femme",
structureId: 1,
villeNaissance: "Bouaké, Côte d'Ivoire",
ref: 5,
createdAt: new Date("2020-12-01T10:00:24.984Z"),
updatedAt: new Date("2020-12-21T17:07:12.911Z"),
};
117 changes: 117 additions & 0 deletions packages/common/src/mocks/USAGER_REFUS.mock.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
import { ETAPE_DOSSIER_COMPLET } from "../usager";

export const USAGER_REFUS_MOCK = {
numeroDistribution: null,

decision: {
orientationDetails: null,
orientation: null,
statut: "REFUS",
dateDebut: new Date("2020-02-12T00:00:00.000Z"),
dateDecision: new Date("2020-02-12T00:00:00.000Z"),
dateFin: new Date("2021-02-12T00:00:00.000Z"),
motif: "NON_MANIFESTATION_3_MOIS",
typeDom: "PREMIERE_DOM",
motifDetails: "",
userId: 30,
userName: "Testeur Robin",
},
lastInteraction: {
colisIn: 0,
courrierIn: 0,
enAttente: false,
recommandeIn: 0,
dateInteraction: new Date("2020-12-01T14:11:28.167Z"),
},
options: {
transfert: {
actif: false,
nom: null,
adresse: null,
dateDebut: null,
dateFin: null,
},
procurations: [
{
nom: null,
prenom: null,
dateFin: null,
dateDebut: null,
dateNaissance: null,
},
],
npai: {
actif: false,
dateDebut: null,
},
portailUsagerEnabled: false,
},
contactByPhone: false,

rdv: { dateRdv: null, userId: 0, userName: "" },
ayantsDroits: [
{
nom: "Karamoko",
prenom: "Mauricette",
dateNaissance: new Date("1978-12-20T00:00:00.000Z"),
lien: "CONJOINT",
},
],
datePremiereDom: new Date("2018-01-11T00:00:00.000Z"),
pinnedNote: null,
email: "[email protected]",
entretien: {
typeMenage: "COUPLE_AVEC_ENFANT",
domiciliation: false,
revenus: false,
orientation: true,
orientationDetail: "Test orientation",
raison: "PRESTATIONS_SOCIALES",
liencommune: "SOCIAL",
liencommuneDetail: "Suivi social",
residence: "DOMICILE_MOBILE",
cause: "EXPULSION",
commentaires: "Ceci est un commentaire",
revenusDetail: null,
residenceDetail: null,
causeDetail: null,
rattachement: null,
raisonDetail: null,
accompagnement: null,
accompagnementDetail: null,
},
etapeDemande: ETAPE_DOSSIER_COMPLET,
historique: [
{
dateDebut: new Date("2020-12-01T10:00:24.980Z"),
dateDecision: new Date("2020-12-01T10:00:24.980Z"),
dateFin: new Date("2020-12-01T10:00:24.980Z"),
motif: null,
orientation: null,
motifDetails: null,
orientationDetails: null,
statut: "INSTRUCTION",
userId: 30,
userName: "Testeur Robin",
typeDom: "PREMIERE_DOM",
},
],
telephone: { countryCode: "FR", numero: "0606060606" },
surnom: "",
import: {
date: new Date("2020-12-01T10:00:24.980Z"),
userId: 30,
userName: "Testeur Robin",
},
typeDom: "RENOUVELLEMENT",
customRef: "5",
dateNaissance: new Date("1998-08-07T00:00:00.000Z"),
nom: "Martine",
prenom: "Sembat",
sexe: "femme",
structureId: 1,
villeNaissance: "Bouaké, Côte d'Ivoire",
ref: 5,
createdAt: new Date("2020-12-01T10:00:24.984Z"),
updatedAt: new Date("2020-12-21T17:07:12.911Z"),
};
3 changes: 3 additions & 0 deletions packages/common/src/mocks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @index('./*', f => `export * from '${f.path}'`)
export * from "./USAGER_ACTIF.mock";
export * from "./USAGER_REFUS.mock";
Loading

0 comments on commit 905021c

Please sign in to comment.