From 3797b40641599c318e7e07d653710b9eb42d819e Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Tue, 7 Mar 2023 11:03:19 -0600 Subject: [PATCH 01/14] PR-579798: Adding Component cypress testing. --- .eslintignore | 1 + .github/workflows/npm-publish.yml | 13 +- .github/workflows/npm-test.yml | 13 +- cypress.config.ts | 13 + cypress/support/component-index.html | 13 + cypress/support/component.ts | 42 ++ package-lock.json | 479 ++++++++++++++++++ package.json | 6 +- .../components/__tests__/App.test.cy.tsx | 16 + webpack.cy.config.ts | 114 +++++ 10 files changed, 706 insertions(+), 4 deletions(-) create mode 100644 cypress/support/component-index.html create mode 100644 cypress/support/component.ts create mode 100644 src/frontend/components/__tests__/App.test.cy.tsx create mode 100644 webpack.cy.config.ts diff --git a/.eslintignore b/.eslintignore index 1a4da11..8a28323 100644 --- a/.eslintignore +++ b/.eslintignore @@ -4,6 +4,7 @@ build webpack.config.ts webpack.config.dev.ts webpack.config.dev.server.ts +webpack.cy.config.ts #Service Worker service-worker.ts serviceWorkerRegistration.ts \ No newline at end of file diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index bc729d0..bc0b04b 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -28,8 +28,19 @@ jobs: with: build: npm run build start: npm start + cypress-run-component: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + # Install NPM dependencies, cache them correctly + # and run all Cypress tests + - name: Cypress run + uses: cypress-io/github-action@v5 # use the explicit version number + with: + component: true publish-npm: - needs: [ build, cypress-run ] + needs: [ test, cypress-run, cypress-run-component ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/.github/workflows/npm-test.yml b/.github/workflows/npm-test.yml index 657252c..66a7d24 100644 --- a/.github/workflows/npm-test.yml +++ b/.github/workflows/npm-test.yml @@ -34,8 +34,19 @@ jobs: with: build: npm run build start: npm start + cypress-run-component: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + # Install NPM dependencies, cache them correctly + # and run all Cypress tests + - name: Cypress run + uses: cypress-io/github-action@v5 # use the explicit version number + with: + component: true test-build-package: - needs: [ test, cypress-run ] + needs: [ test, cypress-run, cypress-run-component ] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 diff --git a/cypress.config.ts b/cypress.config.ts index 2282812..7006ebb 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -1,4 +1,6 @@ import { defineConfig } from 'cypress'; +import webpackConfig from './webpack.cy.config'; + export default defineConfig({ env: {}, e2e: { @@ -9,4 +11,15 @@ export default defineConfig({ specPattern: 'cypress/e2e/**/*.{js,jsx,ts,tsx}', experimentalRunAllSpecs: true, }, + component: { + specPattern: 'src/**/*.cy.{js,jsx,ts,tsx}', + devServer: { + framework: 'react', + bundler: 'webpack', + webpackConfig: webpackConfig, + }, + viewportWidth: 1280, + viewportHeight: 720, + fileServerFolder: 'public', + } }); diff --git a/cypress/support/component-index.html b/cypress/support/component-index.html new file mode 100644 index 0000000..f87366e --- /dev/null +++ b/cypress/support/component-index.html @@ -0,0 +1,13 @@ + + + + + + + + Components App + + +
+ + \ No newline at end of file diff --git a/cypress/support/component.ts b/cypress/support/component.ts new file mode 100644 index 0000000..258a8bc --- /dev/null +++ b/cypress/support/component.ts @@ -0,0 +1,42 @@ +// *********************************************************** +// This example support/component.ts is processed and +// loaded automatically before your test files. +// +// This is a great place to put global configuration and +// behavior that modifies Cypress. +// +// You can change the location of this file or turn off +// automatically serving support files with the +// 'supportFile' configuration option. +// +// You can read more here: +// https://on.cypress.io/configuration +// *********************************************************** + +//Importing global styles +import '../../src/frontend/styles/global.scss'; + +// Import commands.js using ES2015 syntax: +import './commands' + +// Alternatively you can use CommonJS syntax: +// require('./commands') + +import { mount } from 'cypress/react18' + +// Augment the Cypress namespace to include type definitions for +// your custom command. +// Alternatively, can be defined in cypress/support/component.d.ts +// with a at the top of your spec. +declare global { + namespace Cypress { + interface Chainable { + mount: typeof mount + } + } +} + +Cypress.Commands.add('mount', mount) + +// Example use: +// cy.mount() \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 18b167d..1235c13 100644 --- a/package-lock.json +++ b/package-lock.json @@ -70,6 +70,7 @@ "eslint-plugin-react": "^7.32.2", "eslint-webpack-plugin": "^4.0.0", "file-loader": "^6.2.0", + "html-webpack-plugin": "^5.5.0", "identity-obj-proxy": "^3.0.0", "jest": "^29.5.0", "jest-environment-jsdom": "^29.5.0", @@ -3555,6 +3556,12 @@ "hoist-non-react-statics": "^3.3.0" } }, + "node_modules/@types/html-minifier-terser": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz", + "integrity": "sha512-oh/6byDPnL1zeNXFrDXFLyZjkr1MsBG667IM792caf1L2UPOOMf65NFzjUH/ltyfwjAGfs1rsX1eftK0jC/KIg==", + "dev": true + }, "node_modules/@types/http-proxy": { "version": "1.17.9", "resolved": "https://registry.npmjs.org/@types/http-proxy/-/http-proxy-1.17.9.tgz", @@ -5355,6 +5362,22 @@ "node": ">=6" } }, + "node_modules/camel-case": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", + "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", + "dev": true, + "dependencies": { + "pascal-case": "^3.1.2", + "tslib": "^2.0.3" + } + }, + "node_modules/camel-case/node_modules/tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "dev": true + }, "node_modules/camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", @@ -5487,6 +5510,27 @@ "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==", "dev": true }, + "node_modules/clean-css": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.2.tgz", + "integrity": "sha512-JVJbM+f3d3Q704rF4bqQ5UUyTtuJ0JRKNbTKVEeujCCBoMdkEi+V+e8oktO9qGQNSvHrFTM6JZRXrUvGR1czww==", + "dev": true, + "dependencies": { + "source-map": "~0.6.0" + }, + "engines": { + "node": ">= 10.0" + } + }, + "node_modules/clean-css/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/clean-stack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", @@ -6901,6 +6945,15 @@ "integrity": "sha512-NMt+m9zFMPZe0JcY9gN224Qvk6qLIdqex29clBvc/y75ZBX9YA9wNK3frsYvu2DI1xcCIwxwnX+TlsJ2DSOADg==", "dev": true }, + "node_modules/dom-converter": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/dom-converter/-/dom-converter-0.2.0.tgz", + "integrity": "sha512-gd3ypIPfOMr9h5jIKq8E3sHOTCjeirnl0WK5ZdS1AW0Odt0b1PaWaHdJ4Qk4klv+YB9aJBS7mESXjFoDQPu6DA==", + "dev": true, + "dependencies": { + "utila": "~0.4" + } + }, "node_modules/dom-serializer": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", @@ -6968,6 +7021,22 @@ "url": "https://github.com/fb55/domutils?sponsor=1" } }, + "node_modules/dot-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", + "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", + "dev": true, + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/dot-case/node_modules/tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "dev": true + }, "node_modules/dotenv": { "version": "16.0.3", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", @@ -8720,6 +8789,15 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true, + "bin": { + "he": "bin/he" + } + }, "node_modules/helmet": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/helmet/-/helmet-6.0.1.tgz", @@ -8809,6 +8887,78 @@ "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", "dev": true }, + "node_modules/html-minifier-terser": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz", + "integrity": "sha512-YXxSlJBZTP7RS3tWnQw74ooKa6L9b9i9QYXY21eUEvhZ3u9XLfv6OnFsQq6RxkhHygsaUMvYsZRV5rU/OVNZxw==", + "dev": true, + "dependencies": { + "camel-case": "^4.1.2", + "clean-css": "^5.2.2", + "commander": "^8.3.0", + "he": "^1.2.0", + "param-case": "^3.0.4", + "relateurl": "^0.2.7", + "terser": "^5.10.0" + }, + "bin": { + "html-minifier-terser": "cli.js" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/html-minifier-terser/node_modules/commander": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", + "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", + "dev": true, + "engines": { + "node": ">= 12" + } + }, + "node_modules/html-webpack-plugin": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-5.5.0.tgz", + "integrity": "sha512-sy88PC2cRTVxvETRgUHFrL4No3UxvcH8G1NepGhqaTT+GXN2kTamqasot0inS5hXeg1cMbFDt27zzo9p35lZVw==", + "dev": true, + "dependencies": { + "@types/html-minifier-terser": "^6.0.0", + "html-minifier-terser": "^6.0.2", + "lodash": "^4.17.21", + "pretty-error": "^4.0.0", + "tapable": "^2.0.0" + }, + "engines": { + "node": ">=10.13.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/html-webpack-plugin" + }, + "peerDependencies": { + "webpack": "^5.20.0" + } + }, + "node_modules/htmlparser2": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz", + "integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==", + "dev": true, + "funding": [ + "https://github.com/fb55/htmlparser2?sponsor=1", + { + "type": "github", + "url": "https://github.com/sponsors/fb55" + } + ], + "dependencies": { + "domelementtype": "^2.0.1", + "domhandler": "^4.0.0", + "domutils": "^2.5.2", + "entities": "^2.0.0" + } + }, "node_modules/http-deceiver": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz", @@ -12347,6 +12497,21 @@ "loose-envify": "cli.js" } }, + "node_modules/lower-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", + "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", + "dev": true, + "dependencies": { + "tslib": "^2.0.3" + } + }, + "node_modules/lower-case/node_modules/tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "dev": true + }, "node_modules/lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -12680,6 +12845,22 @@ "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" }, + "node_modules/no-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", + "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", + "dev": true, + "dependencies": { + "lower-case": "^2.0.2", + "tslib": "^2.0.3" + } + }, + "node_modules/no-case/node_modules/tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "dev": true + }, "node_modules/node-fetch": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", @@ -13047,6 +13228,22 @@ "node": ">=6" } }, + "node_modules/param-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", + "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", + "dev": true, + "dependencies": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/param-case/node_modules/tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "dev": true + }, "node_modules/parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -13109,6 +13306,22 @@ "node": ">= 0.8" } }, + "node_modules/pascal-case": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", + "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", + "dev": true, + "dependencies": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + } + }, + "node_modules/pascal-case/node_modules/tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "dev": true + }, "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -13823,6 +14036,16 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/pretty-error": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-4.0.0.tgz", + "integrity": "sha512-AoJ5YMAcXKYxKhuJGdcvse+Voc6v1RgnsR3nWcYU7q4t6z0Q6T86sv5Zq8VIRbOWWFpvdGE83LtdSMNd+6Y0xw==", + "dev": true, + "dependencies": { + "lodash": "^4.17.20", + "renderkid": "^3.0.0" + } + }, "node_modules/pretty-format": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", @@ -14304,6 +14527,28 @@ "jsesc": "bin/jsesc" } }, + "node_modules/relateurl": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz", + "integrity": "sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==", + "dev": true, + "engines": { + "node": ">= 0.10" + } + }, + "node_modules/renderkid": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/renderkid/-/renderkid-3.0.0.tgz", + "integrity": "sha512-q/7VIQA8lmM1hF+jn+sFSPWGlMkSAeNYcPLmDQx2zzuiDfaLrOmumR8iaUKlenFgh0XRPIUeSPlH3A+AW3Z5pg==", + "dev": true, + "dependencies": { + "css-select": "^4.1.3", + "dom-converter": "^0.2.0", + "htmlparser2": "^6.1.0", + "lodash": "^4.17.21", + "strip-ansi": "^6.0.1" + } + }, "node_modules/request-progress": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/request-progress/-/request-progress-3.0.0.tgz", @@ -15944,6 +16189,12 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "node_modules/utila": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/utila/-/utila-0.4.0.tgz", + "integrity": "sha512-Z0DbgELS9/L/75wZbro8xAnT50pBVFQZ+hUEueGDU5FN51YSCYM+jdxsfCiHjwNP/4LCDD0i/graKpeBnOXKRA==", + "dev": true + }, "node_modules/utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", @@ -19596,6 +19847,12 @@ "hoist-non-react-statics": "^3.3.0" } }, + "@types/html-minifier-terser": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@types/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz", + "integrity": "sha512-oh/6byDPnL1zeNXFrDXFLyZjkr1MsBG667IM792caf1L2UPOOMf65NFzjUH/ltyfwjAGfs1rsX1eftK0jC/KIg==", + "dev": true + }, "@types/http-proxy": { "version": "1.17.9", "resolved": "https://registry.npmjs.org/@types/http-proxy/-/http-proxy-1.17.9.tgz", @@ -20977,6 +21234,24 @@ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true }, + "camel-case": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/camel-case/-/camel-case-4.1.2.tgz", + "integrity": "sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==", + "dev": true, + "requires": { + "pascal-case": "^3.1.2", + "tslib": "^2.0.3" + }, + "dependencies": { + "tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "dev": true + } + } + }, "camelcase": { "version": "5.3.1", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", @@ -21072,6 +21347,23 @@ "integrity": "sha512-cOU9usZw8/dXIXKtwa8pM0OTJQuJkxMN6w30csNRUerHfeQ5R6U3kkU/FtJeIf3M202OHfY2U8ccInBG7/xogA==", "dev": true }, + "clean-css": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-5.3.2.tgz", + "integrity": "sha512-JVJbM+f3d3Q704rF4bqQ5UUyTtuJ0JRKNbTKVEeujCCBoMdkEi+V+e8oktO9qGQNSvHrFTM6JZRXrUvGR1czww==", + "dev": true, + "requires": { + "source-map": "~0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } + } + }, "clean-stack": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", @@ -22106,6 +22398,15 @@ "integrity": "sha512-NMt+m9zFMPZe0JcY9gN224Qvk6qLIdqex29clBvc/y75ZBX9YA9wNK3frsYvu2DI1xcCIwxwnX+TlsJ2DSOADg==", "dev": true }, + "dom-converter": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/dom-converter/-/dom-converter-0.2.0.tgz", + "integrity": "sha512-gd3ypIPfOMr9h5jIKq8E3sHOTCjeirnl0WK5ZdS1AW0Odt0b1PaWaHdJ4Qk4klv+YB9aJBS7mESXjFoDQPu6DA==", + "dev": true, + "requires": { + "utila": "~0.4" + } + }, "dom-serializer": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.4.1.tgz", @@ -22152,6 +22453,24 @@ "domhandler": "^4.2.0" } }, + "dot-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/dot-case/-/dot-case-3.0.4.tgz", + "integrity": "sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==", + "dev": true, + "requires": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + }, + "dependencies": { + "tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "dev": true + } + } + }, "dotenv": { "version": "16.0.3", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", @@ -23465,6 +23784,12 @@ "has-symbols": "^1.0.2" } }, + "he": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", + "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", + "dev": true + }, "helmet": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/helmet/-/helmet-6.0.1.tgz", @@ -23552,6 +23877,54 @@ "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", "dev": true }, + "html-minifier-terser": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/html-minifier-terser/-/html-minifier-terser-6.1.0.tgz", + "integrity": "sha512-YXxSlJBZTP7RS3tWnQw74ooKa6L9b9i9QYXY21eUEvhZ3u9XLfv6OnFsQq6RxkhHygsaUMvYsZRV5rU/OVNZxw==", + "dev": true, + "requires": { + "camel-case": "^4.1.2", + "clean-css": "^5.2.2", + "commander": "^8.3.0", + "he": "^1.2.0", + "param-case": "^3.0.4", + "relateurl": "^0.2.7", + "terser": "^5.10.0" + }, + "dependencies": { + "commander": { + "version": "8.3.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-8.3.0.tgz", + "integrity": "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==", + "dev": true + } + } + }, + "html-webpack-plugin": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/html-webpack-plugin/-/html-webpack-plugin-5.5.0.tgz", + "integrity": "sha512-sy88PC2cRTVxvETRgUHFrL4No3UxvcH8G1NepGhqaTT+GXN2kTamqasot0inS5hXeg1cMbFDt27zzo9p35lZVw==", + "dev": true, + "requires": { + "@types/html-minifier-terser": "^6.0.0", + "html-minifier-terser": "^6.0.2", + "lodash": "^4.17.21", + "pretty-error": "^4.0.0", + "tapable": "^2.0.0" + } + }, + "htmlparser2": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.1.0.tgz", + "integrity": "sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==", + "dev": true, + "requires": { + "domelementtype": "^2.0.1", + "domhandler": "^4.0.0", + "domutils": "^2.5.2", + "entities": "^2.0.0" + } + }, "http-deceiver": { "version": "1.2.7", "resolved": "https://registry.npmjs.org/http-deceiver/-/http-deceiver-1.2.7.tgz", @@ -26157,6 +26530,23 @@ "js-tokens": "^3.0.0 || ^4.0.0" } }, + "lower-case": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/lower-case/-/lower-case-2.0.2.tgz", + "integrity": "sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==", + "dev": true, + "requires": { + "tslib": "^2.0.3" + }, + "dependencies": { + "tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "dev": true + } + } + }, "lru-cache": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", @@ -26407,6 +26797,24 @@ "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.6.2.tgz", "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==" }, + "no-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/no-case/-/no-case-3.0.4.tgz", + "integrity": "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==", + "dev": true, + "requires": { + "lower-case": "^2.0.2", + "tslib": "^2.0.3" + }, + "dependencies": { + "tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "dev": true + } + } + }, "node-fetch": { "version": "2.6.7", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", @@ -26672,6 +27080,24 @@ "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" }, + "param-case": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/param-case/-/param-case-3.0.4.tgz", + "integrity": "sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==", + "dev": true, + "requires": { + "dot-case": "^3.0.4", + "tslib": "^2.0.3" + }, + "dependencies": { + "tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "dev": true + } + } + }, "parent-module": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", @@ -26715,6 +27141,24 @@ "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" }, + "pascal-case": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/pascal-case/-/pascal-case-3.1.2.tgz", + "integrity": "sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==", + "dev": true, + "requires": { + "no-case": "^3.0.4", + "tslib": "^2.0.3" + }, + "dependencies": { + "tslib": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "dev": true + } + } + }, "path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", @@ -27178,6 +27622,16 @@ "integrity": "sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg==", "dev": true }, + "pretty-error": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/pretty-error/-/pretty-error-4.0.0.tgz", + "integrity": "sha512-AoJ5YMAcXKYxKhuJGdcvse+Voc6v1RgnsR3nWcYU7q4t6z0Q6T86sv5Zq8VIRbOWWFpvdGE83LtdSMNd+6Y0xw==", + "dev": true, + "requires": { + "lodash": "^4.17.20", + "renderkid": "^3.0.0" + } + }, "pretty-format": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-27.5.1.tgz", @@ -27526,6 +27980,25 @@ } } }, + "relateurl": { + "version": "0.2.7", + "resolved": "https://registry.npmjs.org/relateurl/-/relateurl-0.2.7.tgz", + "integrity": "sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==", + "dev": true + }, + "renderkid": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/renderkid/-/renderkid-3.0.0.tgz", + "integrity": "sha512-q/7VIQA8lmM1hF+jn+sFSPWGlMkSAeNYcPLmDQx2zzuiDfaLrOmumR8iaUKlenFgh0XRPIUeSPlH3A+AW3Z5pg==", + "dev": true, + "requires": { + "css-select": "^4.1.3", + "dom-converter": "^0.2.0", + "htmlparser2": "^6.1.0", + "lodash": "^4.17.21", + "strip-ansi": "^6.0.1" + } + }, "request-progress": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/request-progress/-/request-progress-3.0.0.tgz", @@ -28715,6 +29188,12 @@ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=", "dev": true }, + "utila": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/utila/-/utila-0.4.0.tgz", + "integrity": "sha512-Z0DbgELS9/L/75wZbro8xAnT50pBVFQZ+hUEueGDU5FN51YSCYM+jdxsfCiHjwNP/4LCDD0i/graKpeBnOXKRA==", + "dev": true + }, "utils-merge": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", diff --git a/package.json b/package.json index f586a82..e6a894d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@aleleba/create-react-ssr", - "version": "3.8.2", + "version": "3.9.0", "description": "Starter Kit of server side render of react", "bin": "./bin/cli.js", "main": "src/server/index", @@ -15,7 +15,8 @@ "test:watch": "jest --watch", "check-updates": "npx npm-check-updates -u && npm i", "cy:open": "npx cypress open", - "cy:run": "cypress run" + "cy:run": "cypress run", + "cy:run-component": "npx cypress run --headless --component" }, "repository": { "type": "git", @@ -93,6 +94,7 @@ "eslint-plugin-react": "^7.32.2", "eslint-webpack-plugin": "^4.0.0", "file-loader": "^6.2.0", + "html-webpack-plugin": "^5.5.0", "identity-obj-proxy": "^3.0.0", "jest": "^29.5.0", "jest-environment-jsdom": "^29.5.0", diff --git a/src/frontend/components/__tests__/App.test.cy.tsx b/src/frontend/components/__tests__/App.test.cy.tsx new file mode 100644 index 0000000..face8a4 --- /dev/null +++ b/src/frontend/components/__tests__/App.test.cy.tsx @@ -0,0 +1,16 @@ +import React from 'react'; +import { ProviderMock } from '@mocks'; +import App from '@components/App'; + +describe('Testing Card Component', () => { + beforeEach(() => { + cy.mount( + + + + ); + }); + it('Show Text', () => { + cy.get('p').contains('Edit src/frontend/InitialComponent.jsx and save to reload.'); + }); +}); diff --git a/webpack.cy.config.ts b/webpack.cy.config.ts new file mode 100644 index 0000000..4083483 --- /dev/null +++ b/webpack.cy.config.ts @@ -0,0 +1,114 @@ +import path from 'path'; +import fs from 'fs'; +import webpack from 'webpack'; +import * as dotenv from 'dotenv'; +import HtmlWebpackPlugin from 'html-webpack-plugin'; +import MiniCssExtractPlugin from 'mini-css-extract-plugin'; +import { CleanWebpackPlugin } from 'clean-webpack-plugin'; +import CssMinimizerPlugin from 'css-minimizer-webpack-plugin'; +import TerserPlugin from 'terser-webpack-plugin'; +import ESLintPlugin from 'eslint-webpack-plugin'; +import CopyPlugin from 'copy-webpack-plugin'; +import { resolveTsAliases } from 'resolve-ts-aliases'; + +const dotEnvToParse = dotenv.config(); +const externalCss = process.env.EXTERNAL_CSS === 'true' ? true : false; +const externalCssName = process.env.EXTERNAL_CSS_NAME ? process.env.EXTERNAL_CSS_NAME : 'index.css'; +const alias = resolveTsAliases(path.resolve('tsconfig.json')); +const isWin = process.platform === 'win32'; + +const copyPatterns: {from: string, to: string}[] = []; + +let copyFromUrl = `${path.resolve(__dirname)}/public/img`; +let copyFromUrlWin = `${path.resolve(__dirname)}\\public\\img`; +let copyToUrl = 'assets/img'; +let copyToUrlWin = 'assets\\img'; + +if(isWin){ + if(fs.existsSync(copyFromUrlWin)){ + copyPatterns.push({ + from: copyFromUrlWin, to: copyToUrlWin, + }); + } +}else{ + if(fs.existsSync(copyFromUrl)){ + copyPatterns.push({ + from: copyFromUrl, to: copyToUrl, + }); + } +} + +export default { + entry: './src/frontend/components/index.tsx', + resolve: { + extensions: ['.js', '.jsx','.ts','.tsx', '.json'], + alias, + }, + mode: 'development', + output: { + path: path.resolve(__dirname, 'build'), + }, + target: 'web', + plugins: [ + new CleanWebpackPlugin(), + ...(externalCss === true ? [ + new MiniCssExtractPlugin({ + filename: externalCssName, + }), + ] : []), + new webpack.DefinePlugin({ + 'process.env': JSON.stringify(dotEnvToParse.parsed), + }), + new ESLintPlugin(), + new CopyPlugin({ + patterns: copyPatterns + }), + new HtmlWebpackPlugin({ + template: path.join(__dirname, 'build', 'index.html'), + }), + new webpack.ProvidePlugin({ + React: 'react', + }), + ], + module: { + rules: [ + { + test: /\.(js|jsx|ts|tsx)$/, + exclude: /node_modules/, + use: { + loader: 'babel-loader', + }, + }, + { + test: /\.(css|sass|scss)$/, + use: [ + externalCss === true ? MiniCssExtractPlugin.loader : 'style-loader', + 'css-loader', + 'sass-loader', + ], + }, + { + test: /\.(png|jpg|jpeg|gif|svg|ico|mp4|avi|ttf|otf|eot|woff|woff2|pdf)$/, + loader: 'file-loader', + options: { + name: 'assets/[name].[ext]', + }, + }, + { + test: /\.(ttf|otf|eot|woff|woff2)$/, + loader: 'url-loader', + options: { + name: 'assets/fonts/[name].[ext]', + esModule: false, + }, + }, + ] + }, + optimization: { + minimize: true, + minimizer: [ + new CssMinimizerPlugin(), + new TerserPlugin(), + ], + }, +}; From 7f15b775ba36b5a63db9c8ec8aa1f191addd1943 Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Tue, 7 Mar 2023 11:11:45 -0600 Subject: [PATCH 02/14] PR-579798: Fixing unit testing. --- jest.config.js | 1 + 1 file changed, 1 insertion(+) diff --git a/jest.config.js b/jest.config.js index 9c410cf..f94867b 100644 --- a/jest.config.js +++ b/jest.config.js @@ -7,6 +7,7 @@ const aliases = pathsToModuleNameMapper(compilerOptions.paths, { module.exports = { setupFilesAfterEnv: ['/setupTest.ts'], + testPathIgnorePatterns: ['/node_modules/', '\\.cy.(js|jsx|ts|tsx)$'], testEnvironment: 'jsdom', moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json'], modulePathIgnorePatterns: ['/cypress/'], From 220e48857074cfc95cc622e32632d14b340e8b28 Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Tue, 7 Mar 2023 11:26:35 -0600 Subject: [PATCH 03/14] PR-579798: trying to fix Cypress component testing. --- .gitignore | 4 +++- package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 6a24f03..ef29dc1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,6 @@ node_modules #.envs .env #builds -build \ No newline at end of file +build +#cypress +cypress/videos \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 1235c13..8472d51 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@aleleba/create-react-ssr", - "version": "3.8.2", + "version": "3.9.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@aleleba/create-react-ssr", - "version": "3.8.2", + "version": "3.9.0", "license": "MIT", "dependencies": { "@babel/register": "^7.21.0", diff --git a/package.json b/package.json index e6a894d..6dffb73 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "check-updates": "npx npm-check-updates -u && npm i", "cy:open": "npx cypress open", "cy:run": "cypress run", - "cy:run-component": "npx cypress run --headless --component" + "cy:run-component": "cypress run --headless --component" }, "repository": { "type": "git", From 69fa169a718e6462d8e81a9e7efc67e2af59d626 Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Tue, 7 Mar 2023 11:39:02 -0600 Subject: [PATCH 04/14] PR-579798: trying to fix Cypress component testing. --- .github/workflows/npm-publish.yml | 3 +++ .github/workflows/npm-test.yml | 3 +++ 2 files changed, 6 insertions(+) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index bc0b04b..8e7f206 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -35,9 +35,12 @@ jobs: uses: actions/checkout@v3 # Install NPM dependencies, cache them correctly # and run all Cypress tests + - name: Cypress install + run: npm i - name: Cypress run uses: cypress-io/github-action@v5 # use the explicit version number with: + install: false component: true publish-npm: needs: [ test, cypress-run, cypress-run-component ] diff --git a/.github/workflows/npm-test.yml b/.github/workflows/npm-test.yml index 66a7d24..ea83c0c 100644 --- a/.github/workflows/npm-test.yml +++ b/.github/workflows/npm-test.yml @@ -41,9 +41,12 @@ jobs: uses: actions/checkout@v3 # Install NPM dependencies, cache them correctly # and run all Cypress tests + - name: Cypress install + run: npm i - name: Cypress run uses: cypress-io/github-action@v5 # use the explicit version number with: + install: false component: true test-build-package: needs: [ test, cypress-run, cypress-run-component ] From bac407a59bffca5cb3ce3e02af9e34e4cf9f2730 Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Tue, 7 Mar 2023 11:45:13 -0600 Subject: [PATCH 05/14] PR-579798: trying to fix Cypress component testing. --- .github/workflows/npm-publish.yml | 3 --- .github/workflows/npm-test.yml | 3 --- webpack.cy.config.ts | 24 ++++++------------------ 3 files changed, 6 insertions(+), 24 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 8e7f206..bc0b04b 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -35,12 +35,9 @@ jobs: uses: actions/checkout@v3 # Install NPM dependencies, cache them correctly # and run all Cypress tests - - name: Cypress install - run: npm i - name: Cypress run uses: cypress-io/github-action@v5 # use the explicit version number with: - install: false component: true publish-npm: needs: [ test, cypress-run, cypress-run-component ] diff --git a/.github/workflows/npm-test.yml b/.github/workflows/npm-test.yml index ea83c0c..66a7d24 100644 --- a/.github/workflows/npm-test.yml +++ b/.github/workflows/npm-test.yml @@ -41,12 +41,9 @@ jobs: uses: actions/checkout@v3 # Install NPM dependencies, cache them correctly # and run all Cypress tests - - name: Cypress install - run: npm i - name: Cypress run uses: cypress-io/github-action@v5 # use the explicit version number with: - install: false component: true test-build-package: needs: [ test, cypress-run, cypress-run-component ] diff --git a/webpack.cy.config.ts b/webpack.cy.config.ts index 4083483..a3b9556 100644 --- a/webpack.cy.config.ts +++ b/webpack.cy.config.ts @@ -15,27 +15,15 @@ const dotEnvToParse = dotenv.config(); const externalCss = process.env.EXTERNAL_CSS === 'true' ? true : false; const externalCssName = process.env.EXTERNAL_CSS_NAME ? process.env.EXTERNAL_CSS_NAME : 'index.css'; const alias = resolveTsAliases(path.resolve('tsconfig.json')); -const isWin = process.platform === 'win32'; - const copyPatterns: {from: string, to: string}[] = []; -let copyFromUrl = `${path.resolve(__dirname)}/public/img`; -let copyFromUrlWin = `${path.resolve(__dirname)}\\public\\img`; -let copyToUrl = 'assets/img'; -let copyToUrlWin = 'assets\\img'; +const copyFromUrl = `${path.resolve(__dirname)}/public/img`; +const copyToUrl = 'assets/img'; -if(isWin){ - if(fs.existsSync(copyFromUrlWin)){ - copyPatterns.push({ - from: copyFromUrlWin, to: copyToUrlWin, - }); - } -}else{ - if(fs.existsSync(copyFromUrl)){ - copyPatterns.push({ - from: copyFromUrl, to: copyToUrl, - }); - } +if(fs.existsSync(copyFromUrl)){ + copyPatterns.push({ + from: copyFromUrl, to: copyToUrl, + }); } export default { From dbaa73eb082e8e3c9117fb7bf16ef785f9094dbb Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Tue, 7 Mar 2023 11:57:25 -0600 Subject: [PATCH 06/14] PR-579798: trying to fix Cypress component testing. --- webpack.cy.config.ts | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/webpack.cy.config.ts b/webpack.cy.config.ts index a3b9556..9540050 100644 --- a/webpack.cy.config.ts +++ b/webpack.cy.config.ts @@ -12,8 +12,6 @@ import CopyPlugin from 'copy-webpack-plugin'; import { resolveTsAliases } from 'resolve-ts-aliases'; const dotEnvToParse = dotenv.config(); -const externalCss = process.env.EXTERNAL_CSS === 'true' ? true : false; -const externalCssName = process.env.EXTERNAL_CSS_NAME ? process.env.EXTERNAL_CSS_NAME : 'index.css'; const alias = resolveTsAliases(path.resolve('tsconfig.json')); const copyPatterns: {from: string, to: string}[] = []; @@ -39,11 +37,9 @@ export default { target: 'web', plugins: [ new CleanWebpackPlugin(), - ...(externalCss === true ? [ - new MiniCssExtractPlugin({ - filename: externalCssName, - }), - ] : []), + new MiniCssExtractPlugin({ + filename: 'index.css', + }), new webpack.DefinePlugin({ 'process.env': JSON.stringify(dotEnvToParse.parsed), }), @@ -70,7 +66,7 @@ export default { { test: /\.(css|sass|scss)$/, use: [ - externalCss === true ? MiniCssExtractPlugin.loader : 'style-loader', + MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader', ], From 1ab87ac99456fb2e86d04bcd2a2331ea861dbf4e Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Tue, 7 Mar 2023 12:06:22 -0600 Subject: [PATCH 07/14] PR-579798: trying to fix Cypress component testing. --- cypress/support/component.ts | 13 +++++++++---- cypress/support/e2e.ts | 4 ++-- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cypress/support/component.ts b/cypress/support/component.ts index 258a8bc..f067178 100644 --- a/cypress/support/component.ts +++ b/cypress/support/component.ts @@ -17,12 +17,12 @@ import '../../src/frontend/styles/global.scss'; // Import commands.js using ES2015 syntax: -import './commands' +import './commands'; // Alternatively you can use CommonJS syntax: // require('./commands') -import { mount } from 'cypress/react18' +import { mount } from 'cypress/react18'; // Augment the Cypress namespace to include type definitions for // your custom command. @@ -36,7 +36,12 @@ declare global { } } -Cypress.Commands.add('mount', mount) +Cypress.Commands.add('mount', mount); + +Cypress.on('uncaught:exception', (err, runnable) => { + // returning false here prevents Cypress from failing the test + return false; +}); // Example use: -// cy.mount() \ No newline at end of file +// cy.mount() diff --git a/cypress/support/e2e.ts b/cypress/support/e2e.ts index f80f74f..598ab5f 100644 --- a/cypress/support/e2e.ts +++ b/cypress/support/e2e.ts @@ -14,7 +14,7 @@ // *********************************************************** // Import commands.js using ES2015 syntax: -import './commands' +import './commands'; // Alternatively you can use CommonJS syntax: -// require('./commands') \ No newline at end of file +// require('./commands') From 4335ca0ee4cfd3a8bcfc69baf5fc5970d0746183 Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Tue, 7 Mar 2023 12:19:15 -0600 Subject: [PATCH 08/14] PR-579798: trying to fix Cypress component testing. --- cypress.config.ts | 1 - cypress/support/component.ts | 5 ----- 2 files changed, 6 deletions(-) diff --git a/cypress.config.ts b/cypress.config.ts index 7006ebb..6a51df3 100644 --- a/cypress.config.ts +++ b/cypress.config.ts @@ -20,6 +20,5 @@ export default defineConfig({ }, viewportWidth: 1280, viewportHeight: 720, - fileServerFolder: 'public', } }); diff --git a/cypress/support/component.ts b/cypress/support/component.ts index f067178..00ae19b 100644 --- a/cypress/support/component.ts +++ b/cypress/support/component.ts @@ -38,10 +38,5 @@ declare global { Cypress.Commands.add('mount', mount); -Cypress.on('uncaught:exception', (err, runnable) => { - // returning false here prevents Cypress from failing the test - return false; -}); - // Example use: // cy.mount() From 064d338c7b7549241e5c1a251a62ca8863f61fa2 Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Tue, 7 Mar 2023 12:24:23 -0600 Subject: [PATCH 09/14] PR-579798: trying to fix Cypress component testing. --- .github/workflows/npm-publish.yml | 1 + .github/workflows/npm-test.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index bc0b04b..2cb367e 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -39,6 +39,7 @@ jobs: uses: cypress-io/github-action@v5 # use the explicit version number with: component: true + runTests: false publish-npm: needs: [ test, cypress-run, cypress-run-component ] runs-on: ubuntu-latest diff --git a/.github/workflows/npm-test.yml b/.github/workflows/npm-test.yml index 66a7d24..8e766d4 100644 --- a/.github/workflows/npm-test.yml +++ b/.github/workflows/npm-test.yml @@ -45,6 +45,7 @@ jobs: uses: cypress-io/github-action@v5 # use the explicit version number with: component: true + runTests: false test-build-package: needs: [ test, cypress-run, cypress-run-component ] runs-on: ubuntu-latest From 3613816dd10b6097ab0a59b5f6d67e0663e49ce6 Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Tue, 7 Mar 2023 12:26:45 -0600 Subject: [PATCH 10/14] PR-579798: trying to fix Cypress component testing. --- .github/workflows/npm-publish.yml | 2 +- .github/workflows/npm-test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 2cb367e..f9acc46 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -38,8 +38,8 @@ jobs: - name: Cypress run uses: cypress-io/github-action@v5 # use the explicit version number with: - component: true runTests: false + start: npm run cy:run-component publish-npm: needs: [ test, cypress-run, cypress-run-component ] runs-on: ubuntu-latest diff --git a/.github/workflows/npm-test.yml b/.github/workflows/npm-test.yml index 8e766d4..62ee573 100644 --- a/.github/workflows/npm-test.yml +++ b/.github/workflows/npm-test.yml @@ -44,8 +44,8 @@ jobs: - name: Cypress run uses: cypress-io/github-action@v5 # use the explicit version number with: - component: true runTests: false + start: npm run cy:run-component test-build-package: needs: [ test, cypress-run, cypress-run-component ] runs-on: ubuntu-latest From f27cb45a7f190af60a4a3bfbabca3550251e867a Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Tue, 7 Mar 2023 12:32:20 -0600 Subject: [PATCH 11/14] PR-579798: trying to fix Cypress component testing. --- .github/workflows/npm-publish.yml | 5 +++-- .github/workflows/npm-test.yml | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index f9acc46..f920dd4 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -38,8 +38,9 @@ jobs: - name: Cypress run uses: cypress-io/github-action@v5 # use the explicit version number with: - runTests: false - start: npm run cy:run-component + component: true + # quote the url to be safe against YML parsing surprises + wait-on: 'http://localhost:8080' publish-npm: needs: [ test, cypress-run, cypress-run-component ] runs-on: ubuntu-latest diff --git a/.github/workflows/npm-test.yml b/.github/workflows/npm-test.yml index 62ee573..91cc501 100644 --- a/.github/workflows/npm-test.yml +++ b/.github/workflows/npm-test.yml @@ -44,8 +44,9 @@ jobs: - name: Cypress run uses: cypress-io/github-action@v5 # use the explicit version number with: - runTests: false - start: npm run cy:run-component + component: true + # quote the url to be safe against YML parsing surprises + wait-on: 'http://localhost:8080' test-build-package: needs: [ test, cypress-run, cypress-run-component ] runs-on: ubuntu-latest From 0852d39a40212ed7fe4dba50f22adacd2de7117c Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Tue, 7 Mar 2023 12:34:41 -0600 Subject: [PATCH 12/14] PR-579798: trying to fix Cypress component testing. --- .github/workflows/npm-publish.yml | 2 -- .github/workflows/npm-test.yml | 2 -- 2 files changed, 4 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index f920dd4..bc0b04b 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -39,8 +39,6 @@ jobs: uses: cypress-io/github-action@v5 # use the explicit version number with: component: true - # quote the url to be safe against YML parsing surprises - wait-on: 'http://localhost:8080' publish-npm: needs: [ test, cypress-run, cypress-run-component ] runs-on: ubuntu-latest diff --git a/.github/workflows/npm-test.yml b/.github/workflows/npm-test.yml index 91cc501..66a7d24 100644 --- a/.github/workflows/npm-test.yml +++ b/.github/workflows/npm-test.yml @@ -45,8 +45,6 @@ jobs: uses: cypress-io/github-action@v5 # use the explicit version number with: component: true - # quote the url to be safe against YML parsing surprises - wait-on: 'http://localhost:8080' test-build-package: needs: [ test, cypress-run, cypress-run-component ] runs-on: ubuntu-latest From ab42b7ccc58d19fddbc4de5ba03296604a17b4d7 Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Tue, 7 Mar 2023 12:40:16 -0600 Subject: [PATCH 13/14] PR-579798: trying to fix Cypress component testing. --- .github/workflows/npm-publish.yml | 2 ++ .github/workflows/npm-test.yml | 2 ++ 2 files changed, 4 insertions(+) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index bc0b04b..21babef 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -37,6 +37,8 @@ jobs: # and run all Cypress tests - name: Cypress run uses: cypress-io/github-action@v5 # use the explicit version number + env: + ENV: production with: component: true publish-npm: diff --git a/.github/workflows/npm-test.yml b/.github/workflows/npm-test.yml index 66a7d24..8f6ade1 100644 --- a/.github/workflows/npm-test.yml +++ b/.github/workflows/npm-test.yml @@ -43,6 +43,8 @@ jobs: # and run all Cypress tests - name: Cypress run uses: cypress-io/github-action@v5 # use the explicit version number + env: + ENV: production with: component: true test-build-package: From 5682277684324bfba606fd27aa2616ce3c519178 Mon Sep 17 00:00:00 2001 From: Alejandro Lembke Barrientos Date: Tue, 7 Mar 2023 12:49:44 -0600 Subject: [PATCH 14/14] PR-579798: trying to fix Cypress component testing. --- .github/workflows/npm-publish.yml | 2 -- .github/workflows/npm-test.yml | 2 -- webpack.cy.config.ts | 9 ++++----- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/npm-publish.yml b/.github/workflows/npm-publish.yml index 21babef..bc0b04b 100644 --- a/.github/workflows/npm-publish.yml +++ b/.github/workflows/npm-publish.yml @@ -37,8 +37,6 @@ jobs: # and run all Cypress tests - name: Cypress run uses: cypress-io/github-action@v5 # use the explicit version number - env: - ENV: production with: component: true publish-npm: diff --git a/.github/workflows/npm-test.yml b/.github/workflows/npm-test.yml index 8f6ade1..66a7d24 100644 --- a/.github/workflows/npm-test.yml +++ b/.github/workflows/npm-test.yml @@ -43,8 +43,6 @@ jobs: # and run all Cypress tests - name: Cypress run uses: cypress-io/github-action@v5 # use the explicit version number - env: - ENV: production with: component: true test-build-package: diff --git a/webpack.cy.config.ts b/webpack.cy.config.ts index 9540050..9676086 100644 --- a/webpack.cy.config.ts +++ b/webpack.cy.config.ts @@ -1,7 +1,7 @@ import path from 'path'; import fs from 'fs'; +import { config as envConfig } from './config'; import webpack from 'webpack'; -import * as dotenv from 'dotenv'; import HtmlWebpackPlugin from 'html-webpack-plugin'; import MiniCssExtractPlugin from 'mini-css-extract-plugin'; import { CleanWebpackPlugin } from 'clean-webpack-plugin'; @@ -11,7 +11,6 @@ import ESLintPlugin from 'eslint-webpack-plugin'; import CopyPlugin from 'copy-webpack-plugin'; import { resolveTsAliases } from 'resolve-ts-aliases'; -const dotEnvToParse = dotenv.config(); const alias = resolveTsAliases(path.resolve('tsconfig.json')); const copyPatterns: {from: string, to: string}[] = []; @@ -40,10 +39,10 @@ export default { new MiniCssExtractPlugin({ filename: 'index.css', }), - new webpack.DefinePlugin({ - 'process.env': JSON.stringify(dotEnvToParse.parsed), - }), new ESLintPlugin(), + new webpack.EnvironmentPlugin({ + ...envConfig, + }), new CopyPlugin({ patterns: copyPatterns }),