Skip to content

Commit

Permalink
fix(clean-code): nettoyage de fichiers obsolètes, traitement des aler…
Browse files Browse the repository at this point in the history
…tes SonarCloud
  • Loading branch information
pYassine committed Feb 1, 2023
1 parent 35936a9 commit 4d69694
Show file tree
Hide file tree
Showing 19 changed files with 14 additions and 77 deletions.
43 changes: 0 additions & 43 deletions _docs/dev/30.tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,49 +51,6 @@ DOMIFA_FILTER_SEC_TEST=Agenda ENV_FILE=tests-local npx jest -- app-controllers.s

Note: il est aussi possible de filter par tags: <https://codecept.io/advanced/#tags>

### Tests e2e backend

**NOTE**: actuellement non-exécuté par la CI et non maintenu

**TODO**: à réparer

Restaurer les bases de test:

```bash
_scripts/db/restore-database-docker.sh --db=test
```

Démarrer le backend de test (les éventuelles migrations vont être appliquées au démarrage du serveur):

```bash
# /app/packages/backend
# démarrer le backend (branché sur les bases de test)
yarn start:tests-local
```

Démarrer le frontend:

```bash
# démarrer le frontend
yarn start
```

Pour n'exécuter que certains tests:

```bash
# filter by test name
npx codeceptjs run --features --debug ../../features/users/register.feature
npx codeceptjs run --features --debug ../../features/stats/stats.feature
# grep filter (run all tests with name containing "register")
npx codeceptjs run --features --debug --grep register
```

Pour exécuter les tests via une interface graphique:

```bash
yarn test:open-ui
```

## Mettre à jour les données de test

Installer la dernière version des dumps:
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# ---------------------------------------------------------
# 1) BUILDER IMAGE
# ---------------------------------------------------------
FROM node:16.19-bullseye as builder
FROM node:16.19-bullseye AS builder

ENV TZ Europe/Paris

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,7 @@ export class AdminStructuresController {
@Get("stats")
@AllowUserProfiles("super-admin-domifa")
public async stats(): Promise<AdminStructureStatsData> {
const stats =
await this.adminStructuresService.getStatsDomifaAdminDashboard();
return stats;
return await this.adminStructuresService.getStatsDomifaAdminDashboard();
}

@Get("")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ export class CanGetUserStructureGuard implements CanActivate {
);
throw new HttpException("Invalid structureId", HttpStatus.FORBIDDEN);
}
// TODO: remplacer par une jointure
const chosenUserStructure = await userStructureRepository.findOne(
{
id: userId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ export class MessageSmsTable
extends AppTypeormTable<MessageSmsTable>
implements MessageSms
{
// TODO: associer un usagerUUID
// Infos usager
@Column({ type: "integer" })
@Index()
public usagerRef: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { buildCustomDoc } from "..";
import { AppTestHelper } from "../../../../util/test";
import { STRUCTURE_MOCK } from "../../../../_common/mocks";
import {
STRUCTURE_MOCK,
USAGER_REFUS_MOCK,
USAGER_VALIDE_MOCK,
} from "../../../../_common/mocks";
Expand Down
3 changes: 1 addition & 2 deletions packages/backend/src/users/users.controller.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { HttpModule } from "@nestjs/axios";
import { MailsModule } from "../mails/mails.module";
import { StructuresModule } from "../structures/structure.module";
import { UsagersModule } from "../usagers/usagers.module";
import { AppTestContext, AppTestHelper } from "../util/test";
import { AppTestContext, AppTestHelper, AppTestHttpClient } from "../util/test";
import { UsersController } from "./users.controller";
import { AppTestHttpClient } from "../util/test";
import { userMock } from "../_common/mocks";
import { TESTS_USERS_STRUCTURE } from "../_tests";
import { usersDeletor } from "./services/users-deletor.service";
Expand Down
2 changes: 1 addition & 1 deletion packages/frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16.19.0 as builder
FROM node:16.19.0 AS builder
USER node

# these variables are needed at build time because we produce a *static* app
Expand Down
8 changes: 4 additions & 4 deletions packages/frontend/src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ export const routes: Routes = [
path: "stats",
},
{
canActivate: [AuthGuard],
canLoad: [AuthGuard],
loadChildren: () =>
import("./modules/manage-usagers/manage-usagers.module").then(
(m) => m.ManageUsagersModule
),
path: "manage",
},
{
canActivate: [AuthGuard, FacteurGuard],
canLoad: [AuthGuard, FacteurGuard],
loadChildren: () =>
import("./modules/import-usagers/import-usagers.module").then(
(m) => m.ImportUsagersModule
Expand All @@ -76,15 +76,15 @@ export const routes: Routes = [
path: "users",
},
{
canActivate: [AuthGuard, FacteurGuard],
canLoad: [AuthGuard, FacteurGuard],
loadChildren: () =>
import("./modules/usager-dossier/usager-dossier.module").then(
(m) => m.UsagerDossierModule
),
path: "usager",
},
{
canActivate: [AuthGuard],
canLoad: [AuthGuard],
loadChildren: () =>
import("./modules/usager-profil/usager-profil.module").then(
(m) => m.UsagerProfilModule
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class AuthService {
) {
this.currentUserSubject = new BehaviorSubject<UserStructure | null>(
localStorage.getItem("currentUser") !== null
? JSON.parse(localStorage.getItem("currentUser") as string)
? JSON.parse(localStorage.getItem("currentUser"))
: null
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/portail-admins/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16.19.0 as builder
FROM node:16.19.0 AS builder
USER node

# these variables are needed at build time because we produce a *static* app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { StructureType, StructureAddresseCourrier } from ".";
import { AppEntity } from "../_core";

export type StructurePublic = AppEntity & {
id: number; // TODO: à voir si c'est utile
id: number;
adresse: string;
complementAdresse: string;
nom: string;
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Title } from "@angular/platform-browser";
@Component({
selector: "app-politique",
templateUrl: "./politique.component.html",
styleUrls: ["./politique.component.css"],
})
export class PolitiqueComponent implements OnInit {
public constructor(private titleService: Title) {}
Expand Down
8 changes: 0 additions & 8 deletions packages/portail-admins/src/assets/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -177,11 +177,3 @@ html {
background-color: var(--bs-primary);
width: 100%;
}

.head-page .title,
.head-page h1 {
font-style: normal;
font-weight: bold;
font-size: 1.7rem;
color: #ffffff;
}
2 changes: 1 addition & 1 deletion packages/portail-usagers/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM node:16.19.0 as builder
FROM node:16.19.0 AS builder
USER node

# these variables are needed at build time because we produce a *static* app
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ export class FormatInternationalPhoneNumberPipe implements PipeTransform {
telephone.numero,
telephone.countryCode.toUpperCase(),
);
const internationalPhone = this.phoneUtil.format(
numero,
lpn.PhoneNumberFormat.INTERNATIONAL,
);
return internationalPhone;
return this.phoneUtil.format(numero, lpn.PhoneNumberFormat.INTERNATIONAL);
} catch (error) {
console.warn(error);
return "Non renseigné";
Expand Down
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
@Component({
selector: "app-section-options",
templateUrl: "./section-options.component.html",
styleUrls: ["./section-options.component.css"],
})
export class SectionOptionsComponent implements OnInit {
@Input() public usager!: PortailUsagerPublic;
Expand Down

0 comments on commit 4d69694

Please sign in to comment.