aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/test/medium/quality-profiles.spec.js
blob: ecafd4b0c01a8b5691e06eb608b34f996213e9aa (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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
define(function (require) {
  var bdd = require('intern!bdd');
  require('../helpers/test-page');

  bdd.describe('Quality Profiles Page', function () {
    bdd.it('should show list', function () {
      return this.remote
          .open()
          .mockFromFile('/api/users/current', 'quality-profiles/user.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-list .list-group-item')
          .checkElementCount('.js-list .list-group-item', 5)
          .checkElementInclude('.js-list .list-group-item', 'Sonar way')
          .checkElementInclude('.js-list .list-group-item', 'PSR-2')
          .checkElementCount('.js-list-language', 4)
          .checkElementInclude('.js-list-language', 'Java')
          .checkElementInclude('.js-list-language', 'JavaScript')
          .checkElementInclude('.js-list-language', 'PHP')
          .checkElementInclude('.js-list-language', 'Python')
          .checkElementCount('.js-list .badge', 4);
    });

    bdd.it('should filter list by language', function () {
      return this.remote
          .open()
          .mockFromFile('/api/users/current', 'quality-profiles/user.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-list .list-group-item')
          .checkElementCount('.js-list .list-group-item', 5)
          .checkElementExist('.js-list .list-group-item[data-key="java-sonar-way-67887"]:not(.hidden)')
          .checkElementExist('.js-list .list-group-item[data-key="js-sonar-way-71566"]:not(.hidden)')
          .checkElementCount('.js-list-language', 4)
          .checkElementExist('.js-list-language[data-language="java"]:not(.hidden)')
          .checkElementExist('.js-list-language[data-language="js"]:not(.hidden)')
          .checkElementExist('#quality-profiles-filter-by-language')
          .clickElement('#quality-profiles-filter-by-language .dropdown-toggle')
          .clickElement('.js-filter-by-language[data-language="js"]')
          .checkElementNotExist('.js-list .list-group-item[data-key="java-sonar-way-67887"]:not(.hidden)')
          .checkElementExist('.js-list .list-group-item[data-key="js-sonar-way-71566"]:not(.hidden)')
          .checkElementNotExist('.js-list-language[data-language="java"]:not(.hidden)')
          .checkElementExist('.js-list-language[data-language="js"]:not(.hidden)')
          .clickElement('#quality-profiles-filter-by-language .dropdown-toggle')
          .clickElement('.js-filter-by-language:nth-child(1)')
          .checkElementExist('.js-list .list-group-item[data-key="java-sonar-way-67887"]:not(.hidden)')
          .checkElementExist('.js-list .list-group-item[data-key="js-sonar-way-71566"]:not(.hidden)')
          .checkElementExist('.js-list-language[data-language="java"]:not(.hidden)')
          .checkElementExist('.js-list-language[data-language="js"]:not(.hidden)');
    });

    bdd.it('should show details', function () {
      return this.remote
          .open()
          .mockFromFile('/api/users/current', 'quality-profiles/user.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json',
          { data: { qprofile: 'java-sonar-way-67887', activation: 'true' } })
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json',
          { data: { profileKey: 'java-sonar-way-67887' } })
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-list .list-group-item')
          .clickElement('.js-list .list-group-item[data-key="java-sonar-way-67887"]')
          .checkElementExist('.search-navigator-header-component')
          .checkElementCount('.js-list .list-group-item.active', 1)
          .checkElementInclude('.js-list .list-group-item.active', 'Sonar way')
          .checkElementInclude('.search-navigator-workspace-header', 'Sonar way')
          .checkElementInclude('.search-navigator-workspace-header', 'Java')
          .checkElementExist('#quality-profile-backup')
          .checkElementNotExist('#quality-profile-rename')
          .checkElementNotExist('#quality-profile-copy')
          .checkElementNotExist('#quality-profile-delete')
          .checkElementNotExist('#quality-profile-set-as-default')
          .checkElementNotExist('#quality-profile-change-parent');
    });

    bdd.it('should show details for admin', function () {
      return this.remote
          .open()
          .mockFromFile('/api/users/current', 'quality-profiles/user-admin.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json',
          { data: { qprofile: 'java-sonar-way-67887', activation: 'true' } })
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json',
          { data: { profileKey: 'java-sonar-way-67887' } })
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-list .list-group-item')
          .clickElement('.js-list .list-group-item[data-key="java-sonar-way-67887"]')
          .checkElementExist('.search-navigator-header-component')
          .checkElementCount('.js-list .list-group-item.active', 1)
          .checkElementInclude('.js-list .list-group-item.active', 'Sonar way')
          .checkElementInclude('.search-navigator-workspace-header', 'Sonar way')
          .checkElementInclude('.search-navigator-workspace-header', 'Java')
          .checkElementExist('#quality-profile-backup')
          .checkElementExist('#quality-profile-rename')
          .checkElementExist('#quality-profile-copy')
          .checkElementNotExist('#quality-profile-delete')
          .checkElementNotExist('#quality-profile-set-as-default')
          .checkElementExist('#quality-profile-change-parent');
    });

    bdd.it('should show inheritance details', function () {
      return this.remote
          .open()
          .mockFromFile('/api/users/current', 'quality-profiles/user-admin.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search-inheritance.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance-plus.json', {
            data: { profileKey: 'java-inherited-profile-85155' }
          })
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-list .list-group-item')
          .clickElement('.js-list .list-group-item[data-key="java-inherited-profile-85155"]')
          .checkElementExist('.search-navigator-header-component')
          .checkElementCount('#quality-profile-ancestors li', 1)
          .checkElementInclude('#quality-profile-ancestors', 'Sonar way')
          .checkElementInclude('#quality-profile-ancestors', '161')
          .checkElementCount('#quality-profile-inheritance-current', 1)
          .checkElementInclude('#quality-profile-inheritance-current', 'Inherited Profile')
          .checkElementInclude('#quality-profile-inheritance-current', '163')
          .checkElementInclude('#quality-profile-inheritance-current', '7')
          .checkElementCount('#quality-profile-children li', 1)
          .checkElementInclude('#quality-profile-children', 'Second Level Inherited Profile')
          .checkElementInclude('#quality-profile-children', '165');
    });

    bdd.it('should show selected projects', function () {
      return this.remote
          .open()
          .mockFromFile('/api/users/current', 'quality-profiles/user-admin.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .mockFromFile('/api/qualityprofiles/projects?key=php-psr-2-46772', 'quality-profiles/projects.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json')
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-list .list-group-item')
          .clickElement('.js-list .list-group-item[data-key="php-psr-2-46772"]')
          .checkElementExist('#quality-profile-projects')
          .checkElementCount('#quality-profile-projects .select-list-list li', 2)
          .checkElementInclude('#quality-profile-projects .select-list-list li', 'CSS')
          .checkElementInclude('#quality-profile-projects .select-list-list li', 'http-request-parent');
    });

    bdd.it('should move between profiles', function () {
      return this.remote
          .open()
          .mockFromFile('/api/users/current', 'quality-profiles/user.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search-inheritance.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json',
          { data: { qprofile: 'java-inherited-profile-85155', activation: 'true' } })
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance-plus.json')
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-list .list-group-item')
          .clickElement('.js-list .list-group-item[data-key="java-inherited-profile-85155"]')
          .checkElementExist('#quality-profile-ancestors')
          .clearMocks()
          .clearMocks()
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json',
          { data: { qprofile: 'java-sonar-way-67887', activation: 'true' } })
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json')
          .clickElement('#quality-profile-ancestors .js-profile[data-key="java-sonar-way-67887"]')
          .checkElementInclude('.search-navigator-header-component', 'Sonar way');
    });

    bdd.it('should copy profile', function () {
      return this.remote
          .open()
          .mockFromFile('/api/users/current', 'quality-profiles/user-admin.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json')
          .mockFromFile('/api/qualityprofiles/copy', 'quality-profiles/copy.json', {
            data: { fromKey: 'java-sonar-way-67887', toName: 'Copied Profile' }
          })
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-list .list-group-item')
          .checkElementCount('.js-list .list-group-item', 5)
          .clickElement('.js-list .list-group-item[data-key="java-sonar-way-67887"]')
          .checkElementExist('#quality-profile-copy')
          .clickElement('#quality-profile-copy')
          .checkElementExist('.modal')
          .fillElement('#copy-profile-name', 'Copied Profile')
          .clickElement('#copy-profile-submit')
          .checkElementInclude('.search-navigator-header-component', 'Copied Profile')
          .checkElementInclude('.js-list .list-group-item.active', 'Copied Profile')
          .checkElementInclude('.search-navigator-header-component', 'Java')
          .checkElementCount('.js-list .list-group-item', 6);
    });

    bdd.it('should rename profile', function () {
      return this.remote
          .open()
          .mockFromFile('/api/users/current', 'quality-profiles/user-admin.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json')
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-list .list-group-item')
          .clickElement('.js-list .list-group-item[data-key="java-sonar-way-67887"]')
          .checkElementExist('#quality-profile-rename')
          .clickElement('#quality-profile-rename')
          .checkElementExist('.modal')
          .clearMocks()
          .mockFromString('/api/qualityprofiles/rename', '{}', {
            data: { key: 'java-sonar-way-67887', name: 'Renamed Profile' }
          })
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search-renamed.json')
          .fillElement('#rename-profile-name', 'Renamed Profile')
          .clickElement('#rename-profile-submit')
          .checkElementInclude('.js-list .list-group-item.active', 'Renamed Profile')
          .checkElementInclude('.search-navigator-header-component', 'Renamed Profile');
    });

    bdd.it('should make profile default', function () {
      return this.remote
          .open()
          .mockFromFile('/api/users/current', 'quality-profiles/user-admin.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json')
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-list .list-group-item')
          .checkElementNotExist('.js-list .list-group-item[data-key="php-psr-2-46772"] .badge')
          .checkElementExist('.js-list .list-group-item[data-key="php-sonar-way-10778"] .badge')
          .clickElement('.js-list .list-group-item[data-key="php-psr-2-46772"]')
          .checkElementExist('#quality-profile-set-as-default')
          .clearMocks(this.searchMock)
          .mockFromString('/api/qualityprofiles/set_default', '{}', {
            data: { profileKey: 'php-psr-2-46772' }
          })
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search-another-default.json')
          .clickElement('#quality-profile-set-as-default')
          .checkElementNotExist('.js-list .list-group-item[data-key="php-sonar-way-10778"] .badge')
          .checkElementNotExist('#quality-profile-set-as-default')
          .checkElementExist('.js-list .list-group-item[data-key="php-psr-2-46772"] .badge');
    });

    bdd.it('should delete profile', function () {
      return this.remote
          .open()
          .mockFromFile('/api/users/current', 'quality-profiles/user-admin.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search-with-copy.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json')
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-list .list-group-item')
          .checkElementCount('.js-list .list-group-item', 6)
          .clickElement('.js-list .list-group-item[data-key="java-copied-profile-11711"]')
          .checkElementExist('#quality-profile-delete')
          .clickElement('#quality-profile-delete')
          .checkElementExist('.modal')
          .clearMocks()
          .mockFromString('/api/qualityprofiles/delete', '{}', {
            data: { profileKey: 'java-copied-profile-11711' }
          })
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search.json')
          .clickElement('#delete-profile-submit')
          .checkElementCount('.js-list .list-group-item', 5)
          .checkElementNotInclude('.js-list .list-group-item', 'Copied Profile');
    });

    bdd.it('should create profile', function () {
      return this.remote
          .open()
          .mockFromFile('/api/users/current', 'quality-profiles/user-admin.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/qualityprofiles/importers', 'quality-profiles/importers-empty.json')
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-list .list-group-item')
          .checkElementCount('.js-list .list-group-item', 5)
          .clickElement('#quality-profiles-create')
          .checkElementExist('.modal')
          .checkElementExist('#create-profile-name')
          .checkElementExist('#create-profile-language');
    });

    bdd.it('should restore profile', function () {
      return this.remote
          .open()
          .mockFromFile('/api/users/current', 'quality-profiles/user-admin.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json')
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-list .list-group-item')
          .checkElementCount('.js-list .list-group-item', 5)
          .clickElement('#quality-profiles-actions')
          .clickElement('#quality-profiles-restore')
          .checkElementExist('.modal')
          .checkElementExist('.modal input[type="file"]');
    });

    bdd.it('should show importers', function () {
      return this.remote
          .open()
          .mockFromFile('/api/users/current', 'quality-profiles/user-admin.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/qualityprofiles/importers', 'quality-profiles/importers.json')
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-list .list-group-item')
          .clickElement('#quality-profiles-create')
          .checkElementExist('.modal')
          .checkElementExist('.js-importer[data-key="pmd"]:not(.hidden)')
          .checkElementExist('.js-importer[data-key="random"]:not(.hidden)')
          .fillElement('#create-profile-language', 'js')
          .changeElement('#create-profile-language')
          .checkElementNotExist('.js-importer[data-key="pmd"]:not(.hidden)')
          .checkElementExist('.js-importer[data-key="random"]:not(.hidden)')
          .fillElement('#create-profile-language', 'py')
          .changeElement('#create-profile-language')
          .checkElementNotExist('.js-importer[data-key="pmd"]:not(.hidden)')
          .checkElementNotExist('.js-importer[data-key="random"]:not(.hidden)');
    });

    bdd.it('should restore built-in profiles', function () {
      return this.remote
          .open()
          .mockFromFile('/api/users/current', 'quality-profiles/user-admin.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search-modified.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-list .list-group-item')
          .checkElementCount('.js-list .js-list-language', 1)
          .checkElementCount('.js-list .list-group-item', 1)
          .clickElement('#quality-profiles-actions')
          .clickElement('#quality-profiles-restore-built-in')
          .checkElementExist('.modal')
          .clearMocks()
          .mockFromString('/api/qualityprofiles/restore_built_in', '{}', { data: { language: 'java' } })
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search.json')
          .fillElement('#restore-built-in-profiles-language', 'java')
          .clickElement('#restore-built-in-profiles-submit')
          .checkElementCount('.js-list .js-list-language', 4)
          .checkElementCount('.js-list .list-group-item', 5)
          .checkElementInclude('.js-list .list-group-item', 'Sonar way')
          .checkElementNotExist('.search-navigator-header-component');
    });

    bdd.it('should change profile\'s parent', function () {
      return this.remote
          .open()
          .mockFromFile('/api/users/current', 'quality-profiles/user-admin.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search-change-parent.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance-change-parent.json')
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-list .list-group-item')
          .clickElement('.js-list .list-group-item[data-key="java-inherited-profile-85155"]')
          .checkElementExist('#quality-profile-change-parent')
          .clickElement('#quality-profile-change-parent')
          .checkElementExist('.modal')
          .clearMocks()
          .mockFromString('/api/qualityprofiles/change_parent', '{}', {
            data: { profileKey: 'java-inherited-profile-85155', parentKey: 'java-another-profile-00609' }
          })
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search-changed-parent.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance-changed-parent.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .fillElement('#change-profile-parent', 'java-another-profile-00609')
          .clickElement('#change-profile-parent-submit')
          .checkElementInclude('#quality-profile-ancestors', 'Another Profile');
    });

    bdd.it('should open permalink', function () {
      return this.remote
          .open('#show?key=java-sonar-way-67887')
          .mockFromFile('/api/users/current', 'quality-profiles/user-admin.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json')
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('#quality-profile-rename')
          .checkElementCount('.js-list .list-group-item.active', 1)
          .checkElementInclude('.js-list .list-group-item.active', 'Sonar way')
          .checkElementInclude('.search-navigator-workspace-header', 'Sonar way')
          .checkElementInclude('.search-navigator-workspace-header', 'Java')
          .checkElementExist('#quality-profile-backup')
          .checkElementExist('#quality-profile-rename')
          .checkElementExist('#quality-profile-copy')
          .checkElementNotExist('#quality-profile-delete')
          .checkElementNotExist('#quality-profile-set-as-default');
    });

    bdd.it('should show changelog', function () {
      return this.remote
          .open('#show?key=java-sonar-way-67887')
          .mockFromFile('/api/users/current', 'quality-profiles/user.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json')
          .mockFromFile('/api/qualityprofiles/changelog', 'quality-profiles/changelog.json', {
            data: { profileKey: 'java-sonar-way-67887' }
          })
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('#quality-profile-changelog-form-submit')
          .checkElementNotExist('.js-show-more-changelog')
          .clickElement('#quality-profile-changelog-form-submit')
          .checkElementExist('#quality-profile-changelog table')
          .checkElementExist('.js-show-more-changelog')
          .checkElementCount('#quality-profile-changelog tbody tr', 2)
          .checkElementInclude('#quality-profile-changelog tbody tr:nth-child(1)', 'April 13 2015')
          .checkElementInclude('#quality-profile-changelog tbody tr:nth-child(1)', 'System')
          .checkElementInclude('#quality-profile-changelog tbody tr:nth-child(1)', 'ACTIVATED')
          .checkElementInclude('#quality-profile-changelog tbody tr:nth-child(1)', 'Synchronisation should not')
          .checkElementInclude('#quality-profile-changelog tbody tr:nth-child(1)', 'BLOCKER')
          .checkElementInclude('#quality-profile-changelog tbody tr:nth-child(2)', 'April 13 2015')
          .checkElementInclude('#quality-profile-changelog tbody tr:nth-child(2)', 'Anakin Skywalker')
          .checkElementInclude('#quality-profile-changelog tbody tr:nth-child(2)', 'ACTIVATED')
          .checkElementInclude('#quality-profile-changelog tbody tr:nth-child(2)', 'Double.longBitsToDouble')
          .checkElementInclude('#quality-profile-changelog tbody tr:nth-child(2)', 'threshold')
          .checkElementInclude('#quality-profile-changelog tbody tr:nth-child(2)', '3')
          .checkElementInclude('#quality-profile-changelog tbody tr:nth-child(2)', 'emptyParameter')
          .clearMocks()
          .mockFromFile('/api/qualityprofiles/changelog', 'quality-profiles/changelog2.json', {
            data: { profileKey: 'java-sonar-way-67887' }
          })
          .clickElement('.js-show-more-changelog')
          .checkElementCount('#quality-profile-changelog tbody tr', 3)
          .checkElementNotExist('.js-show-changelog')
          .checkElementNotExist('.js-show-more-changelog')
          .checkElementInclude('#quality-profile-changelog tbody tr:nth-child(3)', 'April 13 2015')
          .checkElementInclude('#quality-profile-changelog tbody tr:nth-child(3)', 'System')
          .checkElementInclude('#quality-profile-changelog tbody tr:nth-child(3)', 'DEACTIVATED')
          .checkElementInclude('#quality-profile-changelog tbody tr:nth-child(3)', 'runFinalizersOnExit')
          .clickElement('.js-hide-changelog')
          .checkElementNotExist('#quality-profile-changelog tbody tr');
    });

    bdd.it('should open changelog permalink', function () {
      return this.remote
          .open('#changelog?since=2015-03-25&key=java-sonar-way-67887&to=2015-03-26')
          .mockFromFile('/api/users/current', 'quality-profiles/user.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json')
          .mockFromFile('/api/qualityprofiles/changelog', 'quality-profiles/changelog.json', {
            data: {
              since: '2015-03-25',
              to: '2015-03-26',
              profileKey: 'java-sonar-way-67887'
            }
          })
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-show-more-changelog')
          .checkElementCount('#quality-profile-changelog tbody tr', 2)
          .clearMocks()
          .mockFromFile('/api/qualityprofiles/changelog', 'quality-profiles/changelog2.json', {
            data: {
              since: '2015-03-25',
              to: '2015-03-26',
              profileKey: 'java-sonar-way-67887'
            }
          })
          .clickElement('.js-show-more-changelog')
          .checkElementCount('#quality-profile-changelog tbody tr', 3)
          .checkElementNotExist('.js-show-more-changelog');
    });

    bdd.it('should show comparison', function () {
      return this.remote
          .open('#show?key=java-sonar-way-67887')
          .mockFromFile('/api/users/current', 'quality-profiles/user.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search-with-copy.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json')
          .mockFromFile('/api/qualityprofiles/compare', 'quality-profiles/compare.json', {
            data: { leftKey: 'java-sonar-way-67887', rightKey: 'java-copied-profile-11711' }
          })
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('#quality-profile-comparison-form-submit')
          .checkElementCount('#quality-profile-comparison-with-key option', 1)
          .clickElement('#quality-profile-comparison-form-submit')
          .checkElementExist('#quality-profile-comparison table')
          .checkElementCount('.js-comparison-in-left', 2)
          .checkElementCount('.js-comparison-in-right', 2)
          .checkElementCount('.js-comparison-modified', 2)
          .checkElementInclude('.js-comparison-in-left', '".equals()" should not be used to test')
          .checkElementInclude('.js-comparison-in-left', '"@Override" annotation should be used on')
          .checkElementInclude('.js-comparison-in-right', '"ConcurrentLinkedQueue.size()" should not be used')
          .checkElementInclude('.js-comparison-in-right', '"compareTo" results should not be checked')
          .checkElementInclude('.js-comparison-modified', 'Control flow statements')
          .checkElementInclude('.js-comparison-modified', '"Cloneables" should implement "clone"')
          .checkElementInclude('.js-comparison-modified', 'max: 5')
          .checkElementInclude('.js-comparison-modified', 'max: 3');
    });

    bdd.it('should open comparison permalink', function () {
      return this.remote
          .open('#compare?key=java-sonar-way-67887&withKey=java-copied-profile-11711')
          .mockFromFile('/api/users/current', 'quality-profiles/user.json')
          .mockFromFile('/api/qualityprofiles/search', 'quality-profiles/search-with-copy.json')
          .mockFromFile('/api/qualityprofiles/exporters', 'quality-profiles/exporters.json')
          .mockFromFile('/api/languages/list', 'quality-profiles/languages.json')
          .mockFromFile('/api/rules/search', 'quality-profiles/rules.json')
          .mockFromFile('/api/qualityprofiles/inheritance', 'quality-profiles/inheritance.json')
          .mockFromFile('/api/qualityprofiles/compare', 'quality-profiles/compare.json', {
            data: { leftKey: 'java-sonar-way-67887', rightKey: 'java-copied-profile-11711' }
          })
          .startAppBrowserify('quality-profiles', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('#quality-profile-comparison table')
          .checkElementCount('#quality-profile-comparison-with-key option', 1)
          .checkElementCount('.js-comparison-in-left', 2)
          .checkElementCount('.js-comparison-in-right', 2)
          .checkElementCount('.js-comparison-modified', 2);

    });
  });

});