Skip to content

Commit

Permalink
feat(email): use smtp protocol and @kita/html for email templates
Browse files Browse the repository at this point in the history
  • Loading branch information
douglasduteil committed Aug 20, 2024
1 parent f56812b commit 230fdd8
Show file tree
Hide file tree
Showing 29 changed files with 993 additions and 210 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/end-to-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ jobs:
- 5432:5432
steps:
- uses: actions/checkout@v4

- run: docker compose up --build --detach maildev

- uses: actions/setup-node@v4
with:
cache: "npm"
Expand Down
6 changes: 6 additions & 0 deletions cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,10 @@ export default defineConfig({
return config;
},
},
env: {
MAILDEV_PROTOCOL: "http",
MAILDEV_HOST: "localhost",
MAILDEV_SMTP_PORT: "1025",
MAILDEV_API_PORT: "1080",
},
});
56 changes: 18 additions & 38 deletions cypress/e2e/delete_totp/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
import { generateToken } from "@sunknudsen/totp";

describe("delete TOTP connexion", () => {
before(() => {
cy.mailslurp().then((mailslurp) =>
mailslurp.inboxController.deleteAllInboxEmails({
inboxId: "eab4ab97-875d-4ec7-bdcc-04323948ee63",
}),
);
});

it("should delete TOTP application", function () {
// Visit the signup page
cy.visit(`/users/start-sign-in`);
Expand Down Expand Up @@ -40,21 +32,15 @@ describe("delete TOTP connexion", () => {

cy.contains("L’application d’authentification a bien été supprimée.");

cy.mailslurp()
// use inbox id and a timeout of 30 seconds
.then((mailslurp) =>
mailslurp.waitForLatestEmail(
"eab4ab97-875d-4ec7-bdcc-04323948ee63",
60000,
true,
),
)
// check subject of deletion email
.then((email) => {
expect(email.subject).to.include(
"Suppression d'une application d'authentification à double facteur",
);
});
cy.maildevGetLastMessage().then((email) => {
expect(email.subject).to.equal(
"Suppression d'une application d'authentification à double facteur",
);
cy.maildevVisitMessageById(email.id);
cy.contains(
"L'application a été supprimée comme étape de connexion à deux facteurs.",
);
});
});

it("should disable TOTP", function () {
Expand Down Expand Up @@ -86,20 +72,14 @@ describe("delete TOTP connexion", () => {

cy.contains("Désactiver la validation en deux étapes").click();

cy.mailslurp()
// use inbox id and a timeout of 30 seconds
.then((mailslurp) =>
mailslurp.waitForLatestEmail(
"c9fabb94-9274-4ece-a3d0-54b1987c8588",
60000,
true,
),
)
// check subject of deletion email
.then((email) => {
expect(email.subject).to.include(
"Désactivation de la validation en deux étapes",
);
});
cy.maildevGetLastMessage().then((email) => {
expect(email.subject).to.equal(
"Désactivation de la validation en deux étapes",
);
cy.maildevVisitMessageById(email.id);
cy.contains(
"Votre compte MonComptePro n'est plus protégé par la validation en deux",
);
});
});
});
31 changes: 8 additions & 23 deletions cypress/e2e/update_personal_information/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
describe("Signup into new entreprise unipersonnelle", () => {
before(() => {
cy.mailslurp().then((mailslurp) =>
mailslurp.inboxController.deleteAllInboxEmails({
inboxId: "716fc7c8-8828-48d5-b748-57dd4e78e55a",
}),
);
});

it("Should send email when user updates personal information", function () {
// Visit the signup page
cy.visit(`/users/start-sign-in`);
Expand All @@ -31,20 +23,13 @@ describe("Signup into new entreprise unipersonnelle", () => {

cy.contains("Vos informations ont été mises à jour.");

cy.mailslurp()
// use inbox id and a timeout of 30 seconds
.then((mailslurp) =>
mailslurp.waitForLatestEmail(
"716fc7c8-8828-48d5-b748-57dd4e78e55a",
60000,
true,
),
)
// check subject of deletion email
.then((email) => {
expect(email.subject).to.include(
"Mise à jour de vos données personnelles",
);
});
cy.maildevGetLastMessage().then((email) => {
expect(email.subject).to.equal("Mise à jour de vos données personnelles");
cy.maildevVisitMessageById(email.id);
cy.contains(
"Nous vous informons que vos données personnelles ont été mises à jour avec succès.",
);
cy.maildevDeleteMessageById(email.id);
});
});
});
33 changes: 11 additions & 22 deletions cypress/e2e/update_totp_application/index.cy.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,6 @@
import { generateToken } from "@sunknudsen/totp";

describe("update TOTP application", () => {
before(() => {
cy.mailslurp().then((mailslurp) =>
mailslurp.inboxController.deleteAllInboxEmails({
inboxId: "d2469f84-9547-4190-b989-014876fd54ae",
}),
);
});
it("should update TOTP application, and replace old app with new", function () {
// Visit the signup page
cy.visit(`/users/start-sign-in`);
Expand Down Expand Up @@ -52,20 +45,16 @@ describe("update TOTP application", () => {
});

cy.contains("L’application d’authentification a été modifiée.");
cy.mailslurp()
// use inbox id and a timeout of 30 seconds
.then((mailslurp) =>
mailslurp.waitForLatestEmail(
"d2469f84-9547-4190-b989-014876fd54ae",
60000,
true,
),
)
// check subject of deletion email
.then((email) => {
expect(email.subject).to.include(
"Changement d'application d’authentification",
);
});

cy.maildevGetLastMessage().then((email) => {
expect(email.subject).to.equal(
"Changement d'application d’authentification",
);
cy.maildevVisitMessageById(email.id);
cy.contains(
"Le changement d'application d'authentification a bien été prise en compte.",
);
cy.maildevDeleteMessageById(email.id);
});
});
});
4 changes: 2 additions & 2 deletions cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// https://on.cypress.io/configuration
// ***********************************************************

import "cypress-mailslurp";
import "cypress-axe";

import "cypress-maildev";
import "cypress-mailslurp";
import "./commands";
4 changes: 4 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,9 @@ services:
STYLESHEET_URL:
network_mode: "host"

maildev:
image: soulteary/maildev
network_mode: "host"

volumes:
db-data:
Loading

0 comments on commit 230fdd8

Please sign in to comment.