From 54ed48ce3513a47dc618ae4779238a931b2bf886 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 5 Feb 2026 23:08:49 +0000 Subject: [PATCH] Fix moderation fixture click timeout and logic Fixed a click timeout issue in `tests/visual/moderation.spec.ts` for the 'trusted mute hide' fixture by: 1. Updating `js/ui/components/VideoCard.js` to use `display: flex !important` instead of `block` for the hidden summary container, ensuring consistency with `bv-stack` class and preventing layout issues that made the button unclickable. 2. Adding `url` to fixture videos in `docs/moderation/fixtures/index.html` to prevent them from being hidden by source visibility logic. 3. Adding `onModerationHide` handler to the fixture factory to support the "Restore default moderation" action. 4. Uncommenting the test case logic in `tests/visual/moderation.spec.ts`. Co-authored-by: PR0M3TH3AN <53631862+PR0M3TH3AN@users.noreply.github.com> --- docs/moderation/fixtures/index.html | 11 +++++++++++ js/ui/components/VideoCard.js | 6 +++--- tests/visual/moderation.spec.ts | 8 ++------ 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/docs/moderation/fixtures/index.html b/docs/moderation/fixtures/index.html index c18e1f2a..e4e76db0 100644 --- a/docs/moderation/fixtures/index.html +++ b/docs/moderation/fixtures/index.html @@ -75,6 +75,7 @@ id: "1".repeat(64), title: "Fixture: Blurred Preview", pubkey: "a".repeat(64), + url: "https://example.com/video.mp4", thumbnail: "/assets/jpg/video-thumbnail-fallback.jpg" }, moderation: { @@ -103,6 +104,7 @@ id: "2".repeat(64), title: "Fixture: Autoplay Blocked", pubkey: "e".repeat(64), + url: "https://example.com/video.mp4", thumbnail: "/assets/jpg/video-thumbnail-fallback.jpg" }, moderation: { @@ -127,6 +129,7 @@ id: "3".repeat(64), title: "Fixture: Override Persistence", pubkey: "f".repeat(64), + url: "https://example.com/video.mp4", thumbnail: "/assets/jpg/video-thumbnail-fallback.jpg" }, moderation: { @@ -152,6 +155,7 @@ id: "4".repeat(64), title: "Fixture: Trusted Report Hide", pubkey: "aa".repeat(32), + url: "https://example.com/video.mp4", thumbnail: "/assets/jpg/video-thumbnail-fallback.jpg" }, moderation: { @@ -177,6 +181,7 @@ id: "5".repeat(64), title: "Fixture: Trusted Mute Hide", pubkey: "bb".repeat(32), + url: "https://example.com/video.mp4", thumbnail: "/assets/jpg/video-thumbnail-fallback.jpg" }, moderation: { @@ -607,6 +612,12 @@ } return true; }; + + card.onModerationHide = () => { + overrides = setOverride(overrides, video.id, { showAnyway: false }); + refreshModeration(); + return true; + }; } const root = card.getRoot(); diff --git a/js/ui/components/VideoCard.js b/js/ui/components/VideoCard.js index 4a68da36..342184ea 100644 --- a/js/ui/components/VideoCard.js +++ b/js/ui/components/VideoCard.js @@ -1856,9 +1856,9 @@ export class VideoCard { target.hidden = false; target.removeAttribute("hidden"); target.removeAttribute("aria-hidden"); - // If target is summary container, ensure it's displayed as block + // If target is summary container, ensure it's displayed as flex (to match bv-stack) if (target !== slot) { - target.style.setProperty("display", "block", "important"); + target.style.setProperty("display", "flex", "important"); } else { target.style.removeProperty("display"); } @@ -2009,7 +2009,7 @@ export class VideoCard { if (!this.hiddenSummaryEl) { this.hiddenSummaryEl = this.createElement("div", { - classNames: ["p-md", "bv-stack", "bv-stack--tight"], + classNames: ["p-md", "bv-stack", "bv-stack--tight", "items-start"], }); this.hiddenSummaryEl.dataset.moderationHiddenContainer = "true"; this.hiddenSummaryEl.setAttribute("role", "group"); diff --git a/tests/visual/moderation.spec.ts b/tests/visual/moderation.spec.ts index 945d04d8..8d384374 100644 --- a/tests/visual/moderation.spec.ts +++ b/tests/visual/moderation.spec.ts @@ -219,14 +219,11 @@ test.describe("moderation fixtures", () => { await expect(muteCard).toHaveAttribute("data-moderation-trusted-mute-count", "1"); await expect(badge).toContainText("Hidden ยท 1 trusted mute"); await expect(thumbnail).toHaveAttribute("data-thumbnail-state", "blurred"); - // TODO: Investigate visibility check failure - // await expect(showAnywayButton).toBeVisible(); + await expect(showAnywayButton).toBeVisible(); await expect(restoreButtonQuery).toHaveCount(0); - // TODO: Investigate click timeout failure - // await showAnywayButton.click({ force: true }); + await showAnywayButton.click(); - /* await expect(muteCard).not.toHaveAttribute("data-moderation-hidden", "true"); await expect(muteCard).toHaveAttribute("data-moderation-override", "show-anyway"); await expect(muteCard.locator('[data-moderation-badge="true"]')).toContainText( @@ -245,6 +242,5 @@ test.describe("moderation fixtures", () => { await expect(muteCard).not.toHaveAttribute("data-moderation-override", "show-anyway"); await expect(thumbnail).toHaveAttribute("data-thumbnail-state", "blurred"); await expect(muteCard.getByRole("button", { name: "Show anyway" })).toBeVisible(); - */ }); });