Add explicit per-plan gauge temperature offset
Test and deploy / test-and-deploy (push) Successful in 1m23s
Test and deploy / test-and-deploy (push) Successful in 1m23s
This commit is contained in:
1 parent
d96ed22de1
commit
eda3d8e77f
8 files changed
+90
-7
No files matched your search
@@ -34,3 +34,25 @@ test("streaming JSON decoder exposes only reply text and handles split escapes",
|
||||
assert.equal(partialReply('{"reply":"392\\u00'),"392");
|
||||
assert.equal(partialReply('{"reply":"392\\u00b0F"}'),"392°F");
|
||||
});
|
||||
test("a manual gauge offset shifts illustrative events exactly once and reaches Bean Bro",()=>{
|
||||
const p=blankPlan();p.fields["1.4"]="8:45";p.fields["4.4"]="1:20";
|
||||
const original=buildPlanCurve(p,computeLedger(p));
|
||||
p.temperatureOffsetF="-50";
|
||||
const shifted=buildPlanCurve(p,computeLedger(p));
|
||||
for(let i=0;i<original.length;i++){
|
||||
assert.ok(Math.abs((shifted[i].tempC-original[i].tempC)*1.8+50)<1e-8);
|
||||
assert.equal(shifted[i].timeS,original[i].timeS);
|
||||
}
|
||||
const ctx=buildPlanChatContext(p);
|
||||
assert.equal(ctx.temperatureOffsetF,-50);
|
||||
assert.equal(ctx.displayedMilestones.find(p=>p.event==="fc").tempF,342);
|
||||
p.temps.fc.tempC="190";p.preheat.tempC="175";p.planActual.fc.actualBt="171.111111";
|
||||
const entered=buildPlanChatContext(p);
|
||||
assert.equal(entered.displayedMilestones.find(p=>p.event==="fc").tempF,374);
|
||||
assert.equal(entered.preheatSetpointF,347);
|
||||
assert.equal(entered.recordedMilestones.find(p=>p.event==="fc").actualBtF,340);
|
||||
p.temperatureOffsetF="";delete p.temps.fc.tempC;
|
||||
assert.deepEqual(buildPlanCurve(p,computeLedger(p)),original);
|
||||
p.temperatureOffsetF="25";
|
||||
assert.equal(buildPlanChatContext(p).displayedMilestones.find(p=>p.event==="fc").tempF,417);
|
||||
});
|
||||
@@ -815,3 +815,36 @@ test("browser: an interrupted Bean Bro stream keeps partial text, restores the q
|
||||
assert.equal(await page.locator("#chat-thread .user").count(),1);
|
||||
assert.deepEqual(errors,[]);
|
||||
});
|
||||
|
||||
test("browser: a per-plan gauge offset updates the graph, persists, clones and prints",browserOptions,async(t)=>{
|
||||
const {page,browser,base,create,csrfToken,errors}=await session(t);
|
||||
const saved=await create(warningPlan());
|
||||
await page.goto(base+"/app?plan="+saved.id);
|
||||
await page.getByRole("button",{name:"Preview report",exact:true}).waitFor();
|
||||
const input=page.getByRole("spinbutton",{name:"Gauge temperature offset (°F)"});
|
||||
await input.fill("-50");
|
||||
await page.waitForFunction(()=>document.querySelector("#curve-svg-live").textContent.includes("342°F"));
|
||||
await input.scrollIntoViewIfNeeded();
|
||||
await page.screenshot({path:"/tmp/gauge-offset-desktop.png",animations:"disabled"});
|
||||
await page.getByRole("link",{name:"← Your plans",exact:true}).click();
|
||||
const loaded=(await (await page.request.get(base+"/api/plans/"+saved.id)).json()).plan.plan;
|
||||
assert.equal(loaded.temperatureOffsetF,"-50");
|
||||
const cloned=await (await page.request.post(base+"/api/plans/"+saved.id+"/clone",{headers:{"x-csrf-token":csrfToken}})).json();
|
||||
assert.equal(cloned.plan.plan.temperatureOffsetF,"-50");
|
||||
await page.setViewportSize({width:390,height:844});
|
||||
await page.goto(base+"/app?plan="+saved.id);
|
||||
await input.waitFor();
|
||||
assert.equal(await input.inputValue(),"-50");
|
||||
await input.scrollIntoViewIfNeeded();
|
||||
await page.screenshot({path:"/tmp/gauge-offset-mobile.png",animations:"disabled"});
|
||||
assert.equal(await page.evaluate(()=>document.documentElement.scrollWidth<=innerWidth),true);
|
||||
const report=await browser.newPage();
|
||||
const html=renderReportHtml(loaded);
|
||||
assert.match(html,/Gauge temperature offset/);assert.match(html,/-50°F/);assert.match(html,/342°F/);
|
||||
await report.setContent(html);
|
||||
const {PDFDocument}=await import("pdf-lib");
|
||||
const pdf=await PDFDocument.load(await report.pdf({format:"Letter",preferCSSPageSize:true}));
|
||||
assert.equal(pdf.getPageCount(),2);
|
||||
await report.close();
|
||||
assert.deepEqual(errors,[]);
|
||||
});
|
||||
Reference in new issue
Block a user