mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-10-27 07:52:24 +00:00
- Update `js/ui/components/VideoModal.js` to correctly initialize the modal share popover using the `createPopover(trigger, renderFn, options)` signature instead of a single config object. - Fix the flaky e2e test `tests/e2e/search-and-filter.spec.ts` by increasing the test timeout from 15s to 30s to allow more time for feed items to be retrieved from the network. - Update `tests/e2e/video-modal-share-bug.spec.ts` to attach an `#uiOverlay` wrapper element for the popover so the DOM doesn't crash on tests. Co-authored-by: PR0M3TH3AN <[email protected]>
73 lines
2.4 KiB
TypeScript
73 lines
2.4 KiB
TypeScript
import { expect, test } from "./helpers/instrumentedTest";
|
|
import { applyReducedMotion, failOnConsoleErrors } from "./helpers/uiTestUtils";
|
|
|
|
test.describe("video modal share button", () => {
|
|
test("opens the share menu when clicked", async ({ page }) => {
|
|
await applyReducedMotion(page);
|
|
await page.goto("/components/video-modal.html", { waitUntil: "networkidle" });
|
|
|
|
await page.addScriptTag({
|
|
type: "module",
|
|
content: `
|
|
import { VideoModal } from "/js/ui/components/VideoModal.js";
|
|
|
|
// Mock dependencies
|
|
const mockSetGlobalModalState = (name, isOpen) => {
|
|
console.log(\`setGlobalModalState: \${name} = \${isOpen}\`);
|
|
};
|
|
|
|
const mockMediaLoader = {
|
|
observe: () => {},
|
|
unobserve: () => {},
|
|
};
|
|
|
|
const videoModal = new VideoModal({
|
|
document: document,
|
|
setGlobalModalState: mockSetGlobalModalState,
|
|
mediaLoader: mockMediaLoader,
|
|
});
|
|
|
|
// Force loaded state and hydrate
|
|
const playerModal = document.getElementById("playerModal");
|
|
if (playerModal) {
|
|
videoModal.document = document;
|
|
videoModal.loaded = true;
|
|
videoModal.hydrate(playerModal);
|
|
|
|
// Mock an active video so the share menu has data
|
|
const activeVideo = {
|
|
id: "test-video-id",
|
|
title: "Test Video",
|
|
url: "https://example.com/video.mp4",
|
|
magnet: "magnet:?xt=urn:btih:test",
|
|
};
|
|
|
|
videoModal.shareNostrAuthState = { isLoggedIn: true, hasSigner: true };
|
|
|
|
// Open the modal
|
|
videoModal.open(activeVideo);
|
|
videoModal.setShareEnabled(true);
|
|
}
|
|
|
|
window.__videoModal = videoModal;
|
|
`,
|
|
});
|
|
|
|
// Ensure modal is visible
|
|
const modal = page.locator("#playerModal");
|
|
await expect(modal).not.toHaveClass(/hidden/);
|
|
|
|
// Ensure modal is visible and click share button
|
|
const shareBtn = page.locator("#shareBtn");
|
|
await expect(shareBtn).toBeVisible();
|
|
|
|
await shareBtn.click();
|
|
|
|
// Expect popover to be open
|
|
// The popover engine adds data-popover-state="open" to the panel
|
|
const popoverPanel = page.locator('[data-menu="video-share"]');
|
|
await expect(popoverPanel).toBeVisible();
|
|
await expect(popoverPanel).toHaveAttribute("data-popover-state", "open");
|
|
});
|
|
});
|