From aa472c83a8e59647f347cd6e675bd95d277f0c01 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Fri, 22 Aug 2014 16:29:02 +0600 Subject: [PATCH] SONAR-4406 Rework design page Add MT --- .../main/js/tests/e2e/tests/design-spec.js | 102 ++++++++++++++++++ .../e2e/tests/design-spec/dependencies.json | 80 ++++++++++++++ .../e2e/tests/design-spec/resources.json | 20 ++++ .../src/main/js/tests/e2e/views/design.jade | 11 ++ 4 files changed, 213 insertions(+) create mode 100644 server/sonar-web/src/main/js/tests/e2e/tests/design-spec.js create mode 100644 server/sonar-web/src/main/js/tests/e2e/tests/design-spec/dependencies.json create mode 100644 server/sonar-web/src/main/js/tests/e2e/tests/design-spec/resources.json create mode 100644 server/sonar-web/src/main/js/tests/e2e/views/design.jade diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/design-spec.js b/server/sonar-web/src/main/js/tests/e2e/tests/design-spec.js new file mode 100644 index 00000000000..ef4b615f266 --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/design-spec.js @@ -0,0 +1,102 @@ +var lib = require('../lib'), + testName = lib.testName('Design'); + +lib.initMessages(); +lib.changeWorkingDirectory('design-spec'); + + +casper.test.begin(testName('Base'), function suite(test) { + casper + .start(lib.buildUrl('design'), function () { + lib.setDefaultViewport(); + lib.mockRequest('/api/l10n/index', '{}'); + lib.mockRequestFromFile('/api/resources', 'resources.json'); + lib.mockRequestFromFile('/api/dependencies', 'dependencies.json'); + }) + + .then(function () { + casper.waitWhileSelector('.spinner'); + }) + + .then(function () { + test.assertSelectorContains('.dsm-body', 'src/test/java/com/maif/sonar/cobol/metrics'); + test.assertSelectorContains('.dsm-body', 'src/test/java/com/maif/sonar/cobol/repository'); + test.assertElementCount('.dsm-body-cell-dependency', 12); + test.assertElementCount('.dsm-body-cell-cycle', 1); + test.assertSelectorContains('.dsm-body-cell-cycle', '6'); + }) + + .then(function () { + casper.mouse.doubleclick('.dsm-body-cell-cycle'); + casper.waitForSelector('.spinner', function () { + casper.waitWhileSelector('.spinner'); + }) + }) + + .then(function () { + test.assertElementCount('.dsm-info tr', 7); + test.assertSelectorContains('.dsm-info', 'src/main/java/com/maif/sonar/cobol/api/MaifCobolMeasureProvider.java'); + test.assertSelectorContains('.dsm-info', 'src/main/java/com/maif/sonar/cobol/metrics/BusinessRuleCounter.java '); + test.assertSelectorContains('.dsm-info', 'src/main/java/com/maif/sonar/cobol/metrics/TableMetricsVisitor.java '); + }) + + .run(function () { + test.done(); + }); +}); + + + +casper.test.begin(testName('Stress Test'), function suite(test) { + casper.options.waitTimeout = 1000000; + + casper + .exit(0) // Remove this to enable the test + + .start(lib.buildUrl('design'), function () { + lib.setDefaultViewport(); + lib.mockRequest('/api/l10n/index', '{}'); + lib.mockRequest('/api/resources', generateBigResourcesFile(1000)); + }) + + .then(function () { + casper.waitWhileSelector('.spinner'); + }) + + .then(function () { + test.assertElementCount('.dsm-body tr', 1000); + }) + + .run(function () { + test.done(); + }); +}); + + +function generateBigResourcesFile (limit) { + var s = '[{"id":6924,"key":"com.maif.sonar:maif-cobol-plugin","name":"MAIF :: Cobol plugin","scope":"PRJ","qualifier":"TRK","date":"2014-07-21T23:04:05+0600","creationDate":null,"lname":"MAIF :: Cobol plugin","version":"2.7-SNAPSHOT","description":"","msr":[{"key":"dsm","data":"[', + i, j; + + for (i = 0; i < limit; i++) { + s += '{\\\"i\\\":'; + s += i; + s += ',\\\"n\\\":\\\"src/test/java/com/maif/sonar/cobol/metrics'; + s += i; + s += '\\\",\\\"q\\\":\\\"DIR\\\",\\\"v\\\":['; + + for (j = 0; j < limit; j++) { + s += '{}'; + if (j < limit - 1) { + s += ','; + } + } + + s += ']}'; + if (i < limit - 1) { + s += ','; + } + } + + s += ']"}]}]'; + return s; +} diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/design-spec/dependencies.json b/server/sonar-web/src/main/js/tests/e2e/tests/design-spec/dependencies.json new file mode 100644 index 00000000000..7f23c19b8d5 --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/design-spec/dependencies.json @@ -0,0 +1,80 @@ +[ + { + "id": 14879226, + "fi": 8354, + "ti": 6955, + "u": "USES", + "w": 1, + "fk": "com.maif.sonar:maif-cobol-plugin:src/main/java/com/maif/sonar/cobol/api/MaifCobolMeasureProvider.java", + "fn": "src/main/java/com/maif/sonar/cobol/api/MaifCobolMeasureProvider.java", + "fq": "FIL", + "tk": "com.maif.sonar:maif-cobol-plugin:src/main/java/com/maif/sonar/cobol/metrics/BusinessRuleCounter.java", + "tn": "src/main/java/com/maif/sonar/cobol/metrics/BusinessRuleCounter.java", + "tq": "FIL" + }, + { + "id": 14879225, + "fi": 8354, + "ti": 6956, + "u": "USES", + "w": 1, + "fk": "com.maif.sonar:maif-cobol-plugin:src/main/java/com/maif/sonar/cobol/api/MaifCobolMeasureProvider.java", + "fn": "src/main/java/com/maif/sonar/cobol/api/MaifCobolMeasureProvider.java", + "fq": "FIL", + "tk": "com.maif.sonar:maif-cobol-plugin:src/main/java/com/maif/sonar/cobol/metrics/ExternalizedRuleCallCounter.java", + "tn": "src/main/java/com/maif/sonar/cobol/metrics/ExternalizedRuleCallCounter.java", + "tq": "FIL" + }, + { + "id": 14879228, + "fi": 8354, + "ti": 6957, + "u": "USES", + "w": 1, + "fk": "com.maif.sonar:maif-cobol-plugin:src/main/java/com/maif/sonar/cobol/api/MaifCobolMeasureProvider.java", + "fn": "src/main/java/com/maif/sonar/cobol/api/MaifCobolMeasureProvider.java", + "fq": "FIL", + "tk": "com.maif.sonar:maif-cobol-plugin:src/main/java/com/maif/sonar/cobol/metrics/IadUseDetector.java", + "tn": "src/main/java/com/maif/sonar/cobol/metrics/IadUseDetector.java", + "tq": "FIL" + }, + { + "id": 14879229, + "fi": 8354, + "ti": 8356, + "u": "USES", + "w": 1, + "fk": "com.maif.sonar:maif-cobol-plugin:src/main/java/com/maif/sonar/cobol/api/MaifCobolMeasureProvider.java", + "fn": "src/main/java/com/maif/sonar/cobol/api/MaifCobolMeasureProvider.java", + "fq": "FIL", + "tk": "com.maif.sonar:maif-cobol-plugin:src/main/java/com/maif/sonar/cobol/metrics/Ids2AndIadMatrixDetector.java", + "tn": "src/main/java/com/maif/sonar/cobol/metrics/Ids2AndIadMatrixDetector.java", + "tq": "FIL" + }, + { + "id": 14879227, + "fi": 8354, + "ti": 6958, + "u": "USES", + "w": 1, + "fk": "com.maif.sonar:maif-cobol-plugin:src/main/java/com/maif/sonar/cobol/api/MaifCobolMeasureProvider.java", + "fn": "src/main/java/com/maif/sonar/cobol/api/MaifCobolMeasureProvider.java", + "fq": "FIL", + "tk": "com.maif.sonar:maif-cobol-plugin:src/main/java/com/maif/sonar/cobol/metrics/Ids2UseDetector.java", + "tn": "src/main/java/com/maif/sonar/cobol/metrics/Ids2UseDetector.java", + "tq": "FIL" + }, + { + "id": 14879224, + "fi": 8354, + "ti": 12194, + "u": "USES", + "w": 1, + "fk": "com.maif.sonar:maif-cobol-plugin:src/main/java/com/maif/sonar/cobol/api/MaifCobolMeasureProvider.java", + "fn": "src/main/java/com/maif/sonar/cobol/api/MaifCobolMeasureProvider.java", + "fq": "FIL", + "tk": "com.maif.sonar:maif-cobol-plugin:src/main/java/com/maif/sonar/cobol/metrics/TableMetricsVisitor.java", + "tn": "src/main/java/com/maif/sonar/cobol/metrics/TableMetricsVisitor.java", + "tq": "FIL" + } +] diff --git a/server/sonar-web/src/main/js/tests/e2e/tests/design-spec/resources.json b/server/sonar-web/src/main/js/tests/e2e/tests/design-spec/resources.json new file mode 100644 index 00000000000..3d06975ac57 --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/tests/design-spec/resources.json @@ -0,0 +1,20 @@ +[ + { + "id": 6924, + "key": "com.maif.sonar:maif-cobol-plugin", + "name": "MAIF :: Cobol plugin", + "scope": "PRJ", + "qualifier": "TRK", + "date": "2014-07-21T23:04:05+0600", + "creationDate": null, + "lname": "MAIF :: Cobol plugin", + "version": "2.7-SNAPSHOT", + "description": "", + "msr": [ + { + "key": "dsm", + "data": "[{\"i\":24815,\"n\":\"src/test/java/com/maif/sonar/cobol/metrics\",\"q\":\"DIR\",\"v\":[{},{},{},{\"i\":14879223,\"w\":6},{},{}]},{\"i\":26762,\"n\":\"src/main/java/com/maif/sonar/cobol/plugin\",\"q\":\"DIR\",\"v\":[{},{},{},{},{},{}]},{\"i\":26758,\"n\":\"src/main/java/com/maif/sonar/cobol\",\"q\":\"DIR\",\"v\":[{\"i\":14879242,\"w\":1},{\"i\":14879258,\"w\":114},{},{},{},{}]},{\"i\":33690,\"n\":\"src/test/java/com/maif/sonar/cobol/api\",\"q\":\"DIR\",\"v\":[{\"i\":14879244,\"w\":6},{\"i\":14879373,\"w\":2},{\"i\":14879221,\"w\":1},{},{},{}]},{\"i\":24814,\"n\":\"src/test/java/com/maif/sonar/cobol/ids2\",\"q\":\"DIR\",\"v\":[{\"i\":14879237,\"w\":2},{},{\"i\":14879139,\"w\":24},{},{},{}]},{\"i\":24816,\"n\":\"src/test/java/com/maif/sonar/cobol/repository\",\"q\":\"DIR\",\"v\":[{\"i\":14879240,\"w\":1},{\"i\":14879251,\"w\":6},{\"i\":14879164,\"w\":56},{\"i\":14879230,\"w\":1},{\"i\":14879232,\"w\":4},{}]}]" + } + ] + } +] diff --git a/server/sonar-web/src/main/js/tests/e2e/views/design.jade b/server/sonar-web/src/main/js/tests/e2e/views/design.jade new file mode 100644 index 00000000000..ffc40a94aa8 --- /dev/null +++ b/server/sonar-web/src/main/js/tests/e2e/views/design.jade @@ -0,0 +1,11 @@ +extends ./layouts/main + +block header + script(data-main='/js/design/app', src='../js/require.js') + +block body + #container + #project-design: i.spinner + + script. + window.resourceKey = 'com.maif.sonar:maif-cobol-plugin'; -- 2.39.5