(label, options = {})
| 1113 | } |
| 1114 | |
| 1115 | async function verifyUi(label, options = {}) { |
| 1116 | if (!serverProcess) { |
| 1117 | return verifyUiWithDescribe(label, options); |
| 1118 | } |
| 1119 | |
| 1120 | const attempts = options.attempts ?? (options.expectFixture ? 8 : 3); |
| 1121 | const delayMs = options.delayMs ?? (options.expectFixture ? 1_000 : 500); |
| 1122 | let lastError = ""; |
| 1123 | for (let attempt = 1; attempt <= attempts; attempt += 1) { |
| 1124 | try { |
| 1125 | await resolveKnownSystemPromptsWithQueries(label); |
| 1126 | if (options.expectFixture) { |
| 1127 | await waitForUiElement(label, { id: "fixture.continue" }, options); |
| 1128 | await queryUi(label, { |
| 1129 | selector: { id: "fixture.message" }, |
| 1130 | limit: 1, |
| 1131 | maxDepth: options.maxDepth ?? 3, |
| 1132 | }); |
| 1133 | } |
| 1134 | if (options.expectText) { |
| 1135 | await waitForUiText(label, options.expectText, options); |
| 1136 | } |
| 1137 | if (!options.expectFixture && !options.expectText) { |
| 1138 | await queryUi(label, { limit: 1, maxDepth: 2 }); |
| 1139 | } |
| 1140 | logStep(`ui after ${label}: ${summarizeUiCheck(options)}`); |
| 1141 | return ""; |
| 1142 | } catch (error) { |
| 1143 | lastError = error?.message ?? String(error); |
| 1144 | if (attempt < attempts) { |
| 1145 | await sleep(delayMs); |
| 1146 | } |
| 1147 | } |
| 1148 | } |
| 1149 | throw new Error( |
| 1150 | `${label} did not reach expected UI after ${attempts} UI checks:\n${lastError}`, |
| 1151 | ); |
| 1152 | } |
| 1153 | |
| 1154 | async function verifyUiWithDescribe(label, options = {}) { |
| 1155 | const attempts = options.attempts ?? (options.expectFixture ? 8 : 3); |
no test coverage detected