Skip to content

Commit

Permalink
Upgrade of translation libraries and related (#1616)
Browse files Browse the repository at this point in the history
* upgraded NextJS to fix dependabot vulnerability warnings

* fixed linter and formatting

* reverted next to 13.4.12, updated MUI and translation libraries

* upgraded playwright to latest

* fixed language change and corrected decimal separators

* forced resolution for postcss and zod to fix security recommendations

* added locale for tests to fix decimal separator mixups

* donation amount changed to integer to avoid language specific decimal separators

* upgraded node to v20

* fixing the docker build context to use the already checked out code from github checkout action
  • Loading branch information
quantum-grit authored Oct 26, 2023
1 parent 56293ea commit a4c57c6
Show file tree
Hide file tree
Showing 93 changed files with 1,827 additions and 487 deletions.
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ jobs:
GHOST_API_URL: https://blog.podkrepi.bg
GHOST_CONTENT_KEY: ${{ secrets.GHOST_CONTENT_KEY }}
with:
context: .
push: false
target: runner
build-args: |
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Build target dependencies #
###########################
FROM node:16-alpine3.16 AS base
FROM node:20-alpine AS base
WORKDIR /app
ARG NODE_ENV=production
ENV PATH=/app/node_modules/.bin:$PATH \
Expand Down
4 changes: 2 additions & 2 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
"test": "tests"
},
"dependencies": {
"@playwright/test": "1.30.0",
"playwright": "1.30.0"
"@playwright/test": "^1.38.1",
"playwright": "^1.38.1"
},
"keywords": [],
"author": "",
Expand Down
12 changes: 9 additions & 3 deletions e2e/pages/web-pages/header.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ export class HeaderPage extends BasePage {
language: LanguagesEnum,
): Promise<void> {
await this.waitForElementToBePresentedBySelector(this.toolbarCommonButtonsSelector)

//first switch to the desired language
await this.changeLanguageToBe(language)

//then find the item to click on
if (language === LanguagesEnum.BG) {
await this.clickElement(this.toolbarCommonButtonsSelector, { hasText: navTextBg })
} else if (language === LanguagesEnum.EN) {
Expand Down Expand Up @@ -128,9 +133,10 @@ export class HeaderPage extends BasePage {

/**
* Click on the language header button to change the page language
* @param {LanguagesEnum} languageParam
* @param {LanguagesEnum} language
*/
async changeanguageHeaderButtonToBe(languageParam: LanguagesEnum): Promise<void> {
await this.clickHeaderNavLink(LanguagesEnum.BG, LanguagesEnum.EN, languageParam)
async changeLanguageToBe(language: LanguagesEnum): Promise<void> {
const localeButton = this.page.getByTestId('locale-button')
if ((await localeButton.innerText()) === language) await localeButton.click()
}
}
22 changes: 13 additions & 9 deletions e2e/tests/regression/donation-flow/anon-donation-custom.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { DonationPage } from '../../../pages/web-pages/campaigns/donation.page'
import { bgDonationRegions } from '../../../data/enums/donation-regions.enum'
import { StripeCheckoutPage } from '../../../pages/web-pages/external/stripe-checkout.page'
import { anonDonationTestData } from '../../../data/support-page-tests.data'
import { LanguagesEnum } from '../../../data/enums/languages.enum'

// This spec contains E2E tests related to anonymous donation flow - custom amount
// The tests are dependent, the whole describe should be runned
Expand All @@ -24,6 +25,8 @@ test.describe.serial(
const otherAmountText = bgLocalizationOneTimeDonation['first-step'].other
const bgCardIncludeFeesText = bgLocalizationOneTimeDonation['third-step']['card-include-fees']

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)
Expand All @@ -34,6 +37,7 @@ test.describe.serial(
// For local executions use method navigateToLocalhostHomepage();
// await homepage.navigateToLocalhostHomepage();
await homepage.navigateToEnvHomepage()
await headerPage.changeLanguageToBe(LanguagesEnum.BG)
})

test.afterAll(async () => {
Expand All @@ -58,29 +62,29 @@ test.describe.serial(
.soft(await donationPage.isSelectAmountStepActive(), 'Select Amount step is not active.')
.toBeTruthy()
await donationPage.selectRadioButtonByLabelText([otherAmountText])
await donationPage.fillOtherAmountInputField('7.50')
await donationPage.fillOtherAmountInputField('75')
await donationPage.setDonationRegionFromTheDropdown(bgDonationRegions.EUROPE)
await donationPage.selectCheckboxByLabelText([bgCardIncludeFeesText])
// Expected pattern:
// За вашия превод от {totalChargedAmountText} лв., таксата на Stripe ще е {feeAmountText} лв., а кампанията ще получи {donationAmountText} лв.
const totalChargedAmountText = await donationPage.getTotalChargedAmountsAsText()
const feeAmountText = await donationPage.getFeeAmountsAsText()
const donationAmountText = await donationPage.getDonationAmountsAsText()
expect.soft(totalChargedAmountText).toEqual('8,10 лв.')
expect.soft(feeAmountText).toEqual('0,60 лв.')
expect(donationAmountText).toEqual('7,50 лв.')
expect.soft(totalChargedAmountText).toEqual('76,42 лв.')
expect.soft(feeAmountText).toEqual('1,42 лв.')
expect(donationAmountText).toEqual('75,00 лв.')
})

test('The total charge, fee tax and donation amount are recalculated correctly when the donation amount is changed', async () => {
await donationPage.fillOtherAmountInputField('12.90')
await donationPage.fillOtherAmountInputField('120')
// Expected pattern:
// За вашия превод от {totalChargedAmountText} лв., таксата на Stripe ще е {feeAmountText} лв., а кампанията ще получи {donationAmountText} лв.
const totalChargedAmountText = await donationPage.getTotalChargedAmountsAsText()
const feeAmountText = await donationPage.getFeeAmountsAsText()
const donationAmountText = await donationPage.getDonationAmountsAsText()
expect.soft(totalChargedAmountText).toEqual('13,56 лв.')
expect.soft(feeAmountText).toEqual('0,66 лв.')
expect(donationAmountText).toEqual('12,90 лв.')
expect.soft(totalChargedAmountText).toEqual('121,96 лв.')
expect.soft(feeAmountText).toEqual('1,96 лв.')
expect(donationAmountText).toEqual('120,00 лв.')
})

test('The user is able to fill in e-mail for anonymous donation', async () => {
Expand All @@ -107,7 +111,7 @@ test.describe.serial(
const actualStripeEmail = await stripeCheckoutPage.getReadonlyEmailText()
expect
.soft(stripeTotalAmount, 'The Stripe total donation amount is not correct.')
.toContain('13.56')
.toContain('121,96')
expect(actualStripeEmail, 'The user e-mail is not sent correctly to Stripe.').toEqual(
testEmail,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test.describe.serial(
// For local executions use method navigateToLocalhostHomepage();
// await homepage.navigateToLocalhostHomepage();
await homepage.navigateToEnvHomepage()
await headerPage.changeanguageHeaderButtonToBe(LanguagesEnum.EN)
await headerPage.changeLanguageToBe(LanguagesEnum.EN)
})

test.afterAll(async () => {
Expand Down
Loading

0 comments on commit a4c57c6

Please sign in to comment.