From c21b35db70380fadef7ff8c994fffc1ba90af859 Mon Sep 17 00:00:00 2001 From: abhinav7x94 Date: Sun, 16 Aug 2026 05:25:12 +0530 Subject: [PATCH] fix(web): reset delete confirmation when document changes --- .../components/document-modal/index.test.tsx | 197 ++++++++++++++++++ apps/web/components/document-modal/index.tsx | 6 + apps/web/package.json | 1 + bun.lock | 1 + 4 files changed, 205 insertions(+) create mode 100644 apps/web/components/document-modal/index.test.tsx diff --git a/apps/web/components/document-modal/index.test.tsx b/apps/web/components/document-modal/index.test.tsx new file mode 100644 index 00000000..80548e64 --- /dev/null +++ b/apps/web/components/document-modal/index.test.tsx @@ -0,0 +1,197 @@ +import { afterEach, beforeEach, describe, expect, it, mock } from "bun:test" +import { Window } from "happy-dom" +import { type ComponentProps, type ReactNode, act } from "react" +import { createRoot, type Root } from "react-dom/client" + +const browser = new Window({ url: "http://localhost/" }) + +Object.assign(globalThis, { + window: browser, + document: browser.document, + navigator: browser.navigator, + location: browser.location, + history: browser.history, + localStorage: browser.localStorage, + sessionStorage: browser.sessionStorage, + HTMLElement: browser.HTMLElement, + Element: browser.Element, + Node: browser.Node, + MutationObserver: browser.MutationObserver, + getComputedStyle: browser.getComputedStyle.bind(browser), + requestAnimationFrame: browser.requestAnimationFrame.bind(browser), + cancelAnimationFrame: browser.cancelAnimationFrame.bind(browser), +}) +Object.assign(browser, { SyntaxError }) +;( + globalThis as typeof globalThis & { + IS_REACT_ACT_ENVIRONMENT: boolean + } +).IS_REACT_ACT_ENVIRONMENT = true + +function PassThrough({ children }: { children?: ReactNode }) { + return <>{children} +} + +type MotionProps = { + initial?: unknown + animate?: unknown + exit?: unknown + transition?: unknown +} + +function MotionButton({ + initial: _initial, + animate: _animate, + exit: _exit, + transition: _transition, + ...props +}: ComponentProps<"button"> & MotionProps) { + return