Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,17 @@
frames.forEach(frame => {
frame.setAttribute('src', window.origin);
});
function startTests() {

async function startTests() {
let loaded = 0;
return frames
.reduce((promise, frame) => {
return promise.then(() => {
const id = frame.getAttribute('id');
driver = new SnapDriver();
driver.setWindow(frame.contentWindow);
return driver.login('test');
});
}, Promise.resolve())
.then(() => mocha.run());
for (let i = 0; i < frames.length; i++) {
const id = frames[i].getAttribute('id');
driver = new SnapDriver();
driver.setWindow(frames[i].contentWindow);
await driver.login('test');
}
await loadProjectTests();
mocha.run();
}

function checkLoaded() {
Expand Down Expand Up @@ -86,6 +85,7 @@
<script src="./xml.spec.js"></script>
<script src="./url.spec.js"></script>
<script src="./cloud.spec.js"></script>
<script src="./projects.spec.js"></script>
<script src="/test/lib/materialize.min.js"></script>

<script>
Expand Down
77 changes: 77 additions & 0 deletions test/projects.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/* globals driver */
async function loadProjectTests() {
driver._window.mocha = mocha;
driver._window.it = it;
describe('project tests', function() {

const projectNames = [
//'chart-tests',
//'earthquakes',

'rpc-list-tests',
'serialize-fn-rpcs',
'trivia-tests',
'kvstore-tests',
//'execute-tests',
'hangman-tests',
'air-quality-tests',
'google-maps-tests',
'send-fn-tests',
];

for (let i = projectNames.length; i--;) {
const name = projectNames[i];
describe(`${name} project`, function() {
let error = null;
let handleError = null;

before(async function() {
this.timeout(10000);
await loadProject(name);

const {Process} = driver.globals();
handleError = Process.prototype.handleError;
Process.prototype.handleError = function(e) {
error = e;
return handleError.apply(this, arguments);
};
});

beforeEach(() => error = null);

after(function() {
const {Process} = driver.globals();
Process.prototype.handleError = handleError;
});

it('should run tests without error', async function() {
this.timeout(5000);
driver.ide().runScripts();
await driver.expect(
() => {
const procs = driver.ide().stage.threads.processes;
const runningProcs = procs.filter(proc => !proc.readyToTerminate);
return runningProcs.length === 0;
},
'Script execution did not terminate'
);

if (error) {
throw error;
}
});
});
}
});
}

async function loadProject(name) {
const url = `/test/projects/${name}.xml`;
const response = await fetch(url);
const xml = (await response.text())
.replace(/^.*<project/, '<project')
.replace(/<\/project>.*/, '');

const {SnapActions} = driver.globals();
return SnapActions.openProject(xml);
}
1 change: 1 addition & 0 deletions test/projects/air-quality-tests.xml

Large diffs are not rendered by default.

File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions test/projects/execute-tests.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/projects/google-maps-tests.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/projects/hangman-tests.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/projects/kvstore-tests.xml

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions test/projects/rpc-list-tests.xml

Large diffs are not rendered by default.

File renamed without changes.
1 change: 1 addition & 0 deletions test/projects/send-fn-tests.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/projects/serialize-fn-rpcs.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions test/projects/testing-blocks.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<blocks app="NetsBlox 1.17.0, http://netsblox.org" version="1.17.0"><block-definition collabId="item_89_41" s="it should %&apos;testname&apos; %&apos;action&apos;" type="command" category="sensing"><header></header><code></code><inputs><input type="%s"></input><input type="%cs"></input></inputs><script><block collabId="item_302_4" s="doRun"><block collabId="item_302_6" s="reportJSFunction"><list><l>name</l></list><l>process = arguments[1];&#xD;process.handleError = function(err, element) {&#xD; err.name = &apos;"&apos; + name + &apos;": &apos; + err.name;&#xD; return Process.prototype.handleError.apply(this, arguments);&#xD;};</l></block><list><block collabId="item_302_7" var="testname"/></list></block><block collabId="item_302_5" s="doRun"><block collabId="item_302_13" var="action"/><list></list></block><block collabId="item_302_12" s="doRun"><block collabId="item_302_14" s="reportJSFunction"><list></list><l>delete arguments[0].handleError;</l></block><list></list></block></script></block-definition><block-definition collabId="item_89_12" s="assert %&apos;cond&apos;" type="command" category="lists"><header></header><code></code><inputs><input type="%b"></input></inputs><script><block collabId="item_89_6" s="doRun"><block collabId="item_89_5" s="reportJSFunction"><list><l>cond</l></list><l>if (!cond) {&#xD;throw Error(&apos;ASSERTION FAILED&apos;);&#xD;}</l></block><list><block collabId="item_89" var="cond"/></list></block></script></block-definition></blocks>
7 changes: 7 additions & 0 deletions test/projects/trivia-tests.xml

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion test/rpc/ExecuteServiceTests.xml

This file was deleted.

1 change: 0 additions & 1 deletion test/rpc/airquality-tests.xml

This file was deleted.

1 change: 0 additions & 1 deletion test/rpc/googlemap-tests.xml

This file was deleted.

1 change: 0 additions & 1 deletion test/rpc/hangman-tests.xml

This file was deleted.

Loading