diff --git a/src/features/watch-fork-star-popup.test.ts b/src/features/watch-fork-star-popup.test.ts index 2f58825..37f5620 100644 --- a/src/features/watch-fork-star-popup.test.ts +++ b/src/features/watch-fork-star-popup.test.ts @@ -55,7 +55,8 @@ describe("watch/fork/star popup", () => { await vi.advanceTimersByTimeAsync(300); expect(fetchWatchers).toHaveBeenCalledWith("owner", "repo"); - const items = watchCounter.querySelectorAll(".bg-wfs-popup-item"); + // The popup is portaled to
, so query the document, not the counter. + const items = document.querySelectorAll(".bg-wfs-popup-item"); expect(items).toHaveLength(2); expect(items[0].querySelector(".bg-wfs-popup-username")?.textContent).toBe("alice"); expect(items[0].querySelector("img")?.getAttribute("alt")).toBe("alice"); @@ -63,10 +64,10 @@ describe("watch/fork/star popup", () => { vi.useRealTimers(); }); - it("keeps a clicked stargazer's link pointing at their profile and out of the stargazers anchor", async () => { + it("portals the popup to , out of the stargazers anchor, so clicks can't leak to it", async () => { vi.useFakeTimers(); // GitHub nests the star counter inside an ``. - // Reproduce that so the popup's user links live inside the outer anchor. + // Reproduce that to prove the popup is NOT placed inside the outer anchor. const star = document.getElementById("star-counter")!; const outer = document.createElement("a"); outer.href = `${GH}/owner/repo/stargazers`; @@ -81,41 +82,39 @@ describe("watch/fork/star popup", () => { star.dispatchEvent(new Event("mouseenter")); await vi.advanceTimersByTimeAsync(300); - const item = star.querySelector