diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-06-08 15:37:29 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-06-08 15:59:25 +0200 |
commit | f1f836fa24922996df0906bd1336940de205d5b6 (patch) | |
tree | dc359cfcabfa5a36b10d48320ad613e71bd1680e /server/sonar-web/src/test/js | |
parent | 56963334491068e70db0695c7fc36d9c40bfca9a (diff) | |
download | sonarqube-f1f836fa24922996df0906bd1336940de205d5b6.tar.gz sonarqube-f1f836fa24922996df0906bd1336940de205d5b6.zip |
SONAR-6341 make it possible to bulk delete provisioned projects
Diffstat (limited to 'server/sonar-web/src/test/js')
-rw-r--r-- | server/sonar-web/src/test/js/provisioning-spec.js | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/server/sonar-web/src/test/js/provisioning-spec.js b/server/sonar-web/src/test/js/provisioning-spec.js index 6a1b6b6abb2..8c197cd8c20 100644 --- a/server/sonar-web/src/test/js/provisioning-spec.js +++ b/server/sonar-web/src/test/js/provisioning-spec.js @@ -254,3 +254,130 @@ casper.test.begin(testName('Delete'), 1, function (test) { }); }); + +casper.test.begin(testName('Selection'), 22, function (test) { + casper + .start(lib.buildUrl('provisioning'), function () { + lib.setDefaultViewport(); + lib.mockRequestFromFile('/api/projects/provisioned', 'search.json'); + }) + + .then(function () { + casper.evaluate(function () { + require(['apps/provisioning/app'], function (App) { + App.start({ el: '#provisioning' }); + }); + }); + }) + + .then(function () { + casper.waitForSelector('#provisioning-list li'); + }) + + .then(function () { + test.assertExists('.js-toggle-selection'); + test.assertDoesntExist('.js-toggle-selection.icon-checkbox-checked'); + test.assertElementCount('.js-toggle', 3); + test.assertDoesntExist('.js-toggle.icon-checkbox-checked'); + test.assertExists('#provisioning-bulk-delete[disabled]'); + }) + + .then(function () { + casper.click('#provisioning-list [data-id="id-sonarqube"] .js-toggle'); + + test.assertExists('.js-toggle-selection.icon-checkbox-checked.icon-checkbox-single'); + test.assertExists('#provisioning-list [data-id="id-sonarqube"] .js-toggle.icon-checkbox-checked'); + test.assertExists('#provisioning-bulk-delete'); + test.assertDoesntExist('#provisioning-bulk-delete[disabled]'); + }) + + .then(function () { + casper.click('#provisioning-list [data-id="id-javascript"] .js-toggle'); + casper.click('#provisioning-list [data-id="id-sonarqube-release"] .js-toggle'); + + test.assertDoesntExist('.js-toggle-selection.icon-checkbox-checked.icon-checkbox-single'); + test.assertExists('.js-toggle-selection.icon-checkbox-checked'); + test.assertExists('#provisioning-bulk-delete'); + test.assertDoesntExist('#provisioning-bulk-delete[disabled]'); + }) + + .then(function () { + casper.click('.js-toggle-selection'); + + test.assertDoesntExist('.js-toggle-selection.icon-checkbox-checked'); + test.assertElementCount('.js-toggle', 3); + test.assertDoesntExist('.js-toggle.icon-checkbox-checked'); + test.assertExists('#provisioning-bulk-delete[disabled]'); + }) + + .then(function () { + casper.click('.js-toggle-selection'); + + test.assertDoesntExist('.js-toggle-selection.icon-checkbox-checked.icon-checkbox-single'); + test.assertExists('.js-toggle-selection.icon-checkbox-checked'); + test.assertElementCount('.js-toggle.icon-checkbox-checked', 3); + test.assertExists('#provisioning-bulk-delete'); + test.assertDoesntExist('#provisioning-bulk-delete[disabled]'); + }) + + .then(function () { + lib.sendCoverage(); + }) + .run(function () { + test.done(); + }); +}); + + +casper.test.begin(testName('Bulk Delete'), 1, function (test) { + casper + .start(lib.buildUrl('provisioning'), function () { + lib.setDefaultViewport(); + lib.mockRequestFromFile('/api/projects/provisioned', 'search.json'); + lib.mockRequestFromFile('/api/projects/bulk_delete', 'delete-error.json', { status: 400 }); + }) + + .then(function () { + casper.evaluate(function () { + require(['apps/provisioning/app'], function (App) { + App.start({ el: '#provisioning' }); + }); + jQuery.ajaxSetup({ dataType: 'json' }); + }); + }) + + .then(function () { + casper.waitForSelector('#provisioning-list li'); + }) + + .then(function () { + casper.click('#provisioning-list [data-id="id-sonarqube"] .js-toggle'); + casper.click('#provisioning-list [data-id="id-sonarqube-release"] .js-toggle'); + casper.click('#provisioning-bulk-delete'); + casper.waitForSelector('#bulk-delete-projects-form'); + }) + + .then(function () { + casper.click('#bulk-delete-projects-submit'); + casper.waitForSelector('.alert.alert-danger'); + }) + + .then(function () { + lib.clearRequestMocks(); + lib.mockRequestFromFile('/api/projects/provisioned', 'search-deleted.json'); + lib.mockRequest('/api/projects/bulk_delete', '{}', { data: { ids: 'id-sonarqube,id-sonarqube-release' } }); + casper.click('#bulk-delete-projects-submit'); + casper.waitWhileSelector('[data-id="id-sonarqube"]'); + }) + + .then(function () { + test.assert(true); + }) + + .then(function () { + lib.sendCoverage(); + }) + .run(function () { + test.done(); + }); +}); |