Set the decision and its input
This synthetic document requires a footer independently of its line list. With zero lines the entire repeat section is absent. A faulty fallback creates a line saying Empty, changing the document structure. One and three supplied lines should produce exactly one and three rendered line elements.
| Case | Input JSON |
|---|---|
| Base test | {"lines":[]} |
Run the supplied comparison
The example creates and queries an actual isolated DOM. Section presence, line count and footer text are inspected together; an empty data array alone does not prove the generated document is correct.
| Path | Output JSON |
|---|---|
| Faulty path | {"repeatPresent":true,"lineCount":1,"footer":"Required footer"} |
| Required path | {"repeatPresent":false,"lineCount":0,"footer":"Required footer"} |
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){
return withPage(async page=>{const lines=i.lines.length?i.lines:corrected?[]:['Empty'];
await page.setContent((lines.length?'<section id="repeat">'+lines.map(x=>'<p class="line">'+htmlEscape(x)+'</p>').join('')+'</section>':'')+'<footer>Required footer</footer>');
return page.evaluate(()=>({repeatPresent:!!document.querySelector('#repeat'),lineCount:document.querySelectorAll('.line').length,footer:document.querySelector('footer').textContent}));});
};
const cases=[{"input":{"lines":[]},"corrected":false,"expected":{"repeatPresent":true,"lineCount":1,"footer":"Required footer"}},{"input":{"lines":[]},"corrected":true,"expected":{"repeatPresent":false,"lineCount":0,"footer":"Required footer"}},{"input":{"lines":["A"]},"corrected":true,"expected":{"repeatPresent":true,"lineCount":1,"footer":"Required footer"}},{"input":{"lines":["A","B","C"]},"corrected":true,"expected":{"repeatPresent":true,"lineCount":3,"footer":"Required footer"}}];
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
Populated boundaries retain the repeat section and the same footer. No blank business line is inserted merely to make a template render.
- Separate repeat and fixed regions
- Render the supplied list
- Inspect the resulting DOM
Do not replace missing lines with invented placeholders.
| Condition | Input JSON | Expected output JSON |
|---|---|---|
| one real line | {"lines":["A"]} | {"repeatPresent":true,"lineCount":1,"footer":"Required footer"} |
| three real lines | {"lines":["A","B","C"]} | {"repeatPresent":true,"lineCount":3,"footer":"Required footer"} |
What structure is required for the base empty list?
Show the worked answer
No repeat section and zero line elements, with Required footer still present. The footer is not conditional on line count.