-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(DSFR): migration des pages fiches service public #6277
Merged
Merged
Changes from all commits
Commits
Show all changes
37 commits
Select commit
Hold shift + click to select a range
5f973f2
feat(DSFR): migration des pages fiches service public
carolineBda b1201b3
Merge branch 'dev' into carolineBda/dsfr-fiche-SP
carolineBda 214c28e
implement rest of it
carolineBda 8805627
ts
carolineBda 1263598
add types
carolineBda 7bbcd7b
more typing
carolineBda c6ec94e
add tests
carolineBda 0c2f531
update types
carolineBda 3c5a189
fix test
carolineBda db6bcab
fix spec
carolineBda 5d89d64
prise en compte des retours suite à la réu design
carolineBda e2048a2
ne pas afficher de sous accordéons à partir du 3eme niveau
carolineBda 4db2633
fix
carolineBda cb36953
clean
carolineBda 3744e0f
clean
carolineBda dc63452
do not show accordion for BlocCas (broken with AccordionWithAnchor)
carolineBda 4b760c7
fix test + put back canonical
carolineBda c53d2d6
clean up
carolineBda ce3e9d5
Merge branch 'dev' into carolineBda/dsfr-fiche-SP
m-maillot 41a28b9
duplicate Builder to avoid conflicts with old code
m-maillot 81eb58c
fix types
m-maillot 91859c7
Merge branch 'dev' into carolineBda/dsfr-fiche-SP
m-maillot 7677801
Merge branch 'dev' into carolineBda/dsfr-fiche-SP
carolineBda 130e63d
fix accordion group
carolineBda c971bad
fix accordion
carolineBda cec076f
Merge branch 'dev' into carolineBda/dsfr-fiche-SP
carolineBda b217376
fix refs
carolineBda 356a6cf
fix padding list
carolineBda 7e14b10
fix test
carolineBda ae36367
fix accordion in tabs
carolineBda 35f1e89
fix fix
carolineBda 8bd3e8c
Merge branch 'dev' into carolineBda/dsfr-fiche-SP
carolineBda 3db36f8
fix accordion with id
carolineBda 754c199
add more test
carolineBda d4a6390
update margins
carolineBda 48b72df
remove use client
carolineBda 711f16f
update test
carolineBda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
packages/code-du-travail-frontend/app/fiche-service-public/[slug]/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React from "react"; | ||
import { notFound } from "next/navigation"; | ||
import { DsfrLayout } from "../../../src/modules/layout"; | ||
import { fetchFicheSP } from "../../../src/modules/fiche-service-public/queries"; | ||
import { fetchRelatedItems } from "../../../src/modules/documents"; | ||
import { generateDefaultMetadata } from "../../../src/modules/common/metas"; | ||
import { getRouteBySource, SOURCES } from "@socialgouv/cdtn-utils"; | ||
import { FicheServicePublicContainer } from "../../../src/modules/fiche-service-public/FicheServicePublicContainer"; | ||
|
||
export async function generateMetadata({ params }) { | ||
const { title, description, url } = await getFiche(params.slug); | ||
|
||
return generateDefaultMetadata({ | ||
title: title, | ||
description: description, | ||
path: `/${getRouteBySource(SOURCES.SHEET_SP)}/${params.slug}`, | ||
overrideCanonical: url, | ||
}); | ||
} | ||
|
||
async function Fiche({ params }) { | ||
const { | ||
_id, | ||
breadcrumbs, | ||
date, | ||
description, | ||
raw, | ||
referencedTexts, | ||
title, | ||
url, | ||
} = await getFiche(params.slug); | ||
const relatedItems = await fetchRelatedItems({ _id }, params.slug); | ||
|
||
return ( | ||
<DsfrLayout> | ||
<FicheServicePublicContainer | ||
title={title} | ||
relatedItems={relatedItems} | ||
date={date} | ||
url={url} | ||
metaDescription={description} | ||
raw={raw} | ||
breadcrumbs={breadcrumbs} | ||
referencedTexts={referencedTexts} | ||
/> | ||
</DsfrLayout> | ||
); | ||
} | ||
|
||
const getFiche = async (slug: string) => { | ||
const fiche = await fetchFicheSP(slug); | ||
|
||
if (!fiche) { | ||
return notFound(); | ||
} | ||
return fiche; | ||
}; | ||
|
||
export default Fiche; |
29 changes: 29 additions & 0 deletions
29
packages/code-du-travail-frontend/cypress/integration/light/fiche-service-public.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
describe("Fiche Service public", () => { | ||
it("je vois une page fiche service public", () => { | ||
cy.visit("/fiche-service-public/salaire-primes-et-avantages"); | ||
cy.findAllByRole("heading", { level: 1 }).should( | ||
"have.text", | ||
"Salaire, primes et avantages" | ||
); | ||
cy.get("head > link[rel='canonical']") | ||
.should("have.prop", "href") | ||
.and( | ||
"equal", | ||
"https://www.service-public.fr/particuliers/vosdroits/F2301" | ||
); | ||
|
||
cy.contains("a", "Fiche service-public.fr") | ||
.should("have.attr", "href") | ||
.and( | ||
"contain", | ||
"https://www.service-public.fr/particuliers/vosdroits/F2301" | ||
); | ||
cy.get("body").should("contain", "01/11/2024"); | ||
cy.get("h2").first().should("contain", "Salaire"); | ||
}); | ||
|
||
it("je vois une fiche service public avec un accordéon ouvert", () => { | ||
cy.visit("/fiche-service-public/salaire-primes-et-avantages#salaire"); | ||
cy.get("h2").get('[aria-expanded="true"]').should("contain", "Salaire"); | ||
}); | ||
}); |
13 changes: 0 additions & 13 deletions
13
packages/code-du-travail-frontend/cypress/integration/light/landing-pages.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 0 additions & 77 deletions
77
packages/code-du-travail-frontend/pages/fiche-service-public/[slug].tsx
This file was deleted.
Oops, something went wrong.
51 changes: 51 additions & 0 deletions
51
packages/code-du-travail-frontend/src/modules/common/ReferencesList.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import React from "react"; | ||
import { ServicePublicReference } from "@socialgouv/cdtn-types"; | ||
import { getRouteBySource, SOURCES } from "@socialgouv/cdtn-utils"; | ||
import { fr } from "@codegouvfr/react-dsfr"; | ||
|
||
export const ReferenceList = ({ | ||
references, | ||
}: { | ||
references: ServicePublicReference[]; | ||
}) => { | ||
const formattedRefs = references | ||
.map((ref) => { | ||
switch (ref.type) { | ||
case SOURCES.CDT: | ||
return ( | ||
<a | ||
key={ref.slug + ref.title} | ||
href={`/${getRouteBySource(SOURCES.CDT)}/${ref.slug}`} | ||
>{`Article ${ref.title} du Code du travail`}</a> | ||
); | ||
case SOURCES.CCN: | ||
return ( | ||
<a | ||
key={ref.slug + ref.title} | ||
href={`/${getRouteBySource(SOURCES.CCN)}/${ref.slug}`} | ||
>{`Convention collective: ${ref.title}`}</a> | ||
); | ||
case SOURCES.EXTERNALS: | ||
return ( | ||
<a | ||
key={ref.url + ref.title} | ||
href={ref.url} | ||
target="_blank" | ||
rel="noreferer noopener" | ||
>{`Convention collective: ${ref.title}`}</a> | ||
); | ||
} | ||
}) | ||
.filter((item) => item !== null); | ||
return ( | ||
<ul> | ||
{formattedRefs.map((item) => { | ||
return ( | ||
<li key={item.key}> | ||
<p className={fr.cx("fr-mb-0")}>{item}</p> | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
); | ||
}; |
84 changes: 84 additions & 0 deletions
84
packages/code-du-travail-frontend/src/modules/common/__tests__/ReferenceList.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { render } from "@testing-library/react"; | ||
import React from "react"; | ||
import { ReferenceList } from "../ReferencesList"; | ||
import { ServicePublicReference } from "@socialgouv/cdtn-types"; | ||
|
||
const references = [ | ||
{ | ||
slug: "l2323-4", | ||
title: "L2323-4", | ||
type: "code_du_travail", | ||
}, | ||
{ | ||
title: "Article yyy du JO", | ||
type: "external", | ||
url: "https://article.jo/yyy", | ||
}, | ||
{ | ||
title: "CCN metallurgie", | ||
type: "external", | ||
url: "https://legifrance/ccn-metallurgie", | ||
}, | ||
{ | ||
slug: "123-automobile", | ||
title: "automobile", | ||
type: "conventions_collectives", | ||
}, | ||
{ | ||
slug: "l1234-3", | ||
title: "L1234-3", | ||
type: "code_du_travail", | ||
}, | ||
]; | ||
|
||
describe("<ReferenceList />", () => { | ||
it("should render", () => { | ||
const { container, getByText } = render( | ||
<ReferenceList references={references as ServicePublicReference[]} /> | ||
); | ||
expect(getByText("Article L2323-4 du Code du travail").tagName).toEqual( | ||
"A" | ||
); | ||
expect(getByText("Article L2323-4 du Code du travail")).toHaveAttribute( | ||
"href", | ||
"/code-du-travail/l2323-4" | ||
); | ||
|
||
expect( | ||
getByText("Convention collective: Article yyy du JO").tagName | ||
).toEqual("A"); | ||
expect( | ||
getByText("Convention collective: Article yyy du JO") | ||
).toHaveAttribute("href", "https://article.jo/yyy"); | ||
expect( | ||
getByText("Convention collective: Article yyy du JO") | ||
).toHaveAttribute("target", "_blank"); | ||
expect( | ||
getByText("Convention collective: Article yyy du JO") | ||
).toHaveAttribute("rel", "noreferer noopener"); | ||
|
||
expect(getByText("Convention collective: CCN metallurgie").tagName).toEqual( | ||
"A" | ||
); | ||
expect(getByText("Convention collective: CCN metallurgie")).toHaveAttribute( | ||
"href", | ||
"https://legifrance/ccn-metallurgie" | ||
); | ||
expect(getByText("Convention collective: CCN metallurgie")).toHaveAttribute( | ||
"target", | ||
"_blank" | ||
); | ||
expect(getByText("Convention collective: CCN metallurgie")).toHaveAttribute( | ||
"rel", | ||
"noreferer noopener" | ||
); | ||
|
||
expect(getByText("Convention collective: automobile").tagName).toEqual("A"); | ||
expect(getByText("Convention collective: automobile")).toHaveAttribute( | ||
"href", | ||
"/convention-collective/123-automobile" | ||
); | ||
|
||
expect(container).toMatchSnapshot(); | ||
}); | ||
}); |
67 changes: 67 additions & 0 deletions
67
...u-travail-frontend/src/modules/common/__tests__/__snapshots__/ReferenceList.test.tsx.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<ReferenceList /> should render 1`] = ` | ||
<div> | ||
<ul> | ||
<li> | ||
<p | ||
class="fr-mb-0" | ||
> | ||
<a | ||
href="/code-du-travail/l2323-4" | ||
> | ||
Article L2323-4 du Code du travail | ||
</a> | ||
</p> | ||
</li> | ||
<li> | ||
<p | ||
class="fr-mb-0" | ||
> | ||
<a | ||
href="https://article.jo/yyy" | ||
rel="noreferer noopener" | ||
target="_blank" | ||
> | ||
Convention collective: Article yyy du JO | ||
</a> | ||
</p> | ||
</li> | ||
<li> | ||
<p | ||
class="fr-mb-0" | ||
> | ||
<a | ||
href="https://legifrance/ccn-metallurgie" | ||
rel="noreferer noopener" | ||
target="_blank" | ||
> | ||
Convention collective: CCN metallurgie | ||
</a> | ||
</p> | ||
</li> | ||
<li> | ||
<p | ||
class="fr-mb-0" | ||
> | ||
<a | ||
href="/convention-collective/123-automobile" | ||
> | ||
Convention collective: automobile | ||
</a> | ||
</p> | ||
</li> | ||
<li> | ||
<p | ||
class="fr-mb-0" | ||
> | ||
<a | ||
href="/code-du-travail/l1234-3" | ||
> | ||
Article L1234-3 du Code du travail | ||
</a> | ||
</p> | ||
</li> | ||
</ul> | ||
</div> | ||
`; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:'(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
J'aurais testé les fonctionnalités et les labels soient correctes selon le type de la référence.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pas bloquant du tout :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t'as raison 👍 j'ai mis à jour