]> source.dussan.org Git - sonarqube.git/commitdiff
add issues saved searches web tests
authorStas Vilchik <vilchiks@gmail.com>
Thu, 2 Jul 2015 09:09:32 +0000 (11:09 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 2 Jul 2015 09:10:11 +0000 (11:10 +0200)
server/sonar-web/Gruntfile.coffee
server/sonar-web/src/main/js/apps/issues/app-new.js [deleted file]
server/sonar-web/src/main/js/apps/issues/app.js [new file with mode: 0644]
server/sonar-web/src/main/webapp/WEB-INF/app/views/issues/search.html.erb
server/sonar-web/src/test/json/issues-spec/filter.json [new file with mode: 0644]
server/sonar-web/test/intern.js
server/sonar-web/test/medium/issues.spec.js [new file with mode: 0644]

index 18a37e1349bccdc5d7af9b3618edaf45c667dc55..8e61d0b95536494f67184c8442a7d5ff55b7a88f 100644 (file)
@@ -94,10 +94,6 @@ module.exports = (grunt) ->
         baseUrl: '<%= BUILD_PATH %>/js/'
         preserveLicenseComments: false
 
-      issues: options:
-        name: 'apps/issues/app-new'
-        out: '<%= ASSETS_PATH %>/js/apps/issues/app-new.js'
-
       issuesContext: options:
         name: 'apps/issues/app-context'
         out: '<%= ASSETS_PATH %>/js/apps/issues/app-context.js'
@@ -126,6 +122,7 @@ module.exports = (grunt) ->
           'build-app:computation'
           'build-app:drilldown'
           'build-app:groups'
+          'build-app:issues'
           'build-app:maintenance'
           'build-app:markdown'
           'build-app:measures'
@@ -140,7 +137,6 @@ module.exports = (grunt) ->
           # widgets
           'build-widget:issue-filter'
           # other
-          'requirejs:issues'
           'requirejs:issuesContext'
           'requirejs:selectList'
         ]
diff --git a/server/sonar-web/src/main/js/apps/issues/app-new.js b/server/sonar-web/src/main/js/apps/issues/app-new.js
deleted file mode 100644 (file)
index 12e5671..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-define([
-  './models/state',
-  './layout',
-  './models/issues',
-  'components/navigator/models/facets',
-  './models/filters',
-  './controller',
-  './router',
-  './workspace-list-view',
-  './workspace-header-view',
-  './facets-view',
-  './filters-view',
-  './helpers/format-facet-value'
-], function (State, Layout, Issues, Facets, Filters, Controller, Router, WorkspaceListView, WorkspaceHeaderView,
-             FacetsView, FiltersView) {
-
-  var $ = jQuery,
-      App = new Marionette.Application(),
-      init = function (options) {
-        this.state = new State();
-        this.list = new Issues();
-        this.facets = new Facets();
-        this.filters = new Filters();
-
-        this.layout = new Layout({ app: this, el: options.el });
-        this.layout.render();
-        $('#footer').addClass('search-navigator-footer');
-
-        this.controller = new Controller({ app: this });
-
-        this.issuesView = new WorkspaceListView({
-          app: this,
-          collection: this.list
-        });
-        this.layout.workspaceListRegion.show(this.issuesView);
-        this.issuesView.bindScrollEvents();
-
-        this.workspaceHeaderView = new WorkspaceHeaderView({
-          app: this,
-          collection: this.list
-        });
-        this.layout.workspaceHeaderRegion.show(this.workspaceHeaderView);
-
-        this.facetsView = new FacetsView({
-          app: this,
-          collection: this.facets
-        });
-        this.layout.facetsRegion.show(this.facetsView);
-
-        this.filtersView = new FiltersView({
-          app: this,
-          collection: this.filters
-        });
-        this.layout.filtersRegion.show(this.filtersView);
-
-        this.controller.fetchFilters().done(function () {
-          key.setScope('list');
-          App.router = new Router({ app: App });
-          Backbone.history.start();
-        });
-      };
-
-  App.on('start', function (options) {
-    $.when(window.requestMessages()).done(function () {
-      init.call(App, options);
-    });
-  });
-
-  return App;
-
-});
diff --git a/server/sonar-web/src/main/js/apps/issues/app.js b/server/sonar-web/src/main/js/apps/issues/app.js
new file mode 100644 (file)
index 0000000..12e5671
--- /dev/null
@@ -0,0 +1,71 @@
+define([
+  './models/state',
+  './layout',
+  './models/issues',
+  'components/navigator/models/facets',
+  './models/filters',
+  './controller',
+  './router',
+  './workspace-list-view',
+  './workspace-header-view',
+  './facets-view',
+  './filters-view',
+  './helpers/format-facet-value'
+], function (State, Layout, Issues, Facets, Filters, Controller, Router, WorkspaceListView, WorkspaceHeaderView,
+             FacetsView, FiltersView) {
+
+  var $ = jQuery,
+      App = new Marionette.Application(),
+      init = function (options) {
+        this.state = new State();
+        this.list = new Issues();
+        this.facets = new Facets();
+        this.filters = new Filters();
+
+        this.layout = new Layout({ app: this, el: options.el });
+        this.layout.render();
+        $('#footer').addClass('search-navigator-footer');
+
+        this.controller = new Controller({ app: this });
+
+        this.issuesView = new WorkspaceListView({
+          app: this,
+          collection: this.list
+        });
+        this.layout.workspaceListRegion.show(this.issuesView);
+        this.issuesView.bindScrollEvents();
+
+        this.workspaceHeaderView = new WorkspaceHeaderView({
+          app: this,
+          collection: this.list
+        });
+        this.layout.workspaceHeaderRegion.show(this.workspaceHeaderView);
+
+        this.facetsView = new FacetsView({
+          app: this,
+          collection: this.facets
+        });
+        this.layout.facetsRegion.show(this.facetsView);
+
+        this.filtersView = new FiltersView({
+          app: this,
+          collection: this.filters
+        });
+        this.layout.filtersRegion.show(this.filtersView);
+
+        this.controller.fetchFilters().done(function () {
+          key.setScope('list');
+          App.router = new Router({ app: App });
+          Backbone.history.start();
+        });
+      };
+
+  App.on('start', function (options) {
+    $.when(window.requestMessages()).done(function () {
+      init.call(App, options);
+    });
+  });
+
+  return App;
+
+});
index 1cf75f1d41fbf8779be7cf28be369a2011d127c6..0c105bbd322e40db0cb9c94639e96b38ed3b06d0 100644 (file)
@@ -1,6 +1,6 @@
 <% content_for :extra_script do %>
   <script>
