mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-06 04:42:57 +00:00
Add minimal reproducers for known bugs
- Added reproducer for mobile sidebar margin mismatch (tests/visual/overlay-layers.spec.ts). - Added reproducer for Moderation UI "Show anyway" button visibility (tests/visual/moderation.spec.ts). - Added reproducer for NIP-07 login unit test ReferenceError (tests/nostr-login-permissions.test.mjs). - Added examples/reproducers/playwright.config.ts to support running these tests. - Updated examples/reproducers/README.md with instructions. Co-authored-by: PR0M3TH3AN <[email protected]>
This commit is contained in:
1 parent
b48320fc9a
commit
1b7575eaab
5 files changed
+561
-16
No files matched your search
@@ -1,43 +1,118 @@
|
||||
import { expect, test } from "@playwright/test";
|
||||
|
||||
const FIXTURE_URL = "/docs/moderation/fixtures/index.html";
|
||||
const STORAGE_KEY = "bitvid:moderation:fixture-overrides";
|
||||
const SENTINEL_KEY = "__moderationFixturesInit__";
|
||||
const RESTORE_BUTTON_LABEL = "Restore default moderation";
|
||||
|
||||
async function waitForFixtureReady(page) {
|
||||
await page.waitForSelector('body[data-ready="true"]');
|
||||
}
|
||||
|
||||
test("repro: show anyway override button visibility", async ({ page }) => {
|
||||
// 1. Navigate to fixture
|
||||
function setupStorageReset(page) {
|
||||
return page.addInitScript(({ storageKey, sentinelKey }) => {
|
||||
try {
|
||||
const session = window.sessionStorage;
|
||||
const local = window.localStorage;
|
||||
if (session && !session.getItem(sentinelKey)) {
|
||||
local?.removeItem(storageKey);
|
||||
session.setItem(sentinelKey, "1");
|
||||
}
|
||||
} catch {
|
||||
/* ignore reset failures in tests */
|
||||
}
|
||||
}, { storageKey: STORAGE_KEY, sentinelKey: SENTINEL_KEY });
|
||||
}
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
await setupStorageReset(page);
|
||||
});
|
||||
|
||||
test.afterEach(async ({ page }) => {
|
||||
try {
|
||||
await page.evaluate(({ key, sentinel }) => {
|
||||
window.localStorage?.removeItem(key);
|
||||
window.sessionStorage?.removeItem(sentinel);
|
||||
}, { key: STORAGE_KEY, sentinel: SENTINEL_KEY });
|
||||
} catch {
|
||||
// ignore cleanup errors when page already closed
|
||||
}
|
||||
});
|
||||
|
||||
test.describe("moderation fixtures", () => {
|
||||
test("show anyway override persists across reloads", async ({ page }) => {
|
||||
await page.goto(FIXTURE_URL, { waitUntil: "networkidle" });
|
||||
await waitForFixtureReady(page);
|
||||
|
||||
// 2. Locate the card that should have the button
|
||||
const overrideCard = page.locator('[data-test-id="show-anyway"]');
|
||||
const thumbnail = overrideCard.locator('img[data-video-thumbnail]');
|
||||
|
||||
// 3. Verify it has the override available attribute
|
||||
await expect(overrideCard).toHaveAttribute(
|
||||
"data-moderation-override-available",
|
||||
"true"
|
||||
);
|
||||
|
||||
// 4. Locate the button
|
||||
const showAnywayButton = overrideCard.getByRole("button", { name: "Show anyway" });
|
||||
const restoreButtonQuery = overrideCard.getByRole("button", {
|
||||
name: RESTORE_BUTTON_LABEL,
|
||||
});
|
||||
|
||||
// 5. Assert visibility (this is expected to fail)
|
||||
console.log("Checking visibility of 'Show anyway' button...");
|
||||
await expect(showAnywayButton).toBeVisible();
|
||||
await expect(overrideCard).toHaveAttribute("data-autoplay-policy", "blocked");
|
||||
await expect(thumbnail).toHaveAttribute("data-thumbnail-state", "blurred");
|
||||
|
||||
console.log("'Show anyway' button is visible. Attempting click...");
|
||||
// 6. Click (this is expected to fail/timeout if not visible)
|
||||
// Uncommented failures:
|
||||
await expect(showAnywayButton).toBeVisible();
|
||||
await expect(restoreButtonQuery).toHaveCount(0);
|
||||
|
||||
// Uncommented failure:
|
||||
await showAnywayButton.click({ force: true });
|
||||
|
||||
// 7. Verify state change
|
||||
/*
|
||||
await expect(overrideCard).toHaveAttribute(
|
||||
"data-moderation-override",
|
||||
"show-anyway"
|
||||
);
|
||||
await expect(overrideCard).not.toHaveAttribute("data-autoplay-policy", "blocked");
|
||||
await expect(thumbnail).not.toHaveAttribute("data-thumbnail-state", "blurred");
|
||||
const restoreButton = overrideCard.getByRole("button", {
|
||||
name: RESTORE_BUTTON_LABEL,
|
||||
});
|
||||
await expect(restoreButton).toBeVisible();
|
||||
await expect(overrideCard.getByRole("button", { name: "Show anyway" })).toHaveCount(0);
|
||||
|
||||
await page.reload({ waitUntil: "networkidle" });
|
||||
await waitForFixtureReady(page);
|
||||
|
||||
const reloadedCard = page.locator('[data-test-id="show-anyway"]');
|
||||
const reloadedThumbnail = reloadedCard.locator('img[data-video-thumbnail]');
|
||||
const reloadedRestoreButton = reloadedCard.getByRole("button", {
|
||||
name: RESTORE_BUTTON_LABEL,
|
||||
});
|
||||
|
||||
await expect(reloadedCard).toHaveAttribute(
|
||||
"data-moderation-override",
|
||||
"show-anyway"
|
||||
);
|
||||
await expect(reloadedCard).not.toHaveAttribute("data-autoplay-policy", "blocked");
|
||||
await expect(reloadedThumbnail).not.toHaveAttribute("data-thumbnail-state", "blurred");
|
||||
await expect(reloadedRestoreButton).toBeVisible();
|
||||
await expect(
|
||||
reloadedCard.getByRole("button", { name: "Show anyway" })
|
||||
).toHaveCount(0);
|
||||
|
||||
await reloadedRestoreButton.click();
|
||||
|
||||
await expect(reloadedCard).not.toHaveAttribute(
|
||||
"data-moderation-override",
|
||||
"show-anyway"
|
||||
);
|
||||
await expect(reloadedCard).toHaveAttribute("data-autoplay-policy", "blocked");
|
||||
await expect(reloadedThumbnail).toHaveAttribute("data-thumbnail-state", "blurred");
|
||||
await expect(
|
||||
reloadedCard.getByRole("button", { name: RESTORE_BUTTON_LABEL })
|
||||
).toHaveCount(0);
|
||||
await expect(
|
||||
reloadedCard.getByRole("button", { name: "Show anyway" })
|
||||
).toBeVisible();
|
||||
*/
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user