summaryrefslogtreecommitdiffstats
path: root/testapi/opnfv_testapi/ui/Gruntfile.js
blob: d6a2f476607d76732ce9eea396ad7c75e42699c2 (plain)
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
module.exports = function (grunt) {
    require('load-grunt-tasks')(grunt);
    require('grunt-protractor-coverage')(grunt);
    grunt.loadNpmTasks('grunt-shell-spawn');
    grunt.loadNpmTasks('grunt-wait');
    grunt.loadNpmTasks('grunt-contrib-copy');
    grunt.loadNpmTasks('grunt-contrib-connect');
    grunt.loadNpmTasks('grunt-convert');
    grunt.initConfig({
        convert: {
            options: {
              explicitArray: false,
            },
            json2xml: {
                options: {
                    xml: {
                      header: true
                    }
                  },
              src: ['../tests/UI/coverage/coverage.json'],
                  dest: '../tests/UI/coverage/coverage.xml'
            }
        },
        connect: {
            server: {
                options: {
                    port: 8000,
                    base: './',
                    middleware: function(connect, options, middlewares) {
                        middlewares.unshift(function(req, res, next) {
                            if (req.method.toUpperCase() == 'POST' || req.method.toUpperCase() == "PUT" ||
                                req.method.toUpperCase() == "DELETE")
                                {
                                    req.method='GET';
                                }
                            return next();
                        });
                        return middlewares;
                    }
                }
            }
        },
        copy: {
            assets: {
              expand: true,
              cwd: '../../3rd_party/static/testapi-ui/assets',
              src: '**',
              dest: 'testapi-ui/assets',
            },
            components: {
                expand: true,
                cwd: 'components',
                src: '**',
                dest: 'testapi-ui/components',
            },
            shared: {
                expand: true,
                cwd: 'shared',
                src: '**',
                dest: 'testapi-ui/shared',
            },
            filesPng: {
                expand: true,
                src: '*.png',
                dest: 'testapi-ui/',
            },
            filesIco: {
                expand: true,
                src: '*.ico',
                dest: 'testapi-ui/',
            },
            filesJs: {
                expand: true,
                src: 'app.js',
                dest: 'testapi-ui/',
            },
            filesJson: {
                expand: true,
                src: 'config.json',
                dest: 'testapi-ui/',
            }
        },
        wait: {
            default: {
                options: {
                    delay: 3000
                }
            }
        },
        shell: {
            updateSelenium: {
                command: 'node_modules/protractor/bin/webdriver-manager update',
                options: {
                      async: false
                }
            },
            startSelenium: {
                command: 'node_modules/protractor/bin/webdriver-manager start',
                options: {
                  async: true
                }
            },
            deleteFiles: {
                command: 'rm -r testapi-ui',
                options: {
                  async: false
                }
            },
            options: {
                stdout: false,
                stderr: false
            }
        },
        instrument: {
            files: ['components/**/*.js'],
            options: {
                lazy: false,
                basePath: "./testapi-ui/"
            }
        },
        karma: {
            unit: {
                configFile: 'karma.conf.js'
            }
        },
        protractor_coverage: {
            options: {
                keepAlive: true,
                noColor: false,
                coverageDir: '../tests/UI/coverage',
                args: {
                    specs: [
                            '../tests/UI/e2e/homeControllerSpec.js',
                            '../tests/UI/e2e/podsControllerSpec.js',
                            '../tests/UI/e2e/projectsControllerSpec.js',
                            '../tests/UI/e2e/testCasesControllerSpec.js',
                            '../tests/UI/e2e/resultsControllerSpec.js',
                            '../tests/UI/e2e/scenariosControllerSpec.js',
                            '../tests/UI/e2e/scenarioControllerSpec.js',
                            '../tests/UI/e2e/deployResultsControllerSpec.js',
                            '../tests/UI/e2e/authenticateFalseSpec.js'
                        ]
                }
            },
            local: {
                options: {
                    configFile: 'protractor-conf.js'
                }
            }
        },
        makeReport: {
            src: '../tests/UI/coverage/*.json',
            options: {
                type: 'cobertura',
                print: 'detail'
            }
        }
    });
    grunt.registerTask('test', [
        'karma:unit'
    ]);
    grunt.registerTask('e2e', [
        'copy:assets',
        'copy:components',
        'copy:shared',
        'copy:filesPng',
        'copy:filesIco',
        'copy:filesJs',
        'copy:filesJson',
        'instrument',
        'connect',
        'shell:updateSelenium',
        'shell:startSelenium',
        'wait:default',
        'protractor_coverage',
        'makeReport',
        'convert',
        'shell:deleteFiles'
    ]);
}