Skip to content

Commit 5b01c0c

Browse files
committed
refactor: follow-up to test repair feature
Small follow-up to the test repair feature. One open question is whether we should run tests when serving failed. I'm leaning towards, yes— we can still try to run them and collect more data.
1 parent faab4ec commit 5b01c0c

File tree

3 files changed

+33
-37
lines changed

3 files changed

+33
-37
lines changed

report-app/src/app/pages/report-viewer/report-viewer.html

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,7 @@ <h3 class="chart-title">
8080
<span>Tests</span>
8181
</h3>
8282
<div class="summary-card-item">
83-
<stacked-bar-chart
84-
[data]="testsAsGraphData(overview.stats.tests)"
85-
[compact]="true"
86-
/>
83+
<stacked-bar-chart [data]="testsAsGraphData(overview.stats.tests)" [compact]="true" />
8784
</div>
8885
</div>
8986
}
@@ -258,7 +255,8 @@ <h2>Generated applications</h2>
258255
[label]="`Filter by failed checks (${selectedChecks().length} selected)`"
259256
[options]="allFailedChecks()"
260257
[(selected)]="selectedChecks"
261-
class="check-filter"/>
258+
class="check-filter"
259+
/>
262260
}
263261
<div class="apps-list">
264262
@for (result of filteredResults(); track result) {
@@ -291,7 +289,7 @@ <h2>Generated applications</h2>
291289
}
292290

293291
@if (hasBuildFailureDuringTestRepair(result)) {
294-
<span class="status-badge error">Build failed after a11y repair</span>
292+
<span class="status-badge error">Build failed after a11y/test repair</span>
295293
}
296294
<!-- Test status badges -->
297295
@if (finalAttempt.testResult) {
@@ -381,13 +379,15 @@ <h4>Test Results</h4>
381379
@if (result.testResult.passed) {
382380
<span class="status-text success">✔ Tests passed</span>
383381
@if ((result.testRepairAttempts || 0) > 0) {
384-
<span class="status-text">&nbsp;after {{ result.testRepairAttempts }} repair attempt(s)</span>
382+
<span class="status-text"
383+
>&nbsp;after {{ result.testRepairAttempts }} repair attempt(s)</span
384+
>
385385
}
386386
} @else {
387387
<span class="status-text error">✘ Tests failed</span>
388388
}
389389
</div>
390-
390+
391391
@if (result.testResult.output && !result.testResult.passed) {
392392
<details class="test-output-button">
393393
<summary class="neutral-button">See Test Output</summary>
@@ -507,14 +507,16 @@ <h4>Generated Code</h4>
507507
[audits]="category.audits"
508508
[displayName]="category.displayName"
509509
[score]="category.score"
510-
[description]="category.description"/>
510+
[description]="category.description"
511+
/>
511512
}
512513

513514
@if (lighthouse.uncategorized.length > 0) {
514515
<lighthouse-category
515516
[audits]="lighthouse.uncategorized"
516517
displayName="Uncategorized"
517-
[score]="null"/>
518+
[score]="null"
519+
/>
518520
}
519521
</expansion-panel>
520522
}

runner/orchestration/build-serve-loop.ts renamed to runner/orchestration/build-serve-test-loop.ts

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -133,19 +133,16 @@ export async function attemptBuildAndTest(
133133
progress,
134134
userJourneyAgentTaskInput,
135135
);
136-
const testResult = await runTest(
137-
env,
138-
evalID,
139-
directory,
140-
rootPromptDef,
141-
abortSignal,
142-
workerConcurrencyQueue,
143-
progress,
144-
);
145-
146-
if (testResult !== null) {
147-
lastAttempt.testResult = testResult;
148-
}
136+
lastAttempt.testResult =
137+
(await runTest(
138+
env,
139+
evalID,
140+
directory,
141+
rootPromptDef,
142+
abortSignal,
143+
workerConcurrencyQueue,
144+
progress,
145+
)) ?? undefined;
149146
}
150147

151148
// Attempt to repair testing. This only runs when the last build
@@ -236,19 +233,16 @@ export async function attemptBuildAndTest(
236233
progress,
237234
userJourneyAgentTaskInput,
238235
);
239-
const testResult = await runTest(
240-
env,
241-
evalID,
242-
directory,
243-
rootPromptDef,
244-
abortSignal,
245-
workerConcurrencyQueue,
246-
progress,
247-
);
248-
249-
if (testResult !== null) {
250-
lastAttempt.testResult = testResult;
251-
}
236+
lastAttempt.testResult =
237+
(await runTest(
238+
env,
239+
evalID,
240+
directory,
241+
rootPromptDef,
242+
abortSignal,
243+
workerConcurrencyQueue,
244+
progress,
245+
)) ?? undefined;
252246

253247
if (hasAxeFailure && lastAttempt.serveTestingResult.axeViolations?.length === 0) {
254248
progress.log(rootPromptDef, 'success', `Successfully fixed all Axe accessibility violations`);

runner/orchestration/generate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ import {getRunnerByName} from '../codegen/runner-creation.js';
4747
import {summarizeReportWithAI} from '../reporting/report-ai-summary.js';
4848
import {LocalExecutor} from './executors/local-executor.js';
4949
import {EvalID} from './executors/executor.js';
50-
import {attemptBuildAndTest} from './build-serve-loop.js';
50+
import {attemptBuildAndTest} from './build-serve-test-loop.js';
5151

5252
/**
5353
* Orchestrates the entire assessment process for each prompt defined in the `prompts` array.

0 commit comments

Comments
 (0)