From c976adfb076a571ecefb49aa46418fb5a38617b3 Mon Sep 17 00:00:00 2001 From: hossam-adyen <132500300+hossam-adyen@users.noreply.github.com> Date: Tue, 12 Dec 2023 13:25:54 +0100 Subject: [PATCH] Add .env (#99) * Add .env in ignore file and .env-example to have more clear env reqierments * Update README * Update .env_example --- .env_example | 13 +++++++++++ .gitignore | 3 ++- package-lock.json | 20 +++++++++++++++++ package.json | 5 ++++- projects/magento/magento.config.cjs | 3 ++- readme.md | 34 +++++++++++++++++++---------- 6 files changed, 63 insertions(+), 15 deletions(-) create mode 100644 .env_example diff --git a/.env_example b/.env_example new file mode 100644 index 00000000..b6596be7 --- /dev/null +++ b/.env_example @@ -0,0 +1,13 @@ +MAGENTO_BASE_URL="" +MAGENTO_ADMIN_USERNAME="" +MAGENTO_ADMIN_PASSWORD="" +PAYPAL_USERNAME="" +PAYPAL_PASSWORD="" +ADYEN_MERCHANT="" +ADYEN_CLIENT_KEY="" +ADYEN_API_KEY="" +WEBHOOK_USERNAME="" +WEBHOOK_PASSWORD="" +GOOGLE_USERNAME="" +GOOGLE_PASSWORD="" +PWDEBUG=0 diff --git a/.gitignore b/.gitignore index 8757083b..14ca7097 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ playwright-report/ test-results.json test-report/ .DS_Store -.idea \ No newline at end of file +.idea +.env diff --git a/package-lock.json b/package-lock.json index 490aa0b9..325f0c61 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,9 @@ "name": "pluginstest", "version": "1.0.0", "license": "MIT", + "dependencies": { + "dotenv": "^16.3.1" + }, "devDependencies": { "@playwright/test": "^1.38.0" } @@ -28,6 +31,18 @@ "node": ">=16" } }, + "node_modules/dotenv": { + "version": "16.3.1", + "resolved": "https://nexushost.is.adyen.com/repository/npm-internal/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-OJdaREdsqUPE3kVZe8ZiWI7RREiiVtqCWeQm6XGsApAEqBCLt6qHiTJOWa7FtM28d3TLeQzj1C9eA3t3tVPANw==", + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/motdotla/dotenv?sponsor=1" + } + }, "node_modules/fsevents": { "version": "2.3.2", "resolved": "https://nexushost.is.adyen.com/repository/npm-internal/fsevents/-/fsevents-2.3.2.tgz", @@ -85,6 +100,11 @@ "playwright": "1.38.0" } }, + "dotenv": { + "version": "16.3.1", + "resolved": "https://nexushost.is.adyen.com/repository/npm-internal/dotenv/-/dotenv-16.3.1.tgz", + "integrity": "sha512-OJdaREdsqUPE3kVZe8ZiWI7RREiiVtqCWeQm6XGsApAEqBCLt6qHiTJOWa7FtM28d3TLeQzj1C9eA3t3tVPANw==" + }, "fsevents": { "version": "2.3.2", "resolved": "https://nexushost.is.adyen.com/repository/npm-internal/fsevents/-/fsevents-2.3.2.tgz", diff --git a/package.json b/package.json index 2377d1fc..6f66bf75 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "test:ci:magento:all": "npx playwright test --config=projects/magento/magentoCIContainer.config.cjs", "test:ci:magento": "npx playwright test --config=projects/magento/magentoCIContainer.config.cjs --project='backoffice' --project='user'", "test:ci:magento:express-checkout": "npx playwright test --config=projects/magento/magentoCIContainer.config.cjs --project='express-checkout'", - "test:adyenlocal:magento": "npx playwright test --workers=1 --headed --project=chromium --config=projects/magento/magento.config.cjs", + "test:adyenlocal:magento": "npx playwright test --workers=1 --headed --project='backoffice' --project='user' --config=projects/magento/magento.config.cjs", "test:adyenlocal:magento:headless": "npx playwright test --workers=1 --project=chromium --config=projects/magento/magento.config.cjs", "test:adyenlocal:magento:parallel": "npx playwright test --headed --project=chromium --config=projects/magento/magento.config.cjs", "test:adyenlocal:magento:headless:parallel": "npx playwright test --project=chromium --config=projects/magento/magento.config.cjs", @@ -23,5 +23,8 @@ "license": "MIT", "devDependencies": { "@playwright/test": "^1.38.0" + }, + "dependencies": { + "dotenv": "^16.3.1" } } diff --git a/projects/magento/magento.config.cjs b/projects/magento/magento.config.cjs index 1870b3a9..3a0f3d04 100644 --- a/projects/magento/magento.config.cjs +++ b/projects/magento/magento.config.cjs @@ -1,9 +1,10 @@ // @ts-check const { devices } = require("@playwright/test"); - +const dotenv = require('dotenv'); const VIEWPORT_WIDTH = 1600; const VIEWPORT_HEIGHT = 900; +dotenv.config(); /** * @see https://playwright.dev/docs/test-configuration * @type {import('@playwright/test').PlaywrightTestConfig} diff --git a/readme.md b/readme.md index 3675012f..c8e5d71c 100644 --- a/readme.md +++ b/readme.md @@ -60,23 +60,33 @@ This will run the `CreditCardPayment.spec.js` test only with **one worker** in a Check `package.json` to see all available scripts. -```bash -npm run test:adyenlocal:magento -``` +* Runs all Magento tests on headed Chrome browser with a single worker. -Runs all Magento tests on headed Chrome browser with a single worker. + ```bash + npm run test:adyenlocal:magento + ``` + + **Optional step:** + + You can add your local environment from `.env` file, just copy it from `.env_example` and fill it with your secrets -```bash -npm run test:adyenlocal:magento:headless -``` + ``` + cp .env_example .env + ## Fill .env with your prefered env values + ``` -Runs all Magento tests on headless Chrome browser with a single worker. -```bash -npm run test:adyenlocal:magento:parallel -``` +* Runs all Magento tests on headless Chrome browser with a single worker. + + ```bash + npm run test:adyenlocal:magento:headless + ``` -Runs all Magento tests on headed Chrome browser parallelly with multiple workers. +* Runs all Magento tests on headed Chrome browser parallelly with multiple workers. + + ```bash + npm run test:adyenlocal:magento:parallel + ``` ## Contributing