mirror of
https://github.com/penpot/penpot.git
synced 2026-11-26 21:00:32 +00:00
* ✨ Add per-profile review marks to branch comparisons A reviewer goes through the changes of a branch one by one, and the comparison has to remember which ones they have already seen. Add the `file_branch_change_review` table and two RPC methods, `get-branch-change-reviews` and `set-branch-change-review`. A mark belongs to a branch, a profile, a direction and a change, and keeps the fingerprint of the change at the time it was marked, so the client can ask for a new review when the change moves again. Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com> * ✨ Compare a branch with main on the canvas The comparison and the conflicts of a branch opened in two modals, away from the design they talk about. Move both to a compare mode on the canvas of the branch itself. The left sidebar lists the changes, in either direction, and the right one shows the change chosen. The canvas marks every change where it is, or only the one chosen, and a bar goes through them one at a time. The conflicts of a merge or an update are resolved in the same mode, with a popover beside the layer in conflict. The file is never touched: the workspace is read-only while the mode lasts, and what the canvas shows that the branch does not hold (the update, the choices made, main itself) is drawn by the WASM render alone. Main is put together from the changes of both directions, and can be seen beside the branch or by holding M. Each direction keeps its own selection of changes, and the changes marked as reviewed are stored per profile. The marks and the bar of the design reviews become shared components. That bar and the bar of the review now center on the canvas the rulers leave, as the bar of the branch does. Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com> * ✨ Add end-to-end tests for the compare mode Cover entering and leaving the mode, a merge with a change left out, an update from main and the three kinds of conflict. The tests of the reviews and of the merged branches follow the comparison to the canvas. Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com> * 💄 Move the WebGL rendering label to the bottom of the canvas The top right corner of the canvas now holds the name of the branch while it is compared with main, and the label was drawn under it. Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com> * ✨ Make the canvas answer for the changes in the compare mode While a branch is compared with main both sidebars talk about changes, not about layers, yet the canvas still selected any layer. Make it answer for the layers with a change or a conflict alone. The pointer on such a layer marks it and shows its row in the list, a click chooses it and a double click zooms to it. A click anywhere else lets the choice go, and the canvas marks every change again. The row under the pointer marks its layer too. No layer is selected, outlined or dragged over; pan and zoom stay as they are, and a commenting tool takes the canvas back while it is in use. The bar that goes through the changes shows with a change chosen only. The canvas no longer draws its projection again on every render, only when what it shows changes. Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com> * 💄 Keep the compare navigator grey outside a design review The bar that goes through the changes of a comparison had the blue border of a design review even with no review open. Give it the grey of the bar at the bottom of the canvas, and keep the blue inside a review. Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com> * ✨ Line main up with the change chosen in the side by side view Main beside the branch showed the same spot of the page, so a layer the branch moved fell out of the half of main once the canvas went to it. The side by side view now has two modes: linked, as it was, and aligned to the change, where main is moved by how far the layer chosen moved, so both versions sit at the middle of their halves. Zoom and pan stay linked, and main slides to the next change as it is chosen. The mode is picked in a submenu of the view, or with the A key, and the browser keeps the last one for the next comparison. The note on the canvas says how far main is moved. Main put a moved group, path or boolean at the place the branch has: the diff leaves out the box of a layer, and it was only built again for the layers whose box is their position and size. Their mark in main now stands where they are. Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com> * 💄 Name the side by side view alone in the view menu The control of the view said "Side by side - aligned" with main lined up with the change chosen, which the note under the toolbar already says. It names the view alone now, in both modes. Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com> * 🐛 Fit the whole page in both halves of the side by side view Fitting the whole page, and zooming from the menu or to 100%, took the middle of the canvas as the middle of the page, but beside main that is the divider: both halves showed the page cut on the left, out of its middle. While main is beside the branch these zooms now work in the half of the branch: the page fits in it and stands at its middle, and a zoom with no pointer turns on that middle. Fitting the whole page takes in main too, which can reach further than the branch. Fitting the change chosen goes through the same fit, which every fit of the workspace now shares. Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com> * 🐛 Zoom the canvas with the wheel over the marks of the changes The wheel with ctrl or cmd held only zoomed the canvas over the canvas itself or over the comments. Over the tags of the changes, which take the pointer, the browser zoomed the whole page instead. It zooms the canvas over anything drawn on top of it now: marks, tags and bars. The note that says how main stands beside the branch takes the look of the other notes of the canvas, in the primary colour. Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com> * 🐛 Fix the layers, bars and badges of the compare and review modes - The comments go over the marks of the changes, so a thread or a task opened from a bubble is no longer covered by them. - How far the review of a comparison is reads at the size of the rest of its bar, in Spanish too. - The way out of a comparison, back from its conflicts and out of a review are icon buttons, with what they do in a tooltip. - Beside the branch, main keeps the frame of the canvas, rounded corners included: its half covered it. - The tab of the other direction counts its changes as soon as the comparison opens: they come with every diff, but only the tab shown was counted. - The read-only badge is a quiet grey one with a lock, in the pages panel and over the changes of a comparison. Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com> * 🌐 Translate branching and design reviews into Spanish The Spanish catalog lacked 418 keys, nearly all of them of branching, comparing, conflicts, merges and design reviews, so those buttons, menus, messages and tooltips showed in English. Add them all, with the terms the catalog already uses. Drop 61 keys of both catalogs that nothing reads any more, left over from screens that are gone, and spell "colors" as the rest of the English catalog does. The Spanish word list takes the valid words the glued-word check flagged. Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com> * 🐛 Find the way out of a review by its name in the e2e test The test looked for "Exit review" in the menu of the review bar, but the way out sits on the bar itself, and it is an icon button now, with its name in a tooltip. Click it on the bar, by its name. Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com> * ✨ Rework the detail of a change in the compare mode The property changes and the buttons of a change stand on the background the inspect tab gives its blocks, over the whole width of the sidebar and as one block when they follow each other. The buttons go one over the other, as wide as the sidebar. Under a change or a conflict, the comments that wait for an answer and the tasks still open on its layer give its context, inside a design review and outside it. They replace the tab of the comments of the review the detail had inside one. The bar of a design review says "In review", on one line: a long title is cut short, whole on hover. The arrows of the bar that goes through the changes hold the place in the list between them, with no gap. Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com> * ♻️ Bring the branching styles in line with the design system Review every stylesheet of branching and design reviews against the design system rules. None of them depends on the deprecated styles; a few details did not follow the rules: - colors that change with a state go through a local custom property (the branch counts, the caption of a preview card, the actions of the branch switcher and the next step of a task); - the alias of the canvas frame border resolves to its DS token; - the panels of the compare mode scroll with overflow-y, as overflow-block is not well supported yet; - unused imports are gone, and a z-index and a variable that are not DS tokens say so in a TODO. The generated CSS stays the same, except the overflow and two backgrounds that render as before. Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com> * ♻️ Reuse the design system components in the branching UI Where the branching and design review UI built its own control, it uses the one of the design system, keeping what the screens look like: - the multi-line fields use the DS text area, as high as before, and their labels name them; - renaming a branch uses the DS input; - the filter of comments and tasks is a DS menu, as wide as its button; - the read-only badge is a DS tag, and its own component is gone. The design system had nothing for a floating panel that is not a menu, so it gets a popover: it only closes on a click out of it or on Escape and gives the focus back, and the caller draws the panel. The branch switcher and the branches of a dashboard card use it instead of the legacy dropdown, unchanged on screen. The verdicts of a review and its reviewers read as radios and as checkboxes. The preview card of the design system, unused since the old conflicts dialog went away, is deleted. Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com> --------- Signed-off-by: elhombretecla <delacruzgarciajuan@gmail.com>
277 lines
11 KiB
JavaScript
277 lines
11 KiB
JavaScript
import { test, expect } from "@playwright/test";
|
|
import { WorkspacePage } from "../pages/WorkspacePage";
|
|
|
|
const PR_ID = "c7ce0794-0992-8105-8004-38f280443999";
|
|
|
|
// The review bar at the bottom of the canvas: the review's own chrome,
|
|
// which replaces the branch bar while a design review is open.
|
|
const reviewBar = (page) => page.getByRole("region", { name: "Design review" });
|
|
|
|
test.beforeEach(async ({ page }) => {
|
|
await WorkspacePage.init(page);
|
|
await WorkspacePage.mockConfigFlags(page, ["enable-branching"]);
|
|
});
|
|
|
|
const setupPullRequestSandbox = async (workspacePage) => {
|
|
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-pull-requests?file-id=*":
|
|
"pull-requests/get-file-pull-requests.json",
|
|
"get-pull-request?id=*": "pull-requests/get-pull-request.json",
|
|
"get-branch-diff?branch-id=*": "pull-requests/get-branch-diff-empty.json",
|
|
"submit-pull-request-review":
|
|
"pull-requests/submit-pull-request-review.json",
|
|
});
|
|
};
|
|
|
|
test("opening a file with pr-id enters the design review", async ({ page }) => {
|
|
const workspacePage = new WorkspacePage(page);
|
|
await setupPullRequestSandbox(workspacePage);
|
|
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
|
|
|
// the review bar names the review being read, and the header trades the
|
|
// file name for the title of the review
|
|
const bar = reviewBar(page);
|
|
await expect(bar).toBeVisible();
|
|
await expect(bar.getByText("In review", { exact: true })).toBeVisible();
|
|
await expect(
|
|
bar.getByText("Checkout redesign", { exact: true }),
|
|
).toBeVisible();
|
|
await expect(page.getByTitle("Review: Checkout redesign")).toBeVisible();
|
|
|
|
// the essentials are visible buttons: the details, the verdict of an
|
|
// assigned reviewer, and the way out
|
|
await expect(bar.getByRole("button", { name: "Details" })).toBeVisible();
|
|
await expect(
|
|
bar.getByRole("button", { name: "Submit review" }),
|
|
).toBeVisible();
|
|
await expect(bar.getByRole("button", { name: "Exit review" })).toBeVisible();
|
|
|
|
// comparing, merging and cancelling live behind the kebab menu
|
|
await expect(bar.getByRole("button", { name: "Compare" })).toBeHidden();
|
|
await bar.getByRole("button", { name: "Options" }).click();
|
|
await expect(page.getByText("Compare", { exact: true })).toBeVisible();
|
|
await expect(page.getByText("Merge to main")).toBeVisible();
|
|
await expect(page.getByText("Cancel review")).toBeVisible();
|
|
});
|
|
|
|
test("comparing shows the proposed changes on the canvas", async ({ page }) => {
|
|
const workspacePage = new WorkspacePage(page);
|
|
await setupPullRequestSandbox(workspacePage);
|
|
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
|
|
|
// comparing is one of the review bar's options
|
|
const bar = reviewBar(page);
|
|
await bar.getByRole("button", { name: "Options" }).click();
|
|
await page.getByText("Compare", { exact: true }).click();
|
|
|
|
// the review bar belongs to the comparison, and the changes take the
|
|
// left sidebar: no dialog opens
|
|
await expect(bar.getByText("Comparing", { exact: true })).toBeVisible();
|
|
await expect(page.getByRole("dialog")).toBeHidden();
|
|
await expect(
|
|
page.getByTestId("left-sidebar").getByText("View only"),
|
|
).toBeVisible();
|
|
|
|
// leaving the comparison goes back to the review
|
|
await bar.getByRole("button", { name: "Exit compare" }).click();
|
|
await expect(bar.getByText("In review", { exact: true })).toBeVisible();
|
|
});
|
|
|
|
test("accepting the pull request opens the merge dialog", async ({ page }) => {
|
|
const workspacePage = new WorkspacePage(page);
|
|
await setupPullRequestSandbox(workspacePage);
|
|
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
|
|
|
const banner = reviewBar(page);
|
|
await banner.getByRole("button", { name: "Options" }).click();
|
|
await page.getByText("Merge to main").click();
|
|
|
|
// the branching merge dialog handles the actual integration
|
|
await expect(page.getByText("Merge into main")).toBeVisible();
|
|
await expect(page.getByText("checkout").first()).toBeVisible();
|
|
});
|
|
|
|
test("the review is read-only", async ({ page }) => {
|
|
const workspacePage = new WorkspacePage(page);
|
|
await setupPullRequestSandbox(workspacePage);
|
|
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
|
|
|
await expect(reviewBar(page)).toBeVisible();
|
|
|
|
// the review toolbar replaces the design tools: moving around,
|
|
// commenting and tasks only, so the canvas offers no way to draw
|
|
const toolbar = page.getByRole("toolbar", { name: "Review tools" });
|
|
await expect(toolbar).toBeVisible();
|
|
for (const tool of [
|
|
"Move",
|
|
"Comment",
|
|
"Comment an area",
|
|
"Create a task",
|
|
"Show changes",
|
|
]) {
|
|
await expect(
|
|
toolbar.getByRole("button", { name: tool, exact: true }),
|
|
).toBeVisible();
|
|
}
|
|
await expect(workspacePage.rectShapeButton).toBeHidden();
|
|
|
|
// and the sidebar flags the file as view only
|
|
await expect(page.getByText("View only")).toBeVisible();
|
|
|
|
// the right panel is the review's: the inspect of the selection, the
|
|
// comments and the tasks of the review
|
|
await expect(page.getByRole("tab", { name: "Inspect" })).toBeVisible();
|
|
await expect(page.getByRole("tab", { name: "Comments (0)" })).toBeVisible();
|
|
await expect(page.getByRole("tab", { name: "Tasks (0)" })).toBeVisible();
|
|
});
|
|
|
|
test("an assigned reviewer can submit a verdict from the review bar", async ({
|
|
page,
|
|
}) => {
|
|
const workspacePage = new WorkspacePage(page);
|
|
await setupPullRequestSandbox(workspacePage);
|
|
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
|
|
|
// the logged-in profile is an assigned reviewer in the fixture, so the
|
|
// bar offers the verdict
|
|
const bar = reviewBar(page);
|
|
await bar.getByRole("button", { name: "Submit review" }).click();
|
|
|
|
const dialog = page.getByRole("dialog");
|
|
await expect(dialog).toBeVisible();
|
|
await expect(
|
|
dialog.getByRole("heading", { name: "Submit review" }),
|
|
).toBeVisible();
|
|
|
|
// the verdicts are a choice of one: radios, each with its hint
|
|
const requestChanges = dialog.getByRole("radio", { name: /Request changes/ });
|
|
await requestChanges.click();
|
|
await expect(requestChanges).toBeChecked();
|
|
await dialog.getByRole("button", { name: "Submit review" }).click();
|
|
|
|
await expect(page.getByText("Review submitted")).toBeVisible();
|
|
});
|
|
|
|
test("closing the pull request asks for confirmation", async ({ page }) => {
|
|
const workspacePage = new WorkspacePage(page);
|
|
await setupPullRequestSandbox(workspacePage);
|
|
await workspacePage.mockRPC(
|
|
"close-pull-request",
|
|
"pull-requests/close-pull-request.json",
|
|
);
|
|
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
|
|
|
const banner = reviewBar(page);
|
|
await banner.getByRole("button", { name: "Options" }).click();
|
|
await page.getByText("Cancel review").click();
|
|
|
|
// nothing is closed yet: a confirmation dialog takes over
|
|
await expect(page.getByText("will be cancelled")).toBeVisible();
|
|
|
|
// confirming closes the pull request; being inside its sandbox, the
|
|
// user is taken back to the file (no pr-id in the url)
|
|
await page.getByRole("button", { name: "Cancel design review" }).click();
|
|
await expect(page).not.toHaveURL(/pr-id/);
|
|
});
|
|
|
|
test("on a branch, requesting a review is the primary action", async ({
|
|
page,
|
|
}) => {
|
|
const workspacePage = new WorkspacePage(page);
|
|
await setupPullRequestSandbox(workspacePage);
|
|
// the open file IS a branch without an open pull request
|
|
await workspacePage.mockRPCs({
|
|
"get-file-branch-info?file-id=*":
|
|
"pull-requests/get-file-branch-info-branch.json",
|
|
"get-file-pull-requests?file-id=*":
|
|
"pull-requests/get-file-branches-empty.json",
|
|
});
|
|
await workspacePage.goToWorkspace();
|
|
|
|
// merging moved behind the kebab menu; requesting a review is primary
|
|
await expect(
|
|
page.getByRole("button", { name: "Request review" }),
|
|
).toBeVisible();
|
|
await expect(
|
|
page.getByRole("button", { name: "Merge to main" }),
|
|
).toBeHidden();
|
|
|
|
const banner = page.locator("#branch-banner");
|
|
await banner.getByRole("button", { name: "Options" }).click();
|
|
await page.getByText("Merge to main").click();
|
|
await expect(page.getByText("Merge into main")).toBeVisible();
|
|
});
|
|
|
|
test("exiting the review takes the user back to the file", async ({ page }) => {
|
|
const workspacePage = new WorkspacePage(page);
|
|
await setupPullRequestSandbox(workspacePage);
|
|
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
|
|
|
// the way out is an icon button on the bar, named by its tooltip
|
|
const banner = reviewBar(page);
|
|
await expect(banner).toBeVisible();
|
|
await banner.getByRole("button", { name: "Exit review" }).click();
|
|
|
|
// exiting drops the review context and the pr-id param; the file (the
|
|
// live branch) stays as it was
|
|
await expect(page).not.toHaveURL(/pr-id/);
|
|
await expect(reviewBar(page)).toBeHidden();
|
|
});
|
|
|
|
test("during a review the header names the branch under review", async ({
|
|
page,
|
|
}) => {
|
|
const workspacePage = new WorkspacePage(page);
|
|
await setupPullRequestSandbox(workspacePage);
|
|
// the review link opens the author's branch
|
|
await workspacePage.mockRPC(
|
|
"get-file-branch-info?file-id=*",
|
|
"pull-requests/get-file-branch-info-branch.json",
|
|
);
|
|
await workspacePage.goToWorkspace({ extraParams: `&pr-id=${PR_ID}` });
|
|
|
|
// the review bar replaces the branch bar, so the header loads the
|
|
// branch context itself
|
|
await expect(reviewBar(page)).toBeVisible();
|
|
await expect(page.getByTitle("On branch checkout from main")).toBeVisible();
|
|
});
|
|
|
|
test("a branch that cannot be compared with main says so", async ({ page }) => {
|
|
const workspacePage = new WorkspacePage(page);
|
|
await setupPullRequestSandbox(workspacePage);
|
|
// the backend answers nil counts when it cannot compare the branch
|
|
await workspacePage.mockRPC(
|
|
"get-file-branch-info?file-id=*",
|
|
"pull-requests/get-file-branch-info-uncompared.json",
|
|
);
|
|
await workspacePage.goToWorkspace();
|
|
|
|
const banner = page.locator("#branch-banner");
|
|
await expect(
|
|
banner.getByText("Couldn't compare this branch with main"),
|
|
).toBeVisible();
|
|
await expect(banner.getByText("Up to date with main")).toBeHidden();
|
|
});
|
|
|
|
test("on a branch, the all-branches dialog offers no new branch", async ({
|
|
page,
|
|
}) => {
|
|
const workspacePage = new WorkspacePage(page);
|
|
await setupPullRequestSandbox(workspacePage);
|
|
await workspacePage.mockRPC(
|
|
"get-file-branch-info?file-id=*",
|
|
"pull-requests/get-file-branch-info-branch.json",
|
|
);
|
|
await workspacePage.goToWorkspace();
|
|
|
|
await page.getByTitle("On branch checkout from main").click();
|
|
await page.getByText("All branches").click();
|
|
|
|
// branches only grow from main: the button stays, disabled
|
|
await expect(page.getByRole("button", { name: "New branch" })).toBeDisabled();
|
|
});
|