Skip to content

Commit

Permalink
1018 cad currency support (#1020)
Browse files Browse the repository at this point in the history
* adding playwright test termns and condition creation and checkout

* Fix #1018 adding CAD support

* separating CAD and GBP currency tests

* changing concurrency group

* restructuring CAD tests

* changing email queue mounted folder
  • Loading branch information
joeltejeda authored May 16, 2023
1 parent 679979c commit 0980f47
Show file tree
Hide file tree
Showing 42 changed files with 653 additions and 80 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# that branch.
# The deployed url will be <branchname>.<domain>

name: Deploy pr preview
name: CAD Deploy pr preview
on:
pull_request:
# (pull_request_target get fired on external contributer pull requests)
Expand All @@ -13,12 +13,12 @@ on:
- '**/TESTING.md'
- 'docs/**'
jobs:
deploy-pr:
CAD-deploy-pr:
runs-on: ubuntu-22.04
timeout-minutes: 60
environment: testing
concurrency:
group: ${{ github.ref }}
group: 'CAD-${{ github.ref }}'
cancel-in-progress: true
steps:
- name: Dump context
Expand All @@ -43,7 +43,7 @@ jobs:
- name: Set subdomain (ensure is lowercase for dokku)
run: |
set -x
echo SUBDOMAIN=`echo "${{ github.head_ref }}" | tr '[:upper:]' '[:lower:]' | cut -c -60` >> $GITHUB_ENV
echo SUBDOMAIN=`echo "CAD-${{ github.head_ref }}" | tr '[:upper:]' '[:lower:]' | cut -c -60` >> $GITHUB_ENV
echo $GITHUB_ENV
- name: Create dokku app for pr branch if dosent already exist using dokku apps:create
env:
Expand All @@ -66,7 +66,7 @@ jobs:
ssh dokku@$DOKKU_HOST -C "dokku config:set --no-restart ${{ env.SUBDOMAIN }} FLASK_ENV=development"
ssh dokku@$DOKKU_HOST -C "dokku config:set --no-restart ${{ env.SUBDOMAIN }} EMAIL_QUEUE_FOLDER=${{ secrets.DOKKU_EMAIL_QUEUE_FOLDER }}"
# mount email-queue folder
ssh dokku@$DOKKU_HOST -C "dokku storage:mount ${{ github.head_ref }} ${{ secrets.HOST_EMAIL_QUEUE_PATH }}:${{ secrets.DOKKU_EMAIL_QUEUE_FOLDER }} && dokku ps:restart ${{ github.head_ref }} || true"
ssh dokku@$DOKKU_HOST -C "dokku storage:mount ${{ env.SUBDOMAIN }} ${{ secrets.HOST_EMAIL_QUEUE_PATH }}:${{ secrets.DOKKU_EMAIL_QUEUE_FOLDER }} && dokku ps:restart ${{ env.SUBDOMAIN }} || true"
- name: Deploy branch ${{ github.head_ref }} to dokku
uses: idoberko2/dokku-deploy-github-action@v1
Expand All @@ -81,7 +81,7 @@ jobs:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
DOKKU_HOST: ${{ secrets.DOKKU_HOST }}
run: |
echo Visit your pr here: http://${{ github.head_ref }}.pcpink.co.uk
echo Visit your pr here: http://CAD-${{ github.head_ref }}.pcpink.co.uk
- name: 'Comment PR with web address of application live preview'
uses: actions/github-script@v3
if: github.event_name == 'pull_request'
Expand All @@ -91,7 +91,7 @@ jobs:
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "🙌 Live preview is here: http://${{ github.head_ref }}.pcpink.co.uk"
body: "🙌 Live preview is here: http://CAD-${{ github.head_ref }}.pcpink.co.uk"
})
- uses: actions/setup-node@v3
Expand All @@ -106,7 +106,7 @@ jobs:
- name: Run & Record browser automated tests (Playwright)
env:
PLAYWRIGHT_HOST: http://${{ github.head_ref }}.pcpink.co.uk/
PLAYWRIGHT_HOST: http://CAD-${{ github.head_ref }}.pcpink.co.uk/
PLAYWRIGHT_SLOWMO: 1000
PLAYWRIGHT_HEADLESS: true
SUBSCRIBER_EMAIL_HOST: ${{ secrets.SUBSCRIBER_EMAIL_HOST }}
Expand All @@ -115,12 +115,12 @@ jobs:
EMAIL_SEARCH_API_HOST: ${{ secrets.EMAIL_SEARCH_API_HOST }}
RESET_PASSWORD_IMAP_SEARCH_SUBJECT: ${{ secrets.RESET_PASSWORD_IMAP_SEARCH_SUBJECT }}
IMAP_SEARCH_UNSEEN: "1"
IMAP_SEARCH_SINCE_DATE: "01-Sep-2021"
IMAP_SEARCH_SINCE_DATE: "01-Sep-2022"
run: |
set -x
cp tests/browser-automated-tests-playwright/.env.example tests/browser-automated-tests-playwright/.env
cp .env.example .env
cd tests/browser-automated-tests-playwright; npx playwright test --grep-invert @704 --update-snapshots
cd tests/browser-automated-tests-playwright; npx playwright test --grep @CAD --update-snapshots
- uses: actions/upload-artifact@v2
if: ${{ always() }}
Expand Down
131 changes: 131 additions & 0 deletions .github/workflows/pr-demo-deploy-GBP.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
---
# When a push is made to a branch, deploy an instance of the app using
# that branch.
# The deployed url will be <branchname>.<domain>