-    require(['apps/issues/app-new'], function (App) {
+    require(['apps/issues/app'], function (App) {
       App.start({ el: '#content' });
     });
   </script>
diff --git a/server/sonar-web/src/test/json/issues-spec/filter.json b/server/sonar-web/src/test/json/issues-spec/filter.json
new file mode 100644 (file)
index 0000000..6b6ecfe
--- /dev/null
@@ -0,0 +1,9 @@
+{
+  "filter": {
+    "id": 31,
+    "name": "Critical and Blocker Issues",
+    "shared": true,
+    "query": "resolved=false|severities=BLOCKER,CRITICAL",
+    "canModify": true
+  }
+}
index 17cab286e7d9ae4326b402e888611ce39d56f622..5df2a74da06ef7f167a98bd024b892944db353a5 100644 (file)
@@ -20,7 +20,8 @@ define(['intern'], function (intern) {
     ],
 
     functionalSuites: [
-      'test/medium/users.spec'
+      'test/medium/users.spec',
+      'test/medium/issues.spec'
     ],
 
     tunnel: tunnel,
diff --git a/server/sonar-web/test/medium/issues.spec.js b/server/sonar-web/test/medium/issues.spec.js
new file mode 100644 (file)
index 0000000..4987c91
--- /dev/null
@@ -0,0 +1,65 @@
+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
+            .get(require.toUrl('test/medium/base.html'))
+            .setFindTimeout(5000)
+            .mockFromString('/api/l10n/index', '{}')
+            .mockFromFile('/api/issue_filters/app', 'issues-spec/app.json')
+            .mockFromFile('/api/issues/search', 'issues-spec/search.json')
+            .startApp('issues')
+            .assertElementCount('.js-filter', 2)
+            .assertElementCount('.js-filter[data-id="31"]', 1)
+            .assertElementCount('.js-filter[data-id="32"]', 1);
+      });
+
+      bdd.it('should load a saved search', function () {
+        return this.remote
+            .get(require.toUrl('test/medium/base.html'))
+            .setFindTimeout(5000)
+            .mockFromString('/api/l10n/index', '{}')
+            .mockFromFile('/api/issue_filters/app', 'issues-spec/app.json')
+            .mockFromFile('/api/issues/search', 'issues-spec/search.json')
+            .mockFromFile('/api/issue_filters/show/31', 'issues-spec/filter.json')
+            .startApp('issues')
+            .clickElement('.search-navigator-filters-show-list')
+            .clickElement('.js-filter[data-id="31"]')
+            .assertElementCount('.js-filter-copy', 1)
+            .assertElementCount('.js-filter-edit', 1)
+            .assertElementInclude('.issues-filters-name', 'Critical and Blocker Issues')
+            .assertElementCount('.js-facet.active[data-value="BLOCKER"]', 1)
+            .assertElementCount('.js-facet.active[data-value="CRITICAL"]', 1)
+            .assertElementCount('.js-facet.active[data-unresolved]', 1);
+      });
+
+      bdd.it('should load a saved search and then resets it by new search', function () {
+        return this.remote
+            .get(require.toUrl('test/medium/base.html'))
+            .setFindTimeout(5000)
+            .mockFromString('/api/l10n/index', '{}')
+            .mockFromFile('/api/issue_filters/app', 'issues-spec/app.json')
+            .mockFromFile('/api/issues/search', 'issues-spec/search.json')
+            .mockFromFile('/api/issue_filters/show/31', 'issues-spec/filter.json')
+            .startApp('issues')
+            .clickElement('.search-navigator-filters-show-list')
+            .clickElement('.js-filter[data-id="31"]')
+            .assertElementCount('.js-filter-copy', 1)
+            .assertElementCount('.js-filter-edit', 1)
+            .assertElementInclude('.issues-filters-name', 'Critical and Blocker Issues')
+            .assertElementCount('.js-facet.active[data-value="BLOCKER"]', 1)
+            .assertElementCount('.js-facet.active[data-value="CRITICAL"]', 1)
+            .assertElementCount('.js-facet.active[data-unresolved]', 1)
+            .clickElement('.js-new-search')
+            .assertElementCount('.js-facet[data-value="BLOCKER"]:not(.active)', 1)
+            .assertElementCount('.js-facet[data-value="CRITICAL"]:not(.active)', 1)
+            .assertElementCount('.js-facet.active[data-unresolved]', 1)
+            .assertElementNotInclude('.issues-filters-name', 'Critical and Blocker Issues');
+      });
+    });
+  });
+
+});