Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Commit

Permalink
Finalize contact page
Browse files Browse the repository at this point in the history
  • Loading branch information
desoindx committed Jan 23, 2022
1 parent aa27217 commit ad46dfa
Show file tree
Hide file tree
Showing 19 changed files with 491 additions and 204 deletions.
3 changes: 3 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ DB_LOGGING_ENABLE=true
DEMARCHES_SIMPLIFIEES_TOKEN=api-token
DEMARCHES_SIMPLIFIEES_ID=52209
DEMARCHES_SIMPLIFIEES_CHAMPS=[["Q2hhbXAtMTYwMzgwNQ==", "phone"], ["Q2hhbXAtMTYyNzkzOQ==", "address"], ["Q2hhbXAtMTYzOTUyNA==", "teleconsultation"], ["Q2hhbXAtMTY2MDM0Nw==", "languages"], ["Q2hhbXAtMTYzOTQwMQ==", "website"], ["Q2hhbXAtMjI0NzExMg==", "cdsmsp"], ["Q2hhbXAtMjIyMjcwMg==", "withChildren"]]

MAIL_ENABLED=false
SUPPORT_MAIL=monpsysante@fabrique.social.gouv.fr
9 changes: 8 additions & 1 deletion .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,11 @@ DEMARCHES_SIMPLIFIEES_TOKEN=api-token
DEMARCHES_SIMPLIFIEES_ID=52209
DEMARCHES_SIMPLIFIEES_CHAMPS=[["Q2hhbXAtMTYwMzgwNQ==", "phone"], ["Q2hhbXAtMTYyNzkzOQ==", "address"], ["Q2hhbXAtMTYzOTUyNA==", "teleconsultation"], ["Q2hhbXAtMTY2MDM0Nw==", "languages"], ["Q2hhbXAtMTYzOTQwMQ==", "website"], ["Q2hhbXAtMjI0NzExMg==", "cdsmsp"], ["Q2hhbXAtMjIyMjcwMg==", "withChildren"]]

NEXT_PUBLIC_DISPLAY_DIRECTORY=false
NEXT_PUBLIC_DISPLAY_DIRECTORY=false

MAIL_HOST=smtp.tipimail.com
MAIL_PORT=587
MAIL_TLS=true

MAIL_ENABLED=true
SUPPORT_MAIL=monpsysante@fabrique.social.gouv.fr
9 changes: 8 additions & 1 deletion .env.staging
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@ DEMARCHES_SIMPLIFIEES_TOKEN=api-token
DEMARCHES_SIMPLIFIEES_ID=52209
DEMARCHES_SIMPLIFIEES_CHAMPS=[["Q2hhbXAtMTYwMzgwNQ==", "phone"], ["Q2hhbXAtMTYyNzkzOQ==", "address"], ["Q2hhbXAtMTYzOTUyNA==", "teleconsultation"], ["Q2hhbXAtMTY2MDM0Nw==", "languages"], ["Q2hhbXAtMTYzOTQwMQ==", "website"], ["Q2hhbXAtMjI0NzExMg==", "cdsmsp"], ["Q2hhbXAtMjIyMjcwMg==", "withChildren"]]

NEXT_PUBLIC_DISPLAY_DIRECTORY=true
NEXT_PUBLIC_DISPLAY_DIRECTORY=true

MAIL_HOST=smtp.tipimail.com
MAIL_PORT=587
MAIL_TLS=true

