Skip to content
This repository has been archived by the owner on Feb 23, 2022. It is now read-only.

Commit

Permalink
Merge pull request #309 from multinet-app/fix-client-tests
Browse files Browse the repository at this point in the history
Abort tests on unhandled promises
  • Loading branch information
waxlamp committed Feb 11, 2020
2 parents e365cca + 60ed882 commit 2ab60ad
Showing 1 changed file with 54 additions and 57 deletions.
111 changes: 54 additions & 57 deletions client/test/e2e.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import process from 'process';

import test from 'tape';
import puppeteer from 'puppeteer';

process.on('unhandledRejection', (error) => {
console.log('FATAL: unhandled promise rejection');
console.log(error);

process.exit(1);
});

const width = 1920;
const height = 1080;

Expand All @@ -19,7 +28,7 @@ async function setup() {
const p = await b.newPage();
await p.setViewport({ width, height });
await p.goto('http://127.0.0.1:58080/');
await p.setDefaultTimeout(2000); // Default timeout of 30 seconds
await p.setDefaultTimeout(5000);
return [b, p];
}

Expand Down Expand Up @@ -99,68 +108,56 @@ test('e2e - Check that actions that should work, do work', async (t) => {
// Arrange: Set up the page
const [b, p] = await setup();

try {
// Act: Test creating a workspace
await create_workspace(p, 'puppeteer');
// Act: Test creating a workspace
await create_workspace(p, 'puppeteer');

// Assert: Check that the new workspace exists with no tables
let exists = await workspace_exists(p, 'puppeteer');
t.ok(exists, 'Workspace called "puppeteer" was created.');
// Assert: Check that the new workspace exists with no tables
let exists = await workspace_exists(p, 'puppeteer');
t.ok(exists, 'Workspace called "puppeteer" was created.');

// Assert: Check that there are no tables or graphs yet
exists = await elements_empty('Tables', p, undefined);
// Assert: Check that there are no tables or graphs yet
exists = await elements_empty('Tables', p, undefined);

t.ok(exists, 'The new workspace has no tables.');
t.ok(exists, 'The new workspace has no tables.');

exists = await elements_empty('Networks', p, undefined);
t.ok(exists, 'The new workspace has no networks.');
exists = await elements_empty('Networks', p, undefined);
t.ok(exists, 'The new workspace has no networks.');

// Cleanup
await b.close();
t.end();
} catch(e) {
await b.close();
t.fail('Tests crashed');
t.end();
}
// Cleanup
await b.close();
t.end();
});

test('e2e - Check that actions that shouldn\'t work, don\'t work', async (t) => {
// Arrange: Set up the page
const [b, p] = await setup();

try {
// Act: Test creating invalid workspaces
await create_workspace(p, '123');
await p.click('#workspace-name', { clickCount: 3 });
await p.click('#add-workspace'); // Close the modal (this will cause a failure in the next command if it is made)

await create_workspace(p, '++--==__');
await p.click('#workspace-name', { clickCount: 3 });
await p.click('#add-workspace'); // Close the modal (this will cause a failure in the next command if it is made)

await create_workspace(p, 'a');

// Assert: Check that the new workspace exists with no tables
await sleep(200);
let exists = await workspace_exists(p, '123');
t.notOk(exists, 'Workspace called "123" wasn\'t created.');

exists = await workspace_exists(p, '++--==__');
t.notOk(exists, 'Workspace called "++--==__" wasn\'t created.');

exists = await workspace_exists(p, 'a');
t.ok(exists, 'Workspace called "a" was created.');

exists = await element_exists('Tables', p, 'broken');
t.notOk(exists, 'New workspaces don\'t have tables');

// Cleanup
await b.close();
t.end();
} catch(e) {
await b.close();
t.fail('Tests crashed');
t.end();
}
// Arrange: Set up the page
const [b, p] = await setup();

// Act: Test creating invalid workspaces
await create_workspace(p, '123');
await p.click('#workspace-name', { clickCount: 3 });
await p.click('#add-workspace'); // Close the modal (this will cause a failure in the next command if it is made)

await create_workspace(p, '++--==__');
await p.click('#workspace-name', { clickCount: 3 });
await p.click('#add-workspace'); // Close the modal (this will cause a failure in the next command if it is made)

await create_workspace(p, 'a');

// Assert: Check that the new workspace exists with no tables
await sleep(200);
let exists = await workspace_exists(p, '123');
t.notOk(exists, 'Workspace called "123" wasn\'t created.');

exists = await workspace_exists(p, '++--==__');
t.notOk(exists, 'Workspace called "++--==__" wasn\'t created.');

exists = await workspace_exists(p, 'a');
t.ok(exists, 'Workspace called "a" was created.');

exists = await element_exists('Tables', p, 'broken');
t.notOk(exists, 'New workspaces don\'t have tables');

// Cleanup
await b.close();
t.end();
});

0 comments on commit 2ab60ad

Please sign in to comment.