Compare commits

..

No commits in common. "927051793cd12c0367c9839e52c29ab10c21c4b9" and "a33f641dc792a1806bf0a04c01d5886f0382848e" have entirely different histories.

3 changed files with 35 additions and 57 deletions

View file

@ -286,18 +286,8 @@ describe("Admin tech-steps triage", () => {
} }
this.timeout(60000); this.timeout(60000);
const agent = await adminAgent(); const agent = await adminAgent();
// supertest requests are lazy — they only dispatch when awaited/then'd. const first = agent.post("/admin/tech-steps/retrain").send({});
// Attaching the `.then` here is what actually fires the first request, // Let the first handler acquire the process-wide lock before the second starts.
// 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,16 +105,17 @@ 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. */
* A recipe: one pure-prep "chop onion" step, then (optionally) an async function makeRecipe(name: string, onionQty: number) {
* active "mix" step, then one simmer step. The `withActiveStep` recipe return prisma.recipe.create({
* is still doing hands-on work in the phase after its simmer starts, so data: {
* the other recipe's simmer floats into that phase as `background`. name,
*/ authorId,
async function makeRecipe(name: string, onionQty: number, withActiveStep = false) { portions: 4,
const chopStep = { steps: {
create: [
{
order: 0, order: 0,
description: "Émincer les oignons", description: "Émincer les oignons",
techSteps: { techSteps: {
@ -136,31 +137,20 @@ 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, true); const tarte = await makeRecipe("Tarte", 3);
const planning = await prisma.planning.create({ const planning = await prisma.planning.create({
data: { data: {

View file

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