Skip to content

Commit

Permalink
feat: ajout de nouveau test , maj packages, bug session aborted résolu (
Browse files Browse the repository at this point in the history
#22)

* feat: ajout de nouveau test pour le composant Ajout-Demande sur cypress, déplacement du dossier page dans src/, mise a jour du package react-dsfr + cypress

* fix(package): remove unused package

* fix: enlever les tests de ajout-demande temporairement

* fix: fix script to run cypress with correct config file

* fix downgrade cypress packages

* fix: remove frozen-lockfile in workflows

* conflict: resolve conflict with master

* add 1000jours logo, fix import css

---------

Co-authored-by: MinaBarry <[email protected]>
  • Loading branch information
mbarry-ippon and MinaBarry authored Feb 17, 2023
1 parent c7afbaa commit cffc155
Show file tree
Hide file tree
Showing 38 changed files with 1,502 additions and 1,468 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
${{ runner.os }}-yarn-
- name: Install dependencies
run: |
yarn install --prefer-offline --frozen-lockfile
yarn install --prefer-offline
- name: Build
run: |
yarn build
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
${{ runner.os }}-yarn-
- name: Install dependencies
run: |
yarn install --prefer-offline --frozen-lockfile
yarn install --prefer-offline
- name: Lint
run: |
yarn lint
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/storybook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
${{ runner.os }}-yarn-
- name: Install dependencies
run: |
yarn install --prefer-offline --frozen-lockfile
yarn install --prefer-offline
- name: Deploy
run: |
git remote set-url origin https://git:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
${{ runner.os }}-yarn-
- name: Install dependencies
run: |
yarn install --prefer-offline --frozen-lockfile
yarn install --prefer-offline
- name: Test code
run: |
yarn test
10 changes: 7 additions & 3 deletions .talismanrc
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
fileignoreconfig:
- filename: .env.development
checksum: 25aecef75cc324e49b0ebfa514ed9233996881225cd9c0c3e6ec202925540984
checksum: 537626a2f1936dc80d3da36a5dcd70d3277ea889e747d4368261e9ede5e9d6e6
- filename: .env.production
checksum: ce7ac1eafe19548e095c5bf5ad7d48afbc78015a9fd330b280d825e3b034c294
checksum: 4b7835ad6d2dbad0ea3bef4ce74572b4c240bfeb8206c262a023ec761230cde8
- filename: .env.staging
checksum: 1d29ac593c36873caef00cafce4185b70bd6490f01c7ac482b507016e4b64f88
checksum: 58d12cc16918e20873da415691725a6fccfe620449dc978b943447f74af7719a
- filename: .github/workflows/kontinuous-webhook-delete.yml
checksum: 6debf4f640d4ed9cb39bb19445214ab52dcb23fb7da12feeb85070816d7ee52a
- filename: .github/workflows/kontinuous-webhook-deploy.yml
Expand All @@ -19,8 +19,12 @@ fileignoreconfig:
checksum: abc2a89b85d95e759866b9a7b53ba934aff7b2f65e453e3ef65954320a926b38
- filename: pages/mui.tsx
checksum: 65dd6ab0469f43924ffc92d26055de14a77b1ef873e0efe69a014b582c38b694
- filename: src/__generated__/fragment-masking.ts
checksum: 0abb5ee05bd63638ec998c0eefe4b141850571558d0b430011f43aea026ff471
- filename: src/__generated__/graphql.ts
checksum: 195ca91b5f08fecb069cd9185025e695bf0c465451b789891872fd34528cdad7
- filename: src/__generated__/index.ts
checksum: 71806037df785505323b21435e6a8e68f8de1b29628fa07bdbf9d276e39f950b
- filename: src/components/SelectDepartment.tsx
checksum: d8074633be1f7eb9bf5fbeb4f387ea7ea087b04a5675bff25e9e252dda5f6913
scopeconfig:
Expand Down
4 changes: 2 additions & 2 deletions cypress.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"baseUrl": "http://localhost:3000"
}
"baseUrl": "http://localhost:3000"
}
File renamed without changes.
29 changes: 29 additions & 0 deletions cypress/integration/ajout-demande.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
describe("Formulaire d'ajout page", () => {
it("should be correct input label", () => {
cy.visit('/ajout-demande')
})

//TODO Ajouter la logique de login pour permettre aux tests d'accéder aux composant
// beforeEach(() => {
// cy.visit("/ajout-demande");
// });
// it("should be correct input label", () => {
// cy.get("form > :nth-child(1) > .fr-label").should("contain", "Prénom");
// cy.get("form > :nth-child(2) > .fr-label").should("contain", "Nombre d'enfants");
// cy.get("form > :nth-child(3) > .fr-label").should("contain", "Date de naissance du dernier enfant");
// cy.get("form > :nth-child(4) > .fr-label").should("contain", "Département");
// cy.get("form > :nth-child(5) > .fr-label").should("contain", "Date de prise de contact");
// cy.get("form > :nth-child(6) > .fr-label").should("contain", "Provenance du contact");
// });
// it("allows users to subscribe to the email list", () => {
// cy.get("#name").type("Mina")
// cy.get("#childNumber").type("2")
// cy.get('#select-\\:r8\\:').select("01 - Ain")
// })
// it("should write a comment", () => {
// cy.get("#comment").type("Ceci est un long message de test pour tester mon composant\nLe retour a la ligne se fait il correctement ?")
// })
// it("should click on button", () => {
// cy.get("form > .fr-btn").click()
// })
});
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
14 changes: 14 additions & 0 deletions cypress/support/component-index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>Components App</title>
<!-- Used by Next.js to inject CSS. -->
<div id="__next_css__DO_NOT_USE__"></div>
</head>
<body>
<div data-cy-root></div>
</body>
</html>
File renamed without changes.
1 change: 1 addition & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const customJestConfig = {
"@hooks": "<rootDir>/src/hooks",
"@modules": "<rootDir>/src/modules",
"@lib": "<rootDir>/src/lib",
"@pages": "<rootDir>/src/pages",
},
setupFilesAfterEnv: ["<rootDir>/jest-setup.ts"],
};
Expand Down
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"dependencies": {
"@apollo/client": "^3.7.5",
"@codegouvfr/react-dsfr": "^0.28.0",
"@codegouvfr/react-dsfr": "^0.33.1",
"@emotion/react": "^11.10.5",
"@emotion/server": "^11.10.0",
"@emotion/styled": "^11.10.5",
Expand All @@ -41,6 +41,7 @@
"@sentry/nextjs": "^6.17.9",
"@socialgouv/matomo-next": "^1.4.0",
"axios": "^1.2.4",
"cross-fetch": "^3.1.5",
"date-fns": "^2.29.3",
"graphql": "^16.6.0",
"husky": "^8.0.1",
Expand Down Expand Up @@ -68,8 +69,8 @@
"@storybook/testing-library": "^0.0.13",
"@swc-node/register": "^1.4.2",
"@swc/core": "^1.3.24",
"@testing-library/jest-dom": "^5.16.2",
"@testing-library/react": "^12.1.2",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^12.1.5",
"@types/node": "18.11.19",
"@types/react": "18.0.28",
"@types/react-dom": "18.0.10",
Expand Down
10 changes: 5 additions & 5 deletions src/__generated__/fragment-masking.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/__generated__/gql.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/__generated__/index.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 9 additions & 9 deletions src/utils/main.util.test.ts → src/__test__/main.util.test.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import { accompagnementEnumToString, dateFormattedToString, sortWidgetSourceByName } from './main.util';
import { accompagnementEnumToString, dateFormattedToString, sortWidgetSourceByName } from '../utils/main.util';
import { Enum_Contacts_Personne_Accompagnee, WidgetEpdsSources } from './../__generated__/graphql';

describe("main.util", () => {
describe("sortWidgetSourceByName", () => {
it("should sort source by name", () => {
const data: WidgetEpdsSources[] = [
{id: "1", nom:"siteWeb", created_at:"", updated_at:""},
{id: "2", nom:"abcSite", created_at:"", updated_at:""},
{id: "3", nom:"monSite", created_at:"", updated_at:""},
{ id: "1", nom: "siteWeb", created_at: "", updated_at: "" },
{ id: "2", nom: "abcSite", created_at: "", updated_at: "" },
{ id: "3", nom: "monSite", created_at: "", updated_at: "" },
]
const expected: WidgetEpdsSources[] = [
{id: "2", nom:"abcSite", created_at:"", updated_at:""},
{id: "3", nom:"monSite", created_at:"", updated_at:""},
{id: "1", nom:"siteWeb", created_at:"", updated_at:""},
{ id: "2", nom: "abcSite", created_at: "", updated_at: "" },
{ id: "3", nom: "monSite", created_at: "", updated_at: "" },
{ id: "1", nom: "siteWeb", created_at: "", updated_at: "" },
]
expect(sortWidgetSourceByName(data)).toEqual(expected);
})
})

describe("dateFormattedToString", ()=> {
describe("dateFormattedToString", () => {
it("should return date with dd/MM/yyyy format", () => {
const result = dateFormattedToString(new Date("2023-12-03 10:34:23"))
expect(result).toEqual("03/12/2023")
})
})

describe("dateFormattedToString", ()=> {
describe("dateFormattedToString", () => {
it("should return `Aidée` for enum Aidee", () => {
const result = accompagnementEnumToString(Enum_Contacts_Personne_Accompagnee.Aidee)
expect(result).toEqual("Aidée")
Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions pages/_app.tsx → src/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import '../styles/global.css';

import '../../styles/global.css';
import { useEffect } from "react";
import { useRouter } from "next/router";
import type { AppProps } from "next/app";
Expand Down Expand Up @@ -172,4 +171,4 @@ function App({ Component, pageProps }: AppProps) {
);
}

export default withAppEmotionCache(withDsfr(App));
export default withAppEmotionCache(withDsfr(App));
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pages/accessibilite.tsx → src/pages/accessibilite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Head from "next/head";

import { Alert } from "@codegouvfr/react-dsfr/Alert";

import { DeclarationAccessibilite } from "../src/components/DeclarationAccessibilite";
import { DeclarationAccessibilite } from "../components/DeclarationAccessibilite";

const Accessibilite: NextPage = () => {
return (
Expand Down
24 changes: 10 additions & 14 deletions pages/ajout-demande.tsx → src/pages/ajout-demande.tsx
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
import React, { Fragment, useEffect, useState } from "react";
import { useSession } from "next-auth/react";
import { useLazyQuery, useMutation } from '@apollo/client';
import { client } from "../apollo-client"
import { useMutation, useQuery } from '@apollo/client';
import { client } from "../utils/apollo-client"
import { useRouter } from "next/router";
import { useStyles } from "tss-react/dsfr";
import { LoggedState } from "../src/components/LoggedState";
import DatabaseApi from "../src/services/api/database";
import { LoggedState } from "../components/LoggedState";
import DatabaseApi from "../services/api/database";
import {
Enum_Contacts_Personne_Accompagnee,
Enum_Contacts_Type_De_Contact,
WidgetEpdsSources,
} from "../src/__generated__/graphql";
import { sortWidgetSourceByName } from "../src/utils/main.util";
import { Departement } from "../types/geogouv";
} from "../__generated__/graphql";
import { sortWidgetSourceByName } from "../utils/main.util";
import { Departement } from "../../types/geogouv";

import { SelectDepartment } from "../src/components/SelectDepartment";
import { SelectDepartment } from "../components/SelectDepartment";
import { Input } from "@codegouvfr/react-dsfr/Input";
import Select from "@codegouvfr/react-dsfr/Select";
import Button from "@codegouvfr/react-dsfr/Button";
import Alert from "@codegouvfr/react-dsfr/Alert";


export default function AjoutDemande() {
Expand All @@ -38,12 +37,9 @@ export default function AjoutDemande() {

useEffect(() => {
setLogged(status === "authenticated")

const getSourcesApi = async () => await getWidgetSourcesRequest()
getSourcesApi()
}, [status])

const [getWidgetSourcesRequest] = useLazyQuery(
useQuery(
DatabaseApi.GET_WIDGET_SOURCES, {
client: client,
onCompleted: (data) => setWidgetSources(sortWidgetSourceByName([...data.widgetEpdsSources])),
Expand Down Expand Up @@ -250,4 +246,4 @@ const ContactSupportComponent = ({ label, setSelectedContactSupport }: ContactSu
</fieldset >
</div >
)
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import NextAuth from 'next-auth'
import CredentialsProvider from 'next-auth/providers/credentials'
import axios from 'axios'
import { StrapiUser } from '../../../types/StrapiType';
import { StrapiUser } from '../../../../types/StrapiType';

export default NextAuth({
providers: [
CredentialsProvider({
name: 'Credentials',
credentials: {
email: { label: "Email", type: "text", placeholder: "[email protected]" },
password: { label: "Password", type: "password" }
password: { label: "Password", type: "password" }
},
async authorize(credentials) {
async authorize(credentials) {
try {
const { data } = await axios.post(`${process.env.NEXT_PUBLIC_API_URL}/auth/local`, {
identifier: credentials?.email,
Expand All @@ -34,21 +34,21 @@ export default NextAuth({
},

callbacks: {
async jwt({ token, user, account, profile, isNewUser }) {
async jwt({ token, user, account, profile, isNewUser }) {
const strapiUser = user as StrapiUser
if(strapiUser) {
if (strapiUser) {
token.user = strapiUser.user
token.jwt = strapiUser.jwt
}
if(account) token.account = account
if(profile) token.profile = profile
if (account) token.account = account
if (profile) token.profile = profile

return token
},
async session({ session, token, user }) {
if(token) session.token = token
if(user) session.user = user
async session({ session, token, user }) {
if (token) session.token = token

if (user) session.user = user
else session.user = token.user

return session
Expand Down
2 changes: 1 addition & 1 deletion pages/cgu.tsx → src/pages/cgu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import Head from "next/head";

import { Alert } from "@codegouvfr/react-dsfr/Alert";

import { MentionPart } from "../src/components/MentionPart";
import { MentionPart } from "../components/MentionPart";

const Cgu: NextPage = () => {
return (
Expand Down
File renamed without changes.
5 changes: 2 additions & 3 deletions pages/index.tsx → src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from "react";
import Head from "next/head";
import { NextPage } from "next";

import { LoggedState } from "../src/components/LoggedState";
import { LoggedState } from "../components/LoggedState";

const Home: NextPage = () => {
return (
Expand Down Expand Up @@ -38,4 +37,4 @@ const Home: NextPage = () => {
);
};

export default Home;
export default Home;
Loading

0 comments on commit cffc155

Please sign in to comment.