Some checks failed
Calque le pattern « ingrédient hors-catalogue » sur `TechStep` : cinq colonnes additives (`isPlaceholder`/`displayName`/`createdById`/`createdAt`/ `reviewedAt`), migration purement additive, FK `createdById → user_profiles` en `SET NULL`. Correction d'étape : `submitTechStepCorrectionSchema` accepte `correctedTechStepName` (mutuellement exclusif de `correctedTechStepId`) ; `submitTechStepCorrection` crée une `TechStep` placeholder dans la transaction et poursuit comme si son id avait été fourni. La correction s'applique immédiatement (`source: manual`) ; nouvel event analytics `tech_step.placeholder_proposed`. `TechStepView` gagne `isPlaceholder`/`displayName` ; `GET /reference/tech-steps` exclut les placeholders. Nouveau helper web `techStepLabel` (`displayName ?? t(catalog.techSteps.<key>)`), utilisé par `StepDescription` et le popover. Le popover a une échappatoire « Ma technique n'est pas dans la liste » (champ libre). Admin : `admin-tech-step-catalog.service.ts` + routes `GET/PATCH /admin/api/catalog/tech-step-placeholders` (liste plate — les propositions de technique sont rares) ; `CatalogPage` gagne un sélecteur Ingrédients / Techniques. Tests : Mocha (proposition placeholder, rejet id+nom, exclusion catalogue, liste + mark-reviewed admin) + Cypress (composant popover, e2e admin catalogue). Assertions `.techStep` existantes mises à jour pour les 2 nouveaux champs. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
138 lines
4.5 KiB
TypeScript
138 lines
4.5 KiB
TypeScript
// Mocks the admin API via cy.intercept — no live backend.
|
|
|
|
const adminBody = {
|
|
id: 1,
|
|
email: "ops@example.com",
|
|
name: "Ops",
|
|
createdAt: "2026-08-01T00:00:00.000Z",
|
|
lastLoginAt: "2026-08-28T09:00:00.000Z",
|
|
};
|
|
|
|
function pendingGroups() {
|
|
return [
|
|
{
|
|
normalizedName: "piment d espelette",
|
|
displayNames: ["Piment d'Espelette", "piment d espelette"],
|
|
ingredientIds: [11, 12],
|
|
recipeCount: 2,
|
|
sampleRecipes: [
|
|
{ id: 1, name: "Poulet basquaise" },
|
|
{ id: 2, name: "Piperade" },
|
|
],
|
|
firstSeenAt: "2026-08-20T10:00:00.000Z",
|
|
allReviewed: false,
|
|
},
|
|
{
|
|
normalizedName: "sumac",
|
|
displayNames: ["Sumac"],
|
|
ingredientIds: [13],
|
|
recipeCount: 1,
|
|
sampleRecipes: [{ id: 3, name: "Fattoush" }],
|
|
firstSeenAt: "2026-08-22T10:00:00.000Z",
|
|
allReviewed: false,
|
|
},
|
|
];
|
|
}
|
|
|
|
describe("Admin catalog — off-catalog ingredients", () => {
|
|
beforeEach(() => {
|
|
cy.viewport(1400, 900);
|
|
cy.intercept("GET", "**/admin/api/auth/me", { statusCode: 200, body: adminBody });
|
|
});
|
|
|
|
it("lists placeholder groups newest-impact first with their recipe count and spelling variants", () => {
|
|
cy.intercept("GET", "**/admin/api/catalog/placeholders*", {
|
|
statusCode: 200,
|
|
body: pendingGroups(),
|
|
}).as("getPlaceholders");
|
|
cy.visit("/admin/catalogue");
|
|
cy.wait("@getPlaceholders");
|
|
|
|
cy.get(".catalog-card").should("have.length", 2);
|
|
cy.get(".catalog-card").first().should("contain.text", "Piment d'Espelette");
|
|
cy.contains(".catalog-card", "Piment d'Espelette")
|
|
.should("contain.text", "2 recette")
|
|
.and("contain.text", "piment d espelette")
|
|
.and("contain.text", "Poulet basquaise");
|
|
});
|
|
|
|
it("marks a group reviewed and reloads the list", () => {
|
|
cy.intercept("GET", "**/admin/api/catalog/placeholders*", {
|
|
statusCode: 200,
|
|
body: pendingGroups(),
|
|
}).as("getPlaceholders");
|
|
cy.intercept("PATCH", "**/admin/api/catalog/placeholders/mark-reviewed", {
|
|
statusCode: 200,
|
|
body: { reviewed: 1 },
|
|
}).as("markReviewed");
|
|
|
|
cy.visit("/admin/catalogue");
|
|
cy.wait("@getPlaceholders");
|
|
|
|
cy.contains(".catalog-card", "Sumac").contains("button", "Marquer comme traité").click();
|
|
|
|
cy.wait("@markReviewed")
|
|
.its("request.body")
|
|
.should("deep.equal", { ingredientIds: [13] });
|
|
// The page re-fetches the list after the PATCH.
|
|
cy.get("@getPlaceholders.all").should("have.length.greaterThan", 1);
|
|
});
|
|
|
|
it("switches to the Techniques kind and lists proposed missing techniques (issue #130)", () => {
|
|
cy.intercept("GET", "**/admin/api/catalog/placeholders*", { statusCode: 200, body: [] });
|
|
cy.intercept("GET", "**/admin/api/catalog/tech-step-placeholders*", {
|
|
statusCode: 200,
|
|
body: [
|
|
{
|
|
id: 5,
|
|
displayName: "Flamber au chalumeau",
|
|
createdAt: "2026-09-01T10:00:00.000Z",
|
|
reviewedAt: null,
|
|
recipeCount: 2,
|
|
sampleRecipes: [
|
|
{ id: 1, name: "Crème brûlée" },
|
|
{ id: 2, name: "Tarte flambée" },
|
|
],
|
|
},
|
|
],
|
|
}).as("getTechStepPlaceholders");
|
|
cy.intercept("PATCH", "**/admin/api/catalog/tech-step-placeholders/mark-reviewed", {
|
|
statusCode: 200,
|
|
body: { reviewed: 1 },
|
|
}).as("markTechStepReviewed");
|
|
|
|
cy.visit("/admin/catalogue");
|
|
cy.contains(".catalog-kinds button", "Techniques").click();
|
|
cy.wait("@getTechStepPlaceholders");
|
|
|
|
cy.contains(".catalog-card", "Flamber au chalumeau")
|
|
.should("contain.text", "2 recette")
|
|
.and("contain.text", "Crème brûlée");
|
|
|
|
cy.contains(".catalog-card", "Flamber au chalumeau")
|
|
.contains("button", "Marquer comme traité")
|
|
.click();
|
|
cy.wait("@markTechStepReviewed")
|
|
.its("request.body")
|
|
.should("deep.equal", { techStepIds: [5] });
|
|
});
|
|
|
|
it("switches to the reviewed archive tab", () => {
|
|
// Regex, not a glob: the two calls differ only by the `?reviewed=true`
|
|
// query, and minimatch's `?` is itself a wildcard — a glob can't tell
|
|
// them apart reliably.
|
|
cy.intercept("GET", /\/admin\/api\/catalog\/placeholders$/, {
|
|
statusCode: 200,
|
|
body: pendingGroups(),
|
|
});
|
|
cy.intercept("GET", /\/admin\/api\/catalog\/placeholders\?reviewed=true$/, {
|
|
statusCode: 200,
|
|
body: [],
|
|
}).as("getReviewed");
|
|
|
|
cy.visit("/admin/catalogue");
|
|
cy.contains(".catalog-tabs button", "Traités").click();
|
|
cy.wait("@getReviewed");
|
|
cy.contains("Aucun ingrédient hors-catalogue").should("be.visible");
|
|
});
|
|
});
|