openscad-playground/tests/e2e.test.js

135 lines
3.9 KiB
JavaScript
Raw Normal View History

🌈 Colorful Playground (#37) * glb (color-assimp2 branch) + model-viewer * color support + customizable output format * cleanup * disable monaco on iOS * reinstate STL viewer when output is stl * default to stl * fix iOS editor * script to build openscad-wasm from a branch / local repo * update fork link + build instructions * Update build-openscad-wasm.sh * Update initial-state.ts * update openscad3 refs * update wasm build script * Update Dockerfile.wasm * add jszip dep * multimaterial: color conversion + 3MF face painting * ignore ts error about compression apis * Update tsconfig.json * multimaterial support w/ extruder colors input component * fix wasm build script * symlinks for openscad.{js,wasm} under src * fix error line shift for bundled files * remove obsolete build script * set OPENSCADPATH env var * render-colors feature renamed * Customizer + prepare Multi-asset support * hide customizer button if unselected, hide it if no params, * Create build-openscad-wasm.sh * update build script * complete sound * fetchSource util * wider rotation allowance * use CSG-modules.scad as default * Update CustomizerPanel.tsx * Update index.html * capture save, allow Ctrl+Shift+Save to save project * customizer: fieldsets are better than accordion * expand customizer tabs by default * tooltip for reset buttons * pretty c++ exceptions * Delete inline-openscad-worker.ts * shuffle ux * use uzip instead of jszip for 3mf materialization * handle legacy links * update links to fork * use render-modifiers feature from color-assimp2 in preview mode * include NopSCADlib's STL files in archive * bind global f5 / f6 * update homepage back to openscad2 * styling fixes (editor alpha, customizer margins) * Add help link for customizer * fix customizer sliders (also need to show value input) * fix vector customizer component * style fallback editor * shorter logs button * customizer: rm reset button tooltip * customizer: allow dnd on viewer below, tweak background * add lights to modelviewer using an env image (gltf lights hard to plug across assimp for now) * update customizer styles * Update .gitignore * add license for UZIP.js (MIT) * Update skybox-lights.jpg * Update actions.ts * include NopSCADlib's STLs * Update LICENSE.md * include YAPP_Box examples * limit customizer height * Update skybox-lights.jpg * Update skybox-lights.jpg * Update openscad-worker.ts * build-openscad-wasm.sh fix: docker won't mount files outside home directory * Use Google CDN instead of unpkg for modelviewer * tmp updates before merge * Add ccache support to build-openscad-wasm.sh * Fix makefile * Update README.md * Fix ts imports * Delete build-openscad-wasm.sh * Crude off -> glb converter * Remove assimp related code * gltf diffs * Build using head openscad * readme: Update build prerequisites * make: attempt to build wasm binary in parallel first * Remove 3mf extruder color mapping & fix render / export flows (render all 3d to off) * off2glb: triangulate faces + add default color * Add simple e2e puppeteer test * ci: update pinned build to master output artefact * Update Makefile * Update test.yml * Update test.yml * Update test.yml * Update test.yml * ci: use relative node version names * Update test.yml * state: Remove renderFormat, introduce is2D * disable service worker in devel mode * remove dead code * build: fix NODE_ENV define * ci: simplify env vars * cleanups * Update README.md
2024-12-22 22:41:35 +00:00
const longTimeout = 60000;
const isProd = process.env.NODE_ENV === 'production';
2024-12-26 19:18:46 +00:00
const baseUrl = isProd ? 'http://localhost:3000/dist/' : 'http://localhost:4000/';
🌈 Colorful Playground (#37) * glb (color-assimp2 branch) + model-viewer * color support + customizable output format * cleanup * disable monaco on iOS * reinstate STL viewer when output is stl * default to stl * fix iOS editor * script to build openscad-wasm from a branch / local repo * update fork link + build instructions * Update build-openscad-wasm.sh * Update initial-state.ts * update openscad3 refs * update wasm build script * Update Dockerfile.wasm * add jszip dep * multimaterial: color conversion + 3MF face painting * ignore ts error about compression apis * Update tsconfig.json * multimaterial support w/ extruder colors input component * fix wasm build script * symlinks for openscad.{js,wasm} under src * fix error line shift for bundled files * remove obsolete build script * set OPENSCADPATH env var * render-colors feature renamed * Customizer + prepare Multi-asset support * hide customizer button if unselected, hide it if no params, * Create build-openscad-wasm.sh * update build script * complete sound * fetchSource util * wider rotation allowance * use CSG-modules.scad as default * Update CustomizerPanel.tsx * Update index.html * capture save, allow Ctrl+Shift+Save to save project * customizer: fieldsets are better than accordion * expand customizer tabs by default * tooltip for reset buttons * pretty c++ exceptions * Delete inline-openscad-worker.ts * shuffle ux * use uzip instead of jszip for 3mf materialization * handle legacy links * update links to fork * use render-modifiers feature from color-assimp2 in preview mode * include NopSCADlib's STL files in archive * bind global f5 / f6 * update homepage back to openscad2 * styling fixes (editor alpha, customizer margins) * Add help link for customizer * fix customizer sliders (also need to show value input) * fix vector customizer component * style fallback editor * shorter logs button * customizer: rm reset button tooltip * customizer: allow dnd on viewer below, tweak background * add lights to modelviewer using an env image (gltf lights hard to plug across assimp for now) * update customizer styles * Update .gitignore * add license for UZIP.js (MIT) * Update skybox-lights.jpg * Update actions.ts * include NopSCADlib's STLs * Update LICENSE.md * include YAPP_Box examples * limit customizer height * Update skybox-lights.jpg * Update skybox-lights.jpg * Update openscad-worker.ts * build-openscad-wasm.sh fix: docker won't mount files outside home directory * Use Google CDN instead of unpkg for modelviewer * tmp updates before merge * Add ccache support to build-openscad-wasm.sh * Fix makefile * Update README.md * Fix ts imports * Delete build-openscad-wasm.sh * Crude off -> glb converter * Remove assimp related code * gltf diffs * Build using head openscad * readme: Update build prerequisites * make: attempt to build wasm binary in parallel first * Remove 3mf extruder color mapping & fix render / export flows (render all 3d to off) * off2glb: triangulate faces + add default color * Add simple e2e puppeteer test * ci: update pinned build to master output artefact * Update Makefile * Update test.yml * Update test.yml * Update test.yml * Update test.yml * ci: use relative node version names * Update test.yml * state: Remove renderFormat, introduce is2D * disable service worker in devel mode * remove dead code * build: fix NODE_ENV define * ci: simplify env vars * cleanups * Update README.md
2024-12-22 22:41:35 +00:00
const messages = [];
beforeAll(async () => {
page.on('console', (msg) => messages.push({
type: msg.type(),
text: msg.text(),
stack: msg.stackTrace(),
location: msg.location(),
}));
});
beforeEach(async () => {
messages.length = 0;
await page.goto('about:blank');
});
afterEach(async () => {
// console.log('Messages:', JSON.stringify(messages, null, 2));
2024-12-25 13:58:44 +00:00
const testName = expect.getState().currentTestName;
console.log(`[${testName}] Messages:`, JSON.stringify(messages.map(({text}) => text), null, 2));
🌈 Colorful Playground (#37) * glb (color-assimp2 branch) + model-viewer * color support + customizable output format * cleanup * disable monaco on iOS * reinstate STL viewer when output is stl * default to stl * fix iOS editor * script to build openscad-wasm from a branch / local repo * update fork link + build instructions * Update build-openscad-wasm.sh * Update initial-state.ts * update openscad3 refs * update wasm build script * Update Dockerfile.wasm * add jszip dep * multimaterial: color conversion + 3MF face painting * ignore ts error about compression apis * Update tsconfig.json * multimaterial support w/ extruder colors input component * fix wasm build script * symlinks for openscad.{js,wasm} under src * fix error line shift for bundled files * remove obsolete build script * set OPENSCADPATH env var * render-colors feature renamed * Customizer + prepare Multi-asset support * hide customizer button if unselected, hide it if no params, * Create build-openscad-wasm.sh * update build script * complete sound * fetchSource util * wider rotation allowance * use CSG-modules.scad as default * Update CustomizerPanel.tsx * Update index.html * capture save, allow Ctrl+Shift+Save to save project * customizer: fieldsets are better than accordion * expand customizer tabs by default * tooltip for reset buttons * pretty c++ exceptions * Delete inline-openscad-worker.ts * shuffle ux * use uzip instead of jszip for 3mf materialization * handle legacy links * update links to fork * use render-modifiers feature from color-assimp2 in preview mode * include NopSCADlib's STL files in archive * bind global f5 / f6 * update homepage back to openscad2 * styling fixes (editor alpha, customizer margins) * Add help link for customizer * fix customizer sliders (also need to show value input) * fix vector customizer component * style fallback editor * shorter logs button * customizer: rm reset button tooltip * customizer: allow dnd on viewer below, tweak background * add lights to modelviewer using an env image (gltf lights hard to plug across assimp for now) * update customizer styles * Update .gitignore * add license for UZIP.js (MIT) * Update skybox-lights.jpg * Update actions.ts * include NopSCADlib's STLs * Update LICENSE.md * include YAPP_Box examples * limit customizer height * Update skybox-lights.jpg * Update skybox-lights.jpg * Update openscad-worker.ts * build-openscad-wasm.sh fix: docker won't mount files outside home directory * Use Google CDN instead of unpkg for modelviewer * tmp updates before merge * Add ccache support to build-openscad-wasm.sh * Fix makefile * Update README.md * Fix ts imports * Delete build-openscad-wasm.sh * Crude off -> glb converter * Remove assimp related code * gltf diffs * Build using head openscad * readme: Update build prerequisites * make: attempt to build wasm binary in parallel first * Remove 3mf extruder color mapping & fix render / export flows (render all 3d to off) * off2glb: triangulate faces + add default color * Add simple e2e puppeteer test * ci: update pinned build to master output artefact * Update Makefile * Update test.yml * Update test.yml * Update test.yml * Update test.yml * ci: use relative node version names * Update test.yml * state: Remove renderFormat, introduce is2D * disable service worker in devel mode * remove dead code * build: fix NODE_ENV define * ci: simplify env vars * cleanups * Update README.md
2024-12-22 22:41:35 +00:00
const errors = messages.filter(msg =>
msg.type === 'error' &&
!(msg.text.includes('404')
&& msg.stack.some(s =>
s.url.indexOf('fonts/InterVariable.woff') >= 0)));
expect(errors).toHaveLength(0);
});
function loadSrc(src) {
2024-12-26 19:18:46 +00:00
return page.goto(baseUrl + '#src=' + encodeURIComponent(src));
}
2024-12-25 13:58:44 +00:00
function loadPath(path) {
2024-12-26 19:18:46 +00:00
return page.goto(baseUrl + '#path=' + encodeURIComponent(path));
}
function loadUrl(url) {
return page.goto(baseUrl + '#url=' + encodeURIComponent(url));
2024-12-25 13:58:44 +00:00
}
async function waitForViewer() {
await page.waitForSelector('model-viewer');
await page.waitForFunction(() => {
const viewer = document.querySelector('model-viewer.main-viewer');
return viewer && viewer.src !== '';
});
}
function expectMessage(messages, line) {
const successMessage = messages.filter(msg => msg.type === 'debug' && msg.text === line);
expect(successMessage).toHaveLength(1);
}
function expectObjectList() {
expectMessage(messages, 'stderr: Top level object is a list of objects:');
}
function expect3DPolySet() {
expectMessage(messages, 'stderr: Top level object is a 3D object (PolySet):');
}
function expect3DManifold() {
expectMessage(messages, 'stderr: Top level object is a 3D object (manifold):');
}
function waitForCustomizeButton() {
return page.waitForFunction(() => {
const buttons = document.querySelectorAll('input[role=switch]');
for (const button of buttons) {
if (button.parentElement.innerText === 'Customize') {
return button;
}
}
});
}
function waitForLabel(text) {
return page.waitForFunction((text) => {
return Array.from(document.querySelectorAll('label')).find(el => el.textContent === 'myVar');
// return Array.from(document.querySelectorAll('label')).find(el => el.textContent === text);
}, {}, text);
}
describe('e2e', () => {
test('load the default page', async () => {
2024-12-26 19:18:46 +00:00
await page.goto(baseUrl);
await waitForViewer();
2024-12-25 12:04:44 +00:00
expectObjectList();
}, longTimeout);
test('can render cube', async () => {
await loadSrc('cube([10, 10, 10]);');
await waitForViewer();
expect3DPolySet();
}, longTimeout);
test('use BOSL2', async () => {
await loadSrc(`
include <BOSL2/std.scad>;
prismoid([40,40], [0,0], h=20);
`);
await waitForViewer();
2024-12-25 12:13:12 +00:00
expect3DPolySet();
}, longTimeout);
test('use NopSCADlib', async () => {
await loadSrc(`
include <NopSCADlib/vitamins/led_meters.scad>
meter(led_meter);
`);
await waitForViewer();
expect3DManifold();
}, longTimeout);
2024-12-25 13:58:44 +00:00
test('load a demo by path', async () => {
await loadPath('/libraries/closepoints/demo_3D_art.scad');
await waitForViewer();
expect3DPolySet();
}, longTimeout);
2024-12-26 19:18:46 +00:00
test('load a demo by url', async () => {
await loadUrl('https://github.com/tenstad/keyboard/blob/main/keyboard.scad');
await waitForViewer();
expect3DManifold();
}, longTimeout);
test('customizer & windows line endings work', async () => {
await loadSrc([
'myVar = 10;',
'cube(myVar);',
].join('\r\n'));
await waitForViewer();
expect3DPolySet();
await (await waitForCustomizeButton()).click();
await page.waitForSelector('fieldset');
await waitForLabel('myVar');
🌈 Colorful Playground (#37) * glb (color-assimp2 branch) + model-viewer * color support + customizable output format * cleanup * disable monaco on iOS * reinstate STL viewer when output is stl * default to stl * fix iOS editor * script to build openscad-wasm from a branch / local repo * update fork link + build instructions * Update build-openscad-wasm.sh * Update initial-state.ts * update openscad3 refs * update wasm build script * Update Dockerfile.wasm * add jszip dep * multimaterial: color conversion + 3MF face painting * ignore ts error about compression apis * Update tsconfig.json * multimaterial support w/ extruder colors input component * fix wasm build script * symlinks for openscad.{js,wasm} under src * fix error line shift for bundled files * remove obsolete build script * set OPENSCADPATH env var * render-colors feature renamed * Customizer + prepare Multi-asset support * hide customizer button if unselected, hide it if no params, * Create build-openscad-wasm.sh * update build script * complete sound * fetchSource util * wider rotation allowance * use CSG-modules.scad as default * Update CustomizerPanel.tsx * Update index.html * capture save, allow Ctrl+Shift+Save to save project * customizer: fieldsets are better than accordion * expand customizer tabs by default * tooltip for reset buttons * pretty c++ exceptions * Delete inline-openscad-worker.ts * shuffle ux * use uzip instead of jszip for 3mf materialization * handle legacy links * update links to fork * use render-modifiers feature from color-assimp2 in preview mode * include NopSCADlib's STL files in archive * bind global f5 / f6 * update homepage back to openscad2 * styling fixes (editor alpha, customizer margins) * Add help link for customizer * fix customizer sliders (also need to show value input) * fix vector customizer component * style fallback editor * shorter logs button * customizer: rm reset button tooltip * customizer: allow dnd on viewer below, tweak background * add lights to modelviewer using an env image (gltf lights hard to plug across assimp for now) * update customizer styles * Update .gitignore * add license for UZIP.js (MIT) * Update skybox-lights.jpg * Update actions.ts * include NopSCADlib's STLs * Update LICENSE.md * include YAPP_Box examples * limit customizer height * Update skybox-lights.jpg * Update skybox-lights.jpg * Update openscad-worker.ts * build-openscad-wasm.sh fix: docker won't mount files outside home directory * Use Google CDN instead of unpkg for modelviewer * tmp updates before merge * Add ccache support to build-openscad-wasm.sh * Fix makefile * Update README.md * Fix ts imports * Delete build-openscad-wasm.sh * Crude off -> glb converter * Remove assimp related code * gltf diffs * Build using head openscad * readme: Update build prerequisites * make: attempt to build wasm binary in parallel first * Remove 3mf extruder color mapping & fix render / export flows (render all 3d to off) * off2glb: triangulate faces + add default color * Add simple e2e puppeteer test * ci: update pinned build to master output artefact * Update Makefile * Update test.yml * Update test.yml * Update test.yml * Update test.yml * ci: use relative node version names * Update test.yml * state: Remove renderFormat, introduce is2D * disable service worker in devel mode * remove dead code * build: fix NODE_ENV define * ci: simplify env vars * cleanups * Update README.md
2024-12-22 22:41:35 +00:00
}, longTimeout);
});