diff --git a/frontend/playwright/ui/pages/WorkspacePage.js b/frontend/playwright/ui/pages/WorkspacePage.js index f6b6a5a11a..d2953a2c71 100644 --- a/frontend/playwright/ui/pages/WorkspacePage.js +++ b/frontend/playwright/ui/pages/WorkspacePage.js @@ -600,6 +600,12 @@ export class WorkspacePage extends BaseWebSocketPage { .getByRole("button", { name: "Comments (C)" }) .click(clickOptions); } + + async toggleCommentsVisibilityFromMenu(clickOptions = {}) { + await this.page.getByRole("button", { name: "Main menu" }).click(); + await this.page.getByText("view").last().click(); + await this.page.locator("#file-menu-comments").click(clickOptions); + } } export default WorkspacePage; diff --git a/frontend/playwright/ui/specs/workspace-comments.spec.js b/frontend/playwright/ui/specs/workspace-comments.spec.js index 8cc3cbe203..735b10b044 100644 --- a/frontend/playwright/ui/specs/workspace-comments.spec.js +++ b/frontend/playwright/ui/specs/workspace-comments.spec.js @@ -35,3 +35,64 @@ test("Group bubbles when zooming out if they overlap", async ({ page }) => { /unread/, ); }); + +test("Opening the Comments section only temporarily overrides a disabled global comments setting", async ({ + page, +}) => { + const workspacePage = new WasmWorkspacePage(page); + await workspacePage.setupEmptyFile(); + await workspacePage.setupFileWithComments(); + await workspacePage.goToWorkspace(); + + const bubble = page.getByTestId("floating-thread-bubble-1"); + + // "Display comments" is enabled by default, so the bubble is already visible. + await expect(bubble).toBeVisible(); + + // Turn the global "Display comments" setting off from the main menu. + await workspacePage.toggleCommentsVisibilityFromMenu(); + await expect(bubble).toBeHidden(); + + // Opening the Comments section shows comments regardless of the global setting. + await workspacePage.showComments(); + await expect(bubble).toBeVisible(); + + // Closing the Comments section falls back to the (still disabled) global setting. + await workspacePage.showComments(); + await expect(bubble).toBeHidden(); + + // The global setting itself must be untouched by opening/closing the section. + await page.getByRole("button", { name: "Main menu" }).click(); + await page.getByText("view").last().click(); + await expect(page.locator("#file-menu-comments")).toContainText( + "Show comments", + ); + await page.keyboard.press("Escape"); +}); + +test("Comments stay visible through opening and closing the Comments section when the global setting is enabled", async ({ + page, +}) => { + const workspacePage = new WasmWorkspacePage(page); + await workspacePage.setupEmptyFile(); + await workspacePage.setupFileWithComments(); + await workspacePage.goToWorkspace(); + + const bubble = page.getByTestId("floating-thread-bubble-1"); + + // "Display comments" is enabled by default. + await expect(bubble).toBeVisible(); + + await workspacePage.showComments(); + await expect(bubble).toBeVisible(); + + await workspacePage.showComments(); + await expect(bubble).toBeVisible(); + + await page.getByRole("button", { name: "Main menu" }).click(); + await page.getByText("view").last().click(); + await expect(page.locator("#file-menu-comments")).toContainText( + "Hide comments", + ); + await page.keyboard.press("Escape"); +}); diff --git a/frontend/src/app/main/data/workspace/drawing.cljs b/frontend/src/app/main/data/workspace/drawing.cljs index 4812cf32a0..193b5747af 100644 --- a/frontend/src/app/main/data/workspace/drawing.cljs +++ b/frontend/src/app/main/data/workspace/drawing.cljs @@ -15,7 +15,6 @@ [app.main.data.workspace.drawing.common :as common] [app.main.data.workspace.drawing.curve :as curve] [app.main.data.workspace.drawing.line :as line] - [app.main.data.workspace.layout :as dwlo] [app.main.data.workspace.path :as path] [beicon.v2.core :as rx] [potok.v2.core :as ptk])) @@ -47,11 +46,6 @@ (when (= tool :path) (rx/of (start-drawing :path))) - ;; NOTE: comments are a special case and they manage they - ;; own interrupt cycle. - (when (= tool :comments) - (rx/of (dwlo/toggle-layout-flag :display-comments :force? true))) - (when (and (not= tool :comments) (not= tool :path)) (let [stopper (rx/filter (ptk/type? ::clear-drawing) stream)]