aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/test/medium/update-center.spec.js
blob: 3acc5961cd5d19ad81ce06a21976989524952050 (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
define(function (require) {
  var bdd = require('intern!bdd');
  require('../helpers/test-page');

  bdd.describe('Update Center Page', function () {
    bdd.it('should show plugin card', function () {
      return this.remote
          .open()
          .mockFromString('/api/l10n/index', '{}')
          .mockFromFile('/api/plugins/installed', 'update-center-spec/installed.json')
          .mockFromFile('/api/plugins/updates', 'update-center-spec/updates.json')
          .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
          .startAppBrowserify('update-center', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-plugin-name')
          .checkElementCount('li[data-id]', 5)
          .checkElementInclude('li[data-id="scmgit"] .js-plugin-name', 'Git')
          .checkElementInclude('li[data-id="scmgit"] .js-plugin-category', 'Integration')
          .checkElementInclude('li[data-id="scmgit"] .js-plugin-description', 'Git SCM Provider.')
          .checkElementInclude('li[data-id="scmgit"] .js-plugin-installed-version', '1.0')
          .checkElementCount('li[data-id="scmgit"] .js-update-version', 1)
          .checkElementInclude('li[data-id="scmgit"] .js-update-version', '1.1')
          .checkElementCount('li[data-id="scmgit"] .js-changelog', 1)
          .checkElementCount('li[data-id="scmgit"] .js-plugin-homepage', 1)
          .checkElementCount('li[data-id="scmgit"] .js-plugin-issues', 1)
          .checkElementNotExist('li[data-id="scmgit"] .js-plugin-terms')
          .checkElementInclude('li[data-id="scmgit"] .js-plugin-license', 'GNU LGPL 3')
          .checkElementInclude('li[data-id="scmgit"] .js-plugin-organization', 'SonarSource')
          .checkElementCount('li[data-id="scmgit"] .js-update', 1)
          .checkElementCount('li[data-id="scmgit"] .js-uninstall', 1)
          .checkElementNotExist('li[data-id="scmgit"] .js-install');
    });

    bdd.it('should show system upgrade', function () {
      return this.remote
          .open('#system')
          .mockFromString('/api/l10n/index', '{}')
          .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
          .mockFromFile('/api/system/upgrades', 'update-center-spec/system-updates.json')
          .startAppBrowserify('update-center', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-plugin-name')
          .checkElementCount('li[data-system]', 1)
          .checkElementInclude('li[data-system] .js-plugin-name', 'SonarQube 5.3')
          .checkElementInclude('li[data-system] .js-plugin-category', 'System Upgrade')
          .checkElementInclude('li[data-system] .js-plugin-description', 'New!')
          .checkElementCount('li[data-system] .js-plugin-release-notes', 1)
          .checkElementCount('li[data-system] .js-plugin-date', 1)
          .checkElementCount('li[data-system] .js-plugin-update-steps', 1)
          .checkElementCount('li[data-system] .js-plugin-update-steps > li', 4);
    });

    bdd.it('should show installed', function () {
      return this.remote
          .open('#installed')
          .mockFromString('/api/l10n/index', '{}')
          .mockFromFile('/api/plugins/installed', 'update-center-spec/installed.json')
          .mockFromFile('/api/plugins/updates', 'update-center-spec/updates.json')
          .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
          .startAppBrowserify('update-center', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-plugin-name')
          .checkElementCount('li[data-id]', 5)
          .checkElementExist('li[data-id="scmgit"]')
          .checkElementExist('li[data-id="javascript"]');
    });

    bdd.it('should show updates', function () {
      return this.remote
          .open('#updates')
          .mockFromString('/api/l10n/index', '{}')
          .mockFromFile('/api/plugins/installed', 'update-center-spec/installed.json')
          .mockFromFile('/api/plugins/updates', 'update-center-spec/updates.json')
          .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
          .startAppBrowserify('update-center', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-plugin-name')
          .checkElementCount('li[data-id]', 4)
          .checkElementExist('li[data-id="scmgit"]')
          .checkElementNotExist('li[data-id="javascript"]');
    });

    bdd.it('should show available', function () {
      return this.remote
          .open('#available')
          .mockFromString('/api/l10n/index', '{}')
          .mockFromFile('/api/plugins/available', 'update-center-spec/available.json')
          .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
          .startAppBrowserify('update-center', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-plugin-name')
          .checkElementCount('li[data-id]', 3)
          .checkElementNotExist('li[data-id="scmgit"]')
          .checkElementExist('li[data-id="abap"]');
    });

    bdd.it('should work offline', function () {
      return this.remote
          .open('')
          .mockFromString('/api/l10n/index', '{}')
          .mockFromFile('/api/plugins/installed', 'update-center-spec/installed.json')
          .mockFromFile('/api/plugins/updates', 'update-center-spec/updates.json')
          .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
          .execute(function () {
            window.SS.updateCenterActive = false;
          })
          .startAppBrowserify('update-center', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-plugin-name')
          .checkElementCount('li[data-id]', 5)
          .checkElementExist('li[data-id="scmgit"]')
          .checkElementExist('li[data-id="javascript"]')
          .checkElementNotExist('#update-center-filter-installed[disabled]')
          .checkElementExist('#update-center-filter-updates[disabled]')
          .checkElementExist('#update-center-filter-available[disabled]')
          .checkElementExist('#update-center-filter-system[disabled]');
    });

    bdd.it('should switch between views', function () {
      return this.remote
          .open('#installed')
          .mockFromString('/api/l10n/index', '{}')
          .mockFromFile('/api/plugins/installed', 'update-center-spec/installed.json')
          .mockFromFile('/api/plugins/updates', 'update-center-spec/updates.json')
          .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
          .mockFromFile('/api/plugins/available', 'update-center-spec/available.json')
          .mockFromFile('/api/system/upgrades', 'update-center-spec/system-updates.json')
          .startAppBrowserify('update-center', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-plugin-name')
          .checkElementCount('li[data-id]', 5)
          .checkElementExist('li[data-id="javascript"]')
          .checkElementExist('#update-center-filter-installed:checked')
          .clickElement('[for="update-center-filter-available"]')
          .checkElementExist('li[data-id="abap"]')
          .checkElementCount('li[data-id]', 3)
          .checkElementExist('li[data-id="abap"]')
          .checkElementExist('#update-center-filter-available:checked')
          .clickElement('[for="update-center-filter-updates"]')
          .checkElementExist('li[data-id="scmgit"]')
          .checkElementCount('li[data-id]', 4)
          .checkElementExist('li[data-id="scmgit"]')
          .checkElementExist('#update-center-filter-updates:checked')
          .clickElement('[for="update-center-filter-system"]')
          .checkElementExist('li[data-system]')
          .checkElementExist('#update-center-filter-system:checked')
          .clickElement('[for="update-center-filter-installed"]')
          .checkElementExist('li[data-id="javascript"]')
          .checkElementCount('li[data-id]', 5)
          .checkElementExist('li[data-id="javascript"]')
          .checkElementExist('#update-center-filter-installed:checked')
          .clickElement('[for="update-center-filter-available"]')
          .checkElementExist('li[data-id="abap"]')
          .checkElementCount('li[data-id]', 3)
          .checkElementExist('li[data-id="abap"]')
          .checkElementExist('#update-center-filter-available:checked')
          .clickElement('[for="update-center-filter-updates"]')
          .checkElementExist('li[data-id="scmgit"]')
          .checkElementCount('li[data-id]', 4)
          .checkElementExist('li[data-id="scmgit"]')
          .checkElementExist('#update-center-filter-updates:checked')
          .clickElement('[for="update-center-filter-system"]')
          .checkElementExist('li[data-system]')
          .checkElementExist('#update-center-filter-system:checked');
    });

    bdd.it('should search', function () {
      return this.remote
          .open('#installed')
          .mockFromString('/api/l10n/index', '{}')
          .mockFromFile('/api/plugins/installed', 'update-center-spec/installed.json')
          .mockFromFile('/api/plugins/updates', 'update-center-spec/updates.json')
          .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
          .startAppBrowserify('update-center', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-plugin-name')
          .checkElementCount('li[data-id]', 5)
          .checkElementNotExist('li.hidden[data-id]')
          .fillElement('#update-center-search-query', 'jA')
          .clickElement('#update-center-search-submit')
          .checkElementExist('li.hidden[data-id]')
          .checkElementCount('li[data-id]', 5)
          .checkElementCount('li.hidden[data-id]', 3)
          .checkElementInclude('li:not(.hidden)[data-id] .js-plugin-name', 'JavaScript');
    });

    bdd.it('should search by category on click', function () {
      return this.remote
          .open('#available')
          .mockFromString('/api/l10n/index', '{}')
          .mockFromFile('/api/plugins/available', 'update-center-spec/available.json')
          .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
          .startAppBrowserify('update-center', { urlRoot: '/test/medium/base.html' })
          .checkElementCount('li[data-id]:not(.hidden)', 3)
          .clickElement('li[data-id="abap"] .js-plugin-category')
          .checkElementCount('li[data-id]:not(.hidden)', 2);
    });

    bdd.it('should show changelog of plugin update', function () {
      return this.remote
          .open('#installed')
          .mockFromString('/api/l10n/index', '{}')
          .mockFromFile('/api/plugins/installed', 'update-center-spec/installed.json')
          .mockFromFile('/api/plugins/updates', 'update-center-spec/updates.json')
          .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
          .startAppBrowserify('update-center', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-plugin-name')
          .clickElement('li[data-id="python"] .js-changelog')
          .checkElementExist('.bubble-popup')
          .checkElementCount('.bubble-popup .js-plugin-changelog-version', 2)
          .checkElementCount('.bubble-popup .js-plugin-changelog-date', 2)
          .checkElementCount('.bubble-popup .js-plugin-changelog-link', 2)
          .checkElementCount('.bubble-popup .js-plugin-changelog-description', 2);
    });

    bdd.it('should show changelog of plugin release', function () {
      return this.remote
          .open('#available')
          .mockFromString('/api/l10n/index', '{}')
          .mockFromFile('/api/plugins/available', 'update-center-spec/available.json')
          .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
          .startAppBrowserify('update-center', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-plugin-name')
          .clickElement('li[data-id="abap"] .js-changelog')
          .checkElementExist('.bubble-popup')
          .checkElementCount('.bubble-popup .js-plugin-changelog-version', 1)
          .checkElementCount('.bubble-popup .js-plugin-changelog-date', 1)
          .checkElementCount('.bubble-popup .js-plugin-changelog-link', 1)
          .checkElementCount('.bubble-popup .js-plugin-changelog-description', 1);
    });

    bdd.it('should update plugin', function () {
      return this.remote
          .open('#installed')
          .mockFromString('/api/l10n/index', '{}')
          .mockFromFile('/api/plugins/installed', 'update-center-spec/installed.json')
          .mockFromFile('/api/plugins/updates', 'update-center-spec/updates.json')
          .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
          .mockFromString('/api/plugins/update', '{}', { data: { key: 'scmgit' } })
          .startAppBrowserify('update-center', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-plugin-name')
          .clickElement('li[data-id="scmgit"] .js-update')
          .checkElementNotExist('li[data-id="scmgit"] .js-spinner')
          .checkElementInclude('li[data-id="scmgit"]', 'Update Pending');
    });

    bdd.it('should uninstall plugin', function () {
      return this.remote
          .open('#installed')
          .mockFromString('/api/l10n/index', '{}')
          .mockFromFile('/api/plugins/installed', 'update-center-spec/installed.json')
          .mockFromFile('/api/plugins/updates', 'update-center-spec/updates.json')
          .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
          .mockFromString('/api/plugins/uninstall', '{}', { data: { key: 'scmgit' } })
          .startAppBrowserify('update-center', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-plugin-name')
          .clickElement('li[data-id="scmgit"] .js-uninstall')
          .checkElementNotExist('li[data-id="scmgit"] .js-spinner')
          .checkElementInclude('li[data-id="scmgit"]', 'Uninstall Pending');
    });

    bdd.it('should install plugin', function () {
      return this.remote
          .open('#available')
          .mockFromString('/api/l10n/index', '{}')
          .mockFromFile('/api/plugins/available', 'update-center-spec/available.json')
          .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
          .mockFromString('/api/plugins/install', '{}', { data: { key: 'android' } })
          .startAppBrowserify('update-center', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-plugin-name')
          .clickElement('li[data-id="android"] .js-install')
          .checkElementNotExist('li[data-id="android"] .js-spinner')
          .checkElementInclude('li[data-id="android"]', 'Install Pending');
    });

    bdd.it('should cancel all pending', function () {
      return this.remote
          .open('#available')
          .mockFromString('/api/l10n/index', '{}')
          .mockFromFile('/api/plugins/available', 'update-center-spec/available.json')
          .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
          .mockFromString('/api/plugins/cancel_all', '{}')
          .startAppBrowserify('update-center', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-plugin-name')
          .checkElementExist('.js-pending')
          .clickElement('.js-cancel-all')
          .checkElementNotExist('.js-pending');
    });

    bdd.it('should should check terms and conditions', function () {
      return this.remote
          .open('#available')
          .mockFromString('/api/l10n/index', '{}')
          .mockFromFile('/api/plugins/available', 'update-center-spec/available.json')
          .mockFromFile('/api/plugins/pending', 'update-center-spec/pending.json')
          .mockFromString('/api/plugins/install', '{}', { data: { key: 'abap' } })
          .startAppBrowserify('update-center', { urlRoot: '/test/medium/base.html' })
          .checkElementExist('.js-plugin-name')
          .checkElementExist('li[data-id="abap"] .js-terms')
          .checkElementExist('li[data-id="abap"] .js-install[disabled]')
          .clickElement('li[data-id="abap"] .js-terms')
          .checkElementNotExist('li[data-id="abap"] .js-install[disabled]')
          .clickElement('li[data-id="abap"] .js-install')
          .checkElementNotExist('li[data-id="abap"] .js-spinner')
          .checkElementInclude('li[data-id="abap"]', 'Install Pending');
    });
  });
});