diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-07-08 13:38:29 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-07-08 14:08:00 +0200 |
commit | bfef505c8a0de560805234643f6ee8b58d37d04a (patch) | |
tree | 9ccf94044ea5e802946d6309589d440cf9afd2d0 /server/sonar-web | |
parent | 7a4939f74f1bc53203eb99945182adeb7ab750da (diff) | |
download | sonarqube-bfef505c8a0de560805234643f6ee8b58d37d04a.tar.gz sonarqube-bfef505c8a0de560805234643f6ee8b58d37d04a.zip |
SONAR-6697 add tests
Diffstat (limited to 'server/sonar-web')
9 files changed, 681 insertions, 1 deletions
diff --git a/server/sonar-web/src/test/json/custom-measures-spec/metrics.json b/server/sonar-web/src/test/json/custom-measures-spec/metrics.json new file mode 100644 index 00000000000..fe8cee9801c --- /dev/null +++ b/server/sonar-web/src/test/json/custom-measures-spec/metrics.json @@ -0,0 +1,64 @@ +{ + "metrics": [ + { + "id": "155", + "key": "burned_budget", + "type": "FLOAT", + "name": "Burned budget", + "domain": "Management", + "direction": 0, + "qualitative": false, + "hidden": false, + "custom": true + }, + { + "id": "156", + "key": "business_value", + "type": "FLOAT", + "name": "Business value", + "domain": "Management", + "direction": 1, + "qualitative": true, + "hidden": false, + "custom": true + }, + { + "id": "159", + "key": "dist", + "type": "DISTRIB", + "name": "Distribution", + "description": "", + "domain": "", + "direction": 0, + "qualitative": false, + "hidden": false, + "custom": true + }, + { + "id": "160", + "key": "rating", + "type": "RATING", + "name": "Rating", + "description": "", + "domain": "", + "direction": 0, + "qualitative": false, + "hidden": false, + "custom": true + }, + { + "id": "157", + "key": "team_size", + "type": "INT", + "name": "Team size", + "domain": "Management", + "direction": 0, + "qualitative": false, + "hidden": false, + "custom": true + } + ], + "total": 5, + "p": 1, + "ps": 100 +} diff --git a/server/sonar-web/src/test/json/custom-measures-spec/search-big-1.json b/server/sonar-web/src/test/json/custom-measures-spec/search-big-1.json new file mode 100644 index 00000000000..831b4835987 --- /dev/null +++ b/server/sonar-web/src/test/json/custom-measures-spec/search-big-1.json @@ -0,0 +1,53 @@ +{ + "customMeasures": [ + { + "id": "5", + "value": "1.0", + "description": "", + "metric": { + "id": "160", + "key": "rating", + "type": "RATING", + "name": "Rating", + "domain": "" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T12:26:41+0200", + "updatedAt": "2015-07-08T12:27:41+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + }, + { + "id": "4", + "value": "1", + "description": "", + "metric": { + "id": "159", + "key": "dist", + "type": "DISTRIB", + "name": "Distribution", + "domain": "" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T12:26:22+0200", + "updatedAt": "2015-07-08T12:26:22+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + } + ], + "total": 4, + "p": 1, + "ps": 2 +} diff --git a/server/sonar-web/src/test/json/custom-measures-spec/search-big-2.json b/server/sonar-web/src/test/json/custom-measures-spec/search-big-2.json new file mode 100644 index 00000000000..53f42bd1b01 --- /dev/null +++ b/server/sonar-web/src/test/json/custom-measures-spec/search-big-2.json @@ -0,0 +1,53 @@ +{ + "customMeasures": [ + { + "id": "3", + "value": "35", + "description": "", + "metric": { + "id": "157", + "key": "team_size", + "type": "INT", + "name": "Team size", + "domain": "Management" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T12:13:15+0200", + "updatedAt": "2015-07-08T12:13:15+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + }, + { + "id": "1", + "value": "3.2000123E7", + "description": "Description...", + "metric": { + "id": "155", + "key": "burned_budget", + "type": "FLOAT", + "name": "Burned budget", + "domain": "Management" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T09:21:50+0200", + "updatedAt": "2015-07-08T12:25:37+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + } + ], + "total": 4, + "p": 2, + "ps": 2 +} diff --git a/server/sonar-web/src/test/json/custom-measures-spec/search-created.json b/server/sonar-web/src/test/json/custom-measures-spec/search-created.json new file mode 100644 index 00000000000..b118b9be11b --- /dev/null +++ b/server/sonar-web/src/test/json/custom-measures-spec/search-created.json @@ -0,0 +1,122 @@ +{ + "customMeasures": [ + { + "id": "6", + "value": "17.0", + "description": "example", + "metric": { + "id": "156", + "key": "business_value", + "type": "FLOAT", + "name": "Business value", + "domain": "Management" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T13:21:51+0200", + "updatedAt": "2015-07-08T13:21:51+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + }, + { + "id": "5", + "value": "1.0", + "description": "", + "metric": { + "id": "160", + "key": "rating", + "type": "RATING", + "name": "Rating", + "domain": "" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T12:26:41+0200", + "updatedAt": "2015-07-08T12:27:41+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + }, + { + "id": "4", + "value": "1", + "description": "", + "metric": { + "id": "159", + "key": "dist", + "type": "DISTRIB", + "name": "Distribution", + "domain": "" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T12:26:22+0200", + "updatedAt": "2015-07-08T12:26:22+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + }, + { + "id": "3", + "value": "35", + "description": "", + "metric": { + "id": "157", + "key": "team_size", + "type": "INT", + "name": "Team size", + "domain": "Management" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T12:13:15+0200", + "updatedAt": "2015-07-08T12:13:15+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + }, + { + "id": "1", + "value": "3.2000123E7", + "description": "Description...", + "metric": { + "id": "155", + "key": "burned_budget", + "type": "FLOAT", + "name": "Burned budget", + "domain": "Management" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T09:21:50+0200", + "updatedAt": "2015-07-08T12:25:37+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + } + ], + "total": 5, + "p": 1, + "ps": 100 +} diff --git a/server/sonar-web/src/test/json/custom-measures-spec/search-deleted.json b/server/sonar-web/src/test/json/custom-measures-spec/search-deleted.json new file mode 100644 index 00000000000..e2a82e74804 --- /dev/null +++ b/server/sonar-web/src/test/json/custom-measures-spec/search-deleted.json @@ -0,0 +1,76 @@ +{ + "customMeasures": [ + { + "id": "4", + "value": "1", + "description": "", + "metric": { + "id": "159", + "key": "dist", + "type": "DISTRIB", + "name": "Distribution", + "domain": "" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T12:26:22+0200", + "updatedAt": "2015-07-08T12:26:22+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + }, + { + "id": "3", + "value": "35", + "description": "", + "metric": { + "id": "157", + "key": "team_size", + "type": "INT", + "name": "Team size", + "domain": "Management" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T12:13:15+0200", + "updatedAt": "2015-07-08T12:13:15+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + }, + { + "id": "1", + "value": "3.2000123E7", + "description": "Description...", + "metric": { + "id": "155", + "key": "burned_budget", + "type": "FLOAT", + "name": "Burned budget", + "domain": "Management" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T09:21:50+0200", + "updatedAt": "2015-07-08T12:25:37+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + } + ], + "total": 3, + "p": 1, + "ps": 100 +} diff --git a/server/sonar-web/src/test/json/custom-measures-spec/search-updated.json b/server/sonar-web/src/test/json/custom-measures-spec/search-updated.json new file mode 100644 index 00000000000..60c0a9fda98 --- /dev/null +++ b/server/sonar-web/src/test/json/custom-measures-spec/search-updated.json @@ -0,0 +1,99 @@ +{ + "customMeasures": [ + { + "id": "5", + "value": "2.0", + "description": "new!", + "metric": { + "id": "160", + "key": "rating", + "type": "RATING", + "name": "Rating", + "domain": "" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T12:26:41+0200", + "updatedAt": "2015-07-08T13:28:04+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + }, + { + "id": "4", + "value": "1", + "description": "", + "metric": { + "id": "159", + "key": "dist", + "type": "DISTRIB", + "name": "Distribution", + "domain": "" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T12:26:22+0200", + "updatedAt": "2015-07-08T12:26:22+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + }, + { + "id": "3", + "value": "35", + "description": "", + "metric": { + "id": "157", + "key": "team_size", + "type": "INT", + "name": "Team size", + "domain": "Management" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T12:13:15+0200", + "updatedAt": "2015-07-08T12:13:15+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + }, + { + "id": "1", + "value": "3.2000123E7", + "description": "Description...", + "metric": { + "id": "155", + "key": "burned_budget", + "type": "FLOAT", + "name": "Burned budget", + "domain": "Management" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T09:21:50+0200", + "updatedAt": "2015-07-08T12:25:37+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + } + ], + "total": 4, + "p": 1, + "ps": 100 +} diff --git a/server/sonar-web/src/test/json/custom-measures-spec/search.json b/server/sonar-web/src/test/json/custom-measures-spec/search.json new file mode 100644 index 00000000000..a0739da9efa --- /dev/null +++ b/server/sonar-web/src/test/json/custom-measures-spec/search.json @@ -0,0 +1,99 @@ +{ + "customMeasures": [ + { + "id": "5", + "value": "1.0", + "description": "", + "metric": { + "id": "160", + "key": "rating", + "type": "RATING", + "name": "Rating", + "domain": "" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T12:26:41+0200", + "updatedAt": "2015-07-08T12:27:41+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + }, + { + "id": "4", + "value": "1", + "description": "", + "metric": { + "id": "159", + "key": "dist", + "type": "DISTRIB", + "name": "Distribution", + "domain": "" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T12:26:22+0200", + "updatedAt": "2015-07-08T12:26:22+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + }, + { + "id": "3", + "value": "35", + "description": "", + "metric": { + "id": "157", + "key": "team_size", + "type": "INT", + "name": "Team size", + "domain": "Management" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T12:13:15+0200", + "updatedAt": "2015-07-08T12:13:15+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + }, + { + "id": "1", + "value": "3.2000123E7", + "description": "Description...", + "metric": { + "id": "155", + "key": "burned_budget", + "type": "FLOAT", + "name": "Burned budget", + "domain": "Management" + }, + "projectId": "eb294572-a6a4-43cf-acc2-33c2fe37c02e", + "projectKey": "backbone", + "createdAt": "2015-07-08T09:21:50+0200", + "updatedAt": "2015-07-08T12:25:37+0200", + "pending": true, + "user": { + "login": "admin", + "name": "Administrator", + "email": "", + "active": true + } + } + ], + "total": 4, + "p": 1, + "ps": 100 +} diff --git a/server/sonar-web/test/intern.js b/server/sonar-web/test/intern.js index 6e846af1423..303ad3c87a0 100644 --- a/server/sonar-web/test/intern.js +++ b/server/sonar-web/test/intern.js @@ -24,7 +24,8 @@ define(['intern'], function (intern) { 'test/medium/issues.spec', 'test/medium/update-center.spec', 'test/medium/computation.spec', - 'test/medium/coding-rules.spec' + 'test/medium/coding-rules.spec', + 'test/medium/custom-measures.spec' ], tunnel: tunnel, diff --git a/server/sonar-web/test/medium/custom-measures.spec.js b/server/sonar-web/test/medium/custom-measures.spec.js new file mode 100644 index 00000000000..6e67edc1529 --- /dev/null +++ b/server/sonar-web/test/medium/custom-measures.spec.js @@ -0,0 +1,113 @@ +define(function (require) { + var bdd = require('intern!bdd'); + require('../helpers/test-page'); + + bdd.describe('Custom Measures Page', function () { + var projectId = 'eb294572-a6a4-43cf-acc2-33c2fe37c02e'; + + bdd.it('should show list', function () { + return this.remote + .open() + .mockFromFile('/api/custom_measures/search', 'custom-measures-spec/search.json', + { data: { projectId: projectId } }) + .startApp('custom-measures', { projectId: projectId }) + .checkElementCount('#custom-measures-list li[data-id]', 4) + .checkElementInclude('#custom-measures-list .js-custom-measure-value', '35') + .checkElementInclude('#custom-measures-list .js-custom-measure-metric-name', 'Distribution') + .checkElementInclude('#custom-measures-list .js-custom-measure-domain', 'Management') + .checkElementInclude('#custom-measures-list .js-custom-measure-description', 'Description...') + .checkElementInclude('#custom-measures-list .js-custom-measure-created-at', '2015') + .checkElementInclude('#custom-measures-list .js-custom-measure-user', 'Administrator') + .checkElementCount('#custom-measures-list .js-custom-measure-pending', 4) + .checkElementCount('#custom-measures-list .js-custom-measure-update', 4) + .checkElementCount('#custom-measures-list .js-custom-measure-delete', 4) + .checkElementInclude('#custom-measures-list-footer', '4/4'); + }); + + bdd.it('should show more', function () { + return this.remote + .open() + .mockFromFile('/api/custom_measures/search', 'custom-measures-spec/search-big-1.json', + { data: { projectId: projectId } }) + .startApp('custom-measures', { projectId: projectId }) + .checkElementCount('#custom-measures-list li[data-id]', 2) + .checkElementNotExist('[data-id="3"]') + .clearMocks() + .mockFromFile('/api/custom_measures/search', 'custom-measures-spec/search-big-2.json', + { data: { projectId: projectId, p: 2 } }) + .clickElement('#custom-measures-fetch-more') + .checkElementExist('[data-id="3"]') + .checkElementCount('#custom-measures-list li[data-id]', 4); + }); + + bdd.it('should create a new custom measure', function () { + return this.remote + .open() + .mockFromFile('/api/custom_measures/search', 'custom-measures-spec/search.json', + { data: { projectId: projectId } }) + .mockFromFile('/api/metrics/search', 'custom-measures-spec/metrics.json', { data: { isCustom: true } }) + .startApp('custom-measures', { projectId: projectId }) + .checkElementCount('#custom-measures-list li[data-id]', 4) + .clickElement('#custom-measures-create') + .checkElementExist('#create-custom-measure-form') + .clearMocks() + .mockFromFile('/api/custom_measures/search', 'custom-measures-spec/search-created.json', + { data: { projectId: projectId } }) + .mockFromString('/api/custom_measures/create', '{}', { data: { + metricId: '156', + value: '17', + description: 'example', + projectId: projectId + } }) + .fillElement('#create-custom-measure-metric', '156') + .fillElement('#create-custom-measure-value', '17') + .fillElement('#create-custom-measure-description', 'example') + .clickElement('#create-custom-measure-submit') + .checkElementExist('[data-id="6"]') + .checkElementCount('#custom-measures-list li[data-id]', 5) + .checkElementInclude('[data-id="6"] .js-custom-measure-value', '17'); + }); + + bdd.it('should update a custom measure', function () { + return this.remote + .open() + .mockFromFile('/api/custom_measures/search', 'custom-measures-spec/search.json', + { data: { projectId: projectId } }) + .mockFromFile('/api/metrics/search', 'custom-measures-spec/metrics.json', { data: { isCustom: true } }) + .startApp('custom-measures', { projectId: projectId }) + .clickElement('[data-id="5"] .js-custom-measure-update') + .checkElementExist('#create-custom-measure-form') + .clearMocks() + .mockFromFile('/api/custom_measures/search', 'custom-measures-spec/search-updated.json', + { data: { projectId: projectId } }) + .mockFromString('/api/custom_measures/update', '{}', { data: { + id: '5', + value: '2', + description: 'new!' + } }) + .fillElement('#create-custom-measure-value', '2') + .fillElement('#create-custom-measure-description', 'new!') + .clickElement('#create-custom-measure-submit') + .checkElementExist('[data-id="5"]') + .checkElementInclude('[data-id="5"] .js-custom-measure-value', 'B') + .checkElementInclude('[data-id="5"] .js-custom-measure-description', 'new!'); + }); + + bdd.it('should delete a custom measure', function () { + return this.remote + .open() + .mockFromFile('/api/custom_measures/search', 'custom-measures-spec/search.json', + { data: { projectId: projectId } }) + .startApp('custom-measures', { projectId: projectId }) + .clickElement('[data-id="5"] .js-custom-measure-delete') + .checkElementExist('#delete-custom-measure-form', 1) + .clearMocks() + .mockFromFile('/api/custom_measures/search', 'custom-measures-spec/search-deleted.json', + { data: { projectId: projectId } }) + .mockFromString('/api/custom_measures/delete', '{}', { data: { id: '5' } }) + .clickElement('#delete-custom-measure-submit') + .checkElementNotExist('[data-id="5"]'); + }); + }); + +}); |