Merge pull request 'fix(tests): corrige 3 suites Mocha DB révélées par leur 1er run sur main' (#17) from fix/mocha-db-suites-first-run into main
All checks were successful
CI / lint (push) Successful in 1m40s
CI / build (push) Successful in 1m51s
CI / e2e (push) Successful in 7m29s
CI / intent-service-test (push) Successful in 11m4s
CI / test (push) Successful in 20m19s

Reviewed-on: #17
This commit is contained in:
kyuno 2026-08-29 12:02:03 +02:00
commit 927051793c
3 changed files with 57 additions and 35 deletions

View file

@ -286,8 +286,18 @@ describe("Admin tech-steps triage", () => {
} }
this.timeout(60000); this.timeout(60000);
const agent = await adminAgent(); const agent = await adminAgent();
const first = agent.post("/admin/tech-steps/retrain").send({}); // supertest requests are lazy — they only dispatch when awaited/then'd.
// Let the first handler acquire the process-wide lock before the second starts. // Attaching the `.then` here is what actually fires the first request,
// so its handler acquires the process-wide lock before the second one
// (100ms later) checks it. Swallow its result/rejection — this test
// only asserts on the second request.
const first = agent
.post("/admin/tech-steps/retrain")
.send({})
.then(
(res) => res,
(err) => err,
);
await new Promise((resolve) => setTimeout(resolve, 100)); await new Promise((resolve) => setTimeout(resolve, 100));
const second = await agent.post("/admin/tech-steps/retrain").send({}); const second = await agent.post("/admin/tech-steps/retrain").send({});
expect(second.status).to.equal(409); expect(second.status).to.equal(409);

View file

@ -105,17 +105,16 @@ describe("Cooking session", () => {
const pieceId = await unitId("piece"); const pieceId = await unitId("piece");
const chopId = await techStepId("chop"); const chopId = await techStepId("chop");
const simmerId = await techStepId("simmer"); const simmerId = await techStepId("simmer");
const mixId = await techStepId("mix");
/** A recipe: one pure-prep "chop onion" step, then one simmer step. */ /**
async function makeRecipe(name: string, onionQty: number) { * A recipe: one pure-prep "chop onion" step, then (optionally) an
return prisma.recipe.create({ * active "mix" step, then one simmer step. The `withActiveStep` recipe
data: { * is still doing hands-on work in the phase after its simmer starts, so
name, * the other recipe's simmer floats into that phase as `background`.
authorId, */
portions: 4, async function makeRecipe(name: string, onionQty: number, withActiveStep = false) {
steps: { const chopStep = {
create: [
{
order: 0, order: 0,
description: "Émincer les oignons", description: "Émincer les oignons",
techSteps: { techSteps: {
@ -137,20 +136,31 @@ describe("Cooking session", () => {
}, },
], ],
}, },
}, };
{ const activeStep = {
order: 1, order: 1,
description: "Mélanger l'appareil",
techSteps: { create: [{ techStepId: mixId, order: 0 }] },
};
const simmerStep = {
order: withActiveStep ? 2 : 1,
description: "Faire mijoter", description: "Faire mijoter",
techSteps: { create: [{ techStepId: simmerId, order: 0 }] }, techSteps: { create: [{ techStepId: simmerId, order: 0 }] },
}, };
], return prisma.recipe.create({
data: {
name,
authorId,
portions: 4,
steps: {
create: withActiveStep ? [chopStep, activeStep, simmerStep] : [chopStep, simmerStep],
}, },
}, },
}); });
} }
const soupe = await makeRecipe("Soupe", 2); const soupe = await makeRecipe("Soupe", 2);
const tarte = await makeRecipe("Tarte", 3); const tarte = await makeRecipe("Tarte", 3, true);
const planning = await prisma.planning.create({ const planning = await prisma.planning.create({
data: { data: {

View file

@ -95,6 +95,8 @@ describe("Reference data", () => {
"reproducible", "reproducible",
"allergens", "allergens",
"diets", "diets",
"isPlaceholder",
"displayName",
]); ]);
}); });