penpot/frontend/playwright/ui/specs/branches-library.spec.js
Álvaro Tejero Cantero 26d3c45266
✨ Key branch reviews, threads, and tasks to the file family
A branch review, its verdicts, activity, threads, and tasks now hang
off the file family (a file and every branch cut from it), so they
outlive the branch file. Migration 0817:

- adds file_family, family_id on files and on the rows they own, real
  foreign keys for review_id and merge_id, and thread numbers per
  family, renumbered once;
- renames the review entity and its commands (file_branch_review,
  file_branch_reviewer with a nullable verdict, pinned revision
  columns), the compare marks (file_branch_change_mark, directions
  branch->source and source->branch), and the backend's main to
  source;
- derives a review's target from the branch edge.

At a merge, a thread moves to the target only when it holds an open
task, whole with its tasks, or when it was written outside any
review. Every other thread stays on the closed review, survives the
purge of the branch file, and is listed by get-branch-review-threads.
move-branch-review-thread brings one to the target later.

A branch deleted without a merge takes its reviews, threads, and
tasks with it. Branches of branches are built behind the
branch-stacking flag, off by default.

AI-assisted-by: mixed models
2026-11-23 19:23:21 +01:00

84 lines
2.9 KiB
JavaScript

import { test, expect } from "@playwright/test";
import { WorkspacePage } from "../pages/WorkspacePage";
test.beforeEach(async ({ page }) => {
await WorkspacePage.init(page);
await WorkspacePage.mockConfigFlags(page, ["enable-branching"]);
});
const setupBranching = async (workspacePage, rpcs) => {
await workspacePage.setupEmptyFile();
await workspacePage.mockRPCs({
"get-file-branch-info?file-id=*":
"pull-requests/get-file-branch-info-none.json",
"get-file-branches?file-id=*": "pull-requests/get-file-branches-empty.json",
"get-file-branch-reviews?file-id=*":
"pull-requests/get-file-branches-empty.json",
...rpcs,
});
};
test("on a branch of a library, the header says consumers read main", async ({
page,
}) => {
const workspacePage = new WorkspacePage(page);
await setupBranching(workspacePage, {
"get-file-branch-info?file-id=*":
"pull-requests/get-file-branch-info-library-branch.json",
});
await workspacePage.goToWorkspace();
const chip = page.getByTitle(
"On branch checkout from main. Library consumers can adopt changes from main only.",
);
await expect(chip).toBeVisible();
// the popover says it under the main row
await chip.click();
await expect(page.getByText("Read by library consumers")).toBeVisible();
});
test("on a library, the create dialog says consumers read main", async ({
page,
}) => {
const workspacePage = new WorkspacePage(page);
await setupBranching(workspacePage, {
"get-file-branch-count?file-id=*":
"branches/get-file-branch-count-two.json",
"get-file-branches?file-id=*": "pull-requests/get-file-branches-one.json",
});
await workspacePage.mockGetFile("pull-requests/get-file-blank-shared.json");
await workspacePage.goToWorkspace();
await expect(page.getByText("Default branch", { exact: true })).toBeVisible();
// the header says only "Default branch": the popover adds the library note
await page.getByTitle("Switch branch").click();
await expect(page.getByText("Read by library consumers")).toBeVisible();
await page.getByText("New branch").click();
await expect(
page.getByText(
"files that use this library can adopt changes from main only",
),
).toBeVisible();
});
test("on an ordinary file, the create dialog keeps its note", async ({
page,
}) => {
const workspacePage = new WorkspacePage(page);
await setupBranching(workspacePage, {
"get-file-branch-count?file-id=*":
"branches/get-file-branch-count-two.json",
"get-file-branches?file-id=*": "pull-requests/get-file-branches-one.json",
});
await workspacePage.goToWorkspace();
await expect(page.getByText("Default branch", { exact: true })).toBeVisible();
await page.getByTitle("Switch branch").click();
await page.getByText("New branch").click();
await expect(page.getByText("isolated copy")).toBeVisible();
await expect(page.getByText("files that use this library")).toBeHidden();
});