From e453f42e06cdc69b7cc9226699b0aa973c21b588 Mon Sep 17 00:00:00 2001 From: Raju Udava <86527202+dstala@users.noreply.github.com> Date: Fri, 3 Jun 2022 15:58:57 +0530 Subject: [PATCH] test: webhook Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com> --- package-lock.json | 448 +++++++++++++++++- package.json | 1 + .../nc-gui/components/apiClient/Headers.vue | 4 +- .../project/tableTabs/webhook/HttpWebhook.vue | 2 +- .../tableTabs/webhook/WebhookEditor.vue | 4 +- .../tableTabs/webhook/WebhookSlider.vue | 2 +- scripts/cypress/cypress.json | 1 + .../cypress/integration/common/8a_webhook.js | 393 ++++++++++++++- .../cypress/integration/test/pg-restMisc.js | 5 + scripts/cypress/integration/test/restMisc.js | 5 + .../cypress/integration/test/xcdb-restMisc.js | 6 + scripts/cypress/plugins/index.js | 45 +- scripts/cypress/plugins/server.js | 84 ++++ 13 files changed, 953 insertions(+), 47 deletions(-) create mode 100644 scripts/cypress/plugins/server.js diff --git a/package-lock.json b/package-lock.json index 3393d0c9bd..271529dd51 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2657,6 +2657,15 @@ "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "integrity": "sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==" }, + "accepts": { + "version": "1.3.8", + "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.8.tgz", + "integrity": "sha512-PYAthTa2m2VKxuvSD3DPC/Gy+U+sOA1LAuT8mkmRuvw+NACSaeXEQ+NHcVF7rONl6qcaxV3Uuemwawk+7+SJLw==", + "requires": { + "mime-types": "~2.1.34", + "negotiator": "0.6.3" + } + }, "adler-32": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/adler-32/-/adler-32-1.2.0.tgz", @@ -2821,6 +2830,11 @@ "integrity": "sha1-3wEKoSh+Fku9pvlyOwqWoexBh6E=", "dev": true }, + "array-flatten": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", + "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg==" + }, "array-ify": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/array-ify/-/array-ify-1.0.0.tgz", @@ -3022,6 +3036,61 @@ "integrity": "sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==", "dev": true }, + "body-parser": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.0.tgz", + "integrity": "sha512-DfJ+q6EPcGKZD1QWUjSpqp+Q7bDQTsQIF4zfUAtZ6qk+H/3/QRhg9CEp39ss+/T2vw0+HaidC0ecJj/DRLIaKg==", + "requires": { + "bytes": "3.1.2", + "content-type": "~1.0.4", + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "on-finished": "2.4.1", + "qs": "6.10.3", + "raw-body": "2.5.1", + "type-is": "~1.6.18", + "unpipe": "1.0.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" + }, + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "qs": { + "version": "6.10.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz", + "integrity": "sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==", + "requires": { + "side-channel": "^1.0.4" + } + } + } + }, "brace-expansion": { "version": "1.1.11", "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", @@ -3111,6 +3180,11 @@ "integrity": "sha512-/XuKeqWocKsYa/cBY1YbSJSWWqTi4cFgr9S6OyM7PBaPbr9zvNGwWP33vt0uqGhwDdN+y3yhbXVILEUpnwEWGw==", "dev": true }, + "bytes": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", + "integrity": "sha512-/Nf7TyzTx6S3yRJObOAV7956r8cr2+Oj8AC5dt8wSP3BQAoeX58NoHyCU8P8zGkNXStjTSi6fzO6F0pBdcYbEg==" + }, "cacache": { "version": "12.0.4", "resolved": "https://registry.npmjs.org/cacache/-/cacache-12.0.4.tgz", @@ -3189,7 +3263,6 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", - "dev": true, "requires": { "function-bind": "^1.1.1", "get-intrinsic": "^1.0.2" @@ -3834,6 +3907,26 @@ "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=" }, + "content-disposition": { + "version": "0.5.4", + "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", + "integrity": "sha512-FveZTNuGw04cxlAiWbzi6zTAL/lhehaWbTtgluJh4/E95DqMwTmha3KZN1aAWA8cFIhHzMZUvLevkw5Rqk+tSQ==", + "requires": { + "safe-buffer": "5.2.1" + }, + "dependencies": { + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + } + } + }, + "content-type": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", + "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" + }, "conventional-changelog-angular": { "version": "5.0.13", "resolved": "https://registry.npmjs.org/conventional-changelog-angular/-/conventional-changelog-angular-5.0.13.tgz", @@ -4109,6 +4202,16 @@ } } }, + "cookie": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", + "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==" + }, + "cookie-signature": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", + "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ==" + }, "copy-concurrently": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/copy-concurrently/-/copy-concurrently-1.0.5.tgz", @@ -4473,6 +4576,11 @@ "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==", "dev": true }, + "destroy": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", + "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==" + }, "detect-indent": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-5.0.0.tgz", @@ -4568,11 +4676,21 @@ "safer-buffer": "^2.1.0" } }, + "ee-first": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", + "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" + }, "emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==" + }, "encoding": { "version": "0.1.13", "resolved": "https://registry.npmjs.org/encoding/-/encoding-0.1.13.tgz", @@ -4685,6 +4803,11 @@ "es6-promise": "^4.0.3" } }, + "escape-html": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", + "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==" + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -4697,6 +4820,11 @@ "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==", "dev": true }, + "etag": { + "version": "1.8.1", + "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", + "integrity": "sha512-aIL5Fx7mawVa300al2BnEE4iNvo1qETxLrPI/o05L7z6go7fCw1J6EQmbK4FmJ2AS7kgVF/KEZWufBfdClMcPg==" + }, "eventemitter2": { "version": "6.4.5", "resolved": "https://registry.npmjs.org/eventemitter2/-/eventemitter2-6.4.5.tgz", @@ -4791,6 +4919,77 @@ } } }, + "express": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/express/-/express-4.18.1.tgz", + "integrity": "sha512-zZBcOX9TfehHQhtupq57OF8lFZ3UZi08Y97dwFCkD8p9d/d2Y3M+ykKcwaMDEL+4qyUolgBDX6AblpR3fL212Q==", + "requires": { + "accepts": "~1.3.8", + "array-flatten": "1.1.1", + "body-parser": "1.20.0", + "content-disposition": "0.5.4", + "content-type": "~1.0.4", + "cookie": "0.5.0", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "2.0.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "finalhandler": "1.2.0", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "merge-descriptors": "1.0.1", + "methods": "~1.1.2", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "path-to-regexp": "0.1.7", + "proxy-addr": "~2.0.7", + "qs": "6.10.3", + "range-parser": "~1.2.1", + "safe-buffer": "5.2.1", + "send": "0.18.0", + "serve-static": "1.15.0", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "type-is": "~1.6.18", + "utils-merge": "1.0.1", + "vary": "~1.1.2" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + }, + "qs": { + "version": "6.10.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.10.3.tgz", + "integrity": "sha512-wr7M2E0OFRfIfJZjKGieI8lBKb7fRCH4Fv5KNPEs7gJ8jadvotdsS08PzOKR7opXhZ/Xkjtt3WF9g38drmyRqQ==", + "requires": { + "side-channel": "^1.0.4" + } + }, + "safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==" + } + } + }, "extend": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", @@ -5061,6 +5260,35 @@ "integrity": "sha1-mzERErxsYSehbgFsbF1/GeCAXFs=", "dev": true }, + "finalhandler": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", + "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "requires": { + "debug": "2.6.9", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "on-finished": "2.4.1", + "parseurl": "~1.3.3", + "statuses": "2.0.1", + "unpipe": "~1.0.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + } + } + }, "find-replace": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-replace/-/find-replace-3.0.0.tgz", @@ -5120,6 +5348,11 @@ "mime-types": "^2.1.12" } }, + "forwarded": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz", + "integrity": "sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow==" + }, "frac": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/frac/-/frac-1.1.2.tgz", @@ -5135,6 +5368,11 @@ "map-cache": "^0.2.2" } }, + "fresh": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", + "integrity": "sha512-zJ2mQYM18rEFOudeV4GShTGIQ7RbzA7ozbU9I/XBpm7kqgMywgmylMwXHxZJmkVoYkna9d2pVXVXPdYTP9ej8Q==" + }, "from2": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/from2/-/from2-2.3.0.tgz", @@ -5198,8 +5436,7 @@ "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, "gauge": { "version": "2.7.4", @@ -5241,7 +5478,6 @@ "version": "1.1.1", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", - "dev": true, "requires": { "function-bind": "^1.1.1", "has": "^1.0.3", @@ -5835,7 +6071,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, "requires": { "function-bind": "^1.1.1" } @@ -5855,8 +6090,7 @@ "has-symbols": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "dev": true + "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" }, "has-tostringtag": { "version": "1.0.0", @@ -5916,6 +6150,25 @@ "integrity": "sha512-5ai2iksyV8ZXmnZhHH4rWPoxxistEexSi5936zIQ1bnNTW5VnA85B6P/VpXiRM017IgRvb2kKo1a//y+0wSp3w==", "dev": true }, + "http-errors": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", + "integrity": "sha512-FtwrG/euBzaEjYeRqOgly7G0qviiXoJWnvEH2Z1plBdXgbyjv34pHTSb9zoeHMyDy33+DWy5Wt9Wo+TURtOYSQ==", + "requires": { + "depd": "2.0.0", + "inherits": "2.0.4", + "setprototypeof": "1.2.0", + "statuses": "2.0.1", + "toidentifier": "1.0.1" + }, + "dependencies": { + "depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" + } + } + }, "http-proxy-agent": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/http-proxy-agent/-/http-proxy-agent-2.1.0.tgz", @@ -6295,6 +6548,11 @@ "resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz", "integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo=" }, + "ipaddr.js": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", + "integrity": "sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g==" + }, "is-accessor-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", @@ -7301,6 +7559,11 @@ "integrity": "sha1-/oWy7HWlkDfyrf7BAP1sYBdhFS4=", "dev": true }, + "media-typer": { + "version": "0.3.0", + "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", + "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==" + }, "meow": { "version": "8.1.2", "resolved": "https://registry.npmjs.org/meow/-/meow-8.1.2.tgz", @@ -7473,6 +7736,11 @@ } } }, + "merge-descriptors": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", + "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + }, "merge-stream": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", @@ -7485,6 +7753,11 @@ "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", "dev": true }, + "methods": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", + "integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w==" + }, "micromatch": { "version": "3.1.10", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", @@ -7506,17 +7779,20 @@ "to-regex": "^3.0.2" } }, + "mime": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", + "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" + }, "mime-db": { "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "dev": true + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" }, "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==", - "dev": true, "requires": { "mime-db": "1.52.0" } @@ -7876,8 +8152,7 @@ "negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", - "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==", - "optional": true + "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==" }, "neo-async": { "version": "2.6.2", @@ -8506,8 +8781,7 @@ "object-inspect": { "version": "1.12.0", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.0.tgz", - "integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==", - "dev": true + "integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==" }, "object-keys": { "version": "1.1.1", @@ -8568,6 +8842,14 @@ "integrity": "sha512-fZ4qZdQ2nxJvtcasX7Ghl+WlWS/d9IgnBIwFZXVNNZUmzpno91SX5bc5vuxiuKoCtK78XxGGNuSCrDC7xYB3OQ==", "dev": true }, + "on-finished": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.4.1.tgz", + "integrity": "sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==", + "requires": { + "ee-first": "1.1.1" + } + }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -8767,6 +9049,11 @@ "protocols": "^1.4.0" } }, + "parseurl": { + "version": "1.3.3", + "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", + "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" + }, "pascalcase": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", @@ -8802,6 +9089,11 @@ "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, + "path-to-regexp": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", + "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + }, "path-type": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", @@ -9007,6 +9299,15 @@ "genfun": "^5.0.0" } }, + "proxy-addr": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.7.tgz", + "integrity": "sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg==", + "requires": { + "forwarded": "0.2.0", + "ipaddr.js": "1.9.1" + } + }, "proxy-from-env": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.0.0.tgz", @@ -9093,6 +9394,32 @@ "integrity": "sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==", "dev": true }, + "range-parser": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", + "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" + }, + "raw-body": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz", + "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==", + "requires": { + "bytes": "3.1.2", + "http-errors": "2.0.0", + "iconv-lite": "0.4.24", + "unpipe": "1.0.0" + }, + "dependencies": { + "iconv-lite": { + "version": "0.4.24", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", + "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", + "requires": { + "safer-buffer": ">= 2.1.2 < 3" + } + } + } + }, "read": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/read/-/read-1.0.7.tgz", @@ -9550,11 +9877,64 @@ "integrity": "sha1-myzl094C0XxgEq0yaqa00M9U+U8=", "dev": true }, + "send": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", + "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "requires": { + "debug": "2.6.9", + "depd": "2.0.0", + "destroy": "1.2.0", + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "etag": "~1.8.1", + "fresh": "0.5.2", + "http-errors": "2.0.0", + "mime": "1.6.0", + "ms": "2.1.3", + "on-finished": "2.4.1", + "range-parser": "~1.2.1", + "statuses": "2.0.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + }, + "dependencies": { + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" + } + } + }, + "depd": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", + "integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==" + } + } + }, "seq-queue": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/seq-queue/-/seq-queue-0.0.5.tgz", "integrity": "sha1-1WgS4cAXpuTnw+Ojeh2m143TyT4=" }, + "serve-static": { + "version": "1.15.0", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", + "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "requires": { + "encodeurl": "~1.0.2", + "escape-html": "~1.0.3", + "parseurl": "~1.3.3", + "send": "0.18.0" + } + }, "set-blocking": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", @@ -9583,6 +9963,11 @@ } } }, + "setprototypeof": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", + "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==" + }, "shallow-clone": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", @@ -9611,7 +9996,6 @@ "version": "1.0.4", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", - "dev": true, "requires": { "call-bind": "^1.0.0", "get-intrinsic": "^1.0.2", @@ -10013,6 +10397,11 @@ } } }, + "statuses": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", + "integrity": "sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==" + }, "stream-connect": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/stream-connect/-/stream-connect-1.0.2.tgz", @@ -10409,6 +10798,11 @@ "repeat-string": "^1.6.1" } }, + "toidentifier": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz", + "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA==" + }, "tough-cookie": { "version": "2.5.0", "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", @@ -10461,6 +10855,15 @@ "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", "dev": true }, + "type-is": { + "version": "1.6.18", + "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", + "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", + "requires": { + "media-typer": "0.3.0", + "mime-types": "~2.1.24" + } + }, "typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", @@ -10559,6 +10962,11 @@ "integrity": "sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ==", "dev": true }, + "unpipe": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", + "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" + }, "unset-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", @@ -10646,6 +11054,11 @@ "object.getownpropertydescriptors": "^2.0.3" } }, + "utils-merge": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", + "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" + }, "uuid": { "version": "3.4.0", "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", @@ -10671,6 +11084,11 @@ "builtins": "^1.0.3" } }, + "vary": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", + "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" + }, "verror": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", diff --git a/package.json b/package.json index 1cd9a7d9d5..559c8d471b 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "stop:pg": "docker-compose -f ./scripts/cypress/docker-compose-pg.yml down" }, "dependencies": { + "express": "^4.18.1", "mysql2": "^2.3.3", "pg": "^8.7.3", "sqlite3": "^5.0.2" diff --git a/packages/nc-gui/components/apiClient/Headers.vue b/packages/nc-gui/components/apiClient/Headers.vue index 2f7cc1ff93..fe4dd13b30 100644 --- a/packages/nc-gui/components/apiClient/Headers.vue +++ b/packages/nc-gui/components/apiClient/Headers.vue @@ -32,7 +32,7 @@ ({{ paramsCount }}) - Headers Headers ({{ diff --git a/packages/nc-gui/components/project/tableTabs/webhook/WebhookEditor.vue b/packages/nc-gui/components/project/tableTabs/webhook/WebhookEditor.vue index d23c5262d8..b29d3285fb 100644 --- a/packages/nc-gui/components/project/tableTabs/webhook/WebhookEditor.vue +++ b/packages/nc-gui/components/project/tableTabs/webhook/WebhookEditor.vue @@ -2,7 +2,7 @@ @@ -181,7 +181,7 @@ v-model="hook.condition" dense hide-details - class="mt-1" + class="mt-1 nc-check-box-hook-condition" label="On Condition" /> diff --git a/packages/nc-gui/components/project/tableTabs/webhook/WebhookSlider.vue b/packages/nc-gui/components/project/tableTabs/webhook/WebhookSlider.vue index 832649e50d..86b39655ab 100644 --- a/packages/nc-gui/components/project/tableTabs/webhook/WebhookSlider.vue +++ b/packages/nc-gui/components/project/tableTabs/webhook/WebhookSlider.vue @@ -72,6 +72,6 @@ export default { diff --git a/scripts/cypress/cypress.json b/scripts/cypress/cypress.json index 745f35168f..57eb00a5fe 100644 --- a/scripts/cypress/cypress.json +++ b/scripts/cypress/cypress.json @@ -30,6 +30,7 @@ "retries": 0, "screenshotOnRunFailure": false, "numTestsKeptInMemory": 0, + "experimentalInteractiveRunEvents": true, "env": { "testMode": [ { "apiType": "rest", "dbType": "xcdb" }, diff --git a/scripts/cypress/integration/common/8a_webhook.js b/scripts/cypress/integration/common/8a_webhook.js index a8612fecbc..a1188be0e3 100644 --- a/scripts/cypress/integration/common/8a_webhook.js +++ b/scripts/cypress/integration/common/8a_webhook.js @@ -1,31 +1,374 @@ import { isTestSuiteActive } from "../../support/page_objects/projectConstants"; +import { mainPage } from "../../support/page_objects/mainPage"; +import { loginPage } from "../../support/page_objects/navigation"; -export const genTest = (apiType, dbType) => { - if (!isTestSuiteActive(apiType, dbType)) return; - describe(`Webhook`, () => { - before(() => {}); - after(() => {}); - - it("Create", () => { - // create an on-insert event webhook - // nc-btn-webhook - // nc-btn-create-webhook - }) - it("Verify trigger", () => {}) - it("Modify trigger event", () => {}) - it("Verify trigger", () => {}) - it("Delete trigger event", () => {}) - it("Verify trigger", () => {}) - - it("Create, with condition", () => {}) - it("Verify trigger", () => {}) - it("Modify trigger condition", () => {}) - it("Verify trigger", () => {}) - it("Delete trigger condition", () => {}) - it("Verify trigger", () => {}) - }) +// locally configured hook (server.js) +let hookPath = "http://localhost:9090/hook"; + +function createWebhook(hook, test) { + cy.get(".nc-btn-webhook").should("exist").click(); + cy.get(".nc-btn-create-webhook").should("exist").click(); + + // hardcode "Content-type: application/json" + cy.get(".nc-tab-hook-header").click({ force: true }); + cy.get(".nc-input-hook-header-key") + .should("exist") + .find("input") + .eq(0) + .clear({ force: true }) + .type("Content-Type", { force: true }); + cy.get(".nc-input-hook-header-value") + .should("exist") + .find("input") + .eq(0) + .clear({ force: true }) + .type("application/json", { force: true }); + + // common routine for both create & modify to configure hook + configureWebhook(hook, test); +} + +function deleteWebhook(index) { + cy.get(".nc-btn-webhook").should("exist").click(); + cy.get(".nc-hook-delete-icon").eq(index).click({ force: true }); + cy.get("body").type("{esc}"); +} + +function openWebhook(index) { + cy.get(".nc-btn-webhook").should("exist").click(); + cy.get(".nc-hook").eq(index).click({ force: true }); +} + +function configureWebhook(hook, test) { + // configure what ever is present. ignore rest + // currently works for only URL type + + if (hook?.title) { + cy.get(".nc-text-field-hook-title") + .should("exist") + .find("input") + .clear() + .type(hook.title); + } + + if (hook?.event) { + cy.get(".nc-text-field-hook-event").should("exist").click(); + cy.getActiveMenu() + .find(`[role="option"]`) + .contains(hook.event) + .should("exist") + .click(); + } + + if (hook?.url?.path) { + cy.get(".nc-text-field-hook-url-path") + .should("exist") + .find("input") + .clear() + .type(hook.url.path); + } + + if (hook?.deleteCondition === true) { + cy.get(".nc-filter-item-remove-btn") + .should("exist") + .click({ force: true }); + } + + if (hook?.condition) { + cy.get(".nc-check-box-hook-condition").should("exist").click(); + cy.get(".menu-filter-dropdown") + .last() + .find("button") + .contains("Add Filter") + .click(); + + cy.get(".nc-filter-field-select") + .should("exist") + .last() + .click() + .type(hook.condition.column); + + cy.getActiveMenu() + .find(`.nc-fld-${hook.condition.column}`) + .should("exist") + .click(); + cy.get(".nc-filter-operation-select").should("exist").last().click(); + + cy.getActiveMenu() + .find(`.v-list-item:contains(${hook.condition.operator})`) + .click(); + if ( + hook.condition.operator != "is null" && + hook.condition.operator != "is not null" + ) { + cy.get(".nc-filter-value-select input:text") + .should("exist") + .last() + .type(`${hook.condition.value}`); + cy.get(".nc-filter-operation-select").last().click(); + } + } + + if (test) { + cy.get(".nc-btn-webhook-test").should("exist").click(); + cy.toastWait("some text"); + } + + cy.get(".nc-btn-webhook-save").should("exist").click(); + cy.toastWait("some text"); + cy.get(".nc-icon-hook-navigate-left").should("exist").click(); + cy.get("body").type("{esc}"); +} + +function clearServerData() { + // clear stored data in server + cy.request("http://localhost:9090/hook/clear"); + + // ensure stored message count is 0 + cy.request("http://localhost:9090/hook/count").then((msg) => { + cy.log(msg.body); + expect(msg.body).to.equal(0); + }); +} + +function addNewRow(index, cellValue) { + cy.get(".nc-add-new-row-btn:visible").should("exist"); + cy.get(".nc-add-new-row-btn").click({ force: true }); + cy.get("#data-table-form-Title > input").first().type(cellValue); + cy.getActiveModal() + .find("button") + .contains("Save row") + .click({ force: true }); + + cy.toastWait("updated successfully"); + mainPage.getCell("Title", index).contains(cellValue).should("exist"); +} + +function updateRow(index, cellValue) { + mainPage.getRow(index).find(".nc-row-expand-icon").click({ force: true }); + cy.get("#data-table-form-Title > input").first().clear().type(cellValue); + cy.getActiveModal() + .find("button") + .contains("Save row") + .click({ force: true }); + + cy.toastWait("updated successfully"); } +function verifyHookTrigger(count, lastValue) { + cy.request("http://localhost:9090/hook/count").then((msg) => { + cy.log(msg.body); + expect(msg.body).to.equal(count); + }); + if (count) { + cy.request("http://localhost:9090/hook/last").then((msg) => { + cy.log(msg.body); + expect(msg.body.Title).to.equal(lastValue); + }); + } +} + +function deleteRow(index) { + mainPage.getCell("Title", index).rightclick({ force: true }); + + // delete row + cy.getActiveMenu() + .find('.v-list-item:contains("Delete Row")') + .first() + .click({ force: true }); +} + +export const genTest = (apiType, dbType) => { + if (!isTestSuiteActive(apiType, dbType)) return; + describe(`Webhook`, () => { + before(() => { + loginPage.loginAndOpenProject(apiType, dbType); + cy.createTable("Temp"); + }); + + after(() => { + cy.deleteTable("Temp"); + }); + + it("Create: 'After Insert' event", () => { + createWebhook({ + title: "hook-1", + event: "After Insert", + type: "URL", + url: { + method: "POST", + path: hookPath, + }, + }); + clearServerData(); + addNewRow(1, "Poole"); + verifyHookTrigger(1, "Poole"); + updateRow(1, "Delaware"); + verifyHookTrigger(1, "Poole"); + deleteRow(1); + verifyHookTrigger(1, "Poole"); + }); + + it("Add 'After Update' event", () => { + createWebhook({ + title: "hook-2", + event: "After Update", + type: "URL", + url: { + method: "POST", + path: hookPath, + }, + }); + clearServerData(); + addNewRow(1, "Poole"); + verifyHookTrigger(1, "Poole"); + updateRow(1, "Delaware"); + verifyHookTrigger(2, "Delaware"); + deleteRow(1); + verifyHookTrigger(2, "Delaware"); + }); + + it("Add 'After Delete' event", () => { + createWebhook({ + title: "hook-3", + event: "After Delete", + type: "URL", + url: { + method: "POST", + path: hookPath, + }, + }); + clearServerData(); + addNewRow(1, "Poole"); + verifyHookTrigger(1, "Poole"); + updateRow(1, "Delaware"); + verifyHookTrigger(2, "Delaware"); + deleteRow(1); + verifyHookTrigger(3, "Delaware"); + }); + + it("Modify webhook", () => { + openWebhook(0); + configureWebhook({ event: "After Delete" }); + openWebhook(1); + configureWebhook({ event: "After Delete" }); + + clearServerData(); + addNewRow(1, "Poole"); + verifyHookTrigger(0, ""); + updateRow(1, "Delaware"); + verifyHookTrigger(0, ""); + deleteRow(1); + verifyHookTrigger(3, "Delaware"); + }); + + it("Delete webhook", () => { + deleteWebhook(2); + deleteWebhook(1); + deleteWebhook(0); + + clearServerData(); + addNewRow(1, "Poole"); + verifyHookTrigger(0, ""); + updateRow(1, "Delaware"); + verifyHookTrigger(0, ""); + deleteRow(1); + verifyHookTrigger(0, ""); + }); + + it("Create, with condition", () => { + // create 3 webhooks with all three events, with condition this time + createWebhook({ + title: "hook-with-condition-1", + event: "After Insert", + type: "URL", + url: { + method: "POST", + path: hookPath, + }, + condition: { + column: "Title", + operator: "is like", + value: "Poole", + }, + }); + createWebhook({ + title: "hook-with-condition-2", + event: "After Update", + type: "URL", + url: { + method: "POST", + path: hookPath, + }, + condition: { + column: "Title", + operator: "is like", + value: "Poole", + }, + }); + createWebhook({ + title: "hook-with-condition-3", + event: "After Delete", + type: "URL", + url: { + method: "POST", + path: hookPath, + }, + condition: { + column: "Title", + operator: "is like", + value: "Poole", + }, + }); + + clearServerData(); + addNewRow(1, "Poole"); + addNewRow(2, "Delaware"); + verifyHookTrigger(1, "Poole"); + updateRow(1, "Delaware"); + updateRow(2, "Poole"); + verifyHookTrigger(2, "Poole"); + deleteRow(2); + deleteRow(1); + verifyHookTrigger(3, "Poole"); + }); + + it("Modify trigger condition", () => { + openWebhook(0); + configureWebhook({ deleteCondition: true }); + openWebhook(1); + configureWebhook({ deleteCondition: true }); + openWebhook(2); + configureWebhook({ deleteCondition: true }); + + clearServerData(); + addNewRow(1, "Poole"); + addNewRow(2, "Delaware"); + verifyHookTrigger(2, "Delaware"); + updateRow(1, "Delaware"); + updateRow(2, "Poole"); + verifyHookTrigger(4, "Poole"); + deleteRow(2); + deleteRow(1); + verifyHookTrigger(6, "Delaware"); + }); + + it("Delete trigger condition", () => { + deleteWebhook(2); + deleteWebhook(1); + deleteWebhook(0); + + clearServerData(); + addNewRow(1, "Poole"); + verifyHookTrigger(0, ""); + updateRow(1, "Delaware"); + verifyHookTrigger(0, ""); + deleteRow(1); + verifyHookTrigger(0, ""); + }); + }); +}; + /** * @copyright Copyright (c) 2021, Xgene Cloud Ltd * @@ -46,4 +389,4 @@ export const genTest = (apiType, dbType) => { * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . * - */ \ No newline at end of file + */ diff --git a/scripts/cypress/integration/test/pg-restMisc.js b/scripts/cypress/integration/test/pg-restMisc.js index b2691a3462..32d8e987f3 100644 --- a/scripts/cypress/integration/test/pg-restMisc.js +++ b/scripts/cypress/integration/test/pg-restMisc.js @@ -10,6 +10,7 @@ let t7a = require("../common/7a_create_project_from_excel"); const { setCurrentMode, } = require("../../support/page_objects/projectConstants"); +const t8a = require("../common/8a_webhook"); // use 0 as mode to execute individual files (debug mode, skip pre-configs) // use 1 mode if noco.db doesnt contain user credentials (full run over GIT) @@ -29,6 +30,10 @@ const nocoTestSuite = (apiType, dbType) => { // ncv2@fixme t6c.genTest(apiType, dbType); t6f.genTest(apiType, dbType); t6g.genTest(apiType, dbType); + + // webhook tests + t8a.genTest(apiType, dbType) + // **deletes created project, hence place it @ end t6e.genTest(apiType, dbType); diff --git a/scripts/cypress/integration/test/restMisc.js b/scripts/cypress/integration/test/restMisc.js index 40b7873b1b..ab500541d5 100644 --- a/scripts/cypress/integration/test/restMisc.js +++ b/scripts/cypress/integration/test/restMisc.js @@ -7,6 +7,7 @@ let t6e = require("../common/6e_project_operations"); let t6f = require("../common/6f_attachments"); let t6g = require("../common/6g_base_share"); let t7a = require("../common/7a_create_project_from_excel"); +let t8a = require("../common/8a_webhook") const { setCurrentMode, } = require("../../support/page_objects/projectConstants"); @@ -28,6 +29,10 @@ const nocoTestSuite = (apiType, dbType) => { // exclude@ncv2 t6c.genTest(apiType, dbType); t6f.genTest(apiType, dbType); t6g.genTest(apiType, dbType); + + // webhook tests + t8a.genTest(apiType, dbType) + // **deletes created project, hence place it @ end t6e.genTest(apiType, dbType); diff --git a/scripts/cypress/integration/test/xcdb-restMisc.js b/scripts/cypress/integration/test/xcdb-restMisc.js index da4fc83681..8517e7ec10 100644 --- a/scripts/cypress/integration/test/xcdb-restMisc.js +++ b/scripts/cypress/integration/test/xcdb-restMisc.js @@ -7,6 +7,8 @@ let t6e = require("../common/6e_project_operations"); let t6f = require("../common/6f_attachments"); let t6g = require("../common/6g_base_share"); let t7a = require("../common/7a_create_project_from_excel"); +let t8a = require("../common/8a_webhook") + const { setCurrentMode, } = require("../../support/page_objects/projectConstants"); @@ -30,6 +32,10 @@ const nocoTestSuite = (apiType, dbType) => { // t6c.genTest(apiType, dbType); t6f.genTest(apiType, dbType); t6g.genTest(apiType, dbType); + + // webhook tests + t8a.genTest(apiType, dbType) + // **deletes created project, hence place it @ end t6e.genTest(apiType, dbType); diff --git a/scripts/cypress/plugins/index.js b/scripts/cypress/plugins/index.js index 5a2c516783..56697819e7 100644 --- a/scripts/cypress/plugins/index.js +++ b/scripts/cypress/plugins/index.js @@ -15,7 +15,7 @@ const { rmdir } = require("fs"); // https://stackoverflow.com/questions/61934443/read-excel-files-in-cypress const readXlsx = require("./read-xlsx"); - +const makeServer = require('./server') /** * @type {Cypress.PluginConfig} */ @@ -66,6 +66,27 @@ module.exports = (on, config) => { return null; }, }); + + let server, port, close + + on('before:spec', async (spec) => { + // we can customize the server based on the spec about to run + const info = await makeServer() + // save the server instance information + server = info.server + port = info.port + close = info.close + console.log('started the server on port %d', port) + }) + + on('after:spec', async (spec) => { + if (!server) { + console.log('no server to close') + return + } + await close() + console.log('closed the server running on port %d', port) + }) }; // mysql connection @@ -168,3 +189,25 @@ function _pgExec(query) { client.end(); }); } + +/** + * @copyright Copyright (c) 2021, Xgene Cloud Ltd + * + * @author Raju Udava + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */ diff --git a/scripts/cypress/plugins/server.js b/scripts/cypress/plugins/server.js new file mode 100644 index 0000000000..7ba1fb264b --- /dev/null +++ b/scripts/cypress/plugins/server.js @@ -0,0 +1,84 @@ + +// https://glebbahmutov.com/blog/restart-server/ + +const express = require('express') +const bodyParser = require("body-parser") + +let request = [] + +function makeServer() { + const app = express() + app.use(bodyParser.json()) + + app.get("/hook/all", (req, res) => { + // console.log(request) + res.json(request) + }) + app.get("/hook/last", (req, res) => { + if(request.length) { + // console.log(request[request.length - 1]) + res.json(request[request.length - 1]) + } + }) + app.get("/hook/count", (req, res) => { + // console.log(request.length) + res.json(request.length) + }) + app.get("/hook/clear", (req, res) => { + request = [] + res.status(200).end() + }) + + app.post("/hook", (req, res) => { + request.push(req.body) + // console.log("/hook :: ", req.body) // Call your action on the request here + res.status(200).end() // Responding is important + }) + + app.post("/stop", (req, res) => { + process.exit(); + }) + + const port = 9090 + + return new Promise((resolve) => { + const server = app.listen(port, function () { + const port = server.address().port + console.log('Example app listening at port %d', port) + + // close the server + const close = () => { + return new Promise((resolve) => { + console.log('closing server') + server.close(resolve) + }) + } + + resolve({ server, port, close }) + }) + }) +} + +module.exports = makeServer + +/** + * @copyright Copyright (c) 2021, Xgene Cloud Ltd + * + * @author Raju Udava + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + * + */