mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-10-26 19:01:39 -04:00
Adds a split button to the STL and 3MF preview toolbars that opens the model directly in a desktop slicer via its URL scheme (scheme://open?file=<absolute media URL>). The slicer downloads the file itself over the network. Offers Orca Slicer, Bambu Studio, and Cura; the last-used slicer is remembered in localStorage and becomes the split button's default, since browsers cannot detect which protocol handlers are installed. PrusaSlicer is deliberately omitted: it only downloads from domains whitelisted by Prusa (printables.com, thingiverse.com, cults3d.com), so it cannot fetch from a WROLPi. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
24 lines
1.1 KiB
JavaScript
24 lines
1.1 KiB
JavaScript
import {getSlicerURL, SLICERS} from "./FilePreview";
|
|
|
|
describe('getSlicerURL', () => {
|
|
test('builds a slicer link with the absolute media URL encoded once', () => {
|
|
const previewFile = {path: '3d printing/benchy.stl'};
|
|
const url = getSlicerURL(previewFile, 'orcaslicer');
|
|
expect(url).toEqual(
|
|
`orcaslicer://open?file=${encodeURIComponent('http://localhost/media/3d%20printing/benchy.stl')}`);
|
|
});
|
|
|
|
test('prefers primary_path and encodes special characters', () => {
|
|
const previewFile = {
|
|
primary_path: 'models/Buckle #2 (v2)/buckle.3mf',
|
|
path: 'models/Buckle #2 (v2)/buckle.stl',
|
|
};
|
|
const url = getSlicerURL(previewFile, 'bambustudio');
|
|
expect(url).toEqual(
|
|
`bambustudio://open?file=${encodeURIComponent('http://localhost/media/models/Buckle%20%232%20(v2)/buckle.3mf')}`);
|
|
});
|
|
|
|
test('PrusaSlicer is not offered because it only downloads from whitelisted domains', () => {
|
|
expect(SLICERS.map(s => s.scheme)).not.toContain('prusaslicer');
|
|
});
|
|
});
|