Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playwright e2e Tests for the Donation Flow #1110

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
c5fa1a7
1096 - setup playwright add tests for the first donation step
dimitur2204 Nov 13, 2022
fabde43
1096 - add login page class and global setup
dimitur2204 Nov 16, 2022
5096e8a
1096 - add testing for full payment flow of a logged in user
dimitur2204 Nov 16, 2022
9f4603a
1096 - remove globalSetup.ts
dimitur2204 Nov 16, 2022
34c2761
1096 - remove auth and change selectors on donation e2e tests
dimitur2204 Nov 17, 2022
3b2013d
1096 - add stripe webhook run script to the CI
dimitur2204 Nov 17, 2022
11c7ca3
start stripe webhook before playwright tests
imilchev Nov 20, 2022
9cd2429
remove yarn command for stripe webhook
imilchev Nov 20, 2022
1f3cc15
start debugging session
imilchev Nov 20, 2022
4d7fa7b
record playwright tests
imilchev Nov 20, 2022
13b2674
adjust stripe secrets
imilchev Nov 20, 2022
267d257
Admin can edit donations details imported from bank transfer (#1097)
Margi13 Nov 11, 2022
810a26c
Update Footer (#1092)
ani-kalpachka Nov 13, 2022
8f438e3
Remove Beta text from the logo (#1099)
ani-kalpachka Nov 14, 2022
55bd850
Increase visible campaigns number (#1104)
ani-kalpachka Nov 15, 2022
2d1f16d
Add SuperHosting partner in Footer (#1103)
ani-kalpachka Nov 16, 2022
8719bfe
Fix overlapping bug in Campaign Details page (#1106)
ani-kalpachka Nov 16, 2022
6a13f45
Add tag for successfull camapign (#1107)
ani-kalpachka Nov 16, 2022
55d9d7a
update some gh actions
imilchev Nov 16, 2022
e35b41c
My profile tabs in mobile to be scrollable (#1114)
marinovl7 Nov 17, 2022
56d9392
Consistent date format in update birthday modal (#1115)
batebobo Nov 18, 2022
34995e6
Enable Terms and Conditions and GDPR validation on Register form (#1126)
ani-kalpachka Nov 19, 2022
9d75f80
[Improvement] Upgrade dependencies including Next 13 and React 18 (#1…
dimitur2204 Nov 19, 2022
6f86ce2
add batebobo as a contributor for code (#1127)
allcontributors[bot] Nov 19, 2022
b6cd4de
add valkirilov as a contributor for code, and doc (#1128)
allcontributors[bot] Nov 19, 2022
0f0bb1f
add devkishor8007 as a contributor for code (#1130)
allcontributors[bot] Nov 19, 2022
db39956
add stann1 as a contributor for code, doc, and 3 more (#1131)
allcontributors[bot] Nov 19, 2022
fa1ce50
Typescript Downgrade and WhatsApp @mui/icons change (#1132)
dimitur2204 Nov 19, 2022
33e3cf4
Fix visual issue with Menu items in the MainNav (#1121)
valkirilov Nov 20, 2022
30cdbbe
[Bug] You can click Next if you are both not logged and not anonymous…
dimitur2204 Nov 20, 2022
65f5bf5
Modularize MUI imports and bump up MUI version (#1135)
dimitur2204 Nov 20, 2022
d3cab28
1109 (#1141)
AnzheloD Nov 20, 2022
867233b
1113 Added border to button in login page (#1142)
AnzheloD Nov 20, 2022
6483a2e
add AnzheloD as a contributor for code (#1143)
allcontributors[bot] Nov 20, 2022
713d6fa
1096 - setup playwright add tests for the first donation step
dimitur2204 Nov 13, 2022
13c7009
Merge remote-tracking branch 'origin/master' into 1096-tests-automate…
dimitur2204 Nov 21, 2022
7c858b7
Update yarn.lock
dimitur2204 Nov 21, 2022
63e2849
Remove env variables from the backend actoin
dimitur2204 Nov 21, 2022
fd5839a
Revert yarn.lock to the origin/master file
dimitur2204 Nov 21, 2022
6505d6c
1096 - Update anonymous donation flow to match the new master changes
dimitur2204 Nov 21, 2022
23a96f2
1096 - return env secrets to the backend action
dimitur2204 Nov 21, 2022
7d0ee39
1096 - change env variables down the list in the playwright.yml
dimitur2204 Nov 21, 2022
02fb813
1096 - increase the timeout time for the wait on backend action
dimitur2204 Nov 21, 2022
0ad5b7c
1096 - change action api branch and add logging artifact
dimitur2204 Nov 21, 2022
262064b
1096 - remove unecessary api artifcat action values
dimitur2204 Nov 21, 2022
bba2bc7
1096 - change api logs artifact path
dimitur2204 Nov 21, 2022
46ea8a6
Revert "1096 - change api logs artifact path"
dimitur2204 Nov 21, 2022
2816d2d
1096 - remove backend env variables from actions
dimitur2204 Nov 21, 2022
10b1084
store api and frontend logs to a file for playwright tests
imilchev Nov 24, 2022
88efdb6
set stripe secrets for api in playwright tests
imilchev Nov 24, 2022
77598d9
another try of setting env for api in playwright
imilchev Nov 24, 2022
a098894
1096 - remove the dependabot file
dimitur2204 Nov 27, 2022
a3280f2
1096 - remove change from LoginForm and add a comment to the logged i…
dimitur2204 Nov 27, 2022
77690fa
1096 - resolve master changes
dimitur2204 Nov 27, 2022
3574dbf
try setting the env for playwright tests
imilchev Dec 1, 2022
fd0c044
added: setting version of yarn to ensure v3.3 will be called
Dec 1, 2022
ee25eba
Fix string litteral
kachar Dec 1, 2022
5982ae7
set secrets explicitly for playwright workflow
imilchev Dec 1, 2022
3b45876
set yarn version for playwright workflow in a separate step
imilchev Dec 1, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,4 @@ jobs:
run-playwright:
name: Run Playwright
uses: ./.github/workflows/playwright.yml
secrets: inherit
35 changes: 31 additions & 4 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
ref: master
path: './api'

- name: Set yarn version
run: yarn set version berry

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "dir=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT
Expand All @@ -35,17 +38,32 @@ jobs:
- name: Run db
working-directory: ./api
run: docker compose up -d pg-db

- name: Run stripe webhook
working-directory: ./api
env:
STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_SECRET }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
run: docker compose up -d stripe-webhook

- uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install backend dependencies and seed database
- name: Install backend dependencies
working-directory: ./api
run: yarn

- name: Seed database
working-directory: ./api
run: yarn && yarn prisma generate && yarn prisma migrate deploy && yarn prisma db seed
run: yarn prisma generate && yarn prisma migrate deploy && yarn prisma db seed

- name: Run backend
working-directory: ./api
run: yarn start &
env:
STRIPE_WEBHOOK_SECRET: ${{ secrets.STRIPE_WEBHOOK_SECRET }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
run: yarn start &> api.log &

- name: Install Frontend Dependencies
working-directory: ./frontend
Expand All @@ -71,7 +89,7 @@ jobs:

- name: Start frontend
working-directory: ./frontend
run: yarn start &
run: yarn start &> frontend.log &

- name: Install Playwright Browsers
working-directory: ./frontend
Expand All @@ -93,3 +111,12 @@ jobs:
name: playwright-report
path: ./frontend/playwright-report/
retention-days: 14

- uses: actions/upload-artifact@v3
if: failure()
with:
name: logs
path: |
./frontend/frontend.log
./api/api.log
retention-days: 14
31 changes: 31 additions & 0 deletions e2e/AuthPage.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Page } from '@playwright/test'

const credentials = {
username: process.env.USERNAME ?? '[email protected]',
password: process.env.PASSWORD ?? '$ecurePa33',
}

export class AuthPage {
page: Page
constructor(page: Page) {
this.page = page
}

async _submitLoginForm() {
await this.page.click('input[type="email"]')
await this.page.fill('input[type="email"]', credentials.username)
await this.page.click('input[type="password"]')
await this.page.fill('input[type="password"]', credentials.password)
await this.page.click('text="Вход"')
await this.page.waitForNavigation({ waitUntil: 'networkidle' })
}

async login() {
await Promise.all([
this.page.goto('http://localhost:3040/login'),
this.page.waitForNavigation(),
])

await this._submitLoginForm()
}
}
88 changes: 88 additions & 0 deletions e2e/local/donation.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { test, expect } from '@playwright/test'

test.beforeEach(async ({ page }) => {
await page.goto('http://localhost:3040/', { waitUntil: 'networkidle' })
await page.locator('text="Подкрепете сега"').first().click()
await page.waitForURL((url) => url.pathname.includes('/campaigns/donation'))
})

test.describe('donation page init', () => {
test('test rendering and defaults', async ({ page }) => {
await expect(
page.locator('label', { has: page.locator('text=Карта') }).locator('input[type="radio"]'),
).toBeChecked()
await expect(
page
.locator('label', { has: page.locator('text=Банков превод') })
.locator('input[type="radio"]'),
).not.toBeChecked()
})
})

//This test will not pass since the keycloak is not yet working in the e2e tests

// test.describe('logged in user donation flow', () => {
// test('choosing a predefined value and donate', async ({ page }) => {
// // Choose a predefined value from the radio buttons
// await page.locator('input[value="card"]').check()
// await page.locator('input[value="500"]').check()

// // Click checkbox to cover the tax by stripe
// await page.locator('input[name="cardIncludeFees"]').check()
// await page.locator('button:has-text("Напред")').click()

// await expect(page.locator('text=Вече сте влезли във Вашия профил')).toBeDefined()
// await page.locator('button:has-text("Напред")').click()

// await page.fill('textarea', 'Test message')
// await page.locator('button:has-text("Премини към плащане")').click()

// await page.waitForURL((url) => url.host === 'checkout.stripe.com')

// await expect(page.locator('text=BGN 5.00')).toBeDefined()
// await page.locator('input[name="email"]').fill('[email protected]')
// await page.locator('input[name="cardNumber"]').fill('4242424242424242')
// await page.locator('input[name="cardExpiry"]').fill('0424')
// await page.locator('input[name="cardCvc"]').fill('123')
// await page.locator('input[name="billingName"]').fill('John Doe')
// await page.locator('select[name="billingCountry"]').selectOption('BG')

// await page.locator('button[data-testid="hosted-payment-submit-button"]').click()

// await page.waitForURL((url) => url.searchParams.get('success') === 'true')

// await expect(page.locator('text=Благодарим за доверието и подкрепата!')).toBeDefined()
// })
// })

test.describe('anonymous user donation flow', () => {
test('choosing a custom value and continuing', async ({ page }) => {
// Choose a predefined value from the radio buttons
await page.locator('input[value="card"]').check()
await page.locator('input[value="500"]').check()

// Click checkbox to cover the tax by stripe
await page.locator('input[name="cardIncludeFees"]').check()
await page.locator('button:has-text("Напред")').click()

page.locator('text=Дарете анонимно').click()
await page.locator('button:has-text("Напред")').click()

await page.fill('textarea', 'е2е_tester')
await page.locator('button:has-text("Премини към плащане")').click()

await expect(page.locator('text=BGN 5.00')).toBeDefined()
await page.locator('input[name="email"]').fill('[email protected]')
await page.locator('input[name="cardNumber"]').fill('4242424242424242')
await page.locator('input[name="cardExpiry"]').fill('0424')
await page.locator('input[name="cardCvc"]').fill('123')
await page.locator('input[name="billingName"]').fill('John Doe')
await page.locator('select[name="billingCountry"]').selectOption('BG')

await page.locator('button[data-testid="hosted-payment-submit-button"]').click()

await page.waitForURL((url) => url.searchParams.get('success') === 'true')

await expect(page.locator('text=Благодарим за доверието и подкрепата!')).toBeDefined()
})
})
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const config: PlaywrightTestConfig = {
/* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */
actionTimeout: 0,
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://localhost:3000',
baseURL: process.env.BASE_URL || 'http://localhost:3040',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
Expand Down