(page)
| 74 | /* Was die Seite gerade zeigt */ |
| 75 | |
| 76 | async function state(page) { |
| 77 | return page.evaluate(() => { |
| 78 | const root = document.querySelector('.atlas-architecture'); |
| 79 | if (!root) return null; |
| 80 | const text = (element) => element?.textContent?.replace(/\s+/g, ' ').trim() ?? null; |
| 81 | const history = root.querySelector('[role="group"][aria-label="Architecture history"]'); |
| 82 | const button = (label) => { const element = history?.querySelector(`button[aria-label="${label}"]`); return element ? { disabled: element.disabled, title: element.getAttribute('title') } : null; }; |
| 83 | const location = root.querySelector('[aria-label="Architecture location"]'); |
| 84 | const select = root.querySelector('select[aria-label="Behavior entry point"]'); |
| 85 | const destination = root.querySelector('select[aria-label="Behavior destination"]'); |
| 86 | const systemLabels = [...root.querySelectorAll('.system-scene-node-label')]; |
| 87 | const paths = [...root.querySelectorAll('[aria-label="Indexed paths"] button')]; |
| 88 | return { |
| 89 | view: root.querySelector('.atlas-arch-tab[aria-pressed="true"]')?.getAttribute('data-view') ?? null, |
| 90 | trail: location ? [...location.children].filter((element) => element.tagName === 'BUTTON' || (element.tagName === 'SPAN' && element.textContent !== '/')).map((element) => element.textContent) : null, |
| 91 | camera: text(root.querySelector('[aria-label="Map camera"] button[aria-pressed="true"]')), |
| 92 | perspective: text(root.querySelector('[aria-label="Routes perspective"] button[aria-pressed="true"]')), |
| 93 | filter: root.querySelector('input[type="search"]')?.value ?? null, |
| 94 | routeChips: root.querySelectorAll('button.architecture-node-label[data-node-id^="route"]').length, |
| 95 | focus: systemLabels.filter((element) => element.dataset.focus === 'true' && element.dataset.presentation === 'system').map((element) => text(element.querySelector('strong'))), |
| 96 | expanded: systemLabels.filter((element) => element.dataset.expanded === 'true').map((element) => text(element.querySelector('strong'))), |
| 97 | heading: text(root.querySelector('.behavior-heading h2')), |
| 98 | start: select ? text(select.selectedOptions[0]) : null, |
| 99 | destination: destination ? text(destination.selectedOptions[0]) : null, |
| 100 | systemCamera: text(root.querySelector('[aria-label="System camera"] button[aria-pressed="true"]')), |
| 101 | behaviorCamera: text(root.querySelector('[aria-label="Behavior camera"] button[aria-pressed="true"]')), |
| 102 | chain: text(root.querySelector('[aria-label="Walk the call chain"] span')), |
| 103 | path: paths.length ? paths.findIndex((element) => element.getAttribute('aria-pressed') === 'true') + 1 : null, |
| 104 | /* |
| 105 | * Das "← Back", das System structure und Behavior frueher in der eigenen Leiste hatten. Das gemeinsame |
| 106 | * Zurueck traegt seit dem Handtest vom 2026-10-04 (A1) dieselben Worte wie in Galaxy und zaehlt nicht mit. |
| 107 | */ |
| 108 | inViewBack: [...root.querySelectorAll('button')].filter((element) => element.textContent?.trim() === '← Back' && !history?.contains(element)).length, |
| 109 | back: button('Back'), forward: button('Forward'), |
| 110 | position: history?.getAttribute('data-position') ?? null, |
| 111 | recent: [...(history?.querySelectorAll('[aria-label="Recently visited places"] li button') ?? [])].map((element) => ({ |
| 112 | name: text(element.querySelector('strong')), detail: text(element.querySelector('span')) ?? '', current: element.getAttribute('aria-current') === 'true' })), |
| 113 | }; |
| 114 | }); |
| 115 | } |
| 116 | |
| 117 | /** Wartet, bis die Seite den erwarteten Ort zeigt; liefert den letzten Messwert. */ |
| 118 | async function settle(page, expected, timeout = 90000) { |
no test coverage detected