Executing node src/js/gamut_viewer.test.js (documented in AGENTS.md under Frontend test suites) fails immediately with ReferenceError: window is not defined.
Static ES import statements are hoisted and executed before any other statements. As a result, running the test in Node.js fails during module evaluation.
Unlike src/js/profcheck.test.js and src/js/chartread.test.js, gamut_viewer.test.js lacks the globalThis.window polyfill and does not auto-run runAll() when executed directly from the Node.js CLI (process.argv[1]?.endsWith('gamut_viewer.test.js')).
Steps to Reproduce
Run the test command documented in AGENTS.md:
node src/js/gamut_viewer.test.js
Console output:
file:///Users/gordon/Projects/ICCery/src/js/gamut_viewer.js:4
const { invoke } = window.__TAURI__.core;
^
ReferenceError: window is not defined
at file:///Users/gordon/Projects/ICCery/src/js/gamut_viewer.js:4:20
at ModuleJob.run (node:internal/modules/esm/module_job:343:25)
Proposed Remediation
In src/js/gamut_viewer.test.js, add the Node environment window polyfill and dynamically import gamut_viewer.js (const { parseGamutFile } = await import('./gamut_viewer.js')), or safely guard typeof window !== 'undefined' in gamut_viewer.js.
Add the Node CLI auto-run block at the end of src/js/gamut_viewer.test.js so node src/js/gamut_viewer.test.js executes and reports results (with non-zero exit code on failure) matching the other test suites.
### Summary
Executing `node src/js/gamut_viewer.test.js` (documented in `AGENTS.md` under Frontend test suites) fails immediately with `ReferenceError: window is not defined`.
### Details & Root Cause
1. In `src/js/gamut_viewer.js` (lines 4–5):
```javascript
const { invoke } = window.__TAURI__.core;
const { listen } = window.__TAURI__.event;
```
Top-level code directly dereferences `window`.
2. In `src/js/gamut_viewer.test.js` (line 5):
```javascript
import { parseGamutFile } from './gamut_viewer.js';
```
Static ES import statements are hoisted and executed before any other statements. As a result, running the test in Node.js fails during module evaluation.
3. Unlike `src/js/profcheck.test.js` and `src/js/chartread.test.js`, `gamut_viewer.test.js` lacks the `globalThis.window` polyfill and does not auto-run `runAll()` when executed directly from the Node.js CLI (`process.argv[1]?.endsWith('gamut_viewer.test.js')`).
### Steps to Reproduce
Run the test command documented in `AGENTS.md`:
```bash
node src/js/gamut_viewer.test.js
```
Console output:
```
file:///Users/gordon/Projects/ICCery/src/js/gamut_viewer.js:4
const { invoke } = window.__TAURI__.core;
^
ReferenceError: window is not defined
at file:///Users/gordon/Projects/ICCery/src/js/gamut_viewer.js:4:20
at ModuleJob.run (node:internal/modules/esm/module_job:343:25)
```
### Proposed Remediation
1. In `src/js/gamut_viewer.test.js`, add the Node environment `window` polyfill and dynamically import `gamut_viewer.js` (`const { parseGamutFile } = await import('./gamut_viewer.js')`), or safely guard `typeof window !== 'undefined'` in `gamut_viewer.js`.
2. Add the Node CLI auto-run block at the end of `src/js/gamut_viewer.test.js` so `node src/js/gamut_viewer.test.js` executes and reports results (with non-zero exit code on failure) matching the other test suites.
Guarded window and window.__TAURI__ globals in src/js/gamut_viewer.js to allow headless evaluation without crashing on missing browser globals.
Added Node CLI polyfills for document, window, and WebGL/DOM stubs in src/js/gamut_viewer.test.js along with dynamic ESM import and test assertions runner.
All 8 unit tests in gamut_viewer.test.js pass cleanly under node src/js/gamut_viewer.test.js.
Resolved in commit `ec7eb2f` on `development`.
- Guarded `window` and `window.__TAURI__` globals in `src/js/gamut_viewer.js` to allow headless evaluation without crashing on missing browser globals.
- Added Node CLI polyfills for `document`, `window`, and WebGL/DOM stubs in `src/js/gamut_viewer.test.js` along with dynamic ESM import and test assertions runner.
- All 8 unit tests in `gamut_viewer.test.js` pass cleanly under `node src/js/gamut_viewer.test.js`.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Summary
Executing
node src/js/gamut_viewer.test.js(documented inAGENTS.mdunder Frontend test suites) fails immediately withReferenceError: window is not defined.Details & Root Cause
src/js/gamut_viewer.js(lines 4–5):window.src/js/gamut_viewer.test.js(line 5):src/js/profcheck.test.jsandsrc/js/chartread.test.js,gamut_viewer.test.jslacks theglobalThis.windowpolyfill and does not auto-runrunAll()when executed directly from the Node.js CLI (process.argv[1]?.endsWith('gamut_viewer.test.js')).Steps to Reproduce
Run the test command documented in
AGENTS.md:Console output:
Proposed Remediation
src/js/gamut_viewer.test.js, add the Node environmentwindowpolyfill and dynamically importgamut_viewer.js(const { parseGamutFile } = await import('./gamut_viewer.js')), or safely guardtypeof window !== 'undefined'ingamut_viewer.js.src/js/gamut_viewer.test.jssonode src/js/gamut_viewer.test.jsexecutes and reports results (with non-zero exit code on failure) matching the other test suites.Resolved in commit
ec7eb2fondevelopment.windowandwindow.__TAURI__globals insrc/js/gamut_viewer.jsto allow headless evaluation without crashing on missing browser globals.document,window, and WebGL/DOM stubs insrc/js/gamut_viewer.test.jsalong with dynamic ESM import and test assertions runner.gamut_viewer.test.jspass cleanly undernode src/js/gamut_viewer.test.js.