Set the decision and its input
The local document model has an enabled flag and a numeric value. Enabled true with zero must render the Allowance section and output 0. Enabled false with seven must render neither. Testing only whether the number is truthy fails both decisions.
| Case | Input JSON |
|---|---|
| Base test | {"enabled":true,"value":0} |
Run the supplied comparison
An actual browser document is rendered and queried for section presence and output text. This checks generated structure, not merely a Boolean result stored in a worksheet.
| Path | Output JSON |
|---|---|
| Faulty path | {"sectionPresent":false,"value":null} |
| Required path | {"sectionPresent":true,"value":"0"} |
import assert from 'node:assert/strict';
import {createRequire} from 'node:module';
const htmlEscape=s=>String(s).replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>').replace(/"/g,'"');
async function withPage(action,options={}){
const require=createRequire(import.meta.url);const {chromium}=require('playwright');
const browser=await chromium.launch({headless:true});
try{const context=await browser.newContext(options);const page=await context.newPage();
const requests=[];await page.route('**/*',route=>{requests.push(route.request().url());return route.abort();});
return await action(page,context,requests);
}finally{await browser.close();}
}
const run=async function run(i,corrected=true){
if(typeof i.enabled!=='boolean')return {held:true};
if(i.enabled&&!Number.isFinite(i.value))return {held:true};
return withPage(async page=>{const show=corrected?i.enabled:!!i.value;await page.setContent('<main>'+ (show?'<section id="bonus"><h2>Allowance</h2><output>'+htmlEscape(i.value)+'</output></section>':'')+'</main>');
return page.evaluate(()=>({sectionPresent:!!document.querySelector('#bonus'),value:document.querySelector('output')?.textContent??null}));});
};
const cases=[{"input":{"enabled":true,"value":0},"corrected":false,"expected":{"sectionPresent":false,"value":null}},{"input":{"enabled":true,"value":0},"corrected":true,"expected":{"sectionPresent":true,"value":"0"}},{"input":{"enabled":false,"value":7},"corrected":true,"expected":{"sectionPresent":false,"value":null}},{"input":{"enabled":null,"value":0},"corrected":true,"expected":{"held":true}}];
for(const test of cases){const actual=await run(test.input,test.corrected);assert.deepEqual(actual,test.expected);console.log(actual);}
Choose from the boundary evidence
The disabled-seven case remains absent. A null section choice is held before rendering; a missing decision is not an instruction to hide a zero.
- Read the explicit section choice
- Render or omit the whole section
- Check value and structure separately
Hold an unknown choice before generating a document.
| Condition | Input JSON | Expected output JSON |
|---|---|---|
| disabled nonzero value | {"enabled":false,"value":7} | {"sectionPresent":false,"value":null} |
| section choice unknown | {"enabled":null,"value":0} | {"held":true} |
What must the base enabled-zero output contain?
Show the worked answer
One Allowance section with output text 0. Its presence follows enabled=true, while the value is preserved independently.