Skip to content

Commit

Permalink
fix(convention collectives): fix de la generation du slug pour les CC…
Browse files Browse the repository at this point in the history
… qui sont créés (#1486)
  • Loading branch information
carolineBda authored Oct 7, 2024
1 parent b899de3 commit 061e7da
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import { mapAgreementToDocument } from "../mapAgreementToDocument";
import { Agreement } from "../type";

jest.mock("../../common/getGlossaryContent.ts", () => {
return {
getGlossaryContent: jest.fn(() => "mocked-glossary-content"),
};
});

describe("mapAgreementToDocument", () => {
const agreement: Agreement = {
id: "1234",
isSupported: false,
name: "Ma nouvelle CC du 03 Octobre 2024",
shortName: "Ma nouvelle CC",
synonyms: [],
updatedAt: "3/10/2024",
};

it("crée un nouveau document si pas de doc", async () => {
const result = await mapAgreementToDocument(agreement);
expect(result).toEqual({
cdtn_id: "6f8c4cc14e",
document: {
num: 1234,
shortTitle: "Ma nouvelle CC",
synonymes: [],
},
initial_id: "1234",
is_available: true,
is_published: false,
is_searchable: false,
meta_description: "IDCC 1234: Ma nouvelle CC du 03 Octobre 2024",
slug: "1234-ma-nouvelle-cc",
source: "conventions_collectives",
text: "IDCC 1234: Ma nouvelle CC du 03 Octobre 2024 Ma nouvelle CC",
title: "Ma nouvelle CC du 03 Octobre 2024",
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const mapAgreementToDocument = (
meta_description: `IDCC ${data.id}: ${data.name}`,
title: data.name,
text: `IDCC ${data.id}: ${data.name} ${data.shortName}`,
slug: document?.slug ?? slugify(data.shortName),
slug: document?.slug ?? `${data.id}-${slugify(data.shortName)}`,
is_searchable: document
? document.is_searchable
: data.kali_id !== undefined,
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
UPDATE public.documents
SET slug = '2707-batiment-etam-ile-de-france-hors-seine-et-marne'
WHERE slug = 'batiment-etam-ile-de-france-hors-seine-et-marne';

UPDATE public.documents
SET slug = '3251-bijouterie-joaillerie-orfevrerie-horlogerie-bjoh'
WHERE slug = 'bijouterie-joaillerie-orfevrerie-horlogerie-bjoh';

0 comments on commit 061e7da

Please sign in to comment.