(label, options = {})
| 1152 | } |
| 1153 | |
| 1154 | async function verifyUiWithDescribe(label, options = {}) { |
| 1155 | const attempts = options.attempts ?? (options.expectFixture ? 8 : 3); |
| 1156 | const delayMs = options.delayMs ?? (options.expectFixture ? 3_000 : 1_000); |
| 1157 | let lastSnapshot = ""; |
| 1158 | for (let attempt = 1; attempt <= attempts; attempt += 1) { |
| 1159 | try { |
| 1160 | let snapshot = await retrySimdeckText( |
| 1161 | describeUiVerificationArgs(), |
| 1162 | `${label} describe`, |
| 1163 | { |
| 1164 | attempts: 1, |
| 1165 | timeoutMs: 90_000, |
| 1166 | maxElapsedMs: options.describeMaxElapsedMs ?? describeUiBudgetMs, |
| 1167 | }, |
| 1168 | ); |
| 1169 | snapshot = await resolveKnownSystemPrompts(snapshot, label); |
| 1170 | lastSnapshot = snapshot; |
| 1171 | logStep(`ui after ${label}: ${summarizeUi(snapshot)}`); |
| 1172 | const fixtureOk = !options.expectFixture || fixtureReady(snapshot); |
| 1173 | const textOk = |
| 1174 | !options.expectText || snapshot.includes(options.expectText); |
| 1175 | if (fixtureOk && textOk) { |
| 1176 | return snapshot; |
| 1177 | } |
| 1178 | } catch (error) { |
| 1179 | lastSnapshot = error?.message ?? String(error); |
| 1180 | logStep(`ui after ${label}: describe failed, retrying`); |
| 1181 | } |
| 1182 | if (attempt < attempts) { |
| 1183 | await sleep(delayMs); |
| 1184 | } |
| 1185 | } |
| 1186 | throw new Error( |
| 1187 | `${label} did not reach expected UI after ${attempts} UI checks:\n${lastSnapshot}`, |
| 1188 | ); |
| 1189 | } |
| 1190 | |
| 1191 | async function queryUi(label, body) { |
| 1192 | return retryHttpJson( |
no test coverage detected