Skip to content

Commit

Permalink
feat(contrib): affichage de la réponse CDT dès le début pour essayer …
Browse files Browse the repository at this point in the history
…d'améliorer le SEO (#5442)
  • Loading branch information
carolineBda authored Nov 20, 2023
1 parent 81ea2f5 commit 311b967
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 109 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const ContributionGeneric = ({ answers, content, slug }) => {

const hasConventionAnswers =
answers.conventions && answers.conventions.length > 0;
const [showAnswer, setShowAnswer] = useState(false);
const [hasNoEnterpriseSelected, setHasNoEnterpriseSelected] = useState(false);
const [entreprise, setEnterprise] = useState<Enterprise | undefined>();

Expand Down Expand Up @@ -97,24 +96,14 @@ const ContributionGeneric = ({ answers, content, slug }) => {

setConvention(agreement);
setEnterprise(enterprise);
if (agreementTreated) {
setShowAnswer(false);
}
};

const CC_NOT_SUPPORTED = (
<>
<Paragraph variant="primary" fontSize="default" fontWeight="700" noMargin>
Nous n’avons pas de réponse pour cette convention collective
</Paragraph>
{showAnswer ? (
<p>Vous pouvez consulter les informations générales ci-dessous.</p>
) : (
<p>
Vous pouvez tout de même poursuivre pour obtenir les informations
générales.
</p>
)}
<p>Vous pouvez consulter les informations générales ci-dessous.</p>
</>
);

Expand Down Expand Up @@ -215,7 +204,7 @@ const ContributionGeneric = ({ answers, content, slug }) => {
)}

<Div>
{isSupported(convention) ? (
{isSupported(convention) && (
<Button
variant="primary"
onClick={() => {
Expand All @@ -231,58 +220,13 @@ const ContributionGeneric = ({ answers, content, slug }) => {
Afficher les informations
<StyledDirectionRightIcon />
</Button>
) : (
<>
{(!showAnswer || convention) && (
<Button
variant="primary"
onClick={() => {
matopush([
MatomoBaseEvent.TRACK_EVENT,
"contribution",
convention
? "click_afficher_les_informations_générales"
: "click_afficher_les_informations_sans_CC",
getTitle(),
]);
setShowAnswer(true);
scrollToTitle();
}}
>
Afficher les informations {convention && " générales"}
</Button>
)}
</>
)}
</Div>
</Wrapper>

{!showAnswer && !convention && (
<p>
<Button
variant="navLink"
onClick={() => {
pushAgreementEvents(
getTitle(),
{ route: "not-selected" },
false,
false
);
setShowAnswer(true);
scrollToTitle();
}}
>
<ArrowLink arrowPosition="left">
Accéder aux informations générales sans renseigner ma
convention collective
</ArrowLink>
</Button>
</p>
)}
</SectionNoPadding>
</>
)}
<SectionHidden show={showAnswer && answers.generic}>
<SectionHidden show={answers.generic}>
<Title stripe="left" ref={titleRef}>
Que dit le code du travail&nbsp;?
</Title>
Expand Down Expand Up @@ -355,7 +299,7 @@ const HideOnMobile = styled.span`
}
`;
const SectionHidden = styled(Section)`
display: ${({ show }) => (show ? "block" : "none")};
display: block;
`;
const Div = styled.div`
text-align: center;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ describe("<ContributionGeneric />", () => {
expect(ui.agreement1351.searchResult.query()).toBeInTheDocument()
);
fireEvent.click(ui.agreement1351.searchResult.get());
expect(byText(/Afficher les informations/).get()).toBeInTheDocument();
expect(byText(/Afficher les informations/).query()).not.toBeInTheDocument();
expect(matopush).toHaveBeenCalledTimes(4);
// @ts-ignore
expect(matopush.mock.calls).toEqual([
Expand All @@ -134,14 +134,6 @@ describe("<ContributionGeneric />", () => {
[["trackEvent", "cc_select_p1", "/contribution/my-contrib", "idcc1351"]],
[["trackEvent", "outil", "cc_select_non_traitée", 1351]],
]);
fireEvent.click(byText("Afficher les informations générales").get());
expect(matopush).toHaveBeenCalledTimes(5);
expect(matopush).toHaveBeenLastCalledWith([
"trackEvent",
"contribution",
"click_afficher_les_informations_générales",
"/contribution/my-contrib",
]);
expect(router.push).toHaveBeenCalledTimes(0);
});
it("je ne connais pas ma CC", async () => {
Expand Down Expand Up @@ -198,44 +190,4 @@ describe("<ContributionGeneric />", () => {
[["trackEvent", "outil", "cc_select_non_traitée", 2216]],
]);
});
it("afficher les infos - sans CC", async () => {
expect(matopush).toHaveBeenCalledTimes(0);

render(
<ContributionGeneric slug="my-contrib" answers={ANSWERS} content={{}} />
);
expect(byText(/Afficher les informations/).get()).toBeInTheDocument();
fireEvent.click(byText("Afficher les informations").get());
expect(matopush).toHaveBeenCalledTimes(1);
expect(matopush).toHaveBeenLastCalledWith([
"trackEvent",
"contribution",
"click_afficher_les_informations_sans_CC",
"/contribution/my-contrib",
]);
expect(router.push).toHaveBeenCalledTimes(0);
});

it("voir les infos générales", () => {
expect(matopush).toHaveBeenCalledTimes(0);

render(
<ContributionGeneric slug="my-contrib" answers={ANSWERS} content={{}} />
);

fireEvent.click(
byText(
"Accéder aux informations générales sans renseigner ma convention collective"
).get()
);

expect(matopush).toHaveBeenCalledTimes(1);
expect(matopush).toHaveBeenCalledWith([
"trackEvent",
"cc_search_type_of_users",
"click_p3",
"/contribution/my-contrib",
]);
expect(router.push).toHaveBeenCalledTimes(0);
});
});

0 comments on commit 311b967

Please sign in to comment.