Skip to content

Commit 22196fe

Browse files
test(plot): install sess Suggests so svglite path is tested
remotes::install_local() defaults to dependencies=NA, which installs only Depends/Imports/LinkingTo. After svglite was moved from Imports to Suggests (04ebd7d), the build stopped installing it, so the plot_latest handler fell back to png and the session test's strict svglite assertion failed on CI. Pass dependencies=TRUE to the build's install_local call, matching R CMD check semantics so optional (Suggests) functionality is exercised. Also branch the test assertion on svglite availability so it stays correct whether or not svglite is present.
1 parent 26f3bc5 commit 22196fe

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2017,7 +2017,7 @@
20172017
"scripts": {
20182018
"vscode:prepublish": "node esbuild.js --production",
20192019
"changelog": "npx git-cliff v2.8.5.. -o",
2020-
"build": "node esbuild.js && Rscript -e \"remotes::install_local('sess', force=TRUE)\"",
2020+
"build": "node esbuild.js && Rscript -e \"remotes::install_local('sess', dependencies=TRUE, force=TRUE)\"",
20212021
"watch": "node esbuild.js --watch",
20222022
"clean": "rimraf out",
20232023
"pretest": "npm run clean && tsc -p ./",

src/test/suite/session.test.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ suite('Session Communication', () => {
138138
sandbox.stub(util, 'getRterm').resolves(rPath);
139139
sandbox.stub(util, 'promptToInstallSessPackage').resolves();
140140

141+
// svglite is a Suggests (optional) dependency of the sess package, so it may or
142+
// may not be present. Detect it before stubbing so the format assertions below
143+
// can verify the correct code path (SVG when installed, png fallback otherwise).
144+
const svgliteInstalled = (await util.getRPackageVersion('svglite')) !== undefined;
145+
141146
const result = await rTerminal.createRTerm(true);
142147
assert.ok(result);
143148
await waitFor(() => session.activeSession, 15000, 200);
@@ -175,7 +180,14 @@ suite('Session Communication', () => {
175180
}, 15000, 500);
176181

177182
assert.ok(svgliteResp && svgliteResp.data, 'svglite data should be returned');
178-
assert.strictEqual(svgliteResp.format, 'svglite', 'format should be svglite');
183+
// svglite is an optional (Suggests) dependency of the sess package. When it is
184+
// installed the handler renders SVG; otherwise it falls back to png. Assert the
185+
// path that actually applies to this environment so both branches are tested.
186+
if (svgliteInstalled) {
187+
assert.strictEqual(svgliteResp.format, 'svglite', 'format should be svglite when svglite is installed');
188+
} else {
189+
assert.strictEqual(svgliteResp.format, 'png', 'format should fall back to png when svglite is not installed');
190+
}
179191

180192
// Reset history to ensure we track the next plot if we were to recreate the panel
181193
// Wait, since panel is reused, we shouldn't reset history if we just want it to pass,

0 commit comments

Comments
 (0)