From d4a3987c74480c23848c7e072394f8c66f60d3f6 Mon Sep 17 00:00:00 2001 From: Joanna Dyraga Date: Sun, 5 Jan 2025 21:46:50 +0100 Subject: [PATCH 1/2] Happy path test for payments Implemented happy path test for payments useing left menu option. --- tests/payment.spec.ts | 40 ++++++++++++++++++++++++++++++++++++++++ tests/transfer.spec.ts | 2 +- 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 tests/payment.spec.ts diff --git a/tests/payment.spec.ts b/tests/payment.spec.ts new file mode 100644 index 0000000..d9e70c8 --- /dev/null +++ b/tests/payment.spec.ts @@ -0,0 +1,40 @@ +import { test, expect } from '@playwright/test'; +import { logIn } from '../test-utils/utils'; + +test.describe('User payments (from menu)', () => { + test.beforeEach(async ({ page }) => { + await logIn(page) + await page.getByRole('link', { name: 'płatności' }).click() + }) + + test('successful payment with required form data', async ({ page }) => { + //Arange + const userAccount = '[KO] konto na życie [13 159,20 PLN] 4141...0000'; + const paymentReceiver = 'Anna Kowalska'; + const reciverAccount = '34 5676 6767 6769 8798 7897 9878' + const amountOfPayment = '350' + const titleOfPayment = 'na prezent' + const userEmail = 'jan.demobankowy@gmail.com' + + //Act + await page.locator('#form_account_from').selectOption(userAccount); + await page.getByTestId('transfer_receiver').fill(paymentReceiver); + await page.getByTestId('form_account_to').fill(reciverAccount); + await page.getByTestId('form_amount').fill(amountOfPayment); + await page.getByTestId('form_title').fill(titleOfPayment); + await page.locator('#form_date').click(); + await page.getByRole('link', { name: '5', exact: true }).click(); + await page.getByLabel('ekspresowy').click(); + await page.locator('#uniform-form_is_email span').click(); + await page.locator('#form_email').fill(userEmail); + await page.locator('#uniform-form_add_receiver span').click(); + await page.getByRole('button', { name: 'wykonaj przelew' }).click(); + + //Assert + const successModal = page.getByRole('paragraph') + await expect(successModal).toContainText('Przelew wykonany!') + await expect(successModal).toContainText(`Odbiorca: ${paymentReceiver}`) + await expect(successModal).toContainText(`Kwota: ${amountOfPayment}`) + await expect(successModal).toContainText(`Nazwa: ${titleOfPayment}`) + }); +}); \ No newline at end of file diff --git a/tests/transfer.spec.ts b/tests/transfer.spec.ts index 9b02da4..70c94fd 100644 --- a/tests/transfer.spec.ts +++ b/tests/transfer.spec.ts @@ -1,7 +1,7 @@ import { test, expect, Page } from '@playwright/test'; import { logIn } from '../test-utils/utils'; -test.describe('User money transfer', () => { +test.describe('User quick money transfer', () => { test.beforeEach(async ({ page }) => { await logIn(page) }); From 28718c22c1d75b0259c9ca7917f542385072a244 Mon Sep 17 00:00:00 2001 From: Joanna Dyraga Date: Mon, 6 Jan 2025 21:02:39 +0100 Subject: [PATCH 2/2] Added two test covering payment form validation The first test covers scenario when the receiver name is missing. The second test covers scenario when the receiver account is missing. --- tests/payment.spec.ts | 112 +++++++++++++++++++++++++++++++++--------- 1 file changed, 90 insertions(+), 22 deletions(-) diff --git a/tests/payment.spec.ts b/tests/payment.spec.ts index d9e70c8..525974a 100644 --- a/tests/payment.spec.ts +++ b/tests/payment.spec.ts @@ -1,40 +1,108 @@ -import { test, expect } from '@playwright/test'; +import { test, expect, Page } from '@playwright/test'; import { logIn } from '../test-utils/utils'; test.describe('User payments (from menu)', () => { test.beforeEach(async ({ page }) => { - await logIn(page) - await page.getByRole('link', { name: 'płatności' }).click() + await logIn(page); + await page.getByRole('link', { name: 'płatności' }).click(); }) - test('successful payment with required form data', async ({ page }) => { - //Arange - const userAccount = '[KO] konto na życie [13 159,20 PLN] 4141...0000'; - const paymentReceiver = 'Anna Kowalska'; - const reciverAccount = '34 5676 6767 6769 8798 7897 9878' - const amountOfPayment = '350' - const titleOfPayment = 'na prezent' - const userEmail = 'jan.demobankowy@gmail.com' - - //Act + async function fillPaymentForm( + page: Page, + userAccount: string, + paymentReceiver: string, + receiverAccount: string, + amountOfPayment: string, + titleOfPayment: string, + userEmail: string + ) { await page.locator('#form_account_from').selectOption(userAccount); await page.getByTestId('transfer_receiver').fill(paymentReceiver); - await page.getByTestId('form_account_to').fill(reciverAccount); + await page.getByTestId('form_account_to').fill(receiverAccount); await page.getByTestId('form_amount').fill(amountOfPayment); await page.getByTestId('form_title').fill(titleOfPayment); - await page.locator('#form_date').click(); - await page.getByRole('link', { name: '5', exact: true }).click(); await page.getByLabel('ekspresowy').click(); await page.locator('#uniform-form_is_email span').click(); await page.locator('#form_email').fill(userEmail); await page.locator('#uniform-form_add_receiver span').click(); + } + + test('successful payment with required form data', async ({ page }) => { + // Arrange + const userAccount = '[KO] konto na życie [13 159,20 PLN] 4141...0000'; + const paymentReceiver = 'Anna Kowalska'; + const reciverAccount = '34 5676 6767 6769 8798 7897 9878'; + const amountOfPayment = '350'; + const titleOfPayment = 'na prezent'; + const userEmail = 'jan.demobankowy@gmail.com'; + + // Act + await fillPaymentForm( + page, + userAccount, + paymentReceiver, + reciverAccount, + amountOfPayment, + titleOfPayment, + userEmail + ); await page.getByRole('button', { name: 'wykonaj przelew' }).click(); - //Assert - const successModal = page.getByRole('paragraph') - await expect(successModal).toContainText('Przelew wykonany!') - await expect(successModal).toContainText(`Odbiorca: ${paymentReceiver}`) - await expect(successModal).toContainText(`Kwota: ${amountOfPayment}`) - await expect(successModal).toContainText(`Nazwa: ${titleOfPayment}`) + // Assert + const successModal = page.getByRole('paragraph'); + await expect(successModal).toContainText('Przelew wykonany!'); + await expect(successModal).toContainText(`Odbiorca: ${paymentReceiver}`); + await expect(successModal).toContainText(`Kwota: ${amountOfPayment}`); + await expect(successModal).toContainText(`Nazwa: ${titleOfPayment}`); + }); + + test('unsuccessful payment with missing receiver', async ({ page }) => { + // Arrange + const userAccount = '[KO] konto na życie [13 159,20 PLN] 4141...0000'; + const paymentReceiver = ''; + const receiverAccount = '34 5676 6767 6769 8798 7897 9878'; + const amountOfPayment = '350'; + const titleOfPayment = 'na prezent'; + const userEmail = 'jan.demobankowy@gmail.com'; + + // Act + await fillPaymentForm( + page, + userAccount, + paymentReceiver, + receiverAccount, + amountOfPayment, + titleOfPayment, + userEmail + ); + + // Assert + await expect(page.getByTestId('error-widget-4-transfer-receiver')) + .toContainText('pole wymagane'); + }); + + test('unsuccessful payment with missing receiver account', async ({ page }) => { + // Arrange + const userAccount = '[KO] konto na życie [13 159,20 PLN] 4141...0000'; + const paymentReceiver = 'Anna Kowalska'; + const receiverAccount = ''; + const amountOfPayment = '350'; + const titleOfPayment = 'na prezent'; + const userEmail = 'jan.demobankowy@gmail.com'; + + // Act + await fillPaymentForm( + page, + userAccount, + paymentReceiver, + receiverAccount, + amountOfPayment, + titleOfPayment, + userEmail + ); + + // Assert + await expect(page.getByTestId('error-widget-2-transfer-account')) + .toContainText('pole wymagane'); }); }); \ No newline at end of file