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

    bdd.describe('Issues Page', function () {
        bdd.describe('Saved Searches', function () {
            bdd.it('should show list of saved searches', function () {
                return this.remote
                    .open()
                    .mockFromFile('/api/issue_filters/app', 'issues-spec/app.json')
                    .mockFromFile('/api/issue_filters/search', 'issues-spec/issue-filters.json')
                    .mockFromFile('/api/issues/search', 'issues-spec/search.json')
                    .startApp('issues')
                    .checkElementCount('.js-filter', 2)
                    .checkElementCount('.js-filter[data-id="1"]', 1)
                    .checkElementCount('.js-filter[data-id="2"]', 1);
            });

            bdd.it('should load a saved search', function () {
                return this.remote
                    .open()
                    .mockFromString('/api/l10n/index', '{}')
                    .mockFromFile('/api/issue_filters/app', 'issues-spec/app.json')
                    .mockFromFile('/api/issue_filters/search', 'issues-spec/issue-filters.json')
                    .mockFromFile('/api/issues/search', 'issues-spec/search.json')
                    .startApp('issues')
                    .clickElement('.search-navigator-filters-show-list')
                    .clickElement('.js-filter[data-id="2"]')
                    .checkElementCount('.js-filter-copy', 1)
                    .checkElementCount('.js-filter-edit', 1)
                    .checkElementInclude('.issues-filters-name', 'False Positive and Won\'t Fix Issues')
                    .checkElementCount('.js-facet.active[data-value="FALSE-POSITIVE"]', 1);
            });

            bdd.it('should load a saved search and then resets it by new search', function () {
                return this.remote
                    .open()
                    .mockFromString('/api/l10n/index', '{}')
                    .mockFromFile('/api/issue_filters/app', 'issues-spec/app.json')
                    .mockFromFile('/api/issue_filters/search', 'issues-spec/issue-filters.json')
                    .mockFromFile('/api/issues/search', 'issues-spec/search.json')
                    .startApp('issues')
                    .clickElement('.search-navigator-filters-show-list')
                    .clickElement('.js-filter[data-id="2"]')
                    .checkElementCount('.js-filter-copy', 1)
                    .checkElementCount('.js-filter-edit', 1)
                    .checkElementInclude('.issues-filters-name', 'False Positive and Won\'t Fix Issues')
                    .checkElementCount('.js-facet.active[data-value="FALSE-POSITIVE"]', 1)
                    .clickElement('.js-new-search')
                    .checkElementCount('.js-facet[data-value="FALSE-POSITIVE"]:not(.active)', 1)
                    .checkElementNotInclude('.issues-filters-name', 'False Positive and Won\'t Fix Issues');
            });
        });

        bdd.it('should load', function () {
            return this.remote
                .open('#resolved=false')
                .mockFromString('/api/l10n/index', '{}')
                .mockFromFile('/api/issue_filters/app', 'issues-spec/app.json')
                .mockFromFile('/api/issue_filters/search', 'issues-spec/issue-filters.json')
                .mockFromFile('/api/issues/search', 'issues-spec/search.json')
                .startApp('issues')
                .checkElementExist('.facet[data-value=BLOCKER]')
                .checkElementExist('.facet[data-value=CRITICAL]')
                .checkElementExist('.facet[data-value=MAJOR]')
                .checkElementExist('.facet[data-value=MINOR]')
                .checkElementExist('.facet[data-value=INFO]')

                .checkElementExist('.facet[data-value=OPEN]')
                .checkElementExist('.facet[data-value=REOPENED]')
                .checkElementExist('.facet[data-value=CONFIRMED]')
                .checkElementExist('.facet[data-value=RESOLVED]')
                .checkElementExist('.facet[data-value=CLOSED]')

                .checkElementExist('.facet[data-unresolved]')
                .checkElementExist('.facet[data-value=REMOVED]')
                .checkElementExist('.facet[data-value=FIXED]')
                .checkElementExist('.facet[data-value=FALSE-POSITIVE]')

                .checkElementCount('.issue', 50)
                .checkElementCount('.issue.selected', 1)
                .checkElementInclude('.issue', '1 more branches need to be covered by unit tests to reach')

                .checkElementExist('.js-new-search')
                .checkElementExist('.js-filter-save-as')

                .checkElementInclude('#issues-total', '4623')
                .checkElementExist('.js-prev')
                .checkElementExist('.js-next')
                .checkElementExist('.js-reload')
                .checkElementExist('.js-bulk-change');
        });

        bdd.it('should show severity facet', function () {
            return this.remote
                .open('#resolved=false')
                .mockFromString('/api/l10n/index', '{}')
                .mockFromFile('/api/issue_filters/app', 'issues-spec/app.json')
                .mockFromFile('/api/issue_filters/search', 'issues-spec/issue-filters.json')
                .mockFromFile('/api/issues/search', 'issues-spec/search.json')
                .startApp('issues')
                .checkElementCount('.issue', 50)
                .clearMocks()
                .mockFromFile('/api/issues/search', 'issues-spec/search-reopened.json', { data: { severities: 'BLOCKER' } })
                .clickElement('.facet[data-value=BLOCKER]')
                .checkElementCount('.issue', 4);
        });

        bdd.it('should select issues', function () {
            var issueKey = '94357807-fcb4-40cc-9598-9a715f1eee6e',
                issueSelector = '.issue[data-key="' + issueKey + '"]';

            return this.remote
                .open('#resolved=false')
                .mockFromString('/api/l10n/index', '{}')
                .mockFromFile('/api/issue_filters/app', 'issues-spec/app.json')
                .mockFromFile('/api/issue_filters/search', 'issues-spec/issue-filters.json')
                .mockFromFile('/api/issues/search', 'issues-spec/search.json')
                .startApp('issues')
                .checkElementExist('.js-selection')
                .checkElementNotExist('.js-selection.icon-checkbox-checked')
                .checkElementExist('.issue .js-toggle')
                .checkElementCount('.js-toggle', 50)
                .checkElementNotExist(issueSelector + ' .js-toggle .icon-checkbox-checked')
                .clickElement(issueSelector + ' .js-toggle')
                .checkElementExist(issueSelector + ' .js-toggle .icon-checkbox-checked')
                .checkElementExist('.js-selection.icon-checkbox-single.icon-checkbox-checked')
                .clickElement('.js-selection')
                .checkElementNotExist('.js-selection.icon-checkbox-checked')
                .checkElementNotExist('.js-toggle .icon-checkbox-checked')
                .clickElement('.js-selection')
                .checkElementExist('.js-selection.icon-checkbox-checked')
                .checkElementCount('.js-toggle .icon-checkbox-checked', 50);
        });

        bdd.it('should bulk change issues', function () {
            return this.remote
                .open('#resolved=false')
                .mockFromString('/api/l10n/index', '{}')
                .mockFromFile('/api/issue_filters/app', 'issues-spec/app.json')
                .mockFromFile('/api/issue_filters/search', 'issues-spec/issue-filters.json')
                .mockFromFile('/api/issues/search', 'issues-spec/search.json')
                .mockFromString('/issues/bulk_change_form*',
                '<div id="bulk-change-form">bulk change form</div>', { contentType: 'text/plain' })
                .startApp('issues')
                .clickElement('#issues-bulk-change')
                .clickElement('.js-bulk-change')
                .checkElementExist('#bulk-change-form')
                .checkElementInclude('#bulk-change-form', 'bulk change form');
        });

        bdd.it('should bulk change selected issues', function () {
            var issueKey = '94357807-fcb4-40cc-9598-9a715f1eee6e',
                issueSelector = '.issue[data-key="' + issueKey + '"]';

            return this.remote
                .open('#resolved=false')
                .mockFromString('/api/l10n/index', '{}')
                .mockFromFile('/api/issue_filters/app', 'issues-spec/app.json')
                .mockFromFile('/api/issue_filters/search', 'issues-spec/issue-filters.json')
                .mockFromFile('/api/issues/search', 'issues-spec/search.json')
                .mockFromString('/issues/bulk_change_form*',
                '<div id="bulk-change-form">bulk change form</div>', { contentType: 'text/plain' })
                .startApp('issues')
                .checkElementExist('.js-selection')
                .checkElementNotExist('.js-selection.icon-checkbox-checked')
                .checkElementExist('.issue .js-toggle')
                .checkElementNotExist(issueSelector + ' .js-toggle .icon-checkbox-checked')
                .clickElement(issueSelector + ' .js-toggle')
                .checkElementExist(issueSelector + ' .js-toggle .icon-checkbox-checked')
                .checkElementExist('.js-selection.icon-checkbox-single.icon-checkbox-checked')
                .clickElement('#issues-bulk-change')
                .clickElement('.js-bulk-change-selected')
                .checkElementExist('#bulk-change-form')
                .checkElementInclude('#bulk-change-form', 'bulk change form')
                .clearMocks()
                .mockFromFile('/api/issues/search', 'issues-spec/search-changed.json')
                .execute(function () {
                    window.onBulkIssues();
                })
                .checkElementExist(issueSelector + ' .js-issue-set-severity .icon-severity-blocker')
                .checkElementExist(issueSelector + ' .js-toggle .icon-checkbox-checked');
        });

        bdd.it('should filter similar issues', function () {
            return this.remote
                .open('#resolved=false')
                .mockFromString('/api/l10n/index', '{}')
                .mockFromFile('/api/issue_filters/app', 'issues-spec/app.json')
                .mockFromFile('/api/issue_filters/search', 'issues-spec/issue-filters.json')
                .mockFromFile('/api/issues/search', 'issues-spec/search-filter-similar-issues.json')
                .startApp('issues')
                .checkElementCount('.issue', 2)
                .clickElement('.issue.selected .js-issue-filter')
                .checkElementExist('.bubble-popup')
                .checkElementExist('.bubble-popup [data-property="severities"][data-value="MAJOR"]')
                .checkElementExist('.bubble-popup [data-property="statuses"][data-value="CONFIRMED"]')
                .checkElementExist('.bubble-popup [data-property="resolved"][data-value="false"]')
                .checkElementExist('.bubble-popup [data-property="rules"][data-value="squid:S1214"]')
                .checkElementExist('.bubble-popup [data-property="assigned"][data-value="false"]')
                .checkElementExist('.bubble-popup [data-property="planned"][data-value="false"]')
                .checkElementExist('.bubble-popup [data-property="tags"][data-value="bad-practice"]')
                .checkElementExist('.bubble-popup [data-property="tags"][data-value="brain-overload"]')
                .checkElementExist('.bubble-popup [data-property="projectUuids"][data-value="69e57151-be0d-4157-adff-c06741d88879"]')
                .checkElementExist('.bubble-popup [data-property="moduleUuids"][data-value="7feef7c3-11b9-4175-b5a7-527ca3c75cb7"]')
                .checkElementExist('.bubble-popup [data-property="fileUuids"][data-value="b0517331-0aaf-4091-b5cf-8e305dd0337a"]')
                .clearMocks()
                .mockFromFile('/api/issues/search',
                'issues-spec/search-filter-similar-issues-severities.json', { data: { severities: 'MAJOR' } })
                .clickElement('.bubble-popup [data-property="severities"]')
                .checkElementCount('.issue', 1);
        });

        bdd.it('should open issue permalink', function () {
            var issueKey = 'some-issue-key';

            return this.remote
                .open('#issues=' + issueKey)
                .mockFromString('/api/l10n/index', '{}')
                .mockFromFile('/api/issue_filters/app', 'issues-page-should-open-issue-permalink/app.json')
                .mockFromFile('/api/issue_filters/search', 'issues-spec/issue-filters.json')
                //.mockFromString('/api/issues/search', '{}', { data: { issues: issueKey, p: 2 } })
                .mockFromFile('/api/issues/search', 'issues-page-should-open-issue-permalink/search.json', { data: { issues: issueKey } })
                .mockFromFile('/api/components/app', 'issues-page-should-open-issue-permalink/components-app.json')
                .mockFromFile('/api/sources/lines', 'issues-page-should-open-issue-permalink/lines.json')
                .startApp('issues')
                .checkElementExist('.source-line')
                .checkElementInclude('.source-line', 'public void executeOn(Project project, SensorContext context')
                .checkElementCount('.issue', 1)
                .checkElementCount('.issue[data-key="' + issueKey + '"]', 1);
        });

        bdd.it('should open closed facet', function () {
            return this.remote
                .open()
                .mockFromString('/api/l10n/index', '{}')
                .mockFromFile('/api/issue_filters/app', 'issues-spec/app.json')
                .mockFromFile('/api/issue_filters/search', 'issues-spec/issue-filters.json')
                .mockFromFile('/api/issues/search', 'issues-spec/search-rules-facet.json', { data: { facets: 'rules' } })
                .mockFromFile('/api/issues/search', 'issues-spec/search.json')
                .startApp('issues')
                .clickElement('[data-property="rules"] .js-facet-toggle')
                .checkElementCount('[data-property="rules"] .js-facet', 13)
                .checkElementInclude('[data-property="rules"] .js-facet:nth-child(1)', 'Objects should be compared with');
        });

        bdd.it('should open comment form after FP or WF transition', function () {
            return this.remote
                .open('#resolved=false')
                .mockFromString('/api/l10n/index', '{}')
                .mockFromFile('/api/issue_filters/app', 'issues-spec/app.json')
                .mockFromFile('/api/issue_filters/search', 'issues-spec/issue-filters.json')
                .mockFromFile('/api/issues/search', 'issues-spec/search.json')
                .mockFromFile('/api/issues/do_transition', 'issues-spec/show-fp-new.json')
                .startApp('issues')
                .checkElementExist('.issue.selected')
                .clickElement('.issue.selected .js-issue-transition')
                .clickElement('.js-issue-transition[data-value="falsepositive"]')
                .checkElementExist('.js-issue-comment-submit');
        });
    });

});