Skip to content

Commit 8b5a18c

Browse files
fix(site): watch build logs while job is pending or running (#15341)
Closes #15292. Currently, if the frontend never sees a build job enter 'running', it'll never end up watching the logs. If we start watching the logs earlier we're able to catch cases where the job goes `pending` -> `failed`, such as when the build fails immediately.
1 parent 3c60dc3 commit 8b5a18c

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

site/src/modules/templates/useWatchVersionLogs.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@ export const useWatchVersionLogs = (
2020
return;
2121
}
2222

23-
if (templateVersionStatus !== "running") {
23+
if (
24+
templateVersionStatus !== "running" &&
25+
templateVersionStatus !== "pending"
26+
) {
2427
return;
2528
}
2629

site/src/pages/TemplateVersionEditorPage/TemplateVersionEditorPage.test.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -324,14 +324,13 @@ test("display pending badge and update it to running when status changes", async
324324
},
325325
};
326326

327-
let calls = 0;
327+
let running = false;
328328
server.use(
329329
http.get(
330330
"/api/v2/organizations/:org/templates/:template/versions/:version",
331331
() => {
332-
calls += 1;
333332
return HttpResponse.json(
334-
calls > 1 ? MockRunningTemplateVersion : MockPendingTemplateVersion,
333+
running ? MockRunningTemplateVersion : MockPendingTemplateVersion,
335334
);
336335
},
337336
),
@@ -348,6 +347,10 @@ test("display pending badge and update it to running when status changes", async
348347
const status = await screen.findByRole("status");
349348
expect(status).toHaveTextContent("Pending");
350349

350+
// Manually update the endpoint, as to not rely on the editor page
351+
// making a specific number of requests.
352+
running = true;
353+
351354
await waitFor(
352355
() => {
353356
expect(status).toHaveTextContent("Running");

0 commit comments

Comments
 (0)