test(harness): support node-side control plane specs
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
@@ -7,22 +7,25 @@ import { matchesMediaQuery, resetAccessibilityPreferences } from "./a11y";
|
||||
|
||||
afterEach(() => {
|
||||
resetAccessibilityPreferences();
|
||||
if (typeof document !== "undefined") {
|
||||
cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
class ResizeObserverMock {
|
||||
if (typeof window !== "undefined" && typeof MouseEvent !== "undefined") {
|
||||
class ResizeObserverMock {
|
||||
observe() {}
|
||||
unobserve() {}
|
||||
disconnect() {}
|
||||
}
|
||||
}
|
||||
|
||||
class PointerEventMock extends MouseEvent {
|
||||
class PointerEventMock extends MouseEvent {
|
||||
constructor(type: string, props: PointerEventInit = {}) {
|
||||
super(type, props);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(window, "matchMedia", {
|
||||
Object.defineProperty(window, "matchMedia", {
|
||||
writable: true,
|
||||
value: vi.fn().mockImplementation((query: string) => ({
|
||||
matches: matchesMediaQuery(query),
|
||||
@@ -34,34 +37,35 @@ Object.defineProperty(window, "matchMedia", {
|
||||
removeListener: vi.fn(),
|
||||
dispatchEvent: vi.fn()
|
||||
}))
|
||||
});
|
||||
});
|
||||
|
||||
Object.defineProperty(window, "ResizeObserver", {
|
||||
Object.defineProperty(window, "ResizeObserver", {
|
||||
writable: true,
|
||||
value: ResizeObserverMock
|
||||
});
|
||||
});
|
||||
|
||||
Object.defineProperty(window, "PointerEvent", {
|
||||
Object.defineProperty(window, "PointerEvent", {
|
||||
writable: true,
|
||||
value: PointerEventMock
|
||||
});
|
||||
});
|
||||
|
||||
Object.defineProperty(window.HTMLElement.prototype, "scrollIntoView", {
|
||||
Object.defineProperty(window.HTMLElement.prototype, "scrollIntoView", {
|
||||
configurable: true,
|
||||
value: vi.fn()
|
||||
});
|
||||
});
|
||||
|
||||
Object.defineProperty(window.HTMLElement.prototype, "hasPointerCapture", {
|
||||
Object.defineProperty(window.HTMLElement.prototype, "hasPointerCapture", {
|
||||
configurable: true,
|
||||
value: vi.fn(() => false)
|
||||
});
|
||||
});
|
||||
|
||||
Object.defineProperty(window.HTMLElement.prototype, "releasePointerCapture", {
|
||||
Object.defineProperty(window.HTMLElement.prototype, "releasePointerCapture", {
|
||||
configurable: true,
|
||||
value: vi.fn()
|
||||
});
|
||||
});
|
||||
|
||||
Object.defineProperty(window.HTMLElement.prototype, "setPointerCapture", {
|
||||
Object.defineProperty(window.HTMLElement.prototype, "setPointerCapture", {
|
||||
configurable: true,
|
||||
value: vi.fn()
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ export default defineConfig({
|
||||
test: {
|
||||
clearMocks: true,
|
||||
environment: "jsdom",
|
||||
include: ["packages/ui/src/**/*.test.{ts,tsx}"],
|
||||
include: ["packages/ui/src/**/*.test.{ts,tsx}", "scripts/harness/**/*.test.ts"],
|
||||
restoreMocks: true,
|
||||
setupFiles: [path.resolve(rootDir, "packages/ui/src/test/setup.ts")]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user