mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -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");
|
||||
|
||||
Reference in New Issue
Block a user