Normalize CRLF to \n and test customizer in e2e test
This commit is contained in:
parent
657ccb9181
commit
32fee6eb06
2 changed files with 45 additions and 5 deletions
|
|
@ -157,7 +157,7 @@ export async function fetchSource({content, path, url}: Source) {
|
||||||
} else if (url) {
|
} else if (url) {
|
||||||
if (path.endsWith('.scad') || path.endsWith('.json')) {
|
if (path.endsWith('.scad') || path.endsWith('.json')) {
|
||||||
content = await (await fetch(url)).text();
|
content = await (await fetch(url)).text();
|
||||||
return content;
|
return content.replace(/\r\n/g, '\n');
|
||||||
} else {
|
} else {
|
||||||
// Fetch bytes
|
// Fetch bytes
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
|
|
|
||||||
|
|
@ -45,18 +45,43 @@ function expectMessage(messages, line) {
|
||||||
const successMessage = messages.filter(msg => msg.type === 'debug' && msg.text === line);
|
const successMessage = messages.filter(msg => msg.type === 'debug' && msg.text === line);
|
||||||
expect(successMessage).toHaveLength(1);
|
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', () => {
|
describe('e2e', () => {
|
||||||
test('load the default page', async () => {
|
test('load the default page', async () => {
|
||||||
await page.goto(url);
|
await page.goto(url);
|
||||||
await waitForViewer();
|
await waitForViewer();
|
||||||
expectMessage(messages, 'stderr: Top level object is a list of objects:');
|
expectOjbectList();
|
||||||
}, longTimeout);
|
}, longTimeout);
|
||||||
|
|
||||||
test('can render cube', async () => {
|
test('can render cube', async () => {
|
||||||
await loadSrc('cube([10, 10, 10]);');
|
await loadSrc('cube([10, 10, 10]);');
|
||||||
await waitForViewer();
|
await waitForViewer();
|
||||||
expectMessage(messages, 'stderr: Top level object is a 3D object (PolySet):');
|
expect3DPolySet();
|
||||||
}, longTimeout);
|
}, longTimeout);
|
||||||
|
|
||||||
test('use BOSL2', async () => {
|
test('use BOSL2', async () => {
|
||||||
|
|
@ -65,7 +90,7 @@ describe('e2e', () => {
|
||||||
prismoid([40,40], [0,0], h=20);
|
prismoid([40,40], [0,0], h=20);
|
||||||
`);
|
`);
|
||||||
await waitForViewer();
|
await waitForViewer();
|
||||||
expectMessage(messages, 'stderr: Top level object is a 3D object (PolySet):');
|
expect3DManifold();
|
||||||
}, longTimeout);
|
}, longTimeout);
|
||||||
|
|
||||||
test('use NopSCADlib', async () => {
|
test('use NopSCADlib', async () => {
|
||||||
|
|
@ -74,6 +99,21 @@ describe('e2e', () => {
|
||||||
meter(led_meter);
|
meter(led_meter);
|
||||||
`);
|
`);
|
||||||
await waitForViewer();
|
await waitForViewer();
|
||||||
expectMessage(messages, 'stderr: Top level object is a 3D object (manifold):');
|
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');
|
||||||
}, longTimeout);
|
}, longTimeout);
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue