diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index b3f72cc..8e8fba0 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -1,12 +1,25 @@ name: Unit Tests -on: [pull_request] +on: + push: + branches: + - main + pull_request: + branches: + - main jobs: tests: runs-on: ubuntu-latest env: - MY_SALT: ${{ vars.SALT }} + MY_SALT: ${{ secrets.SALT }} + MY_DB: ${{ secrets.DB }} + MY_JWTPRIVATEKEY: ${{ secrets.JWTPRIVATEKEY }} + MY_RAZORPAY_KEY_ID: ${{ secrets.RAZORPAY_KEY_ID }} + MY_RAZORPAY_KEY_SECRET: ${{ secrets.RAZORPAY_KEY_SECRET }} + MY_CLOUDNARY_API_KEY: ${{ secrets.CLOUDNARY_API_KEY }} + MY_CLOUDNARY_API_SECREAT: ${{ secrets.CLOUDNARY_API_SECREAT }} + MY_CLOUDNARY_API_NAME: ${{ secrets.CLOUDNARY_API_NAME }} strategy: matrix: node-version: [18.x] @@ -19,9 +32,17 @@ jobs: node-version: ${{ matrix.node-version }} - name: npm intsall run: npm ci - - name: env vars - run: echo ${{ vars.SALT }} - name: Manage .env - run: source cicd.sh + run: | + source cicd.sh + source cicd.sh > ./server/.env + source cicd.sh > ./.env + cat ./server/.env - name: tests - run: npm test + run: | + cd server + npm i --force + cd .. + pwd + npm test + cat log.txt diff --git a/.gitignore b/.gitignore index 30bc162..c152a78 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ -/node_modules \ No newline at end of file +/node_modules +mongoURL.js +.env \ No newline at end of file diff --git a/cicd.sh b/cicd.sh index b2f82e3..72c1f4b 100644 --- a/cicd.sh +++ b/cicd.sh @@ -1,2 +1,10 @@ #!/bin/bash -echo "My SALT is $MY_SALT" +echo "DB=$MY_DB" +echo "JWTPRIVATEKEY=$MY_JWTPRIVATEKEY" +echo "SALT = $MY_SALT" +echo "RAZORPAY_KEY_ID=$MY_RAZORPAY_KEY_ID" +echo "RAZORPAY_KEY_SECRET=$MY_RAZORPAY_KEY_SECRET" + +echo "CLOUDNARY_API_KEY=$MY_CLOUDNARY_API_KEY" +echo "CLOUDNARY_API_SECREAT=$MY_CLOUDNARY_API_SECREAT" +echo "CLOUDNARY_API_NAME=$MY_CLOUDNARY_API_NAME" \ No newline at end of file diff --git a/demo.test.js b/demo.test.js index dd85b18..b5d5431 100644 --- a/demo.test.js +++ b/demo.test.js @@ -1,5 +1,14 @@ -const { default: expect } = require("expect") +require('dotenv').config() +const { expect } = require("expect") +const supertest = require('supertest') +const {app} = require('./server/test_server.js') test('demo testing for sum', () => { - expect(1+2).toBe(3) + expect(1 + 2).toBe(3) +}) + +test('testing get all services', async () => { + const response = await supertest(app).get("/api/customer/viewServices") + expect(response).not.toBe(null) + return }) \ No newline at end of file diff --git a/jest.config.js b/jest.config.js new file mode 100644 index 0000000..92ae8e8 --- /dev/null +++ b/jest.config.js @@ -0,0 +1,35 @@ +// jest.config.js +module.exports = { + roots: ["./"], + collectCoverageFrom: ["./**/*.{js,jsx,ts,tsx}", "!src/**/*.d.ts"], + // setupFilesAfterEnv: ["/setupTests.js"], + testMatch: [ + "./**/__tests__/**/*.{js,jsx,ts,tsx}", + "./**/*.{spec,test}.{js,jsx,ts,tsx}", + ], + testEnvironment: "node", + transform: { + "^.+\\.(js|jsx|ts|tsx)$": "./node_modules/babel-jest", + }, + transformIgnorePatterns: ["[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$"], + modulePaths: [], + moduleNameMapper: { + "^react-native$": "react-native-web", + "\\.(css|less|scss|sss|styl)$": "./node_modules/jest-css-modules", + }, + moduleFileExtensions: [ + "web.js", + "js", + "json", + "web.jsx", + "jsx", + "node", + "ts", + "tsx", + ], + // watchPlugins: [ + // "jest-watch-typeahead/filename", + // "jest-watch-typeahead/testname", + // ], + }; + \ No newline at end of file diff --git a/log.txt b/log.txt new file mode 100644 index 0000000..e69de29 diff --git a/package-lock.json b/package-lock.json index 0c17c8a..e35dc31 100644 --- a/package-lock.json +++ b/package-lock.json @@ -46,6 +46,7 @@ "deepmerge": "^4.3.1", "detect-newline": "^3.1.0", "diff-sequences": "^29.6.3", + "dotenv": "^16.4.5", "electron-to-chromium": "^1.4.751", "emittery": "^0.13.1", "emoji-regex": "^8.0.0", @@ -182,6 +183,7 @@ "strip-bom": "^4.0.0", "strip-final-newline": "^2.0.0", "strip-json-comments": "^3.1.1", + "supertest": "^7.0.0", "supports-color": "^7.2.0", "supports-preserve-symlinks-flag": "^1.0.0", "test-exclude": "^6.0.0", @@ -1240,6 +1242,16 @@ "sprintf-js": "~1.0.2" } }, + "node_modules/asap": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", + "integrity": "sha512-BSHWgDSAiKs50o2Re8ppvp3seVHXSRM44cdSsT9FfNEUUZLOGWVCsiWaRPWM1Znn+mqZ1OfVZ3z3DWEzSp7hRA==" + }, + "node_modules/asynckit": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", + "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" + }, "node_modules/babel-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz", @@ -1410,6 +1422,24 @@ "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==" }, + "node_modules/call-bind": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz", + "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/callsites": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/callsites/-/callsites-3.1.0.tgz", @@ -1538,6 +1568,25 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "node_modules/combined-stream": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", + "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dependencies": { + "delayed-stream": "~1.0.0" + }, + "engines": { + "node": ">= 0.8" + } + }, + "node_modules/component-emitter": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.3.1.tgz", + "integrity": "sha512-T0+barUSQRTUQASh8bx02dl+DhF54GtIDY13Y3m9oWTklKbb3Wv974meRpeZ3lp1JpLVECWWNHC4vaG2XHXouQ==", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -1548,6 +1597,11 @@ "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==" }, + "node_modules/cookiejar": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.4.tgz", + "integrity": "sha512-LDx6oHrK+PhzLKJU9j5S7/Y3jM/mUHvD/DeI1WQmJn652iPC5Y4TBzC9l+5OMOXlyTTA+SmVUPm0HQUwpD5Jqw==" + }, "node_modules/create-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/create-jest/-/create-jest-29.7.0.tgz", @@ -1618,6 +1672,28 @@ "node": ">=0.10.0" } }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/delayed-stream": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", + "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", + "engines": { + "node": ">=0.4.0" "node_modules/denque": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", @@ -1634,6 +1710,15 @@ "node": ">=8" } }, + "node_modules/dezalgo": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/dezalgo/-/dezalgo-1.0.4.tgz", + "integrity": "sha512-rXSP0bf+5n0Qonsb+SVVfNfIsimO4HEtmnIpPHY8Q1UCzKlQrDMfdobr8nJOOsRgWCyMRqeSBQzmWUMq7zvVig==", + "dependencies": { + "asap": "^2.0.0", + "wrappy": "1" + } + }, "node_modules/diff-sequences": { "version": "29.6.3", "resolved": "https://registry.npmjs.org/diff-sequences/-/diff-sequences-29.6.3.tgz", @@ -1642,6 +1727,17 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/dotenv": { + "version": "16.4.5", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.4.5.tgz", + "integrity": "sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/electron-to-chromium": { "version": "1.4.751", "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.4.751.tgz", @@ -1671,6 +1767,25 @@ "is-arrayish": "^0.2.1" } }, + "node_modules/es-define-property": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz", + "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", + "dependencies": { + "get-intrinsic": "^1.2.4" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/es-errors": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz", + "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/escalade": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.2.tgz", @@ -1749,6 +1864,11 @@ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" }, + "node_modules/fast-safe-stringify": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/fast-safe-stringify/-/fast-safe-stringify-2.1.1.tgz", + "integrity": "sha512-W+KJc2dmILlPplD/H4K9l9LcAHAfPtP6BY84uVLXQ6Evcz9Lcg33Y2z1IVblT6xdY54PXYVHEv+0Wpq8Io6zkA==" + }, "node_modules/fb-watchman": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", @@ -1780,6 +1900,32 @@ "node": ">=8" } }, + "node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/formidable": { + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/formidable/-/formidable-3.5.1.tgz", + "integrity": "sha512-WJWKelbRHN41m5dumb0/k8TeAx7Id/y3a+Z7QfhxP/htI9Js5zYaEDtG8uMgG0vM0lOlqnmjE99/kfpOYi/0Og==", + "dependencies": { + "dezalgo": "^1.0.4", + "hexoid": "^1.0.0", + "once": "^1.4.0" + }, + "funding": { + "url": "https://ko-fi.com/tunnckoCore/commissions" + } + }, "node_modules/fs.realpath": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", @@ -1822,6 +1968,24 @@ "node": "6.* || 8.* || >= 10.*" } }, + "node_modules/get-intrinsic": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz", + "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", + "dependencies": { + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "has-proto": "^1.0.1", + "has-symbols": "^1.0.3", + "hasown": "^2.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/get-package-type": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", @@ -1868,6 +2032,17 @@ "node": ">=4" } }, + "node_modules/gopd": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz", + "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", + "dependencies": { + "get-intrinsic": "^1.1.3" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/graceful-fs": { "version": "4.2.11", "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", @@ -1881,6 +2056,39 @@ "node": ">=8" } }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz", + "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-symbols": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/hasown": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", @@ -1892,6 +2100,14 @@ "node": ">= 0.4" } }, + "node_modules/hexoid": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/hexoid/-/hexoid-1.0.0.tgz", + "integrity": "sha512-QFLV0taWQOZtvIRIAdBChesmogZrtuXvVWsFHZTk2SU+anspqZ2vMnoLg7IE1+Uk16N19APic1BuF8bC8c2m5g==", + "engines": { + "node": ">=8" + } + }, "node_modules/html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", @@ -2835,6 +3051,14 @@ "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==" }, + "node_modules/methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==", + "engines": { + "node": ">= 0.6" + } + }, "node_modules/micromatch": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz", @@ -2847,6 +3071,36 @@ "node": ">=8.6" } }, + "node_modules/mime": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-2.6.0.tgz", + "integrity": "sha512-USPkMeET31rOMiarsBNIHZKLGgvKc/LrjofAnBlOttf5ajRvqiRA8QsenbcooctK6d6Ts6aqZXBA+XbkKthiQg==", + "bin": { + "mime": "cli.js" + }, + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/mimic-fn": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", @@ -2905,6 +3159,14 @@ "node": ">=8" } }, + "node_modules/object-inspect": { + "version": "1.13.1", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz", + "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -3106,6 +3368,20 @@ } ] }, + "node_modules/qs": { + "version": "6.12.1", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.12.1.tgz", + "integrity": "sha512-zWmv4RSuB9r2mYQw3zxQuHWeU+42aKi1wWig/j4ele4ygELZ7PEO6MM7rim9oAQH2A5MWfsAVf/jPvTPgCbvUQ==", + "dependencies": { + "side-channel": "^1.0.6" + }, + "engines": { + "node": ">=0.6" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/react": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react/-/react-18.2.0.tgz", @@ -3250,6 +3526,22 @@ "semver": "bin/semver.js" } }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/shebang-command": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", @@ -3269,6 +3561,23 @@ "node": ">=8" } }, + "node_modules/side-channel": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz", + "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", + "dependencies": { + "call-bind": "^1.0.7", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.4", + "object-inspect": "^1.13.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/signal-exit": { "version": "3.0.7", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", @@ -3388,6 +3697,37 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/superagent": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/superagent/-/superagent-9.0.2.tgz", + "integrity": "sha512-xuW7dzkUpcJq7QnhOsnNUgtYp3xRwpt2F7abdRYIpCsAt0hhUqia0EdxyXZQQpNmGtsCzYHryaKSV3q3GJnq7w==", + "dependencies": { + "component-emitter": "^1.3.0", + "cookiejar": "^2.1.4", + "debug": "^4.3.4", + "fast-safe-stringify": "^2.1.1", + "form-data": "^4.0.0", + "formidable": "^3.5.1", + "methods": "^1.1.2", + "mime": "2.6.0", + "qs": "^6.11.0" + }, + "engines": { + "node": ">=14.18.0" + } + }, + "node_modules/supertest": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/supertest/-/supertest-7.0.0.tgz", + "integrity": "sha512-qlsr7fIC0lSddmA3tzojvzubYxvlGtzumcdHgPwbFWMISQwL22MhM2Y3LNt+6w9Yyx7559VW5ab70dgphm8qQA==", + "dependencies": { + "methods": "^1.1.2", + "superagent": "^9.0.1" + }, + "engines": { + "node": ">=14.18.0" + } + }, "node_modules/supports-color": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", diff --git a/package.json b/package.json index 625b90b..f756f67 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "deepmerge": "^4.3.1", "detect-newline": "^3.1.0", "diff-sequences": "^29.6.3", + "dotenv": "^16.4.5", "electron-to-chromium": "^1.4.751", "emittery": "^0.13.1", "emoji-regex": "^8.0.0", @@ -177,6 +178,7 @@ "strip-bom": "^4.0.0", "strip-final-newline": "^2.0.0", "strip-json-comments": "^3.1.1", + "supertest": "^7.0.0", "supports-color": "^7.2.0", "supports-preserve-symlinks-flag": "^1.0.0", "test-exclude": "^6.0.0", @@ -203,7 +205,7 @@ "jest": "^29.7.0" }, "scripts": { - "test": "npx jest", + "test": "jest", "server": "node server\\index.js" }, "author": "", diff --git a/server/Controllers/ConsumerViewServiceController.js b/server/Controllers/ConsumerViewServiceController.js index d167f23..39451b9 100644 --- a/server/Controllers/ConsumerViewServiceController.js +++ b/server/Controllers/ConsumerViewServiceController.js @@ -6,9 +6,7 @@ const { Services } = require("../Models/service"); async function ConsumerViewServiceController(req, res) { try { - const data = await Services.find({}).populate('pointer') - console.log(data); res.status(201).send({ message: "displayed all availaible services", data: data}); }catch (e) { console.log(e) diff --git a/server/Routes/ConsumerViewServicesRoute.js b/server/Routes/ConsumerViewServicesRoute.js index 415f0f8..2e17488 100644 --- a/server/Routes/ConsumerViewServicesRoute.js +++ b/server/Routes/ConsumerViewServicesRoute.js @@ -3,6 +3,8 @@ const router = require("express").Router(); const {authenticateToken}=require('../Middleware/CheckTokenLocally'); -router.get("/",authenticateToken,ConsumerViewServiceController) +router.get("/", + // authenticateToken, + ConsumerViewServiceController) module.exports = router; \ No newline at end of file diff --git a/server/jest.config.js b/server/jest.config.js new file mode 100644 index 0000000..92ae8e8 --- /dev/null +++ b/server/jest.config.js @@ -0,0 +1,35 @@ +// jest.config.js +module.exports = { + roots: ["./"], + collectCoverageFrom: ["./**/*.{js,jsx,ts,tsx}", "!src/**/*.d.ts"], + // setupFilesAfterEnv: ["/setupTests.js"], + testMatch: [ + "./**/__tests__/**/*.{js,jsx,ts,tsx}", + "./**/*.{spec,test}.{js,jsx,ts,tsx}", + ], + testEnvironment: "node", + transform: { + "^.+\\.(js|jsx|ts|tsx)$": "./node_modules/babel-jest", + }, + transformIgnorePatterns: ["[/\\\\]node_modules[/\\\\].+\\.(js|jsx|ts|tsx)$"], + modulePaths: [], + moduleNameMapper: { + "^react-native$": "react-native-web", + "\\.(css|less|scss|sss|styl)$": "./node_modules/jest-css-modules", + }, + moduleFileExtensions: [ + "web.js", + "js", + "json", + "web.jsx", + "jsx", + "node", + "ts", + "tsx", + ], + // watchPlugins: [ + // "jest-watch-typeahead/filename", + // "jest-watch-typeahead/testname", + // ], + }; + \ No newline at end of file diff --git a/server/test_server.js b/server/test_server.js new file mode 100644 index 0000000..ebfa984 --- /dev/null +++ b/server/test_server.js @@ -0,0 +1,204 @@ +/** + * Add morgan + * Add RFS + * rubricks + * Add Global error handler (a,b,c,d) => {retutn xyz} + * Unit Test - done + * Git Actions + */ +const bodyparser = require('body-parser') + +var views = 0 + +function increment(req, res, next){ + views += 1 + next() +} + +const Multer = require("multer"); +// const cloudinary = require("cloudinary").v2; +// const {CloudinaryStorage} = require("multer-storage-cloudinary"); + +require('dotenv').config(); +const express=require("express") +const app = express(); +module.exports = {app} +// const Razorpay=require('razorpay') +// const crypto=require('crypto') +const cors=require("cors"); +const connection=require("./db"); +const consumerRegistrationRoutes=require('./Routes/ConsumerRegistrationRoutes') +const consumerLoginRoute=require('./Routes/ConsumerLoginRoutes') +const ConsumerProfileRoute=require('./Routes/ConsumerProfileRoute'); +const ConsumerProfileUpdateRoute=require('./Routes/ConsumerProfileRouteUpdate'); +const ConsumerGivenSellerRatingRoute=require("./Routes/ConsumerRatingRoute") +const ConsumerViewBroadcastRoute=require("./Routes/ViewBroadcastConsumerRoute") +const SellerGivenConsumerRatingRoute=require("./Routes/SellerReviewConsumerViewRoute") +const ServiceInfoConsumerRoute=require('./Routes/SellerServiceDataOptedByConsumerRoute') +const pendingRequestDeleteRequestRoute=require('./Routes/PendingServiceDeleteRequestRoute') +const checkConsumerHistoryRoute=require("./Routes/ConsumerHistoryRoute") +const ConsumerChatSendRoute=require("./Routes/ConsumerChatSendRoute") +const ConsumerChatReadRoute=require("./Routes/ConsumerViewChatRoute") +const MakePaymentConsumer=require("./Routes/ConsumerMakePaymentRoute") +const TransactionHistoryRoute=require("./Routes/TransactionHistoryRoute") + +const TransactionAdminRoute=require("./Routes/TransactionAdminRoute") +const TransactionSellerRoute=require("./Routes/TransactionSellerRoute") +const TransactionConsumerRoute=require("./Routes/TransactionConsumerRoute") + +const SellerViewBroadcastRoute=require("./Routes/ViewBroadcastSellerRoute") +const SellerProfileConsumerRoute=require("./Routes/SellerProfileFromConsumerRoute") + +const adminRegistrationRoutes=require('./Routes/AdminRegistrationRoute') +const adminLoginRoutes=require('./Routes/AdminLoginRoute') +const adminProfileRoute=require('./Routes/AdminProfileRoute') +const adminProfileUpdateRoute=require('./Routes/AdminProfileUpdateRoute') +const adminConsumerListRoute=require('./Routes/AdminConsumerListRoute') +const adminSellerListRoute=require('./Routes/AdminSellerListRoute') +const adminBlockSellerRoute=require('./Routes/AdminSellerBlockRoute') +const adminBlockConsumerRoute=require('./Routes/AdminConsumerBlockRoute') +const makeBroadCastRoute=require('./Routes/MakeBroadcastRoute') +const viewBroadcastAdminRoute=require('./Routes/ViewBroadcastAdminRoute') +const viewallServicesRoute=require('./Routes/AdminTotalServiceRoute') +const AdminHistoryRoute=require('./Routes/AdminHistoryRoutes') +const AdminAllServiceRequest=require('./Routes/AdminRequestsListRoute') + + +const sellerRegistrationRoutes=require('./Routes/SellerRegistrationRoute') +const sellerLoginRoutes=require('./Routes/SellerLoginRoute') +const sellerProfileRoute=require('./Routes/SellerProfileRoute') +const sellerProfileUpdateRoute=require('./Routes/SellerProfileUpdateRoute') +const blockedconsumerlistRoute=require('./Routes/ConsumerBlockedListRoute') +const blockedsellerlistRoute=require('./Routes/SellerBlockedListRoute') +const unblockconsumerRoute=require('./Routes/UnblockConsumerRoute') +const unblocksellerRoute=require('./Routes/UnblockSellerRoute') +const SellerReviewViewRoute=require('./Routes/SellerReviewViewRoute') +const SellerHistoryRoute=require('./Routes/SellerHistoryRoute') +const SellerViewChatTileRoute=require('./Routes/SellerViewChatTileRoute') +const SellerViewChatRoute=require('./Routes/SellerViewChatRoute') +const SellerSendChatRoute=require('./Routes/SellerSendChatRoute') + + +const sellerServicesRouter = require('./Routes/SellerServiceRoute') +const GetService_SellerDetailsRouter = require('./Routes/GetService_SellerDetailsRouter') +const MakeRequestRouter = require('./Routes/MakeRequestRouter') +const PendingRequestRouter = require('./Routes/PendingRequestsRoute') +const AcceptedRequestRouter = require('./Routes/AcceptedRequestRoute') +const SellerViewCustomerRequestRoute = require('./Routes/SellerViewCustomerRequestRoute') +const SellerAcceptedRequestRoute = require('./Routes/SellerAcceptedRequestRoute') +const SellerDeleteRequestRoute = require('./Routes/SellerDeleteRequestRoute') +const CompleteRequestRouter = require('./Routes/CompleteRequestRouter') +const ConsumerViewServicesRoute = require('./Routes/ConsumerViewServicesRoute'); +const { default: mongoose } = require('mongoose'); + + +// cloudinary.config({ +// cloud_name: process.env.CLOUDNARY_API_NAME, +// api_key: process.env.CLOUDNARY_API_KEY, +// api_secret: process.env.CLOUDNARY_API_SECREAT, +// }); + + +// // Configure Multer to use Cloudinary as storage +// const storage = new CloudinaryStorage({ +// cloudinary: cloudinary, +// params: { +// folder: 'cover', // optional, destination folder in Cloudinary +// allowed_formats: ['jpg', 'jpeg', 'png'], // optional, allowed formats +// // other configuration options +// }, +// }) + +// const upload = Multer({ +// storage:storage +// }); + + + +connection(); + + + +app.use(express.json()) +app.use(cors()); +app.use(bodyparser.urlencoded({extended:false})) + +app.use(increment) + +app.use("/api/consumer/register",consumerRegistrationRoutes);//left +app.use("/api/consumer/login",consumerLoginRoute); +app.use("/api/consumer/profile",ConsumerProfileRoute); //left +app.use("/api/consumer/profile/update",ConsumerProfileUpdateRoute) //left +app.use('/api/customer/service', GetService_SellerDetailsRouter) +app.use("/api/consumer/sellerrating",ConsumerGivenSellerRatingRoute)//left to submit review +app.use("/api/consumer/viewbroadcast",ConsumerViewBroadcastRoute) +app.use("/api/consumer/sellerprofileview",SellerProfileConsumerRoute) +app.use("/api/consumer/sellerreview",SellerGivenConsumerRatingRoute) +app.use("/api/consumer/seller/optedservice",ServiceInfoConsumerRoute) +app.use("/api/consumer/pendingrequestdelete",pendingRequestDeleteRequestRoute) +app.use("/api/consumer/history",checkConsumerHistoryRoute) +app.use('/api/customer/completed', CompleteRequestRouter) +app.use('/api/customer/viewServices', ConsumerViewServicesRoute)//left +app.use('/api/customer/service', GetService_SellerDetailsRouter) +app.use('/api/customer/makerequest', MakeRequestRouter) +app.use('/api/customer/pendingrequests', PendingRequestRouter) +app.use('/api/customer/acceptedrequests', AcceptedRequestRouter) +app.use("/api/consumer/sendmessage",ConsumerChatSendRoute) +app.use("/api/consumer/history",checkConsumerHistoryRoute) +app.use("/api/consumer/readmessage",ConsumerChatReadRoute) +app.use('/api/consumer/payment',MakePaymentConsumer) +app.use('/api/consumer/transactionsave',TransactionHistoryRoute) +app.use('/api/consumer/transaction',TransactionConsumerRoute)//left + +app.use("/api/admin/register",adminRegistrationRoutes); +app.use("/api/admin/login",adminLoginRoutes); +app.use("/api/admin/profile",adminProfileRoute); +app.use("/api/admin/profile/update",adminProfileUpdateRoute); +app.use("/api/admin/consumerlist",adminConsumerListRoute) +app.use("/api/admin/sellerlist",adminSellerListRoute) +app.use("/api/admin/blockseller",adminBlockSellerRoute) +app.use("/api/admin/blockconsumer",adminBlockConsumerRoute) +app.use("/api/admin/blockedconsumerlist",blockedconsumerlistRoute) +app.use("/api/admin/blockedsellerlist",blockedsellerlistRoute) +app.use("/api/admin/unblockconsumer",unblockconsumerRoute) +app.use("/api/admin/unblockseller",unblocksellerRoute) +app.use("/api/admin/makebroadcast",makeBroadCastRoute) +app.use("/api/admin/broadcast/view",viewBroadcastAdminRoute)//left +app.use("/api/admin/totalservice",viewallServicesRoute) +app.use("/api/admin/history",AdminHistoryRoute) +app.use('/api/admin/transaction',TransactionAdminRoute) +app.use('/api/admin/allpendingrequest',AdminAllServiceRequest) + + + +app.use('/api/seller/transaction',TransactionSellerRoute) + +app.use("/api/seller/register",sellerRegistrationRoutes); +app.use("/api/seller/login",sellerLoginRoutes); +app.use("/api/seller/profile",sellerProfileRoute); +app.use("/api/seller/profile/update",sellerProfileUpdateRoute) +app.use("/api/seller/viewbroadcast",SellerViewBroadcastRoute) +app.use("/api/seller/review/route",SellerReviewViewRoute) + +app.use("/api/seller/history",SellerHistoryRoute) + +app.use('/api/seller/services', sellerServicesRouter) +app.use('/api/seller/viewrequests',SellerViewCustomerRequestRoute) +app.use('/api/seller/request/accepted',SellerAcceptedRequestRoute) +app.use('/api/seller/request/cancel',SellerDeleteRequestRoute) +app.use('/api/seller/chattile',SellerViewChatTileRoute) +app.use('/api/seller/viewchat',SellerViewChatRoute) +app.use('/api/seller/sendchat',SellerSendChatRoute) + +// var int = setInterval(()=>{ +// if (views != 0) { +// setTimeout(()=>{ +// mongoose.connection.close() +// clearInterval(int); +// }, 500) +// } +// }, 700) + +setTimeout(()=>{ + mongoose.connection.close() +}, 5000)