Skip to content

fix(site): watch build logs while job is pending or running #15341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion site/src/modules/templates/useWatchVersionLogs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ export const useWatchVersionLogs = (
return;
}

if (templateVersionStatus !== "running") {
if (
templateVersionStatus !== "running" &&
templateVersionStatus !== "pending"
) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Copy link
Member Author

@ethanndickson ethanndickson Nov 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test was failing because as we end up querying versions/{id} an extra time with this change. I think we should just manually update the status instead of relying on a specific number of api calls.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please leave a comment in the code about why we are using running? I can see my self not remembering this in two months.

);
},
),
Expand All @@ -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");
Expand Down
Loading