name: GBP Deploy pr preview
on:
pull_request:
# (pull_request_target get fired on external contributer pull requests)
#pull_request_target
paths-ignore:
- '**/README.md'
- '**/TESTING.md'
- 'docs/**'
jobs:
GBP-deploy-pr:
runs-on: ubuntu-20.04
timeout-minutes: 60
environment: testing
concurrency:
group: 'GBP-${{ github.ref }}'
cancel-in-progress: true
steps:
- name: Dump context
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: |
echo $GITHUB_CONTEXT
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: psf/black@stable # Fail early if fails Black code style
- name: Prepare runner with ssh keys
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
DOKKU_HOST: ${{ secrets.DOKKU_HOST }}
run: |
set -x
mkdir -p ~/.ssh
eval `ssh-agent -s`
ssh-add - <<< "$SSH_PRIVATE_KEY"
ssh-keyscan $DOKKU_HOST >> ~/.ssh/known_hosts
- name: Set subdomain (ensure is lowercase for dokku)
run: |
set -x
echo SUBDOMAIN=`echo "GBP-${{ github.head_ref }}" | tr '[:upper:]' '[:lower:]' | cut -c -60` >> $GITHUB_ENV
echo $GITHUB_ENV
- name: Create dokku app for pr branch if dosent already exist using dokku apps:create
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
DOKKU_HOST: ${{ secrets.DOKKU_HOST }}
run: |
set -x
echo The PR was raised by: ${{ github.event.pull_request.user.login }}
eval `ssh-agent -s`
ssh-add - <<< "$SSH_PRIVATE_KEY"
echo Creating dokku app ${{ github.head_ref }}
ssh dokku@$DOKKU_HOST -C "dokku apps:create ${{ env.SUBDOMAIN }}" | true
echo The url will be ${{ github.head_ref }}.pcpink.co.uk
ssh dokku@$DOKKU_HOST -C "dokku git:initialize ${{ env.SUBDOMAIN }}"
ssh dokku@$DOKKU_HOST -C "dokku git:set ${{ env.SUBDOMAIN }} deploy-branch ${{ github.head_ref }}"
# set Stripe test keys as env vars dor dokku/docker
ssh dokku@$DOKKU_HOST -C "dokku config:set --no-restart ${{ env.SUBDOMAIN }} STRIPE_TEST_SECRET_KEY=${{ secrets.STRIPE_TEST_SECRET_KEY }}"
ssh dokku@$DOKKU_HOST -C "dokku config:set --no-restart ${{ env.SUBDOMAIN }} STRIPE_TEST_PUBLISHABLE_KEY=${{ secrets.STRIPE_TEST_PUBLISHABLE_KEY }}"
ssh dokku@$DOKKU_HOST -C "dokku config:set --no-restart ${{ env.SUBDOMAIN }} STRIPE_CONNECT_ACCOUNT_ANNOUNCER_HOST=${{ secrets.STRIPE_CONNECT_ACCOUNT_ANNOUNCER_HOST }}"
ssh dokku@$DOKKU_HOST -C "dokku config:set --no-restart ${{ env.SUBDOMAIN }} FLASK_ENV=development"
ssh dokku@$DOKKU_HOST -C "dokku config:set --no-restart ${{ env.SUBDOMAIN }} EMAIL_QUEUE_FOLDER=${{ secrets.DOKKU_EMAIL_QUEUE_FOLDER }}"
# mount email-queue folder
ssh dokku@$DOKKU_HOST -C "dokku storage:mount ${{ env.SUBDOMAIN }} ${{ secrets.HOST_EMAIL_QUEUE_PATH }}:${{ secrets.DOKKU_EMAIL_QUEUE_FOLDER }} && dokku ps:restart ${{ env.SUBDOMAIN }} || true"
- name: Deploy branch ${{ github.head_ref }} to dokku
uses: idoberko2/dokku-deploy-github-action@v1
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
dokku-host: ${{ secrets.DOKKU_HOST }}
app-name: ${{ env.SUBDOMAIN }}
git-push-flags: '--force'
remote-branch: ${{ github.head_ref }}
- name: Click to see your PR web address
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
DOKKU_HOST: ${{ secrets.DOKKU_HOST }}
run: |
echo Visit your pr here: http://GBP-${{ github.head_ref }}.pcpink.co.uk
- name: 'Comment PR with web address of application live preview'
uses: actions/github-script@v3
if: github.event_name == 'pull_request'
with:
script: |
github.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "🙌 Live preview is here: http://GBP-${{ github.head_ref }}.pcpink.co.uk"
})
- uses: actions/setup-node@v3

