Skip to content

Commit

Permalink
Merge branch 'main' into chore/generate-api-types
Browse files Browse the repository at this point in the history
  • Loading branch information
hissalht authored Dec 20, 2024
2 parents 0010a5d + 9a901bd commit 0f10256
Show file tree
Hide file tree
Showing 47 changed files with 1,556 additions and 2,368 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

Tous les changements notables de Ara sont documentés ici avec leur date, leur catégorie (nouvelle fonctionnalité, correction de bug ou autre changement) et leur pull request (PR) associée.

## 18/12/2024

### Corrections 🐛

- Corrige les menus déroulants en rendant le code HTML généré valide ([#881](https://github.com/DISIC/Ara/pull/881))
- Corrige la mauvaise position verticale dans la page après utilisation des ancres « Pages » du rapport ([#879](https://github.com/DISIC/Ara/pull/879))

## 13/12/2024

### Corrections 🐛

- Corrige la position des infobulle "Non-applicable" sur la liste des audits ([#904](https://github.com/DISIC/Ara/pull/904))

## 12/12/2024

### Corrections 🐛
Expand Down
9 changes: 8 additions & 1 deletion confiture-rest-api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { MailModule } from "./mail/mail.module";
import { AuthModule } from "./auth/auth.module";
import { ProfileModule } from "./profile/profile.module";
import { UserMiddleware } from "./auth/user.middleware";
import { DebugController } from "./debug.controller";
import { PrismaService } from "./prisma.service";

@Module({
imports: [
Expand All @@ -23,7 +25,12 @@ import { UserMiddleware } from "./auth/user.middleware";
AuthModule,
ProfileModule
],
controllers: [HealthCheckController]
providers: process.env.DEBUG_ENDPOINTS ? [PrismaService] : [],
controllers: [
HealthCheckController,
// enable debug enpoints only when the DEBUG_ENDPOINTS variable is set
...(process.env.DEBUG_ENDPOINTS ? [DebugController] : [])
]
})
export class AppModule implements NestModule {
configure(consumer: MiddlewareConsumer) {
Expand Down
3 changes: 2 additions & 1 deletion confiture-rest-api/src/auth/auth.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { CreateAccountController } from "./create-account.controller";
}),
FeedbackModule,
AuditsModule
]
],
exports: [AuthService]
})
export class AuthModule {}
199 changes: 199 additions & 0 deletions confiture-rest-api/src/debug.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
import { Body, Controller, Post } from "@nestjs/common";
import { PrismaService } from "./prisma.service";
import { AuthService } from "./auth/auth.service";
import {
CriterionResultStatus,
CriterionResultUserImpact
} from "@prisma/client";
import { nanoid } from "nanoid";
import { CRITERIA } from "./audits/criteria";

@Controller("debug")
export class DebugController {
constructor(
private readonly prisma: PrismaService,
private readonly auth: AuthService
) {}

@Post("verification-token")
async getAccountVerificationToken(@Body() body: { username: string }) {
const token = this.auth.regenerateVerificationToken(body.username);
return token;
}

@Post("password-reset-verification-token")
async getPasswordResetVerificationToken(@Body() body: { username: string }) {
const token = this.auth.generatePasswordResetVerificationToken(
body.username
);

return token;
}

@Post("email-update-verification-token")
async getEmailUpdateVerificationToken(@Body() body: { uid: string }) {
const token = this.auth.regenerateEmailUpdateVerificationToken(body.uid);

return token;
}

@Post("create-verified-user")
async createVerifiedUser() {
const email = `john-doe${Math.random()}@example.com`;
const password = "pouetpouetpouet";

await this.auth.createUnverifiedUser(email, password);
const user = await this.prisma.user.update({
data: {
isVerified: true,
verificationJti: null
},
where: {
username: email
}
});

const authToken = await this.auth.signin(email, password);

return {
username: email,
password,
authToken,
uid: user.uid
};
}

@Post("create-audit")
async createAudit(
@Body()
body: {
isComplete: boolean;
isPristine: boolean;
noImprovements: boolean;
auditorEmail?: string;
}
) {
const editUniqueId = `edit-${nanoid()}`;
const reportUniqueId = `report-${nanoid()}`;

const completedAudit = await this.prisma.audit.create({
data: {
editUniqueId: editUniqueId,
consultUniqueId: reportUniqueId,
creationDate: new Date(),
publicationDate: body.isComplete ? new Date() : null,
auditTrace: {
create: {
auditConsultUniqueId: editUniqueId,
auditEditUniqueId: reportUniqueId
}
},
auditType: "FULL",
procedureName: "Audit de mon petit site",
auditorEmail: body.auditorEmail || "[email protected]",
auditorName: "Étienne Durand",
transverseElementsPage: {
create: {
name: "Éléments transverses",
url: ""
}
},
pages: {
createMany: {
data: [
{
name: "Accueil",
url: "https://example.com"
},
{
name: "Contact",
url: "https://example.com/contact"
},
{
name: "À propos",
url: "https://example.com/a-propos"
},
{
name: "Blog",
url: "https://example.com/blog"
},
{
name: "Article",
url: "https://example.com/blog/article"
},
{
name: "Connexion",
url: "https://example.com/connexion"
},
{
name: "Documentation",
url: "https://example.com/documentation"
},
{
name: "FAQ",
url: "https://example.com/faq"
}
]
}
}
},
include: {
transverseElementsPage: true
}
});

const auditPages = await this.prisma.auditedPage.findMany({
where: {
auditUniqueId: editUniqueId
}
});

if (!body.isPristine) {
await Promise.all(
[completedAudit.transverseElementsPage, ...auditPages].map(async (p) =>
this.prisma.criterionResult.createMany({
data: CRITERIA.map((c, i) => ({
status: [
CriterionResultStatus.COMPLIANT,
CriterionResultStatus.NOT_APPLICABLE,
CriterionResultStatus.NOT_COMPLIANT
][i % 3],
notCompliantComment: "Une erreur ici",
notApplicableComment: body.noImprovements
? null
: "Attention quand même si ça devient applicable",
compliantComment: body.noImprovements ? null : "Peut mieux faire",
quickWin: i % 7 === 0,
userImpact: [
CriterionResultUserImpact.MINOR,
CriterionResultUserImpact.MAJOR,
CriterionResultUserImpact.BLOCKING,
null
][i % 4],
topic: c.topic,
criterium: c.criterium,
pageId: p.id
}))
})
)
);
}

if (!body.isComplete && !body.isPristine) {
await this.prisma.criterionResult.delete({
where: {
pageId_topic_criterium: {
topic: 1,
criterium: 1,
pageId: auditPages[0].id
}
}
});
}

return {
editId: editUniqueId,
reportId: reportUniqueId
};
}
}
18 changes: 0 additions & 18 deletions confiture-web-app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,6 @@ Lancer le [serveur local sur le port 3000](http://localhost:3000) :
yarn dev
```

## Tests

[Cypress](https://www.cypress.io/) est utilisé pour lancer des tests end-to-end (e2e) dans un navigateur pour reproduire le comportement des utilisateurs.

Les tests peuvent être lancés de 2 manières :

- Via l’application Cypress avec :

```sh
yarn cypress open
```

- Via le terminal avec :

```sh
yarn cypress run
```

## Guidelines

- Utiliser les media queries en "desktop first" et avec la notation suivante avec les [valeurs de points de rupture du DSFR](https://www.systeme-de-design.gouv.fr/elements-d-interface/fondamentaux-techniques/grille-et-points-de-rupture) :
Expand Down
12 changes: 6 additions & 6 deletions confiture-web-app/src/components/account/dashboard/AuditRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function copyAuditLink(uniqueId: string) {
}
function copyReportLink(uniqueId: string) {
const url = `${window.location.origin}/rapports/${uniqueId}`;
const url = `${window.location.origin}/rapport/${uniqueId}`;
navigator.clipboard.writeText(url).then(() => {
notify(
Expand Down Expand Up @@ -174,8 +174,8 @@ function copyStatementLink(uniqueId: string) {
'fr-badge--purple-glycine': isInProgress || isNotStarted
}"
>
<span class="fr-sr-only">Statut </span>
{{ isInProgress || isNotStarted ? "En cours" : "Terminé" }}
<span class="fr-sr-only">Statut </span
>{{ isInProgress || isNotStarted ? "En cours" : "Terminé" }}
</p>

<!-- Creation date -->
Expand Down Expand Up @@ -233,12 +233,12 @@ function copyStatementLink(uniqueId: string) {
Non-applicable
<button
class="fr-btn--tooltip fr-btn audit-compliance-level-tooltip"
aria-describedby="compliance-tooltip"
:aria-describedby="`compliance-tooltip-${zIndex}`"
>
Information contextuelle
</button>
<span
id="compliance-tooltip"
:id="`compliance-tooltip-${zIndex}`"
class="fr-tooltip fr-placement"
role="tooltip"
aria-hidden="true"
Expand Down Expand Up @@ -273,7 +273,7 @@ function copyStatementLink(uniqueId: string) {
? "Continuer l’audit"
: "Voir le rapport"
}}
<span v-if="isInProgress" class="fr-sr-only">
<span v-if="isInProgress || isNotStarted" class="fr-sr-only">
{{ audit.procedureName }}</span
>
<span v-else class="fr-sr-only"
Expand Down
3 changes: 1 addition & 2 deletions confiture-web-app/src/components/audit/AraTabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@ watch(currentTab, (currentTab) => {
@keydown.home.prevent="selectFirstTab"
@keydown.end.prevent="selectLastTab"
>
<LayoutIcon v-if="i === 0" class="fr-mr-2v" />
{{ tab.label }}
<LayoutIcon v-if="i === 0" class="fr-mr-2v" />{{ tab.label }}
</button>
</li>
</ul>
Expand Down
1 change: 0 additions & 1 deletion confiture-web-app/src/components/audit/PagesSample.vue
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ function updatePageOrder(startIndex: number, endIndex: number) {
class="fr-btn fr-btn--tertiary-no-outline"
type="button"
:disabled="pages.length === 1"
data-cy="delete"
@click="deletePage(i)"
>
Supprimer
Expand Down
2 changes: 1 addition & 1 deletion confiture-web-app/src/components/layout/SiteFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const bottomLinks = [
</script>

<template>
<footer id="footer" class="fr-footer" role="contentinfo">
<footer id="footer" class="fr-footer fr-mt-auto" role="contentinfo">
<div v-if="accountStore.account" class="fr-footer__top">
<div class="fr-container">
<div class="fr-grid-row fr-grid-row--start fr-grid-row--gutters">
Expand Down
Loading

0 comments on commit 0f10256

Please sign in to comment.