From e9eba09ebb359cebd8bfa31a5004d42cf3088e80 Mon Sep 17 00:00:00 2001 From: Emili Castells Guasch Date: Mon, 27 Feb 2023 11:39:30 +0100 Subject: [PATCH] Use existing e2e environment config file --- .env.e2e.example | 9 +++++++++ .env.sample | 8 -------- playwright.config.js | 6 +----- tests/playwright/README.md | 2 +- tests/playwright/place-order.spec.js | 6 ++---- 5 files changed, 13 insertions(+), 18 deletions(-) delete mode 100644 .env.sample diff --git a/.env.e2e.example b/.env.e2e.example index 02ffdb0bc..6caba9f7c 100644 --- a/.env.e2e.example +++ b/.env.e2e.example @@ -1 +1,10 @@ PPCP_E2E_WP_DIR=${ROOT_DIR}/.ddev/wordpress + +BASEURL="http://example.com" + +CUSTOMER_EMAIL="customer@example.com" +CUSTOMER_PASSWORD="password" + +CREDIT_CARD_NUMBER="1234567890" +CREDIT_CARD_EXPIRATION="01/2042" +CREDIT_CARD_CVV="123" diff --git a/.env.sample b/.env.sample deleted file mode 100644 index d29ddcf5f..000000000 --- a/.env.sample +++ /dev/null @@ -1,8 +0,0 @@ -BASEURL="http://example.com" - -CUSTOMER_EMAIL="customer@example.com" -CUSTOMER_PASSWORD="password" - -CREDIT_CARD_NUMBER="1234567890" -CREDIT_CARD_EXPIRATION="01/2042" -CREDIT_CARD_CVV="123" diff --git a/playwright.config.js b/playwright.config.js index 2b3c3a244..081c1c0f8 100644 --- a/playwright.config.js +++ b/playwright.config.js @@ -1,8 +1,4 @@ -/** - * Read environment variables from file. - * https://github.com/motdotla/dotenv - */ -require('dotenv').config(); +require('dotenv').config({ path: '.env.e2e' }); const config = { testDir: './tests/playwright', diff --git a/tests/playwright/README.md b/tests/playwright/README.md index 48e70b36a..cd8e56468 100644 --- a/tests/playwright/README.md +++ b/tests/playwright/README.md @@ -3,7 +3,7 @@ ## Local Environment Variables Allows using environment variables inside the tests. -- Duplicate `.env.sample` and rename it as `.env`, set values and add new variables if needed. +- Duplicate `.env.e2e.example` and rename it as `.env.e2e`, set values and add new variables if needed. ## Run Tests ``` diff --git a/tests/playwright/place-order.spec.js b/tests/playwright/place-order.spec.js index 2a28fbd2c..c778446da 100644 --- a/tests/playwright/place-order.spec.js +++ b/tests/playwright/place-order.spec.js @@ -1,5 +1,3 @@ -require('dotenv').config(); - const {test, expect} = require('@playwright/test'); const { CUSTOMER_EMAIL, @@ -20,7 +18,7 @@ async function fillCheckoutForm(page) { await page.fill('#billing_email', CUSTOMER_EMAIL); } -test('PayPal button place order from product page', async ({page}) => { +test('PayPal button place order from Product page', async ({page}) => { await page.goto('/product/product/'); @@ -48,7 +46,7 @@ test('PayPal button place order from product page', async ({page}) => { await expect(title).toHaveText('Order received'); }); -test('ACDC', async ({page}) => { +test('Advanced Credit and Debit Card (ACDC) place order from Checkout page', async ({page}) => { await page.goto('/product/product/'); await page.locator('.single_add_to_cart_button').click();