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.
This commit is contained in:
Ethan
2024-11-06 01:20:27 +11:00
committed by GitHub
parent 3c60dc3bb5
commit 8b5a18cade
2 changed files with 10 additions and 4 deletions
@@ -20,7 +20,10 @@ export const useWatchVersionLogs = (
return;
}
if (templateVersionStatus !== "running") {
if (
templateVersionStatus !== "running" &&
templateVersionStatus !== "pending"
) {
return;
}
@@ -324,14 +324,13 @@ test("display pending badge and update it to running when status changes", async
},
};
let calls = 0;
let running = false;
server.use(
http.get(
"/api/v2/organizations/:org/templates/:template/versions/:version",
() => {
calls += 1;
return HttpResponse.json(
calls > 1 ? MockRunningTemplateVersion : MockPendingTemplateVersion,
running ? MockRunningTemplateVersion : MockPendingTemplateVersion,
);
},
),
@@ -348,6 +347,10 @@ test("display pending badge and update it to running when status changes", async
const status = await screen.findByRole("status");
expect(status).toHaveTextContent("Pending");
// Manually update the endpoint, as to not rely on the editor page
// making a specific number of requests.
running = true;
await waitFor(
() => {
expect(status).toHaveTextContent("Running");