-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathacceptance-test-basic-start.js
89 lines (73 loc) · 2.71 KB
/
acceptance-test-basic-start.js
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
85
86
87
88
89
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2021-2024 Stichting Open Electronics Lab
// vim: set sts=4 shiftwidth=4 expandtab :
"use strict";
/*
'/usr/bin/node',
'/home/ace/src/adfice-ace/node_modules/testcafe/lib/cli',
'firefox:headless',
'acceptance-test-cafe.js',
'http://127.0.0.1:8090'
*/
/* To run tests not headless (using 55556 as an arbitrary port):
node adfice-webserver-runner.js 55556
./node_modules/.bin/testcafe firefox acceptance-test-cafe.js http://127.0.0.1:55556
*/
let BASE_URL = process.argv[4];
import {
Selector,
ClientFunction
} from 'testcafe';
fixture `Adfice`;
fixture `TestController.setNativeDialogHandler`;
const getLocation = ClientFunction(() => document.location.href);
async function load(t, mrn, fhir, participant) {
let user = 'dr_bob';
let study = 'studyid';
let iss = 'https://fake.iss.example.com';
let launch = 'BOGUSLAUNCH1';
let url = `${BASE_URL}/load` +
`?mrn=${mrn}` +
`&fhir=${fhir}` +
`&user=${user}` +
`&study=${study}` +
`&participant=${participant}` +
`&iss=` + encodeURIComponent(iss) +
`&launch=${launch}`;
// console.log("load:", url);
return await t.openWindow(url);
}
async function check_checkbox_and_freetext(t, mrn, fhir, participant, id) {
await load(t, mrn, fhir, participant);
// ensure our cb is selected
let cb_id = Selector('#cb_' + id);
if (!(await cb_id.checked)) {
await t.click(cb_id);
}
await t.expect(cb_id.checked).ok();
let ft_id_1 = Selector('#ft_' + id + '_1');
let eft_id_1 = Selector('#eft_' + id + '_1');
let pft_id_1 = Selector('#pft_' + id + '_1');
await t.selectText(ft_id_1);
await t.typeText(ft_id_1, 'foo');
await t.expect(ft_id_1.value).eql('foo');
await t.expect(eft_id_1.innerText).eql('foo');
await t.expect(pft_id_1.innerText).eql('foo');
await t.selectText(ft_id_1);
await t.typeText(ft_id_1, 'bar');
await t.expect(ft_id_1.value).eql('bar');
await t.expect(eft_id_1.innerText).eql('bar');
await t.expect(pft_id_1.innerText).eql('bar');
}
// TODO: make launching of the adfice-webserver the job of the test
// TODO: have each test launch a different adfice instance on a different port
test('test incoming link from EHR', async t => {
let mrn = 'DummyMRN-000000163';
let fhir = 'DummyFHIR-000000163';
let participant = 100163;
let window1 = await load(t, mrn, fhir, participant);
const getLocation = ClientFunction(() => document.location.href);
let patient_id_span = Selector('span#patient-info-id');
await t.expect(getLocation()).contains('/start?');
await t.expect(patient_id_span.withText("DummyMRN-000000163").exists).ok();
});