Skip to content

Commit

Permalink
chore: TU fix
Browse files Browse the repository at this point in the history
  • Loading branch information
victor committed Jan 8, 2025
1 parent e9cd917 commit e903723
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export async function generateMetadata({ params }) {
});
}

async function Fiche({ params }) {
async function Contribution({ params }) {
const { _id, ...source } = await getContribution(params.slug);
const relatedItems = await fetchRelatedItems({ _id }, params.slug);
return (
Expand All @@ -37,4 +37,4 @@ const getContribution = async (slug: string) => {
return contribution;
};

export default Fiche;
export default Contribution;
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export function ContributionLayout({ relatedItems, contribution }: Props) {
| ElasticSearchContributionConventionnelle
}
titleLevel={2}
></ContributionContent>
/>
{contribution.references.length && (
<Accordion label="Références">
<ListWithArrow
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { render } from "@testing-library/react";
import React from "react";

import PageContribution from "../pages/contribution/[slug]";
import { ContributionLayout } from "../ContributionLayout";
import { ElasticSearchContribution } from "@socialgouv/cdtn-types";

const contribution = {
Expand All @@ -15,12 +15,13 @@ const contribution = {
},
title: "La période d’essai peut-elle être renouvelée ?",
breadcrumbs: [],
slug: "slug",
} as Partial<ElasticSearchContribution> as any;

describe("<PageContribution />", () => {
it("should render title with cc name in it", () => {
const { getByRole } = render(
<PageContribution contribution={contribution} />
<ContributionLayout contribution={contribution} relatedItems={[]} />
);
const titreH1 = getByRole("heading", { level: 1 });
expect(titreH1.textContent).toBe(
Expand All @@ -30,29 +31,11 @@ describe("<PageContribution />", () => {
it("should render title with only question", () => {
contribution.ccnShortTitle = "Ce short title fait plus de 15 caractères";
const { getByRole } = render(
<PageContribution contribution={contribution} />
<ContributionLayout contribution={contribution} relatedItems={[]} />
);
const titreH1 = getByRole("heading", { level: 1 });
expect(titreH1.textContent).toBe(
"La période d’essai peut-elle être renouvelée ?"
);
});
it("should render title with linked content with no description", () => {
let contribution = {
source: "contributions",
linkedContent: [{ source: "", title: "My link", slug: "" }],
references: [],
idcc: "",
metas: {
title: "SEO Title",
description: "SEO Description",
},
title: "La période d’essai peut-elle être renouvelée ?",
} as any;
const { getByRole } = render(
<PageContribution contribution={contribution} />
);
const titreH3 = getByRole("heading", { level: 3 });
expect(titreH3.textContent).toBe("My link");
});
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { render, RenderResult } from "@testing-library/react";
import React from "react";
import { EnterpriseAgreementSelection } from "../EnterpriseAgreementSelectionLink";
import { EnterpriseAgreementSelectionLink } from "../EnterpriseAgreementSelectionLink";
import { ui } from "./ui";
import { sendEvent } from "../../../utils";
import { UserAction } from "src/common";
Expand Down Expand Up @@ -51,7 +51,7 @@ describe("Trouver sa CC - recherche par nom d'entreprise CC", () => {
let userAction: UserAction;
it("Vérifier l'affichage de la selection", async () => {
rendering = render(
<EnterpriseAgreementSelection enterprise={defaultEnterprise} />
<EnterpriseAgreementSelectionLink enterprise={defaultEnterprise} />
);
userAction = new UserAction();
expect(
Expand Down Expand Up @@ -91,7 +91,7 @@ describe("Trouver sa CC - recherche par nom d'entreprise CC", () => {

it("Vérifier l'affichage de la selection avec une CC sans slug", async () => {
rendering = render(
<EnterpriseAgreementSelection
<EnterpriseAgreementSelectionLink
enterprise={{
...defaultEnterprise,
conventions: [
Expand All @@ -113,7 +113,7 @@ describe("Trouver sa CC - recherche par nom d'entreprise CC", () => {

it("Vérifier l'affichage de la selection avec une CC sans url et contribution", async () => {
rendering = render(
<EnterpriseAgreementSelection
<EnterpriseAgreementSelectionLink
enterprise={{
...defaultEnterprise,
conventions: [
Expand All @@ -136,7 +136,10 @@ describe("Trouver sa CC - recherche par nom d'entreprise CC", () => {

it("Vérifier l'affichage de la selection en widgetMode", async () => {
rendering = render(
<EnterpriseAgreementSelection enterprise={defaultEnterprise} widgetMode />
<EnterpriseAgreementSelectionLink
enterprise={defaultEnterprise}
widgetMode
/>
);
expect(
ui.enterpriseAgreementSelection.agreement.IDCC2216.link.query()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ describe("Trouver sa CC - recherche par nom d'entreprise CC", () => {
expect(sendEvent).toHaveBeenLastCalledWith({
action: "Trouver sa convention collective",
category: "enterprise_select",
name: JSON.stringify(enterprise),
name: JSON.stringify({
label: enterprise.label,
siren: enterprise.siren,
}),
});
userAction.click(ui.enterpriseAgreementSearch.buttonPrevious.get());
expect(sendEvent).toHaveBeenCalledTimes(4);
Expand Down

0 comments on commit e903723

Please sign in to comment.