diff --git a/Gruntfile.js b/Gruntfile.js index 6a4c18ca..f3670f3c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -251,7 +251,7 @@ module.exports = function (grunt) { name: 'main', generateSourceMaps: true, preserveLicenseComments: false, - optimize: 'uglify2', + optimize: 'none', paths: { 'proactive/config': 'empty:' } diff --git a/test/json-server-data/mock-scheduler-rest.js b/test/json-server-data/mock-scheduler-rest.js index fcc056f7..e9cafdb4 100644 --- a/test/json-server-data/mock-scheduler-rest.js +++ b/test/json-server-data/mock-scheduler-rest.js @@ -1,90 +1,97 @@ -// server.js -var PORT = 9000; -var jsonServer = require('json-server'); -var express = require('express'); -var parseFormdata = require('parse-formdata') +const PORT = 9000; +const jsonServer = require('json-server'); +const express = require('express'); +const parseFormdata = require('parse-formdata'); + +const server = jsonServer.create(); +const middlewares = jsonServer.defaults(); + +// Define routers for different resources +const bucket1000ResRouter = jsonServer.router('test/json-server-data/buckets-resources/bucket-id-1000-res.json'); +const bucket1001ResRouter = jsonServer.router('test/json-server-data/buckets-resources/bucket-id-1001-res.json'); +const bucket1002ResRouter = jsonServer.router('test/json-server-data/buckets-resources/bucket-id-1002-res.json'); +const object1RevRouter = jsonServer.router('test/json-server-data/objects-revisions/2min-cron-rev.json'); +const object2RevRouter = jsonServer.router('test/json-server-data/objects-revisions/cloud-automation-rev.json'); +const object3RevRouter = jsonServer.router('test/json-server-data/objects-revisions/data-mgnt-rev.json'); +const object4RevRouter = jsonServer.router('test/json-server-data/objects-revisions/distrib-comput-rev.json'); +const object5RevRouter = jsonServer.router('test/json-server-data/objects-revisions/docker-exec-env-rev.json'); +const object6RevRouter = jsonServer.router('test/json-server-data/objects-revisions/file-trigger-rev.json'); +const object7RevRouter = jsonServer.router('test/json-server-data/objects-revisions/proactive-rev.json'); +const object8RevRouter = jsonServer.router('test/json-server-data/objects-revisions/proactive-delete-rev.json'); +const bucketsRouter = jsonServer.router('test/json-server-data/buckets-list.json'); +const templatesRouter = jsonServer.router('test/json-server-data/templates.json'); -var server = jsonServer.create(); -var bucket1000ResRouter = jsonServer.router('test/json-server-data/buckets-resources/bucket-id-1000-res.json'); -var bucket1001ResRouter = jsonServer.router('test/json-server-data/buckets-resources/bucket-id-1001-res.json'); -var bucket1002ResRouter = jsonServer.router('test/json-server-data/buckets-resources/bucket-id-1002-res.json'); -var object1RevRouter = jsonServer.router('test/json-server-data/objects-revisions/2min-cron-rev.json'); -var object2RevRouter = jsonServer.router('test/json-server-data/objects-revisions/cloud-automation-rev.json'); -var object3RevRouter = jsonServer.router('test/json-server-data/objects-revisions/data-mgnt-rev.json'); -var object4RevRouter = jsonServer.router('test/json-server-data/objects-revisions/distrib-comput-rev.json'); -var object5RevRouter = jsonServer.router('test/json-server-data/objects-revisions/docker-exec-env-rev.json'); -var object6RevRouter = jsonServer.router('test/json-server-data/objects-revisions/file-trigger-rev.json'); -var object7RevRouter = jsonServer.router('test/json-server-data/objects-revisions/proactive-rev.json'); -var object8RevRouter = jsonServer.router('test/json-server-data/objects-revisions/proactive-delete-rev.json'); -var bucketsRouter = jsonServer.router('test/json-server-data/buckets-list.json'); -var templatesRouter = jsonServer.router('test/json-server-data/templates.json'); -var middlewares = jsonServer.defaults(); server.use(middlewares); server.post('/rest/studio/login', function (req, res, next) { console.log('LOGIN'); parseFormdata(req, function (err, data) { - console.log("Received body data:"); - console.log('received:'); - console.log(JSON.stringify(data)); - if (err) throw err + if (err) { + console.error('Error parsing form data:', err); + if (!res.headersSent) { + res.status(500).end(); + } + return; + } - if (err) throw err - console.log('fields:', data.fields) - data.parts.forEach(function (part) { - console.log('part:', part.fieldname) - }) - // We assume the request is well formed - var username = data.fields.username; - var password = data.fields.password; + const { username, password } = data.fields; - console.log("username : "+ username); - console.log("password : "+ password); + console.log("Received username:", username); + console.log("Received password:", password); - // check the user/pass - var statusCode = 404; if (username === 'user' && password === 'pwd') { - console.log('login successful'); - statusCode = 200; + console.log('Login successful'); + if (!res.headersSent) { + res.setHeader('content-type', 'application/json'); + res.status(200).json({ sessionId: 'MOCKED_SESSION_ID' }); + } + } else { + console.log('Invalid credentials'); + if (!res.headersSent) { + res.status(401).end(); + } } - res.status(statusCode); - res.setHeader('content-type', 'application/json'); - res.write('MOCKED_SESSION_ID'); - res.end(); }); }); server.put('/rest/studio/logout', function (req, res, next) { console.log('LOGOUT'); - res.status(204); - res.setHeader('content-type', 'application/json'); - res.end(); + if (!res.headersSent) { + res.setHeader('content-type', 'application/json'); + res.status(204).end(); + } }); server.get('/rest/studio/connected', function (req, res, next) { console.log('CHECK FOR AUTH'); - res.status(200); - res.write('true'); - res.end(); + if (!res.headersSent) { + res.setHeader('content-type', 'application/json'); + res.status(200).write('true'); + res.end(); + } }); -server.get('/rest/common/permissions/portals/studio', function (reqq, ress, nextt) { +server.get('/rest/common/permissions/portals/studio', function (req, res, next) { console.log('CHECK FOR PERMISSION'); - ress.status(200); - ress.setHeader('content-type', 'application/json'); - ress.write('true'); - ress.end(); + if (!res.headersSent) { + res.setHeader('content-type', 'application/json'); + res.status(200).write('true'); + res.end(); + } }); server.post('/rest/studio/validate', function (req, res, next) { console.log('VALIDATE'); - res.status(200); - res.write('{"valid":true,"taskName":null,"errorMessage":null,"stackTrace":null}'); - res.end(); + if (!res.headersSent) { + res.setHeader('content-type', 'application/json'); + res.status(200).write('{"valid":true,"taskName":null,"errorMessage":null,"stackTrace":null}'); + res.end(); + } }); server.use(express.static('public')); +// Define the routes for different resources server.use('/catalog/buckets/1000/resources/2%20Minutes%20Cron', object1RevRouter); server.use('/catalog/buckets/1000/resources/Cloud%20Automation', object2RevRouter); server.use('/catalog/buckets/1000/resources/Data%20Management', object3RevRouter); @@ -93,7 +100,6 @@ server.use('/catalog/buckets/1000/resources/Docker%20Exec.%20Env.', object5RevRo server.use('/catalog/buckets/1000/resources/File%20Trigger', object6RevRouter); server.use('/catalog/buckets/1001/resources/ProActive', object7RevRouter); server.use('/catalog/buckets/1001/resources/ProActive%20delete', object8RevRouter); - server.use('/catalog/buckets/1000', bucket1000ResRouter); server.use('/catalog/buckets/1001', bucket1001ResRouter); server.use('/catalog/buckets/1002', bucket1002ResRouter); @@ -107,4 +113,3 @@ server.listen(PORT, function () { console.log(' user: user'); console.log(' password: pwd'); }); - diff --git a/test/ui/specs/form.js b/test/ui/specs/form.js index b2eee684..b7bea593 100644 --- a/test/ui/specs/form.js +++ b/test/ui/specs/form.js @@ -5,7 +5,7 @@ module.exports = { "Detailed form by default": function (browser) { browser .login() - .closeNotification() + //.closeNotification() .clickCloseWorkflow() .removeAllWorkflows() .createNewWorkflow() @@ -24,7 +24,7 @@ module.exports = { "Switch from job to simple view and back": function (browser) { browser .login() - .closeNotification() + //.closeNotification() .clickCloseWorkflow() .removeAllWorkflows() .createNewWorkflow() @@ -48,7 +48,7 @@ module.exports = { "Switch from task to detailed view and back": function (browser) { browser .login() - .closeNotification() + //.closeNotification() .clickCloseWorkflow() .removeAllWorkflows() .createNewWorkflow() @@ -77,7 +77,7 @@ module.exports = { browser .login() - .closeNotification() + //.closeNotification() .clickCloseWorkflow() .removeAllWorkflows() .createNewWorkflow()