penpot/frontend/playwright/ui/specs/branches-library.spec.js
Álvaro Tejero Cantero ee9067e154
✨ Apply the branch review vocabulary and drop the pinned revision
Apply the designer's answers on the wording of branch reviews:

- A verdict is two buttons, Approve and Request changes. A stale
  verdict reads Approved an earlier version or Requested changes on
  an earlier version, and Send appears only with a comment.
- Close review everywhere, Branch review in titles, Merges for the
  merge list, Mark as viewed for compare marks, and Merge into main.
- Publishing goes, with the pinned revision it moved. Reviewers see
  the live branch, a verdict goes stale once the branch is saved
  after it, and the review viewer plays the live branch. Migration
  0819 drops the pinned columns and hands their snapshots to the
  snapshot clean-up.
- The frontend takes the branch-review names: namespaces, state
  keys, events, i18n prefixes, and the branch-compare namespace for
  the compare panel.

A failed branch count no longer stays an error after a listing
succeeds: the listing's size stands in for the count.

AI-assisted-by: claude-opus-5-5
2026-11-24 15:00:25 +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=*":
"branch-reviews/get-file-branch-info-none.json",
"get-file-branches?file-id=*": "branch-reviews/get-file-branches-empty.json",
"get-file-branch-reviews?file-id=*":
"branch-reviews/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=*":
"branch-reviews/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=*": "branch-reviews/get-file-branches-one.json",
});
await workspacePage.mockGetFile("branch-reviews/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=*": "branch-reviews/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();
});