Files
kandev/apps/web/e2e/tests/git/fork-pr-comparison-target.spec.ts
T
Alassane 262ecdf270 feat(mcp): handle task change links (#3506)
Co-authored-by: Carlos Florêncio <carlosmflorencio@gmail.com>
Co-authored-by: ayattara <alassane.yattara@savoirfairelinux.com>
2026-09-14 15:00:35 +01:00

104 lines
3.7 KiB
TypeScript

import { expect } from "@playwright/test";
import { test } from "../../fixtures/test-base";
import { SessionPage } from "../../pages/session-page";
import {
resetForkPRComparisonRepository,
seedForkPRComparisonTask,
} from "./fork-pr-comparison-target-helpers";
test.describe("Fork pull-request comparison target", () => {
test.describe.configure({ timeout: 120_000 });
test.afterEach(async ({ seedData, backend, apiClient }) => {
await resetForkPRComparisonRepository(seedData, backend, apiClient);
});
test("uses the upstream target for one fork commit and three files", async ({
testPage,
apiClient,
seedData,
backend,
}) => {
const { task } = await seedForkPRComparisonTask(apiClient, seedData, backend);
await testPage.goto(`/t/${task.id}`);
const session = new SessionPage(testPage);
await session.waitForLoad();
await session.waitForChatIdle({ timeout: 45_000 });
await session.clickTab("Changes");
await expect(session.changes).toBeVisible({ timeout: 15_000 });
await session.expandCommitsSection();
await expect(session.commitsSection().locator('[data-testid^="commit-row-"]')).toHaveCount(1);
await expect(session.commitsSection()).toContainText("Add three fork contribution files");
await session.expandPRChangesSection();
await expect(
session.prFilesSection().locator('[data-changes-file="fork-one.txt"]'),
).toBeVisible();
await expect(
session.prFilesSection().locator('[data-changes-file="fork-two.txt"]'),
).toBeVisible();
await expect(
session.prFilesSection().locator('[data-changes-file="fork-three.txt"]'),
).toBeVisible();
const branchDetails = testPage.getByRole("button", {
name: "Show branch and Git credential details",
});
await branchDetails.hover();
await expect(testPage.getByTestId("changes-comparison-target")).toContainText(
"upstream/widget:main",
);
await expect(testPage.getByTestId("comparison-target-notice")).toHaveCount(0);
});
test("shows an unavailable state when the upstream target cannot be fetched", async ({
testPage,
apiClient,
seedData,
backend,
}) => {
const { task, comparisonTargetFixture } = await seedForkPRComparisonTask(
apiClient,
seedData,
backend,
{
comparisonTargetAvailable: false,
localUncommittedFile: "local-auth-recovery.txt",
},
);
await testPage.goto(`/t/${task.id}`);
const session = new SessionPage(testPage);
await session.waitForLoad();
await session.waitForChatIdle({ timeout: 45_000 });
await session.clickTab("Changes");
await expect(session.changes).toBeVisible({ timeout: 15_000 });
await expect(testPage.getByTestId("comparison-target-notice")).toContainText(
"upstream/widget:main",
);
await expect
.poll(() => comparisonTargetFixture?.unauthorizedRequestCount() ?? 0, {
timeout: 15_000,
message: "the comparison fixture should observe the failed HTTP authentication request",
})
.toBeGreaterThan(0);
await expect(
session.changes.locator('[data-changes-file="local-auth-recovery.txt"]'),
).toBeVisible();
// Changes is a right-column panel and stays active while the chat session
// tab changes. Leave it explicitly so returning to Changes fires the
// activation refresh that recovers the comparison target.
await session.clickTab("Files");
comparisonTargetFixture?.setAvailable(true);
await session.clickTab("Changes");
await expect(testPage.getByTestId("comparison-target-notice")).toHaveCount(0, {
timeout: 30_000,
});
await session.expandCommitsSection();
await expect(session.commitsSection().locator('[data-testid^="commit-row-"]')).toHaveCount(1);
});
});