(model: TwinViewModel)
| 1333 | * drop the identity that makes them clickable. |
| 1334 | */ |
| 1335 | export function visibleTextOf(model: TwinViewModel): string { |
| 1336 | const parts = [ |
| 1337 | model.question, |
| 1338 | model.subject, |
| 1339 | ...model.context, |
| 1340 | ...model.paragraphs, |
| 1341 | ...model.notes, |
| 1342 | ...model.chips.map(chip => chip.label), |
| 1343 | ...model.steps.map(step => step.text), |
| 1344 | ...model.terms.flatMap(term => [term.term, term.explanation]), |
| 1345 | ...model.facts.flatMap(fact => [fact.label, fact.name]), |
| 1346 | ...model.limits.map(limit => limit.text) |
| 1347 | ]; |
| 1348 | for (const block of model.blocks) { |
| 1349 | parts.push(block.title, block.lead, block.weight ?? ''); |
| 1350 | if (block.rows.length === 0) { |
| 1351 | parts.push(block.emptyText); |
| 1352 | } |
| 1353 | for (const row of block.rows) { |
| 1354 | parts.push( |
| 1355 | row.group ?? '', |
| 1356 | row.label, |
| 1357 | row.detail ?? '', |
| 1358 | row.badge?.text ?? '', |
| 1359 | row.confidenceLabel ?? '', |
| 1360 | ...(row.extras ?? []) |
| 1361 | ); |
| 1362 | } |
| 1363 | } |
| 1364 | for (const section of model.sections) { |
| 1365 | parts.push( |
| 1366 | section.title, |
| 1367 | section.text ?? '', |
| 1368 | section.stateNote ?? '', |
| 1369 | section.countLabel ?? '', |
| 1370 | // The sentence about the half of a section the index cannot see is |
| 1371 | // on screen beside the rows, so it is part of what the reader is |
| 1372 | // being told and belongs in what the depth tests assert over. |
| 1373 | section.note ?? '' |
| 1374 | ); |
| 1375 | // Same rule the renderer follows: the absence sentence is on screen |
| 1376 | // only when there is nothing else in the section. |
| 1377 | if (section.rows.length === 0) { |
| 1378 | parts.push(section.emptyText); |
| 1379 | } |
| 1380 | for (const row of section.rows) { |
| 1381 | parts.push(row.label, row.detail ?? '', row.badge?.text ?? '', row.confidenceLabel ?? '', ...(row.extras ?? [])); |
| 1382 | } |
| 1383 | } |
| 1384 | return parts.filter(part => part.length > 0).join('\n'); |
| 1385 | } |
no test coverage detected