case-layout.js
1.1 KB
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
const _ = require('lodash');
const config = require('../config.json');
module.exports.getCases = () => {
const cases = config.cases[global.TEST_PLATFORM];
_.each(cases, c => {
c.scenes = _.filter(c.scenes, s => s.driverFn);
})
return _.filter(cases, c => c.scenes.length);
};
module.exports.addScene = (sceneObj) => {
const cases = config.cases[global.TEST_PLATFORM];
let hasCase = false;
_.each(cases, c => {
_.each(c.scenes, (scene, inx) => {
if (sceneObj.scene === scene) {
hasCase = true;
if (!c.config) {
c.config = {
caps: sceneObj.caps,
serverConfig: sceneObj.serverConfig
};
}
c.scenes[inx] = {
scene,
title: sceneObj.title,
driverFn: sceneObj.driverFn
}
}
});
});
if (!hasCase) {
cases.push({
name: sceneObj.scene,
config: {
caps: sceneObj.caps,
serverConfig: sceneObj.serverConfig
},
scenes: [{
scene: sceneObj.scene,
title: sceneObj.title,
driverFn: sceneObj.driverFn
}]
})
}
}