Browse Source

No more javascriptExecutionTree bu default (option)

Gaël Métais 10 years ago
parent
commit
42c27af604
2 changed files with 18 additions and 3 deletions
  1. 13 2
      lib/server/controllers/apiController.js
  2. 5 1
      test/api/apiTest.js

+ 13 - 2
lib/server/controllers/apiController.js

@@ -32,7 +32,8 @@ var ApiController = function(app) {
                 url: req.body.url,
                 url: req.body.url,
                 waitForResponse: req.body.waitForResponse !== false && req.body.waitForResponse !== 'false' && req.body.waitForResponse !== 0,
                 waitForResponse: req.body.waitForResponse !== false && req.body.waitForResponse !== 'false' && req.body.waitForResponse !== 0,
                 partialResult: req.body.partialResult || null,
                 partialResult: req.body.partialResult || null,
-                screenshot: req.body.screenshot || false
+                screenshot: req.body.screenshot || false,
+                jsTimeline: req.body.jsTimeline || false
             }
             }
         };
         };
 
 
@@ -64,7 +65,8 @@ var ApiController = function(app) {
             debug('Launching test %s on %s', run.runId, run.params.url);
             debug('Launching test %s on %s', run.runId, run.params.url);
 
 
             var runOptions = {
             var runOptions = {
-                screenshot: run.params.screenshot ? screenshot.getTmpFilePath() : false
+                screenshot: run.params.screenshot ? screenshot.getTmpFilePath() : false,
+                jsDeepAnalysis: run.params.jsTimeline
             };
             };
 
 
             return ylt(run.params.url, runOptions);
             return ylt(run.params.url, runOptions);
@@ -107,7 +109,16 @@ var ApiController = function(app) {
 
 
                 // Save results
                 // Save results
                 .then(function() {
                 .then(function() {
+                    // Remove uneeded temp screenshot path
                     delete data.params.options.screenshot;
                     delete data.params.options.screenshot;
+
+                    // Empty javascriptExecutionTree if not needed
+                    if (!run.params.jsTimeline) {
+                        data.javascriptExecutionTree = {};
+                    }
+
+                    // Remove tools results if not needed
+
                     return resultsDatastore.saveResult(data);
                     return resultsDatastore.saveResult(data);
                 })
                 })
 
 

+ 5 - 1
test/api/apiTest.js

@@ -159,7 +159,10 @@ describe('api', function() {
                 body.should.have.a.property('scoreProfiles').that.is.an('object');
                 body.should.have.a.property('scoreProfiles').that.is.an('object');
                 body.should.have.a.property('rules').that.is.an('object');
                 body.should.have.a.property('rules').that.is.an('object');
                 body.should.have.a.property('toolsResults').that.is.an('object');
                 body.should.have.a.property('toolsResults').that.is.an('object');
+
+                // javascriptExecutionTree should only be filled if option jsTimeline is true
                 body.should.have.a.property('javascriptExecutionTree').that.is.an('object');
                 body.should.have.a.property('javascriptExecutionTree').that.is.an('object');
+                body.javascriptExecutionTree.should.deep.equal({});
 
 
                 // Check if the screenshot temporary file was correctly removed
                 // Check if the screenshot temporary file was correctly removed
                 body.params.options.should.not.have.a.property('screenshot');
                 body.params.options.should.not.have.a.property('screenshot');
@@ -188,7 +191,8 @@ describe('api', function() {
             url: serverUrl + '/api/runs',
             url: serverUrl + '/api/runs',
             body: {
             body: {
                 url: wwwUrl + '/simple-page.html',
                 url: wwwUrl + '/simple-page.html',
-                waitForResponse: false
+                waitForResponse: false,
+                jsTimeline: true
             },
             },
             json: true,
             json: true,
             headers: {
             headers: {