@@ -79,9 +79,18 @@ Since gglite generates HTML/JavaScript visualizations, **plots must be tested in
7979headless browsers** to make sure they can be rendered correctly and produce no
8080errors in the browser console. The workflow is:
8181
82- 1. **Render to a full HTML page** — both `.Rmd` and `.R` files can be rendered
83- to `.html` via `litedown::fuse()`. The output is self-contained (all JS/CSS
84- embedded) because `embed_resources` is enabled in `copilot-setup-steps.yml`.
82+ > **Prefer SVG rendering for headless tests.** Set
83+ > `options(gglite.renderer = ' svg' )` before calling `litedown::fuse()` so the
84+ > rendered output contains an `<svg>` element that you can inspect directly in
85+ > the DOM. SVG attributes (fill, stroke, etc.) are directly readable without
86+ > relying on canvas pixel values, making theme and style verification much
87+ > easier. Use `document.querySelectorAll(' svg rect[fill]' )` or similar to check
88+ > theme properties.
89+
90+ 1. **Render to a full HTML page** — set `options(gglite.renderer = ' svg' )`,
91+ then render both `.Rmd` and `.R` files to `.html` via `litedown::fuse()`.
92+ The output is self-contained (all JS/CSS embedded) because `embed_resources`
93+ is enabled in `copilot-setup-steps.yml`.
8594
86952. **Open with `google-chrome` under Xvfb** and enable remote debugging. Use
8796 `google-chrome`, **not** `chromium` — `chromium` crashes in this
@@ -140,14 +149,19 @@ errors in the browser console. The workflow is:
140149 {" url" : " file:///absolute/path/to/foo.html" })
141150 await asyncio.sleep(8) # wait for G2 charts to render
142151
152+ # For SVG renderer: inspect element attributes directly
143153 r = await js(ws, " JSON.stringify({G2: typeof G2 !== 'undefined', "
144- " c : document.querySelectorAll('canvas ').length})" )
154+ " svgs : document.querySelectorAll('svg ').length})" )
145155 print(" Status:" , r[" result" ][" value" ])
146156
147- # Hover over a canvas to trigger tooltip
148- await send(ws, " Input.dispatchMouseEvent" ,
149- {" type" : " mouseMoved" , " x" : 400, " y" : 300})
150- await asyncio.sleep(0.8)
157+ # Example: check area fill color for dark theme
158+ r2 = await js(ws, " " "
159+ var areas = Array.from(document.querySelectorAll('.area'));
160+ JSON.stringify(areas.map(el => ({fill: el.getAttribute('fill'),
161+ stroke: el.getAttribute('stroke')})))
162+ " " " )
163+ print(" Area elements:" , r2[" result" ][" value" ])
164+
151165 await shot(ws, " /tmp/screenshot.png" )
152166
153167 asyncio.run(main ())
@@ -158,6 +172,8 @@ errors in the browser console. The workflow is:
158172 - The chart container element exists in the DOM.
159173 - The G2 chart renders without JavaScript errors (check ` console.error` ).
160174 - No warnings or errors appear in the browser console.
175+ - For SVG renderer: inspect element attributes (fill, stroke) directly to
176+ verify theme colors.
161177
162178# ## Submitting Plot Changes in PRs
163179
0 commit comments