From 5ee47ff3c646f628b355c76bbe0cf9e1f4388301 Mon Sep 17 00:00:00 2001 From: vamsee Date: Wed, 11 Sep 2019 16:21:01 +0530 Subject: [PATCH 1/7] Using NPM_REGISTRY and CI_JOB_ID --- .gitlab-ci.yml | 8 +++----- package.json | 6 +++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index de9de29..5ca6c11 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,7 +35,6 @@ npminstall: - if [ $status_vulnerabilities == 1 ]; then echo "Dependency vulnerabilities exist"; fi - if [ $exit_status == 1 ]; then exit $exit_status; fi artifacts: - untracked: true expire_in: 2h paths: - node_modules/ @@ -50,11 +49,10 @@ mongotest: - export NODE_ENV=mongo - export MONGO_HOST="10.73.53.144" - export DB=mongo - - export DB_NAME=${CI_PIPELINE_ID}_mongo + - export DB_NAME=${CI_JOB_ID}_mongo - time npm install --no-optional - npm run grunt-cover artifacts: - untracked: true expire_in: 2h paths: - coverage/ @@ -69,7 +67,7 @@ postgrestest: - export NODE_ENV=postgres - export DB=postgres - export POSTGRES_HOST="10.73.53.144" - - export DB_NAME=${CI_PIPELINE_ID}_pg + - export DB_NAME=${CI_JOB_ID}_pg - export ENABLE_DS_AUTOUPDATE=true - time npm install --no-optional - npm run grunt-cover @@ -88,7 +86,7 @@ oracletest: - export ORACLE_SYSUSER=oeadmin - export ORACLE_SYSPASSWORD=oeadmin - export ORACLE_SID=ORCLCDB - - export DB_NAME=${CI_PIPELINE_ID}_pg + - export DB_NAME=${CI_JOB_ID}_pg - time npm install git+http://evgit/atul/oe-connector-oracle.git --no-optional - time npm install --no-optional - mv /oracledb node_modules/ diff --git a/package.json b/package.json index 7ca5bd8..8cd89f4 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "async": "2.6.1", "glob": "7.1.3", "lodash": "4.17.14", - "oe-logger": "git+http://evgit/oecloud.io/oe-logger.git#2.1.0" + "oe-logger": "git+http://evgit/oecloud.io/oe-logger.git#master" }, "devDependencies": { "babel-eslint": "7.2.3", @@ -35,8 +35,8 @@ "istanbul": "0.4.5", "loopback-connector-mongodb": "3.9.2", "mocha": "5.2.0", - "oe-cloud": "git+http://evgit/oecloud.io/oe-cloud.git#2.1.0", - "oe-connector-postgresql": "git+http://evgit/oecloud.io/oe-connector-postgresql.git#2.0.0", + "oe-cloud": "git+http://evgit/oecloud.io/oe-cloud.git#master", + "oe-connector-postgresql": "git+http://evgit/oecloud.io/oe-connector-postgresql.git#master", "superagent-defaults": "0.1.14", "supertest": "3.4.2" }, From 6b84f4796f9615ac25d6bba224cf0e9e5feb2b50 Mon Sep 17 00:00:00 2001 From: vamsee Date: Wed, 11 Sep 2019 17:01:46 +0530 Subject: [PATCH 2/7] fixed eslint error --- common/models/ui-component.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/models/ui-component.js b/common/models/ui-component.js index 0fd72ba..7a7ddc4 100644 --- a/common/models/ui-component.js +++ b/common/models/ui-component.js @@ -385,7 +385,7 @@ module.exports = function uiComponent(UIComponent) { field.subModelMeta = allmodels[field.modeltype].properties; } } else if (field.itemtype === 'object') { - field.type = 'grid' + field.type = 'grid'; } else { field.type = 'tags'; } From cba720900a6bd62674b9cee433347dd35aea5915 Mon Sep 17 00:00:00 2001 From: vamsee Date: Mon, 23 Sep 2019 11:20:29 +0530 Subject: [PATCH 3/7] Using node 10.16.0 in CI --- .gitlab-ci.yml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5ca6c11..828f436 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,15 +4,19 @@ stages: - build - cleanup -image: $REGISTRY/debian-node-oracle-docker variables: + DOMAIN_NAME: oecloud.local + PERF_DOMAIN_NAME: oecloud.perf REGISTRY: registry.${DOMAIN_NAME} + EXECUTOR_IMAGE: oecloud-executor:10.x + EXECUTOR_IMAGE_ORACLE: debian-node-oracle-docker:10.x + +image: ${REGISTRY}/${EXECUTOR_IMAGE} before_script: - export project=${CI_PROJECT_NAME//[^[:alnum:]]/} - export group=${CI_PROJECT_NAMESPACE//[^[:alnum:]]/} - export branch=${CI_BUILD_REF_NAME//[^[:alnum:]]/} - - export pipelineId=${CI_PIPELINE_ID//[^[:alnum:]]/} npminstall: stage: pre-build @@ -77,6 +81,7 @@ postgrestest: - CEP_RUNNER oracletest: + image: ${REGISTRY}/${EXECUTOR_IMAGE_ORACLE} stage: pre-build-test script: - echo 'Performing Oracle Test' From 36eed570b66995bdfcd824b4d92221ec06afc7fa Mon Sep 17 00:00:00 2001 From: vamsee Date: Fri, 8 Nov 2019 11:04:24 +0530 Subject: [PATCH 4/7] Using node 12.13.0 in CI --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 828f436..dfbb0c5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -8,8 +8,8 @@ variables: DOMAIN_NAME: oecloud.local PERF_DOMAIN_NAME: oecloud.perf REGISTRY: registry.${DOMAIN_NAME} - EXECUTOR_IMAGE: oecloud-executor:10.x - EXECUTOR_IMAGE_ORACLE: debian-node-oracle-docker:10.x + EXECUTOR_IMAGE: oecloud-executor:12.x + EXECUTOR_IMAGE_ORACLE: debian-node-oracle-docker:12.x image: ${REGISTRY}/${EXECUTOR_IMAGE} From 0e8c1c124ba936b543148236d57cf1b1c865974d Mon Sep 17 00:00:00 2001 From: vamsee Date: Fri, 8 Nov 2019 11:45:42 +0530 Subject: [PATCH 5/7] Removing user and password from mongo db config --- test/datasources.mongo.js | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/test/datasources.mongo.js b/test/datasources.mongo.js index 3bf5470..8b23b41 100644 --- a/test/datasources.mongo.js +++ b/test/datasources.mongo.js @@ -17,15 +17,13 @@ module.exports = "connector": "transient" }, "db": { - "host": mongoHost, - "port": 27017, - "url": "mongodb://" + mongoHost + ":27017/" + dbName, - "database": dbName, - "password": "admin", - "name": "db", - "connector": "mongodb", - "user": "admin", - "connectionTimeout": 500000 + 'host': mongoHost, + 'port': 27017, + 'url': 'mongodb://' + mongoHost + ':27017/' + dbName, + 'database': dbName, + 'name': 'db', + 'connector': 'mongodb', + 'connectionTimeout': 500000 } }; From 94ee6dcaa6eeacf11b07358e0f1b5e261054d529 Mon Sep 17 00:00:00 2001 From: vamsee Date: Fri, 10 Jan 2020 16:51:20 +0530 Subject: [PATCH 6/7] removed unneeded packages and updated ci --- .eslintignore | 13 ++- .eslintrc | 2 +- .gitignore | 1 + .gitlab-ci.yml | 144 ++++++++++++++++------- Gruntfile.js | 38 +----- package.json | 7 +- test/boot/populate-data.js | 2 +- test/datasources.json | 3 +- test/datasources.mongo.js | 24 ++-- test/datasources.oracle.js | 12 +- test/datasources.postgres.js | 40 +++---- test/oracle-utility.js | 176 +++++++++++++++------------- test/scripts/gridconfig-test.js | 116 +++++++++---------- test/scripts/literal-test.js | 92 +++++++-------- test/scripts/ui-component-test.js | 184 +++++++++++++++--------------- test/scripts/ui-manager-test.js | 27 +++-- test/scripts/ui-resource-test.js | 32 +++--- test/scripts/ui-route-test.js | 27 +++-- test/scripts/ui-utils-test.js | 76 ++++++------ test/server.js | 4 +- test/test.js | 111 +++++++++--------- 21 files changed, 572 insertions(+), 559 deletions(-) diff --git a/.eslintignore b/.eslintignore index 398a1eb..9c8d714 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,6 +1,7 @@ -/client/ -/coverage/ -/node_modules/ -server/dropdb.js -/lib/expression-language/expression-syntax-parser.js -/test/ +build/ +client/ +coverage/ +node_modules/ +test/ +drop.js +Gruntfile.js diff --git a/.eslintrc b/.eslintrc index 8f2f7cc..6edc78f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -111,7 +111,7 @@ "no-undefined": 1, // http://eslint.org/docs/rules/no-undefined "no-with": 2, // http://eslint.org/docs/rules/no-with "handle-callback-err": 1, // http://eslint.org/docs/rules/handle-callback-err - "radix": 2, // http://eslint.org/docs/rules/radix + "radix": 0, // http://eslint.org/docs/rules/radix "wrap-iife": [2, "any"], // http://eslint.org/docs/rules/wrap-iife "yoda": 2, // http://eslint.org/docs/rules/yoda diff --git a/.gitignore b/.gitignore index 908522f..4631a8a 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ out/ *.zip /common/models/test package-lock.json +oracle-user.sh diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dfbb0c5..524e715 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,8 +1,8 @@ stages: - pre-build - pre-build-test - - build - - cleanup + - push-artifacts + - performance variables: DOMAIN_NAME: oecloud.local @@ -17,24 +17,31 @@ before_script: - export project=${CI_PROJECT_NAME//[^[:alnum:]]/} - export group=${CI_PROJECT_NAMESPACE//[^[:alnum:]]/} - export branch=${CI_BUILD_REF_NAME//[^[:alnum:]]/} + - if [ ${group} == "oecloudio" ]; then export APP_IMAGE_NAME=$project; else export APP_IMAGE_NAME=$group"-"$project; fi + - export APP_IMAGE_NAME=$(echo $APP_IMAGE_NAME | tr '[:upper:]' '[:lower:]') + - if [ ${branch} == "master" ]; then export APP_TAG=latest; else export APP_TAG=${branch}; fi + - export APP_TAG=$(echo $APP_TAG | tr '[:upper:]' '[:lower:]') + + - npm config set unsafe-perm true + - npm config set progress false + - npm config set registry ${NPM_REGISTRY} + # - npm config set registry https://registry.npmjs.org/ npminstall: stage: pre-build script: - echo "Performing code style check..." - - status_eslint=0 - - exit_status=0 - - npm config set registry http://registry.npmjs.org/ - - npm set progress=false + - export status_eslint=0 + - export exit_status=0 - time npm install eslint babel-eslint --no-optional - if npm run lint; then status_eslint=0; else status_eslint=1; fi - - if [ $status_eslint == 1 ]; then exit_status=1 && echo "esLint errors exist"; fi + - if [ $status_eslint == 1 ]; then export exit_status=1 && echo "esLint errors exist"; fi - if [ $exit_status == 1 ]; then exit $exit_status; fi - echo "Code style check done successfully" - time npm install --no-optional - echo "Node Modules Installed" - - mkdir -p ./artifacts/${CI_PROJECT_NAME}/ - - npm audit --json > ./artifacts/${CI_PROJECT_NAME}/vulnerabilities.json || true + - npm config rm registry + - npm audit --json > vulnerabilities.json || true - if npm audit; then status_vulnerabilities=0; else status_vulnerabilities=1; fi - if [ $status_vulnerabilities == 1 ]; then echo "Dependency vulnerabilities exist"; fi - if [ $exit_status == 1 ]; then exit $exit_status; fi @@ -42,80 +49,129 @@ npminstall: expire_in: 2h paths: - node_modules/ + - vulnerabilities.json tags: - CEP_RUNNER - mongotest: + coverage: /Statements.*?(\d+(?:\.\d+)?)%/ stage: pre-build-test + variables: + NODE_ENV: mongo + DB: mongo + MONGO_HOST: 10.73.53.144 + MONGO_PORT: '27017' + DB_NAME: ${CI_JOB_ID}_mongo script: - echo 'Performing MongoDB Test' - - export NODE_ENV=mongo - - export MONGO_HOST="10.73.53.144" - - export DB=mongo - - export DB_NAME=${CI_JOB_ID}_mongo - time npm install --no-optional - npm run grunt-cover artifacts: expire_in: 2h paths: - coverage/ - when: on_failure tags: - CEP_RUNNER postgrestest: + coverage: /Statements.*?(\d+(?:\.\d+)?)%/ stage: pre-build-test + variables: + NODE_ENV: postgres + DB: postgres + POSTGRES_HOST: 10.73.53.144 + POSTGRES_PORT: '5432' + DB_NAME: ${CI_JOB_ID}_pg + ENABLE_DS_AUTOUPDATE: 'true' script: - echo 'Performing PostgreSQL Test' - - export NODE_ENV=postgres - - export DB=postgres - - export POSTGRES_HOST="10.73.53.144" - - export DB_NAME=${CI_JOB_ID}_pg - - export ENABLE_DS_AUTOUPDATE=true - time npm install --no-optional - npm run grunt-cover - tags: - - CEP_RUNNER tags: - CEP_RUNNER oracletest: + coverage: /Statements.*?(\d+(?:\.\d+)?)%/ image: ${REGISTRY}/${EXECUTOR_IMAGE_ORACLE} stage: pre-build-test + variables: + NODE_ENV: oracle + DB: oracle + ORACLE_HOST: 10.73.53.144 + ORACLE_PORT: '1521' + ORACLE_SYSUSER: oeadmin + ORACLE_SYSPASSWORD: oeadmin + ORACLE_SID: ORCLCDB + ENABLE_DS_AUTOUPDATE: 'true' script: - echo 'Performing Oracle Test' - - export APP_TAG=oracle - - export NODE_ENV=oracle - - export ORACLE_HOST=10.73.53.144 - - export ORACLE_SYSUSER=oeadmin - - export ORACLE_SYSPASSWORD=oeadmin - - export ORACLE_SID=ORCLCDB - - export DB_NAME=${CI_JOB_ID}_pg - - time npm install git+http://evgit/atul/oe-connector-oracle.git --no-optional + # - export DB_NAME=${CI_JOB_ID}_pg + # - time npm install git+http://evgit/oecloud.io/oe-connector-oracle.git#master --no-optional - time npm install --no-optional - mv /oracledb node_modules/ - - export CI_PROJECT_NAMESPACE=${group} - node test/oracle-utility.js - - export ORACLE_USERNAME=${CI_PROJECT_NAMESPACE}"-"${CI_PROJECT_NAME} - - export ORACLE_USERNAME=$(echo $ORACLE_USERNAME | tr '[:lower:]' '[:upper:]') - - export ORACLE_PASSWORD=$(echo $CI_PROJECT_NAMESPACE | tr '[:upper:]' '[:lower:]') + # - export ORACLE_USERNAME=${group}"_"${project} + # - export ORACLE_USERNAME=$(echo $ORACLE_USERNAME | tr '[:lower:]' '[:upper:]') + # - export ORACLE_PASSWORD=$(echo $group | tr '[:upper:]' '[:lower:]') + - . ./oracle-user.sh + - env | grep -i oracle - echo "Oracle user details:"${ORACLE_USERNAME}"/"${ORACLE_PASSWORD} - npm run grunt-cover - tags: - - CEP_RUNNER - -buildjob: - stage: build - script: - - echo "Building Image" tags: - CEP_RUNNER -lastcleanup: - stage: cleanup +pushartifacts: + stage: push-artifacts script: - - echo "Finishing CI CD" + - echo "Copying all artifacts" + - mkdir -p ./artifacts/${CI_PROJECT_NAME}/${CI_BUILD_REF_NAME}/ + - cp vulnerabilities.json ./artifacts/${CI_PROJECT_NAME}/${CI_BUILD_REF_NAME}/ + - cp -r coverage/ ./artifacts/${CI_PROJECT_NAME}/${CI_BUILD_REF_NAME}/ + - git clone http://10.73.97.24/oecloud.io/build-tools.git + - sh ./build-tools/push_artifacts.sh tags: - CEP_RUNNER + only: + - /^.*/@oecloud.io/oe-metadata-ui +.performancejob: + image: $REGISTRY/jmeter:docker + stage: performance + variables: + NODE_ENV: "mongo" + MONGO_HOST: "10.73.97.17" + MONGO_PORT: "27017" + DB_NAME: "${CI_JOB_ID}_mongo" + APP_PROTOCOL: "https" + APP_PORT: "443" + PERF_USERS: "1" + PERF_LOOPCOUNT: "50000" + script: + - export STACK_NAME=${APP_IMAGE_NAME}-${APP_TAG} + - export APP_URL=${APP_IMAGE_NAME}-${APP_TAG}.${PERF_DOMAIN_NAME} + - if [ ${branch} == "master" ]; then export STACK_NAME=${APP_IMAGE_NAME}; export APP_URL=${APP_IMAGE_NAME}.${PERF_DOMAIN_NAME}; fi + - if docker stack rm ${STACK_NAME}; then echo "stack removed"; else echo "nothing found in stack"; fi + - time npm install --no-optional + - git clone http://10.73.97.24/oecloud.io/build-tools.git + - sed 's/\$REGISTRY/'"$REGISTRY"'/g' ./build-tools/performance/Dockerfile > Dockerfile + - echo "Building ${APP_IMAGE_NAME}:${APP_TAG} image and pushing to registry..." + - time docker image build -t ${REGISTRY}/${APP_IMAGE_NAME}:${APP_TAG} --no-cache --pull . + - time docker image push ${REGISTRY}/${APP_IMAGE_NAME}:${APP_TAG} + - echo "Image (${REGISTRY}/${APP_IMAGE_NAME}:${APP_TAG}) built and pushed to registry" + - docker stack deploy --compose-file ./build-tools/performance/docker-compose.yml ${STACK_NAME} + - export HTTP_RESPONSE_CODE=200 + - export countElapsed=0 + - export app_exit_status=0 + - export no_proxy=$no_proxy,${APP_URL} + - export NO_PROXY=$no_proxy + - echo "${DOCKER_ROUTER_HOST} ${APP_URL}" >> /etc/hosts + - export isStarted=$(curl -k --write-out %{http_code} --output curl.out --silent https://${APP_URL}/api/ModelDefinitions) + - while [ ${isStarted} -ne ${HTTP_RESPONSE_CODE} ]; do let countElapsed=countElapsed+1; echo ""; sleep 10; export isStarted=$(curl -k --write-out %{http_code} --output curl.out --silent https://${APP_URL}/api/ModelDefinitions); echo -n "Waiting till the URL is up..."; echo ${isStarted}; if [ $countElapsed -eq 18 ] ; then export app_exit_status=1; export isStarted=${HTTP_RESPONSE_CODE}; fi; done + - if [ $app_exit_status -eq 1 ]; then echo "App failed to start....."; docker stack ps ${STACK_NAME}; docker service logs ${STACK_NAME}_web; docker stack rm ${STACK_NAME}; exit $app_exit_status; else echo "Your application URL is accessible @ https://${APP_URL}/"; fi + - mkdir -p ./artifacts/${CI_PROJECT_NAME}/${CI_BUILD_REF_NAME}/performance + - sh ./build-tools/performance/performance.sh + - sh ./build-tools/push_artifacts.sh + - if docker stack rm ${STACK_NAME}; then echo "stack removed"; else echo "nothing found in stack"; fi + when: manual + tags: + - PERF_RUNNER diff --git a/Gruntfile.js b/Gruntfile.js index 6d0917b..1eee861 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -10,38 +10,6 @@ module.exports = function GruntConfig(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json'), - mkdir: { - all: { - options: { - create: ['dist'] - } - } - }, - - copy: { - main: { - files: [ - // includes files within path and its sub-directories - { - expand: true, - src: ['**', '!node_modules/**', '!coverage/**'], - dest: 'dist/' - } - ] - } - }, - - mochaTest: { - test: { - options: { - quiet: false, - clearRequireCache: true, - timeout: 100000 - }, - src: ['test/test.js', 'test/scripts/*.js'] - } - }, - clean: { coverage: { src: ['coverage/'] @@ -72,12 +40,8 @@ module.exports = function GruntConfig(grunt) { }); // Add the grunt-mocha-test tasks. - grunt.loadNpmTasks('grunt-mocha-test'); - grunt.loadNpmTasks('grunt-mocha-istanbul'); grunt.loadNpmTasks('grunt-contrib-clean'); - - grunt.loadNpmTasks('grunt-mkdir'); - grunt.loadNpmTasks('grunt-contrib-copy'); + grunt.loadNpmTasks('grunt-mocha-istanbul'); grunt.registerTask('test-with-coverage', ['clean:coverage', 'mocha_istanbul']); }; diff --git a/package.json b/package.json index 8cd89f4..220d5dd 100644 --- a/package.json +++ b/package.json @@ -22,20 +22,17 @@ "devDependencies": { "babel-eslint": "7.2.3", "chai": "3.4.1", - "chai-datetime": "1.4.0", "chai-things": "0.2.0", "chalk": "1.1.1", "eslint": "4.10.0", "grunt": "1.0.4", "grunt-contrib-clean": "2.0.0", - "grunt-contrib-copy": "1.0.0", - "grunt-mkdir": "1.0.0", "grunt-mocha-istanbul": "5.0.2", - "grunt-mocha-test": "0.13.3", "istanbul": "0.4.5", - "loopback-connector-mongodb": "3.9.2", "mocha": "5.2.0", "oe-cloud": "git+http://evgit/oecloud.io/oe-cloud.git#master", + "oe-connector-mongodb": "git+http://evgit/oecloud.io/oe-connector-mongodb.git#master", + "oe-connector-oracle": "git+http://evgit/oecloud.io/oe-connector-oracle.git#master", "oe-connector-postgresql": "git+http://evgit/oecloud.io/oe-connector-postgresql.git#master", "superagent-defaults": "0.1.14", "supertest": "3.4.2" diff --git a/test/boot/populate-data.js b/test/boot/populate-data.js index af45c41..16f5d9d 100644 --- a/test/boot/populate-data.js +++ b/test/boot/populate-data.js @@ -35,5 +35,5 @@ module.exports = function (app, done) { // }); // }); // }); -} +}; diff --git a/test/datasources.json b/test/datasources.json index f0fcf7d..3aa2d66 100644 --- a/test/datasources.json +++ b/test/datasources.json @@ -7,7 +7,6 @@ "name": "transient", "connector": "transient" }, - "db": { "host": "localhost", "port": 27017, @@ -15,7 +14,7 @@ "database": "oe-metadata-ui", "password": "admin", "name": "db", - "connector": "mongodb", + "connector": "oe-connector-mongodb", "user": "admin", "connectionTimeout": 500000, "connectTimeoutMS": 500000, diff --git a/test/datasources.mongo.js b/test/datasources.mongo.js index 8b23b41..05a1e25 100644 --- a/test/datasources.mongo.js +++ b/test/datasources.mongo.js @@ -5,24 +5,24 @@ * */ var mongoHost = process.env.MONGO_HOST || 'localhost'; +var mongoPort = process.env.MONGO_PORT ? parseInt(process.env.MONGO_PORT) : 27017; var dbName = process.env.DB_NAME || 'oe-metadata-ui-test'; -module.exports = -{ - "memdb": { - "name": "memdb", - "connector": "memory" +module.exports = { + 'memdb': { + 'name': 'memdb', + 'connector': 'memory' }, - "transient": { - "name": "transient", - "connector": "transient" + 'transient': { + 'name': 'transient', + 'connector': 'transient' }, - "db": { + 'db': { 'host': mongoHost, - 'port': 27017, - 'url': 'mongodb://' + mongoHost + ':27017/' + dbName, + 'port': mongoPort, + 'url': 'mongodb://' + mongoHost + ':' + mongoPort + '/' + dbName, 'database': dbName, 'name': 'db', - 'connector': 'mongodb', + 'connector': 'oe-connector-mongodb', 'connectionTimeout': 500000 } }; diff --git a/test/datasources.oracle.js b/test/datasources.oracle.js index 8792ffd..b6f012a 100644 --- a/test/datasources.oracle.js +++ b/test/datasources.oracle.js @@ -4,16 +4,10 @@ * Bangalore, India. All Rights Reserved. * */ -/** - ** - ** ©2016-2017 EdgeVerve Systems Limited (a fully owned Infosys subsidiary), - ** Bangalore, India. All Rights Reserved. - ** - **/ -var oracleSID = process.env.ORACLE_SID || 'orclpdb.ad.infosys.com'; +var oracleSID = process.env.ORACLE_SID || 'ORCLCDB'; var oracleHost = process.env.ORACLE_HOST || 'localhost'; -var oraclePort = process.env.ORACLE_PORT || 1521; +var oraclePort = process.env.ORACLE_PORT ? parseInt(process.env.ORACLE_PORT) : 1521; var oracleUserName = process.env.ORACLE_USERNAME || 'oeadmin'; var oracleUserPassword = process.env.ORACLE_PASSWORD || 'oeadmin'; @@ -36,5 +30,3 @@ module.exports = { 'user': oracleUserName } }; - - diff --git a/test/datasources.postgres.js b/test/datasources.postgres.js index 7f9b683..fa467d2 100644 --- a/test/datasources.postgres.js +++ b/test/datasources.postgres.js @@ -5,29 +5,27 @@ * */ var postgresHost = process.env.POSTGRES_HOST || 'localhost'; +var postgresPort = process.env.POSTGRES_PORT ? parseInt(process.env.POSTGRES_PORT) : 5432; var dbName = process.env.DB_NAME || 'oe-metadata-ui-test'; -module.exports = -{ - "memdb": { - "name": "memdb", - "connector": "memory" +module.exports = { + 'memdb': { + 'name': 'memdb', + 'connector': 'memory' }, - "transient": { - "name": "transient", - "connector": "transient" + 'transient': { + 'name': 'transient', + 'connector': 'transient' }, - - "db": { - "host": postgresHost, - "port": 5432, - "url": "postgres://postgres:postgres@" + postgresHost + ":5432/" + dbName, - "database": dbName, - "password": "postgres", - "name": "db", - "connector": "oe-connector-postgresql", - "user": "postgres", - "max": 50, - "connectionTimeout": 50000 + 'db': { + 'host': postgresHost, + 'port': postgresPort, + 'url': 'postgres://postgres:postgres@' + postgresHost + ':' + postgresPort + '/' + dbName, + 'database': dbName, + 'password': 'postgres', + 'name': 'db', + 'connector': 'oe-connector-postgresql', + 'user': 'postgres', + 'max': 50, + 'connectionTimeout': 50000 } }; - diff --git a/test/oracle-utility.js b/test/oracle-utility.js index 153da7f..40a1734 100644 --- a/test/oracle-utility.js +++ b/test/oracle-utility.js @@ -15,22 +15,29 @@ // ORACLE_SYSUSER // ORACLE_SYSPASSWORD // ORACLE_SID -// CI_PROJECT_NAME // CI_PROJECT_NAMESPACE +// CI_PROJECT_NAME var oracledb = require('oracledb'); var async = require('async'); +var fs = require('fs'); +var os = require('os'); + var oracleHost = process.env.ORACLE_HOST || 'localhost'; -var oraclePort = process.env.ORACLE_PORT || 1521; +var oraclePort = process.env.ORACLE_PORT ? parseInt(process.env.ORACLE_PORT) : 1521; +var oracleSID = process.env.ORACLE_SID || 'ORCLCDB'; var oracleConnectSettings = { 'password': process.env.ORACLE_SYSPASSWORD || 'manager1', 'user': process.env.ORACLE_SYSUSER || 'sys', - 'connectString': oracleHost + ':' + oraclePort + '/' + (process.env.ORACLE_SID || 'orclpdb.ad.infosys.com') + 'connectString': oracleHost + ':' + oraclePort + '/' + oracleSID }; -var userName = process.env.CI_PROJECT_NAMESPACE.toUpperCase() + '-' + (process.env.CI_PROJECT_NAME || 'oecloud').toUpperCase(); -var password = process.env.CI_PROJECT_NAMESPACE.toLowerCase(); +var namespace = process.env.CI_PROJECT_NAMESPACE ? process.env.CI_PROJECT_NAMESPACE.replace(/[^a-zA-Z0-9]/g, '') : 'oecloudio'; +var name = process.env.CI_PROJECT_NAME ? process.env.CI_PROJECT_NAME.replace(/[^a-zA-Z0-9]/g, '') : 'oecloud'; + +var userName = namespace.toUpperCase() + '_' + name.toUpperCase(); +var password = namespace.toLowerCase(); var grants = [ 'CREATE VIEW', @@ -44,30 +51,32 @@ var grants = [ ]; function createUser(connection, cb) { - var sql = 'alter session set "_ORACLE_SCRIPT"=true'; - connection.execute(sql, function (e, r) { - if (e) { - console.error('Ignoring error of alter session. UserName : ' + userName + ' Error :' + e); + var alterSQL = 'alter session set "_ORACLE_SCRIPT"=true'; + connection.execute(alterSQL, function (alterErr, alterRes) { + if (alterErr) { + console.error('Ignoring error of alter session. UserName : ' + userName + ' Error :' + alterErr); } - console.log(sql, ' ......... ok'); - var sql = 'CREATE USER "' + userName + '" IDENTIFIED BY ' + password; + console.log(alterSQL, ' ......... ok'); - connection.execute(sql, function (err, result) { - if (err) { - throw new Error('Unable to create user ' + userName + ' Error :' + err); + var createUserSQL = 'CREATE USER "' + userName + '" IDENTIFIED BY ' + password; + connection.execute(createUserSQL, function (createErr, createRes) { + if (createErr) { + console.error(createErr); + throw new Error('Unable to create user ' + userName); } - console.log(sql, ' ......... ok'); - async.each(grants, function (g, callback) { - var sql = 'GRANT ' + g + ' to "' + userName + '"'; + console.log(createUserSQL, ' ......... ok'); - connection.execute(sql, function (err2, result2) { - if (err2) { - throw new Error('Unable to execute grant ' + sql); + async.each(grants, function (g, callback) { + var grantSQL = 'GRANT ' + g + ' to "' + userName + '"'; + connection.execute(grantSQL, function (grantErr, grantRes) { + if (grantErr) { + console.error(grantErr); + throw new Error('Unable to execute grant ' + grantSQL); } - console.log(sql, ' ......... ok'); + console.log(grantSQL, ' ......... ok'); return callback(); }); - }, function (err) { + }, function (grantAsyncErr) { console.log('User ' + userName + ' Created successfully'); return cb(); }); @@ -75,78 +84,83 @@ function createUser(connection, cb) { }); } - function dropTables(cb) { - var oracleConnectSettings2 = Object.assign({}, oracleConnectSettings); - oracleConnectSettings2.user = userName; - oracleConnectSettings2.password = password; - - oracledb.getConnection( - oracleConnectSettings2, - function (err, connection) { - if (err) { - throw new Error('Unable to connect to Oracle Database ' + JSON.stringify(oracleConnectSettings)); + var oracleUserConnectSettings = { + 'password': password, + 'user': userName, + 'connectString': oracleHost + ':' + oraclePort + '/' + oracleSID + }; + + oracledb.getConnection(oracleUserConnectSettings, function (userConnectionErr, connection) { + if (userConnectionErr) { + console.error(userConnectionErr); + throw new Error('Unable to connect to Oracle Database ' + JSON.stringify(oracleUserConnectSettings)); + } + + var totalRows = 1000; + var selectDropTableSQL = "select 'drop table \"' || table_name || '\"' from all_tables where owner = '" + userName + "'"; + connection.execute(selectDropTableSQL, {}, { maxRows: totalRows }, function (selectDropErr, selectDropRes) { + if (selectDropErr) { + console.error(selectDropErr); + throw new Error('Unable to find tables ' + userName); } - var sql = "select 'drop table \"' || table_name || '\"' from all_tables where owner = '" + userName + "'"; - var totalRows = 1000; - connection.execute(sql, {}, {maxRows: totalRows}, function (err, result) { - if (err) { - throw new Error('Unable to find tables ' + userName + ' Error :' + err); - } - connection.execute(sql, {}, {maxRows: totalRows}, function (err2, result2) { - if (err2) { - throw new Error('Unable to execute droping of table ' + sql); - } - if (!result2 || !result2.rows || result2.rows.length === 0) { - return cb(); + if (!selectDropRes || !selectDropRes.rows || selectDropRes.rows.length === 0) { + return cb(); + } + + async.each(selectDropRes.rows, function (row, callback) { + var dropTableSQL = row[0]; + connection.execute(dropTableSQL, function (dropTableErr, dropTableRes) { + if (dropTableErr) { + console.error(dropTableErr); + throw new Error('Unable to drop table\nSQL: ' + sql); } - async.each(result2.rows, function (row, callback) { - var sql = row[0]; - connection.execute(sql, function (err2, result2) { - if (err2) { - throw new Error('Unable to drop table\nERROR : ' + err2 + '\nSQL : ' + sql); - } - console.log(sql, ' ......... ok'); - return callback(); - }); - }, function (err) { - console.log('Tables of user ' + userName + ' dropped successfully'); - return cb(); - }); + console.log(dropTableSQL, ' ......... ok'); + return callback(); }); + }, function (dropAsyncErr) { + console.log('Tables of user ' + userName + ' dropped successfully'); + return cb(); }); }); + }); } -oracledb.getConnection( - oracleConnectSettings, - function (err, connection) { +function generateUserBundle() { + console.log("Generating oracle user details shell script"); + fs.writeFileSync('./oracle-user.sh', '#!/bin/sh' + os.EOL); + fs.appendFileSync('./oracle-user.sh', 'export ORACLE_USERNAME=' + userName + os.EOL); + fs.appendFileSync('./oracle-user.sh', 'export ORACLE_PASSWORD=' + password + os.EOL); +} + +oracledb.getConnection(oracleConnectSettings, function (connectionErr, connection) { + if (connectionErr) { + console.error(connectionErr); + throw new Error('Unable to connect to Oracle Database ' + JSON.stringify(oracleConnectSettings)); + } + var sql = "select username, user_id from dba_users where username = '" + userName + "'"; + console.log(sql); + connection.execute(sql, function (err, result) { if (err) { - throw new Error('Unable to connect to Oracle Database ' + JSON.stringify(oracleConnectSettings)); + console.error(err); return; } - var sql = "select username, user_id from dba_users where username = '" + userName + "'"; - console.log(sql); - connection.execute(sql, - function (err, result) { + if (!result.rows || result.rows.length == 0) { + createUser(connection, function (err) { if (err) { - console.error(err); return; + return process.exit(1); } - if (!result.rows || result.rows.length == 0) { - createUser(connection, function (err) { - if (err) { - return process.exit(1); - } - return process.exit(); - }); - } else { - dropTables(function (err) { - if (err) { - return process.exit(1); - } - return process.exit(); - }); + generateUserBundle(); + return process.exit(); + }); + } else { + dropTables(function (err) { + if (err) { + return process.exit(1); } + generateUserBundle(); + return process.exit(); }); + } }); - +}); diff --git a/test/scripts/gridconfig-test.js b/test/scripts/gridconfig-test.js index e3eb921..8505e63 100644 --- a/test/scripts/gridconfig-test.js +++ b/test/scripts/gridconfig-test.js @@ -1,8 +1,8 @@ /** - * + * * ©2016-2017 EdgeVerve Systems Limited (a fully owned Infosys subsidiary), * Bangalore, India. All Rights Reserved. - * + * */ var bootstrap = require('../test'); @@ -12,72 +12,72 @@ var chalk = bootstrap.chalk; var chai = bootstrap.chai; var api = bootstrap.api; -describe(chalk.blue('grid-config tests'), function() { +describe(chalk.blue('grid-config tests'), function () { var testGridConfig = { - "code": "PersonTable", - "label": "Users", - "editorFormUrl": "/components/person-form.html", - "columns": [{ - "key": "firstName", - "label": "First Name", - "type": "string" - }, - { - "key": "middleName", - "label": "Middle Name", - "type": "string" - }, - { - "key": "lastName", - "label": "Last Name", - "type": "string" - }, - { - "key": "email", - "label": "E-Mail", - "type": "string" - } + 'code': 'PersonTable', + 'label': 'Users', + 'editorFormUrl': '/components/person-form.html', + 'columns': [{ + 'key': 'firstName', + 'label': 'First Name', + 'type': 'string' + }, + { + 'key': 'middleName', + 'label': 'Middle Name', + 'type': 'string' + }, + { + 'key': 'lastName', + 'label': 'Last Name', + 'type': 'string' + }, + { + 'key': 'email', + 'label': 'E-Mail', + 'type': 'string' + } ] }; var testGridConfig1 = { - "code": "PersonTable1", - "label": "Users", - "editorFormUrl": "/components/person-form.html", - "columns": [{ - "key": "firstName", - "label": "First Name", - "type": "string" - }, - { - "key": "middleName", - "label": "Middle Name", - "type": "string" - }, - { - "key": "lastName", - "label": "Last Name", - "type": "string" - }, - { - "key": "email", - "label": "E-Mail", - "type": "string" - } + 'code': 'PersonTable1', + 'label': 'Users', + 'editorFormUrl': '/components/person-form.html', + 'columns': [{ + 'key': 'firstName', + 'label': 'First Name', + 'type': 'string' + }, + { + 'key': 'middleName', + 'label': 'Middle Name', + 'type': 'string' + }, + { + 'key': 'lastName', + 'label': 'Last Name', + 'type': 'string' + }, + { + 'key': 'email', + 'label': 'E-Mail', + 'type': 'string' + } ] }; - before('Load test data', function(done) { + before('Load test data', function (done) { bootstrap.deleteAndCreate(models.GridConfig, [testGridConfig, testGridConfig1], done); }); - after('remove test data', function(done) { + after('remove test data', function (done) { bootstrap.deleteAll(models.GridConfig, done); }); - it('should return an error if invalid configCode is provided', function(done) { + it('should return an error if invalid configCode is provided', function (done) { api .get(bootstrap.basePath + '/GridConfigs/config/unknownConfig') - .expect(404).end(function(err, res) { + .expect(404).end(function (err, res) { var error = res.body.error; expect(res.status).to.equal(404); expect(error).to.exist; @@ -87,10 +87,10 @@ describe(chalk.blue('grid-config tests'), function() { }); }); - it('should generate grid config if configCode is a model', function(done) { + it('should generate grid config if configCode is a model', function (done) { api .get(bootstrap.basePath + '/GridConfigs/config/Order') - .expect(200).end(function(err, res) { + .expect(200).end(function (err, res) { expect(res.status).to.equal(200); var response = res.body; expect(response).to.exist; @@ -102,10 +102,10 @@ describe(chalk.blue('grid-config tests'), function() { }); }); - it('should return the defined grid config', function(done) { + it('should return the defined grid config', function (done) { api .get(bootstrap.basePath + '/GridConfigs/config/PersonTable') - .expect(200).end(function(err, res) { + .expect(200).end(function (err, res) { var response = res.body; expect(response).to.exist; expect(response.label).to.exist; @@ -115,4 +115,4 @@ describe(chalk.blue('grid-config tests'), function() { done(); }); }); -}); \ No newline at end of file +}); diff --git a/test/scripts/literal-test.js b/test/scripts/literal-test.js index f862566..a4e9f8f 100644 --- a/test/scripts/literal-test.js +++ b/test/scripts/literal-test.js @@ -1,8 +1,8 @@ /** - * + * * ©2016-2017 EdgeVerve Systems Limited (a fully owned Infosys subsidiary), * Bangalore, India. All Rights Reserved. - * + * */ var bootstrap = require('../test'); var expect = bootstrap.chai.expect; @@ -11,49 +11,49 @@ var chalk = bootstrap.chalk; var chai = bootstrap.chai; var api = bootstrap.api; -describe(chalk.blue('literal tests'), function() { +describe(chalk.blue('literal tests'), function () { var data = [{ - "key": "Auth Scheme", - "value": "Auth Scheme" - }, - { - "key": "rangeOverflow", - "value": "Must be max $max$ characters" - }, - { - "key": "rangeOverflow", - "value": "Value should be $max$ characters long", - "locale": "en-US" - }, - { - "key": "rangeUnderflow", - "value": "Min $min$ allowed for $field$", - "placeholders": ["field", "min"] - }, - { - "key": "valueMissing", - "value": "Value is required for this field", - "locale": "en-US" - } + 'key': 'Auth Scheme', + 'value': 'Auth Scheme' + }, + { + 'key': 'rangeOverflow', + 'value': 'Must be max $max$ characters' + }, + { + 'key': 'rangeOverflow', + 'value': 'Value should be $max$ characters long', + 'locale': 'en-US' + }, + { + 'key': 'rangeUnderflow', + 'value': 'Min $min$ allowed for $field$', + 'placeholders': ['field', 'min'] + }, + { + 'key': 'valueMissing', + 'value': 'Value is required for this field', + 'locale': 'en-US' + } ]; - before('setup test data', function(done) { - bootstrap.deleteAndCreate(models.Literal, data, function(err) { + before('setup test data', function (done) { + bootstrap.deleteAndCreate(models.Literal, data, function (err) { done(err); }); }); - it('populates placeholder data', function(done) { + it('populates placeholder data', function (done) { api.get(bootstrap.basePath + '/Literals') .set('Accept', 'application/json') - .expect(200).end(function(err, resp) { + .expect(200).end(function (err, resp) { if (err) { return done(err); } var result = resp.body; expect(result).to.be.an.array; - var rangeOverflow = result.find(function(item) { - return item.key === 'rangeOverflow' + var rangeOverflow = result.find(function (item) { + return item.key === 'rangeOverflow'; }); expect(rangeOverflow.placeholders).to.be.ok; expect(rangeOverflow.placeholders).to.have.key('max'); @@ -64,17 +64,17 @@ describe(chalk.blue('literal tests'), function() { }); }); - it('If placeholders are specified as array, ordering is maintained', function(done) { + it('If placeholders are specified as array, ordering is maintained', function (done) { api.get(bootstrap.basePath + '/Literals') .set('Accept', 'application/json') - .expect(200).end(function(err, resp) { + .expect(200).end(function (err, resp) { if (err) { return done(err); } var result = resp.body; expect(result).to.be.an.array; - var rangeUnderflow = result.find(function(item) { - return item.key === 'rangeUnderflow' + var rangeUnderflow = result.find(function (item) { + return item.key === 'rangeUnderflow'; }); expect(rangeUnderflow.placeholders).to.be.ok; expect(rangeUnderflow.placeholders).to.have.keys(['field', 'min']); @@ -88,10 +88,10 @@ describe(chalk.blue('literal tests'), function() { }); }); - it('render returns data as object', function(done) { + it('render returns data as object', function (done) { api.get(bootstrap.basePath + '/Literals/render/en-US') .set('Accept', 'application/json') - .expect(200).end(function(err, resp) { + .expect(200).end(function (err, resp) { if (err) { return done(err); } @@ -102,10 +102,10 @@ describe(chalk.blue('literal tests'), function() { }); }); - it('render ignores the .json extension', function(done) { + it('render ignores the .json extension', function (done) { api.get(bootstrap.basePath + '/Literals/render/en-US.json') .set('Accept', 'application/json') - .expect(200).end(function(err, resp) { + .expect(200).end(function (err, resp) { if (err) { return done(err); } @@ -116,10 +116,10 @@ describe(chalk.blue('literal tests'), function() { }); }); - it('Default locale is returned when locale specific data not present', function(done) { + it('Default locale is returned when locale specific data not present', function (done) { api.get(bootstrap.basePath + '/Literals/render/en-IN') .set('Accept', 'application/json') - .expect(200).end(function(err, resp) { + .expect(200).end(function (err, resp) { if (err) { return done(err); } @@ -132,10 +132,10 @@ describe(chalk.blue('literal tests'), function() { }); }); - it('Locale data overrides the defaults', function(done) { + it('Locale data overrides the defaults', function (done) { api.get(bootstrap.basePath + '/Literals/render/en-US') .set('Accept', 'application/json') - .expect(200).end(function(err, resp) { + .expect(200).end(function (err, resp) { if (err) { return done(err); } @@ -148,12 +148,12 @@ describe(chalk.blue('literal tests'), function() { }); }); - after('clean up', function(done) { - bootstrap.deleteAll(models.Literal, function(err, d) { + after('clean up', function (done) { + bootstrap.deleteAll(models.Literal, function (err, d) { if (err) { console.log('Error - not able to delete literals ', err, d); } done(); }); }); -}); \ No newline at end of file +}); diff --git a/test/scripts/ui-component-test.js b/test/scripts/ui-component-test.js index 179af95..03bcb46 100644 --- a/test/scripts/ui-component-test.js +++ b/test/scripts/ui-component-test.js @@ -1,8 +1,8 @@ /** - * + * * ©2016-2017 EdgeVerve Systems Limited (a fully owned Infosys subsidiary), * Bangalore, India. All Rights Reserved. - * + * */ var bootstrap = require('../test'); @@ -11,20 +11,20 @@ var models = bootstrap.app.models; var chalk = bootstrap.chalk; var api = bootstrap.api; -describe(chalk.blue('ui-component tests'), function() { +describe(chalk.blue('ui-component tests'), function () { var metadataCache = {}; function fetchComponent(componentName, callback) { - models.UIComponent.component(componentName, null, bootstrap.defaultContext, function(err, data) { + models.UIComponent.component(componentName, null, bootstrap.defaultContext, function (err, data) { if (err) return callback(err); var start = data.indexOf(''); - var metaString - if(start === -1 && end === -1){ - //js file + var metaString; + if (start === -1 && end === -1) { + // js file metaString = data; - }else{ + } else { metaString = data.substr(start + 8, end - start - 8); } metaString = metaString.replace('window.OEUtils ||', ''); @@ -37,18 +37,18 @@ describe(chalk.blue('ui-component tests'), function() { } function simulateComponent(component, callback) { - models.UIComponent.simulate(component, null, bootstrap.defaultContext, function(err, data) { + models.UIComponent.simulate(component, null, bootstrap.defaultContext, function (err, data) { if (err) return callback(err); var start = data.indexOf(''); var htmlPart; var metaString; - if(start === -1 && end === -1){ - //js file + if (start === -1 && end === -1) { + // js file metaString = data; htmlPart = data; - }else{ + } else { metaString = data.substr(start + 8, end - start - 8); htmlPart = data.substr(end + 9).trim(); } @@ -72,22 +72,22 @@ describe(chalk.blue('ui-component tests'), function() { modelName: 'Order' }]; - before('setup data', function(done) { - bootstrap.deleteAndCreate(models.UIElement, elementsData, function(err1) { - bootstrap.deleteAndCreate(models.UIComponent, componentData, function(err2) { + before('setup data', function (done) { + bootstrap.deleteAndCreate(models.UIElement, elementsData, function (err1) { + bootstrap.deleteAndCreate(models.UIComponent, componentData, function (err2) { done(err1 || err2); }); }); }); - after('cleanup data', function(done) { - bootstrap.deleteAll(models.UIComponent, function(err) { + after('cleanup data', function (done) { + bootstrap.deleteAll(models.UIComponent, function (err) { bootstrap.deleteAll(models.UIElement, done); }); }); - it('fetch using modelmeta method', function(done) { + it('fetch using modelmeta method', function (done) { var UIComponent = models.UIComponent; - UIComponent.modelmeta('person', null, bootstrap.defaultContext, function(err, data) { + UIComponent.modelmeta('person', null, bootstrap.defaultContext, function (err, data) { expect(data).to.exist; expect(data.componentName).to.equal('person'); expect(data.modelName).to.equal('Person'); @@ -95,8 +95,8 @@ describe(chalk.blue('ui-component tests'), function() { }); }); - it('returns error if model is not found', function(done) { - fetchComponent('missingmodel-form', function(err, data) { + it('returns error if model is not found', function (done) { + fetchComponent('missingmodel-form', function (err, data) { expect(err).to.exist; expect(data).to.not.exist; expect(err.code).to.equal('MODEL_NOT_FOUND'); @@ -104,8 +104,8 @@ describe(chalk.blue('ui-component tests'), function() { }); }); - it('returns error if form-template is not provided', function(done) { - fetchComponent('person-', function(err, data) { + it('returns error if form-template is not provided', function (done) { + fetchComponent('person-', function (err, data) { expect(err).to.exist; expect(data).to.not.exist; expect(err.code).to.equal('TEMPLATE_TYPE_UNDEFINED'); @@ -113,9 +113,9 @@ describe(chalk.blue('ui-component tests'), function() { }); }); - it('returns error if form-template is not found', function(done) { + it('returns error if form-template is not found', function (done) { this.timeout(4000); - fetchComponent('person-missing', function(err, data) { + fetchComponent('person-missing', function (err, data) { expect(err).to.exist; expect(data).to.not.exist; expect(err.code).to.equal('TEMPLATE_TYPE_MISSING'); @@ -123,9 +123,9 @@ describe(chalk.blue('ui-component tests'), function() { }); }); - it('glob searches the template, when not found in configured paths', function(done) { + it('glob searches the template, when not found in configured paths', function (done) { this.timeout(4000); - fetchComponent('person-tpl', function(err, metadata) { + fetchComponent('person-tpl', function (err, metadata) { console.log(err); expect(err).to.not.exist; expect(metadata).to.exist; @@ -136,8 +136,8 @@ describe(chalk.blue('ui-component tests'), function() { }); }); - it('loads default form template', function(done) { - fetchComponent('person-form', function(err, metadata) { + it('loads default form template', function (done) { + fetchComponent('person-form', function (err, metadata) { expect(metadata).to.exist; expect(metadata.componentName).to.equal('person-form'); expect(metadata.modelName).to.equal('Person'); @@ -146,35 +146,35 @@ describe(chalk.blue('ui-component tests'), function() { }); }); - it('default form has model definition', function(done) { - fetchComponent('person-form', function(err, metadata) { + it('default form has model definition', function (done) { + fetchComponent('person-form', function (err, metadata) { expect(metadata.metadata.models).to.be.an('object'); expect(metadata.metadata.models.Person).to.exist; done(); }); }); - it('default form metadata has properties', function(done) { - fetchComponent('person-form', function(err, metadata) { + it('default form metadata has properties', function (done) { + fetchComponent('person-form', function (err, metadata) { expect(metadata.metadata.properties).to.be.an('object'); - expect(metadata.metadata.properties).to.not.have.property('id') - expect(Object.keys(metadata.metadata.properties)).to.include.members(Object.keys(models.Person.definition.properties).filter(function(v) { + expect(metadata.metadata.properties).to.not.have.property('id'); + expect(Object.keys(metadata.metadata.properties)).to.include.members(Object.keys(models.Person.definition.properties).filter(function (v) { return v !== 'id' && models.Person.settings.hidden.indexOf(v) > 0; })); done(); }); }); - it('default form loads element definitions', function(done) { - fetchComponent('person-form', function(err, metadata) { + it('default form loads element definitions', function (done) { + fetchComponent('person-form', function (err, metadata) { expect(metadata.elements).to.be.an('object'); expect(metadata.elements.firstName).to.be.an('object').and.have.property('minlength'); done(); }); }); - it('belongsTo relashionship reflects in properties as typeahead', function(done) { - fetchComponent('person-form', function(err, metadata) { + it('belongsTo relashionship reflects in properties as typeahead', function (done) { + fetchComponent('person-form', function (err, metadata) { expect(metadata.metadata.properties).to.be.an('object'); expect(metadata.metadata.properties.departmentId).to.exist; expect(metadata.metadata.properties.departmentId.type).to.equal('typeahead'); @@ -185,17 +185,17 @@ describe(chalk.blue('ui-component tests'), function() { }); }); - it('embedsMany relashionship reflects in properties as grid', function(done) { - fetchComponent('person-form', function(err, metadata) { + it('embedsMany relashionship reflects in properties as grid', function (done) { + fetchComponent('person-form', function (err, metadata) { expect(metadata.metadata.properties).to.be.an('object'); - expect(metadata.metadata.properties['_addresses']).to.exist; - expect(metadata.metadata.properties['_addresses'].type).to.equal('grid'); + expect(metadata.metadata.properties._addresses).to.exist; + expect(metadata.metadata.properties._addresses.type).to.equal('grid'); done(); }); }); - it('Array of primitive property reflects as tags', function(done) { - fetchComponent('person-form', function(err, metadata) { + it('Array of primitive property reflects as tags', function (done) { + fetchComponent('person-form', function (err, metadata) { expect(metadata.metadata.properties).to.be.an('object'); expect(metadata.metadata.properties.qualifications).to.exist; expect(metadata.metadata.properties.qualifications.type).to.equal('tags'); @@ -204,8 +204,8 @@ describe(chalk.blue('ui-component tests'), function() { }); }); - it('Array of composite property reflects in properties as grid', function(done) { - fetchComponent('person-form', function(err, metadata) { + it('Array of composite property reflects in properties as grid', function (done) { + fetchComponent('person-form', function (err, metadata) { expect(metadata.metadata.properties).to.be.an('object'); expect(metadata.metadata.properties.languages).to.be.ok; expect(metadata.metadata.properties.languages.type).to.equal('grid'); @@ -217,8 +217,8 @@ describe(chalk.blue('ui-component tests'), function() { }); - it('hasOne reflects in properties type as model', function(done) { - fetchComponent('person-form', function(err, metadata) { + it('hasOne reflects in properties type as model', function (done) { + fetchComponent('person-form', function (err, metadata) { expect(metadata.metadata.properties).to.be.an('object'); expect(metadata.metadata.properties.permanentAddress).to.be.ok; expect(metadata.metadata.properties.permanentAddress.type).to.equal('model'); @@ -227,8 +227,8 @@ describe(chalk.blue('ui-component tests'), function() { }); }); - it('Composite property reflects properties type as model', function(done) { - fetchComponent('person-form', function(err, metadata) { + it('Composite property reflects properties type as model', function (done) { + fetchComponent('person-form', function (err, metadata) { expect(metadata.metadata.properties).to.be.an('object'); expect(metadata.metadata.properties.shippingAddress).to.be.ok; expect(metadata.metadata.properties.shippingAddress.type).to.equal('model'); @@ -237,8 +237,8 @@ describe(chalk.blue('ui-component tests'), function() { }); }); - it('Validations are populated', function(done) { - fetchComponent('person-form', function(err, metadata) { + it('Validations are populated', function (done) { + fetchComponent('person-form', function (err, metadata) { expect(metadata.metadata.properties).to.be.an('object'); expect(metadata.metadata.properties.firstName).to.be.ok; expect(metadata.metadata.properties.firstName.required).to.equal(true); @@ -248,8 +248,8 @@ describe(chalk.blue('ui-component tests'), function() { }); }); - it('Validate when validations are ignored', function(done) { - fetchComponent('person-form', function(err, metadata) { + it('Validate when validations are ignored', function (done) { + fetchComponent('person-form', function (err, metadata) { expect(metadata.metadata.properties).to.be.an('object'); expect(metadata.metadata.properties.gender).to.be.ok; expect(metadata.metadata.properties.gender.required).to.not.exist; @@ -257,20 +257,20 @@ describe(chalk.blue('ui-component tests'), function() { }); }); - it('default list has gridConfig with all required fields as columns', function(done) { - fetchComponent('person-list', function(err, metadata) { + it('default list has gridConfig with all required fields as columns', function (done) { + fetchComponent('person-list', function (err, metadata) { expect(metadata.gridConfig).to.be.an('object'); expect(metadata.gridConfig.modelGrid).to.be.an('array').and.include.members(['firstName', 'gender']); done(); }); }); - it('simulate method returns the component definition', function(done) { + it('simulate method returns the component definition', function (done) { var component = { name: 'salutation-form', modelName: 'Salutation' }; - simulateComponent(component, function(err, data) { + simulateComponent(component, function (err, data) { expect(data.componentName).to.equal(component.name); expect(data.modelName).to.equal(component.modelName); expect(data.metadata.properties).to.be.an('object').and.have.keys('code', 'description'); @@ -278,83 +278,83 @@ describe(chalk.blue('ui-component tests'), function() { }); }); - it('When template is not defined, content is returned as html', function(done) { + it('When template is not defined, content is returned as html', function (done) { var component = { name: 'salutation-form', modelName: 'Salutation', content: '
Dummy
' }; - simulateComponent(component, function(err, data, htmlPart) { + simulateComponent(component, function (err, data, htmlPart) { expect(htmlPart).to.equal(component.content); done(); }); }); - it('When template is defined, content is returned as response.content', function(done) { + it('When template is defined, content is returned as response.content', function (done) { var component = { name: 'salutation-form', templateName: 'default-form.html', modelName: 'Salutation', content: '
Dummy
' }; - simulateComponent(component, function(err, data, htmlPart) { + simulateComponent(component, function (err, data, htmlPart) { expect(data.content).to.equal(component.content); done(); }); }); - it('When template is defined as js file, content is returned as response.content', function(done) { + it('When template is defined as js file, content is returned as response.content', function (done) { var component = { name: 'salutation-form', templateName: 'default-form.js', modelName: 'Salutation', content: 'Dummy' }; - simulateComponent(component, function(err, data, htmlPart) { + simulateComponent(component, function (err, data, htmlPart) { expect(data.content).to.equal(component.content); done(); }); }); - it('When filePath is defined, its content are returned as html', function(done) { + it('When filePath is defined, its content are returned as html', function (done) { var component = { name: 'sample-element', filePath: 'client/templates/sample-element.html' }; - simulateComponent(component, function(err, data, htmlPart) { + simulateComponent(component, function (err, data, htmlPart) { expect(htmlPart.indexOf('')).to.equal(0); done(); }); }); - it('When templateName is defined, its content are returned as html', function(done) { + it('When templateName is defined, its content are returned as html', function (done) { var component = { name: 'sample-element', templateName: 'sample-element.html' }; - simulateComponent(component, function(err, data, htmlPart) { + simulateComponent(component, function (err, data, htmlPart) { expect(htmlPart.indexOf('')).to.equal(0); done(); }); }); - it('importUrls are added as link tags', function(done) { + it('importUrls are added as link tags', function (done) { var component = { name: 'salutation-form', templateName: 'default-form.html', importUrls: ['link1.html', 'link2.html'] }; - simulateComponent(component, function(err, data, htmlPart) { + simulateComponent(component, function (err, data, htmlPart) { expect(htmlPart.indexOf(' Date: Thu, 23 Jan 2020 14:32:46 +0530 Subject: [PATCH 7/7] commit for version 2.2.0 --- package.json | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 220d5dd..4675870 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "oe-metadata-ui", - "version": "2.1.0", + "version": "2.2.0", "description": "holds and serves metadata used by oe-ui framework", "engines": { "node": ">=6" @@ -17,7 +17,7 @@ "async": "2.6.1", "glob": "7.1.3", "lodash": "4.17.14", - "oe-logger": "git+http://evgit/oecloud.io/oe-logger.git#master" + "oe-logger": "git+http://evgit/oecloud.io/oe-logger.git#2.2.0" }, "devDependencies": { "babel-eslint": "7.2.3", @@ -30,10 +30,10 @@ "grunt-mocha-istanbul": "5.0.2", "istanbul": "0.4.5", "mocha": "5.2.0", - "oe-cloud": "git+http://evgit/oecloud.io/oe-cloud.git#master", - "oe-connector-mongodb": "git+http://evgit/oecloud.io/oe-connector-mongodb.git#master", - "oe-connector-oracle": "git+http://evgit/oecloud.io/oe-connector-oracle.git#master", - "oe-connector-postgresql": "git+http://evgit/oecloud.io/oe-connector-postgresql.git#master", + "oe-cloud": "git+http://evgit/oecloud.io/oe-cloud.git#2.2.0", + "oe-connector-mongodb": "git+http://evgit/oecloud.io/oe-connector-mongodb.git#2.2.0", + "oe-connector-oracle": "git+http://evgit/oecloud.io/oe-connector-oracle.git#2.2.0", + "oe-connector-postgresql": "git+http://evgit/oecloud.io/oe-connector-postgresql.git#2.2.0", "superagent-defaults": "0.1.14", "supertest": "3.4.2" },