-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathapp.test.ts
84 lines (69 loc) · 2.36 KB
/
app.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
import path from 'path';
import { Application } from 'spectron';
import socketio from 'socket.io-client';
const PORT = 8090;
describe('App', () => {
let app: Application;
beforeAll(() => {
app = new Application({
env: {
USERDATA: path.join(__dirname, 'data'),
PORT: PORT,
NODE_ENV: 'CI'
},
path: path.join(
__dirname,
'..',
'node_modules',
'.bin',
'electron'
),
args: [path.join(__dirname, '..')],
chromeDriverArgs: ['--no-sandbox', '--disable-dev-shm-usage']
});
return app.start();
}, 30000);
afterAll(async () => {
if (app && app.isRunning()) {
await app.stop();
app.mainProcess.abort();
}
});
describe('launch', () => {
it('shows an initial window', async () => {
const count = await app.client.getWindowCount();
expect(count).toBeGreaterThan(0);
});
it('shows the H5P Editor pad', async () => {
const h5peditor = await app.client.$('launchpad-h5peditor');
expect(h5peditor).toBeTruthy();
}, 30000);
it('shows the Analytics pad', async () => {
const analytics = await app.client.$('launchpad-analytics');
expect(analytics).toBeTruthy();
}, 30000);
});
describe('Open H5P file', () => {
it('displays an error snackbar if the open .h5p file is not valid', async () => {
const ws = socketio(`http://localhost:${PORT}`);
ws.emit('dispatch', {
payload: { paths: [`${__dirname}/broken.h5p`] },
type: 'OPEN_H5P'
});
const snackbar = await app.client.$('#notistack-snackbar');
expect(await snackbar.getText()).toBeDefined();
ws.disconnect();
});
// it('opens a valid .h5p file', async () => {
// const ws = socketio(`http://localhost:${PORT}`);
// ws.emit('dispatch', {
// payload: { paths: [`${__dirname}/valid.h5p`] },
// type: 'OPEN_H5P'
// });
// setTimeout(() => {
// ws.disconnect();
// ;
// }, 10000);
// });
});
});