-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenderer.js
79 lines (68 loc) · 2.96 KB
/
renderer.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
const cli = require('./helper/cli');
const conf = require(process.env.HOST);
const objekt = conf.config.suites;
// unchecks all checked checkboxes
function resetAll() {
var allCheckboxes = document.querySelectorAll('input[type=checkbox]');
allCheckboxes.forEach(element => {
if (element.checked) {
element.checked = false;
}
});
};
// displays all suites from conf.js
function listAllSuites() {
var allSuites = Object.keys(objekt);
allSuites.forEach(suite => {
document.querySelector('#suites').innerHTML += `<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="${suite}">
<label class="custom-control-label" for="${suite}">${suite}</label>
</div>`;
});
};
// displays all tests from conf.js
function listAllTests() {
for (const suite in objekt) {
if (objekt.hasOwnProperty(suite)) {
objekt[suite].forEach(element => {
document.querySelector('#tests').innerHTML += `<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="${element}">
<label class="custom-control-label" for="${element}">${element}</label>
</div>`;
});
}
}
};
// gets all checked items and returns them in array
// need to pass id of container where to get items #tests or #suites
function getAllCheckedItems(container) {
var wrapper = document.querySelector(container);
var chckbox = wrapper.querySelectorAll('input');
var testCollection = [];
chckbox.forEach(element => {
if (element.checked) {
var _parent = element.parentElement.children;
var label = _parent[1].innerHTML;
testCollection.push(label);
return testCollection;
}
});
return testCollection;
};
// EVENT LISTENERS
document.querySelector('#btnTests').addEventListener('click', () => {
var tests = getAllCheckedItems('#tests');
alert(`these tests are checked ${tests}`);
});
document.querySelector('#btnSuites').addEventListener('click', () => {
var suites = getAllCheckedItems('#suites');
alert(`these suites are checked ${suites}`);
});
document.querySelector('#reset').addEventListener('click', () => {
resetAll();
});
document.querySelector('#cliBtn').addEventListener('click', (params) => {
cli.runCli('--suite="ActionPanel"');
});
listAllSuites();
listAllTests();