Skip to content

Commit 0c4ba41

Browse files
Symphony Agentcodex
andcommitted
test(dashboard): restore writable DOM globals
Summary: - Mark the dashboard SSE test globals as writable when installing and restoring the happy-dom environment. Rationale: - The full unit suite includes server inline-dashboard tests that assign to globalThis. Restoring readonly global descriptors from the SSE test leaked isolation state into later tests. Tests: - bun test tests/unit - bun run lint Co-authored-by: Codex <codex@openai.com>
1 parent ac0c37c commit 0c4ba41

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

tests/unit/dashboard-app.test.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,34 +63,42 @@ function installDom(): void {
6363

6464
Object.defineProperty(globalThis, "window", {
6565
configurable: true,
66+
writable: true,
6667
value: window,
6768
});
6869
Object.defineProperty(globalThis, "document", {
6970
configurable: true,
71+
writable: true,
7072
value: window.document,
7173
});
7274
Object.defineProperty(globalThis, "navigator", {
7375
configurable: true,
76+
writable: true,
7477
value: window.navigator,
7578
});
7679
Object.defineProperty(globalThis, "Element", {
7780
configurable: true,
81+
writable: true,
7882
value: window.Element,
7983
});
8084
Object.defineProperty(globalThis, "HTMLElement", {
8185
configurable: true,
86+
writable: true,
8287
value: window.HTMLElement,
8388
});
8489
Object.defineProperty(globalThis, "EventSource", {
8590
configurable: true,
91+
writable: true,
8692
value: MockEventSource,
8793
});
8894
Object.defineProperty(window, "EventSource", {
8995
configurable: true,
96+
writable: true,
9097
value: MockEventSource,
9198
});
9299
Object.defineProperty(globalThis, "IS_REACT_ACT_ENVIRONMENT", {
93100
configurable: true,
101+
writable: true,
94102
value: true,
95103
});
96104

@@ -102,30 +110,37 @@ function installDom(): void {
102110
function restoreDom(): void {
103111
Object.defineProperty(globalThis, "window", {
104112
configurable: true,
113+
writable: true,
105114
value: previousWindow,
106115
});
107116
Object.defineProperty(globalThis, "document", {
108117
configurable: true,
118+
writable: true,
109119
value: previousDocument,
110120
});
111121
Object.defineProperty(globalThis, "navigator", {
112122
configurable: true,
123+
writable: true,
113124
value: previousNavigator,
114125
});
115126
Object.defineProperty(globalThis, "Element", {
116127
configurable: true,
128+
writable: true,
117129
value: previousElement,
118130
});
119131
Object.defineProperty(globalThis, "HTMLElement", {
120132
configurable: true,
133+
writable: true,
121134
value: previousHTMLElement,
122135
});
123136
Object.defineProperty(globalThis, "EventSource", {
124137
configurable: true,
138+
writable: true,
125139
value: previousEventSource,
126140
});
127141
Object.defineProperty(globalThis, "IS_REACT_ACT_ENVIRONMENT", {
128142
configurable: true,
143+
writable: true,
129144
value: previousActEnvironment,
130145
});
131146
}

0 commit comments

Comments
 (0)