- uses: microsoft/playwright-github-action@v1

- name: Install node dependencies needed for Playwright browser tests
run: |
npm i -D @playwright/[email protected]
npx playwright install
sudo npx playwright install-deps
- name: Run & Record browser automated tests (Playwright)
env:
PLAYWRIGHT_HOST: http://GBP-${{ github.head_ref }}.pcpink.co.uk/
PLAYWRIGHT_SLOWMO: 1000
PLAYWRIGHT_HEADLESS: true
SUBSCRIBER_EMAIL_HOST: ${{ secrets.SUBSCRIBER_EMAIL_HOST }}
SUBSCRIBER_EMAIL_USER: ${{ secrets.SUBSCRIBER_EMAIL_USER }}
SUBSCRIBER_EMAIL_PASSWORD: ${{ secrets.SUBSCRIBER_EMAIL_PASSWORD }}
EMAIL_SEARCH_API_HOST: ${{ secrets.EMAIL_SEARCH_API_HOST }}
RESET_PASSWORD_IMAP_SEARCH_SUBJECT: ${{ secrets.RESET_PASSWORD_IMAP_SEARCH_SUBJECT }}
IMAP_SEARCH_UNSEEN: "1"
IMAP_SEARCH_SINCE_DATE: "01-Sep-2022"
run: |
set -x
cp tests/browser-automated-tests-playwright/.env.example tests/browser-automated-tests-playwright/.env
cp .env.example .env
cd tests/browser-automated-tests-playwright; npx playwright test --grep @GBP --update-snapshots
- uses: actions/upload-artifact@v2
if: ${{ always() }}
with:
name: Screenshots-and-video-artifacts
path: |
./index.spec.js-snapshots/*
./tests/browser-automated-tests-playwright/test-results/*
1 change: 1 addition & 0 deletions subscribie/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"SK": "EUR",
"SI": "EUR",
"ES": "EUR",
"CA": "CAD",
"AU": "AUD",
}

Expand Down
3 changes: 1 addition & 2 deletions tests/browser-automated-tests-playwright/github.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const { test, expect } = require('@playwright/test');

test.describe("Github actions test:", () => {
const magic_login_receives_email = require('./tests/704_shop_owner_magic_login_receives_email');
const magic_login_receives_email = require(`./tests/704_shop_owner_magic_login_receives_email`);

});
31 changes: 14 additions & 17 deletions tests/browser-automated-tests-playwright/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { test, expect } = require('@playwright/test');

const TEST = process.env.TEST;
//Subscribie tests
test.describe("Subscribie tests:", () => {
test.beforeEach(async ({ page }) => {
Expand All @@ -13,7 +13,7 @@ test.describe("Subscribie tests:", () => {
expect(content === 'Checklist'); // If we see "Checklist", we're logged in to admin
});
//Stripe Test
test("@293@connect-to-stripe@shop-owner@Stripe Test", async ({ page }) => {
test("@293@connect-to-stripe@shop-owner@Stripe Test @GBP @CAD", async ({ page }) => {
// Go to Stripe Connect payment gateways page
await page.goto('admin/connect/stripe-connect');
// Check onboarding not already completed
Expand All @@ -29,6 +29,9 @@ test.describe("Subscribie tests:", () => {
console.log("Continuing with Stripe Connect onboarding");
}
});
const stripe_connect = require('./tests/GBP-tests/stripe_connect.js');

const order_plan_with_only_recurring_charge = require(`./tests/GBP-tests/293_subscriber_order_plan_with_only_recurring_charge`);
test("@293@connect-to-stripe@shop-owner@detect stripe onboarding page", async ({ page }) => {

// Go to Stripe Connect payment gateways page
Expand Down Expand Up @@ -155,25 +158,19 @@ test.describe("Subscribie tests:", () => {

await page.click('[data-test="requirements-index-done-button"]')

console.log("Announce stripe account automatically visiting announce url. In prod this is called via uwsgi cron");
await new Promise(x => setTimeout(x, 5000));
const stripe_connected = await page.textContent("text=Your currently running in test mode.");
expect(stripe_connected === "Your currently running in test mode.");
console.log("Stripe Connected");
await page.goto('/admin/announce-stripe-connect');
await page.textContent(':has-text("Announced Stripe connect account")') === "Announced Stripe connect account";
console.log("Announced to Stripe connect account");

});
const order_plan_with_only_recurring_charge = require('./tests/293_subscriber_order_plan_with_only_recurring_charge');

const order_plan_with_only_upfront_charge = require('./tests/293_subscriber_order_plan_with_only_upfront_charge');
const order_plan_with_only_upfront_charge = require(`./tests/GBP-tests/293_subscriber_order_plan_with_only_upfront_charge`);

const order_plan_with_free_trial = require('./tests/475_subscriber_order_plan_with_free_trial');
const order_plan_with_free_trial = require(`./tests/GBP-tests/475_subscriber_order_plan_with_free_trial`);
// When you run order subscription and upfront charge, it will run 2 more tests that are inside:
// 1. Transacion filter by name and plan title
// 2. 2.A pause, resume and 2.B cancel subscription test.
const order_plan_with_subscription_and_upfront_charge = require('./tests/293_subscriber_order_plan_with_recurring_and_upfront_charge');
const order_plan_with_subscription_and_upfront_charge = require(`./tests/GBP-tests/293_subscriber_order_plan_with_recurring_and_upfront_charge`);

// Tests for CAD currency
const stripe_connect_CAD = require('./tests/CAD-tests/stripe_connect.js');

const order_plan_with_subscription_and_upfront_charge_CAD = require(`./tests/CAD-tests/293_subscriber_order_plan_with_recurring_and_upfront_charge`);


});

Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const PLAYWRIGHT_SLOWMO = parseInt(process.env.PLAYWRIGHT_SLOWMO);
const { devices } = require('@playwright/test');
/** @type {import('@playwright/test').PlaywrightTestConfig} */
const config: PlaywrightTestConfig = {
testDir: 'tests',
testDir: '../browser-automated-tests-playwright',
timeout: 180000,
retries: 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const checkShopOwnerLogin = require('./checkShopOwnerLogin.js');
const SHOP_OWNER_LOGIN_URL = process.env.SHOP_OWNER_LOGIN_URL
const SHOP_OWNER_EMAIL = process.env.SHOP_OWNER_EMAIL_USER

test('@704@shop_owner@magic login receives email', async ({ page }) => {
test('@704@shop_owner@magic login receives email @GBP', async ({ page }) => {
await page.goto(SHOP_OWNER_LOGIN_URL);
await page.fill('#email', SHOP_OWNER_EMAIL);
await page.click('#login');
Expand Down
Loading

0 comments on commit 0980f47

Please sign in to comment.