MAIL_ENABLED=true
SUPPORT_MAIL=monpsysante@fabrique.social.gouv.fr
17 changes: 17 additions & 0 deletions .socialgouv/environments/dev/app.sealed-secret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
annotations:
sealedsecrets.bitnami.com/cluster-wide: 'true'
name: mon-psy-sante
namespace: mon-psy-sante-preprod
spec:
encryptedData:
MAIL_AUTH_PASS: AgBXoippgPAY9XCDtuppex7e5C/bDqnjJnN+iTkk44+TxZxyscI/5dpUfbYzTqn+aaHvySmkXShX2KJi6dHfIi6MfnTVRP2TsSa3oxA7IWDNCbN9N0HnFFz6L3ITRHcUTO28TJBOwfPur3dN8Sw5x3WWmbvPFJEO0TF8ZrLqePD6a1/M6o95z8O/H7AWDx0QK6/61aXvUgHXj6L3RrKd+534Fns8Dn5TEPDzouUTUPNZXqih7J7k3Byq+zfBHMZD4tKc0hPTFg2TuiZUANXWkiGjHEQU5lw59chm2xpPE7SYSvTxsWGyZtupuYXP1AKvtL87ry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q7XYYSVA0Yy2xvnIg5bqD1fHQ9hrVifhUONBnZ0Npvlzx4DUjUYnlPZRisX7yIlPHf4TNUbyk8ZwrO2yNFuY2PgmZL0fq8lN3l1zr+F8GeYeUsA==
template:
metadata:
annotations:
sealedsecrets.bitnami.com/cluster-wide: 'true'
name: mon-psy-sante
type: Opaque
17 changes: 17 additions & 0 deletions .socialgouv/environments/preprod/app.sealed-secret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
annotations:
sealedsecrets.bitnami.com/cluster-wide: 'true'
name: mon-psy-sante
namespace: mon-psy-sante-preprod
spec:
encryptedData:
MAIL_AUTH_PASS: AgBXoippgPAY9XCDtuppex7e5C/bDqnjJnN+iTkk44+TxZxyscI/5dpUfbYzTqn+aaHvySmkXShX2KJi6dHfIi6MfnTVRP2TsSa3oxA7IWDNCbN9N0HnFFz6L3ITRHcUTO28TJBOwfPur3dN8Sw5x3WWmbvPFJEO0TF8ZrLqePD6a1/M6o95z8O/H7AWDx0QK6/61aXvUgHXj6L3RrKd+534Fns8Dn5TEPDzouUTUPNZXqih7J7k3Byq+zfBHMZD4tKc0hPTFg2TuiZUANXWkiGjHEQU5lw59chm2xpPE7SYSvTxsWGyZtupuYXP1AKvtL87ryd/mSa9SIik/ojVpRCZ6yp36u2/JaYtbBEEQmmbYugesj9BWv4t0TnwC+wrjcpkuD+MDhgIN94NMoP0Ug6Ga80NEppWqZMrjlwY3hT2dQvZTVctCEkM2TF+B9TziJLI2hh8RAI/4o8myDx0QjAvHKxOLiXO19sBL3DKBaXDPPmvr8frsplUux01LqpT+HCc+UsDte+DcxfSwrvT3PLpabQaB+x0V/FBDouTOpjUcdQ3EjkzefNevcPQAKiiDD63ycSFIvd/jnaAMRQ8R7izZd1ttWkCD+XZi0RG9fmBz3AnYcfEmeZJrzjUk9DqdIS3+c44KwKl57S09MT+WqFXwr6l/UfHv+6XMXy7q3Q9sxz1bkC1j8wyqSWy2FyTMtHuKgNnH2oSjuYasyAK9goRgo4Udl5gBG25i9ziBLDonQ==
MAIL_AUTH_USER: AgDHN1LPlykEhWv0mvKhb3pDM68bymYCF65+gKiS3rV20WeNIIFZbid/nWOCqlXgKnMrAI5oXoGOVqaHH18X6WQNFbmGuAI3YR2P7OaRrUJsQN3/Q5pfoEF3H3NyMIBD2xfhDUKTVdGjcya+B3NGEJLqEly7BYadInCZVwCt6jVJrXa/bhwQmumhv/f5PucS/UzvMTKumQMkJHU5/UTiYiLDzO/gemufkfZTvVTREjXzXyeTtKPLtzTL0k5wZSU/x1/nlE4LuNT/BmxppKx4wnM+JrxCyb/bqjaqFrOzqtOy5LclnVTOe4CG8LP1HH77lolSbBPTWyiG0hn9TsoKwXY4LMOFou9WfU2AwKcgldA23wyOpIThBag30ruRIs4GlZoORiJR2Dmf4xQA2qSj/h/KyoBO/cxkGrTiXQOMcTEqTZcxeZtzcOD11IdLlHrH8y03uHGzk2VR0zBQf4EZbFG0oK3s2P4ZPW/gtSY3rNAyLh67UZdt3fihNz/iP0lnp3RqYHHzXzjGdGlyh67lE1wtPJwUgmkl5/ZGIX4Kl2qOQToaVmU789tMJ9ADaL5TP6LrJhgXolSM3Gb4K5R46Z0zxVpvCRhQa4nOKroMg1sg5LofyCSu7hs+rrE7+fJq7XYYSVA0Yy2xvnIg5bqD1fHQ9hrVifhUONBnZ0Npvlzx4DUjUYnlPZRisX7yIlPHf4TNUbyk8ZwrO2yNFuY2PgmZL0fq8lN3l1zr+F8GeYeUsA==
template:
metadata:
annotations:
sealedsecrets.bitnami.com/cluster-wide: 'true'
name: mon-psy-sante
type: Opaque
15 changes: 15 additions & 0 deletions .socialgouv/environments/prod/app.sealed-secret.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: bitnami.com/v1alpha1
kind: SealedSecret
metadata:
annotations: {}
name: app.sealed-secret.yml
namespace: mon-psy-sante
spec:
encryptedData:
MAIL_AUTH_PASS: AgCqXteifRLz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1Fy7X24M9DWqEn60SU3I+HgKmIII0c/5O191OxrPdkOErs4FNFD0HxQ3nkjL4EC9p/AU5C11h9RXvy3Vp/upQHMdIQ0diuv0H9ClxwYxc01Z0AhtRYxRyT0AXzSYMi+MNiVYb5N8XKEF1GBi7wpI+Q4b0LJrcIStIYxslxHxLWMqQlg30Ou2kgp6O39PSC3clqWgcxe5T8H4UP+szeY8IyL8im0hiVaM2lgu2lubgkhv4kJdovWvCKXUPzSnNAbqqDpedStW2WRZ+sHaXLYl09Ef33h1CTi0u4/wJdbbF7C4qV0VHNPA1k3DF4QkRlCGS+Q29YnqIbZJd8HkF/y/5CpD4rMbtt0nRZx9xFrzEWwc0j9+L9MuGkQibfUgwBTugPrTihqvgtfqeggYZUj1HW7ZLxT22UlSw1T9UvQEPacZqXulteg==
template:
metadata:
annotations: {}
name: app.sealed-secret.yml
type: Opaque
51 changes: 48 additions & 3 deletions cypress/integration/contact.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ describe("Contact page", () => {
cy.get('[data-test-id="department-select"]')
.type('95');
cy.get('[data-test-id="reason-select"] > select > option')
.eq(3)
.eq(2)
.then((element) =>
cy
.get('[data-test-id="reason-select"] > select')
Expand All @@ -38,12 +38,12 @@ describe("Contact page", () => {

cy.wait("@contact")

cy.get('[data-test-id="alert"]').should('have.text', "Message envoyé.")
cy.get('[data-test-id="alert"]').should('have.text', "Votre message a bien été transmis à nos équipes, nous vous répondrons dans les plus brefs délais.")
});

it("should send a mail without reason for others", () => {
cy.get('[data-test-id="user-type-select"] > select > option')
.eq(4)
.eq(5)
.then((element) =>
cy
.get('[data-test-id="user-type-select"] > select')
Expand All @@ -70,4 +70,49 @@ describe("Contact page", () => {

cy.get('[data-test-id="alert"]').should('have.text', "Message envoyé.")
});

it("should display public info", () => {
cy.get('[data-test-id="public-info"]')
.should('not.exist')

cy.get('[data-test-id="user-type-select"] > select > option')
.eq(3)
.then((element) =>
cy
.get('[data-test-id="user-type-select"] > select')
.select(element.val())
);
cy.get('[data-test-id="public-info"]')
.should('exist')
});

it("should display psychologist info", () => {
cy.get('[data-test-id="psychologist-info"]')
.should('not.exist')

cy.get('[data-test-id="user-type-select"] > select > option')
.eq(1)
.then((element) =>
cy
.get('[data-test-id="user-type-select"] > select')
.select(element.val())
);
cy.get('[data-test-id="psychologist-info"]')
.should('exist')
});

it("should display doctor info", () => {
cy.get('[data-test-id="psychologist-info"]')
.should('not.exist')

cy.get('[data-test-id="user-type-select"] > select > option')
.eq(4)
.then((element) =>
cy
.get('[data-test-id="user-type-select"] > select')
.select(element.val())
);
cy.get('[data-test-id="psychologist-info"]')
.should('exist')
});
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"pg-hstore": "^2.3.4",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"sanitize-html": "^2.6.1",
"sequelize": "^6.13.0",
"sequelize-cli": "^6.3.0",
"ts-node": "^10.4.0",
Expand Down
50 changes: 42 additions & 8 deletions src/__tests__/api/contact.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,74 @@ describe("/api/contact", () => {
lastName: "Dane",
message: "Hello you !",
reason: CONTACT_REASON.ELIGIBILITY,
userType: CONTACT_USER_TYPE.PSYCHOLOGIST_INTERESTED,
userType: CONTACT_USER_TYPE.PSYCHOLOGIST_PARTNER,
});

expect(result.status).toEqual(200);
});

it("should return a 200 when everything is filled for a Doctor", async () => {
it("should return a 200 when everything is filled for an other person", async () => {
const result = await axios.post("http://localhost:3000/api/contact", {
department: "06 - Alpes-Maritimes",
email: "jane.dane@msp.fr",
firstName: "Jane",
lastName: "Dane",
message: "Hello you !",
userType: CONTACT_USER_TYPE.DOCTOR,
userType: CONTACT_USER_TYPE.OTHER,
});

expect(result.status).toEqual(200);
});

const errors = [
{ label: "without department", values: { department: "95" } },
{ label: "with wrong department", values: { department: "95" } },
{ label: "without department", values: { department: "" } },
{ label: "with wrong email", values: { email: "test" } },
{ label: "without email", values: { email: "" } },
{ label: "without lastName", values: { lastName: "" } },
{ label: "without firstName", values: { firstName: "" } },
{ label: "without message", values: { message: "" } },
{
label: "with wrong userType",
values: { userType: CONTACT_USER_TYPE.DOCTOR },
},
{ label: "without userType", values: { userType: "" } },
{
label: "with psychologist and without reason",
values: {
reason: "",
userType: CONTACT_USER_TYPE.PSYCHOLOGIST_PARTNER,
},
},
{
label: "with psychologist and with wrong reason",
values: {
reason: "wrong reason",
userType: CONTACT_USER_TYPE.PSYCHOLOGIST_PARTNER,
},
},
];
errors.map((error) =>
it(`Should return a 400 for a contact ${error.label}`, async () => {
expect.assertions(1);
expect.assertions(2);
try {
await axios.post("http://localhost:3000/api/contact", {
const defaultValues = {
department: "06 - Alpes-Maritimes",
email: "jane.dane@msp.fr",
firstName: "Jane",
lastName: "Dane",
message: "Hello you !",
reason: CONTACT_REASON.ELIGIBILITY,
userType: CONTACT_USER_TYPE.PSYCHOLOGIST_INTERESTED,
userType: CONTACT_USER_TYPE.OTHER,
};

const resutSuccess = await axios.post(
"http://localhost:3000/api/contact",
defaultValues
);
expect(resutSuccess.status).toEqual(200);

await axios.post("http://localhost:3000/api/contact", {
...defaultValues,
...error.values,
});
} catch (e) {
Expand Down
Loading

0 comments on commit ad46dfa

Please sign in to comment.