-
Notifications
You must be signed in to change notification settings - Fork 92
/
anon-donation-custom.spec.ts
101 lines (89 loc) · 4.33 KB
/
anon-donation-custom.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import { test, expect, Page } from '@playwright/test'
import { HeaderPage } from '../../../pages/web-pages/header.page'
import { HomePage } from '../../../pages/web-pages/home.page'
import { CampaignsPage } from '../../../pages/web-pages/campaigns/campaigns.page'
import { DonationPage } from '../../../pages/web-pages/donation/donation.page'
import { LanguagesEnum } from '../../../data/enums/languages.enum'
import { bgLocalizationDonationFlow } from '../../../data/localization'
import {
DonationFormAuthState,
DonationFormPaymentMethod,
} from '../../../../src/components/client/donation-flow/helpers/types'
import { DonationStatusPage } from '../../../pages/web-pages/donation/donation-status.page'
import { DonationRegions } from '../../../data/enums/donation-regions.enum'
// This spec contains E2E tests related to anonymous donation flow - custom amount
// The tests are dependent, the whole describe should be runned
test.describe.serial(
'Anonymous contributor is able to donate custom amount - BG language version',
async () => {
let page: Page
let homepage: HomePage
let headerPage: HeaderPage
let campaignsPage: CampaignsPage
let donationPage: DonationPage
let statusPage: DonationStatusPage
// Localization texts
const otherAmountText = bgLocalizationDonationFlow.step.amount.field['other-amount'].label
const paymentMode = bgLocalizationDonationFlow.step['payment-mode'].fields['one-time']
const bgCardIncludeFeesText =
bgLocalizationDonationFlow.step['payment-method'].field['include-fees'].label
test.use({ locale: 'bg-BG' }) //this is to ensure decimal separator is correctly expected
test.beforeAll(async ({ browser }) => {
page = await browser.newPage()
homepage = new HomePage(page)
headerPage = new HeaderPage(page)
campaignsPage = new CampaignsPage(page)
donationPage = new DonationPage(page)
statusPage = new DonationStatusPage(page)
// For local executions use method navigateToLocalhostHomepage();
// await homepage.navigateToLocalhostHomepage();
await homepage.navigateToEnvHomepage()
await headerPage.changeLanguageToBe(LanguagesEnum.BG)
})
test.afterAll(async () => {
await page.close()
})
test('Particular campaign can be opened through the Campaign page', async () => {
await headerPage.clickDonateHeaderNavButton(LanguagesEnum.BG)
await campaignsPage.clickCampaignCardByIndex(0)
// We move from the common Campaigns page to the particular campain page
// check if the url is changed only based on the url pattern http://localhost:3040/campaigns/{slug-based-regexp}
expect(
await campaignsPage.checkPageUrlByRegExp(),
'The url is not changed after clicking on the campaign card.',
)
})
test('The total charge, fee tax and donation amount are visible on the Campaign page', async () => {
await campaignsPage.clickDonationSupportButton()
await donationPage.checkPageUrlByRegExp()
await donationPage.selectRadioButtonByLabelText([otherAmountText])
await donationPage.fillOtherAmountInputField('8')
await donationPage.selectPaymentMethod(DonationFormPaymentMethod.CARD)
await donationPage.setDonationRegionFromTheDropdown(DonationRegions.EUROPE)
await donationPage.selectCheckboxByLabelText([bgCardIncludeFeesText])
})
test('The total charge, fee tax and donation amount are recalculated correctly when the donation amount is changed', async () => {
await donationPage.fillOtherAmountInputField('120')
await donationPage.checkTotalAmount(121.96)
})
test('Select payment type', async () => {
await donationPage.selectRadioButtonByLabelText([paymentMode])
})
test('Fill in the stripe card form', async () => {
await donationPage.fillCardForm({
fail: false,
})
})
test('The user is able to fill in e-mail for anonymous donation', async () => {
await donationPage.selectAuthentication(DonationFormAuthState.NOREGISTER)
})
test('The user can submit the form', async () => {
await donationPage.checkPrivacyCheckbox()
await donationPage.submitForm()
})
test('The user is redirected to succes page', async () => {
await statusPage.checkPageUrlByRegExp()
expect(await statusPage.isSucceededStatusTitleDisplayed()).toBe(true)
})
},
)