test: cover direct tasks sidebar PR hydration (#3051)

Co-authored-by: ayattara <alassane.yattara@savoirfairelinux.com>
Co-authored-by: Carlos Florencio <carlosmflorencio@gmail.com>
This commit is contained in:
Alassane
2026-08-27 10:08:22 +00:00
committed by GitHub
parent 0e4ae865dc
commit 566e36bc96
@@ -102,6 +102,71 @@ async function expectTopbarReadyState(
}
test.describe("PR status badge", () => {
// seedBadgeTest selects a temporary workflow and changes preview behavior.
// Restore the fixture defaults so those changes do not leak between tests.
test.afterEach(async ({ apiClient, seedData }) => {
await apiClient.saveUserSettings({
workspace_id: seedData.workspaceId,
workflow_filter_id: seedData.workflowId,
enable_preview_on_click: false,
});
});
test("hydrates the sidebar PR badge on /tasks when details are off", async ({
testPage,
apiClient,
seedData,
}) => {
test.setTimeout(120_000);
const baselineShowDetails =
(await apiClient.getUserSettings()).settings.tasks_list_show_details ?? false;
try {
const { task } = await seedBadgeTest(
apiClient,
seedData.workspaceId,
seedData.agentProfileId,
seedData.repositoryId,
"Direct tasks sidebar PR badge",
);
await apiClient.saveUserSettings({ tasks_list_show_details: false });
await apiClient.mockGitHubAssociateTaskPR({
task_id: task.id,
owner: "testorg",
repo: "testrepo",
pr_number: 100,
pr_url: "https://github.com/testorg/testrepo/pull/100",
pr_title: "Hydrate sidebar badge on direct tasks load",
head_branch: "fix/direct-tasks-hydration",
base_branch: "main",
author_login: "test-user",
state: "open",
review_state: "approved",
checks_state: "success",
mergeable_state: "clean",
});
await waitForTaskPRFields(apiClient, task.id, {
state: "open",
review_state: "approved",
checks_state: "success",
mergeable_state: "clean",
});
await testPage.goto("/tasks");
await expect(testPage.getByTestId("tasks-list")).toBeVisible();
const sidebar = testPage.getByTestId("app-sidebar");
const taskRow = sidebar.getByTestId("sidebar-task-item").filter({ hasText: task.title });
const icon = taskRow.getByTestId(`pr-task-icon-${task.id}`);
await expect(icon).toBeVisible();
await expect(icon).toHaveAttribute("data-pr-count", "1");
await expect(icon).toHaveAttribute("data-pr-state", "open");
await expect(icon).toHaveAttribute("data-pr-ready-to-merge", "true");
} finally {
await apiClient.saveUserSettings({ tasks_list_show_details: baselineShowDetails });
}
});
/**
* Regression for the "CI pending" bug: GitHub reports all checks passed
* (one skipped, many successful). We used to compute "pending" because