Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 21 additions & 0 deletions pages/login.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Locator, Page, expect } from '@playwright/test';
import { loginData } from '../test-data/login.data';

export class LoginPage {
loginInput: Locator
passwordInput: Locator
loginButton: Locator

constructor(private page: Page) {
this.loginInput = this.page.getByTestId('login-input')
this.passwordInput = this.page.getByTestId('password-input')
this.loginButton = this.page.getByTestId('login-button')
}

async loginSuccesfully() {
await this.page.goto('/')
await this.loginInput.fill(loginData.userId);
await this.passwordInput.fill(loginData.userPassword)
await this.loginButton.click();
}
}
43 changes: 43 additions & 0 deletions pages/payment.page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { Locator, Page } from "@playwright/test";
import { paymentData } from "../test-data/payment.data";

export class PaymentPage {
userAccount: Locator
paymentReceiver: Locator
receiverAccount: Locator
amountOfPayment: Locator
titleOfPayment: Locator
userEmail: Locator
checkboxEmail: Locator
checkboxListOfReceiver: Locator

constructor(private page: Page) {
this.userAccount = this.page.locator('#form_account_from')
this.paymentReceiver = this.page.getByTestId('transfer_receiver')
this.receiverAccount = this.page.getByTestId('form_account_to')
this.amountOfPayment = this.page.getByTestId('form_amount')
this.titleOfPayment = this.page.getByTestId('form_title')
this.userEmail = this.page.locator('#form_email')
this.checkboxEmail = this.page.locator('#uniform-form_is_email span')
this.checkboxListOfReceiver = this.page.locator('#uniform-form_add_receiver span')
}

async fillPaymentForm(
userAccount: string,
paymentReceiver: string,
receiverAccount: string,
amountOfPayment: string,
titleOfPayment: string,
userEmail: string
) {
await this.userAccount.selectOption(userAccount);
await this.paymentReceiver.fill(paymentReceiver);
await this.receiverAccount.fill(receiverAccount);
await this.amountOfPayment.fill(amountOfPayment);
await this.titleOfPayment.fill(titleOfPayment);
await this.checkboxEmail.click();
await this.userEmail.fill(userEmail);
await this.checkboxListOfReceiver.click();

}
}
8 changes: 8 additions & 0 deletions test-data/payment.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export const paymentData = {
userAccount: '[KO] konto na życie [13 159,20 PLN] 4141...0000',
paymentReceiver: 'Anna Kowalska',
reciverAccount: '34 5676 6767 6769 8798 7897 9878',
amountOfPayment: '350',
titleOfPayment: 'na prezent',
userEmail: 'jan.demobankowy@gmail.com',
}
11 changes: 0 additions & 11 deletions test-utils/utils.ts

This file was deleted.

23 changes: 11 additions & 12 deletions tests/login.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, expect } from '@playwright/test';
import { loginData } from '../test-data/login.data';
import { LoginPage } from '../pages/login.page';

test.describe('User login', () => {
test.beforeEach(async ({ page }) => {
Expand All @@ -8,16 +9,12 @@ test.describe('User login', () => {

test('successful login with correct credentials', async ({ page }) => {
// Arrange
const userId = loginData.userId;
const userPassword = loginData.userPassword;
const expectedUserName = loginData.expectedUserName;

// Act
await page.getByTestId('login-input').fill(userId);
await page.getByTestId('password-input').fill(userPassword);
await page.getByTestId('login-button').click();
await new LoginPage(page).loginSuccesfully();

//Assert
// Assert
await expect(page.getByTestId('user-name')).toHaveText(expectedUserName);
});

Expand All @@ -27,10 +24,11 @@ test.describe('User login', () => {
const expectedTextForShortUsername = 'identyfikator ma min. 8 znaków';

// Act
await page.getByTestId('login-input').fill(userId);
await page.getByTestId('password-input').click();
const loginPage = new LoginPage(page)
await loginPage.loginInput.fill(userId);
await loginPage.passwordInput.click();

//Assert
// Assert
await expect(page.getByTestId('error-login-id')).toHaveText(expectedTextForShortUsername);
});

Expand All @@ -41,9 +39,10 @@ test.describe('User login', () => {
const expectedTextForTooShortPassword = 'hasło ma min. 8 znaków';

// Act
await page.getByTestId('login-input').fill(userId);
await page.getByTestId('password-input').fill(userPassword);
await page.getByTestId('password-input').blur();
const loginPage = new LoginPage(page)
await loginPage.loginInput.fill(userId);
await loginPage.passwordInput.fill(userPassword);
await loginPage.passwordInput.blur();

// Assert
await expect(page.getByTestId('error-login-password')).toHaveText(expectedTextForTooShortPassword);
Expand Down
4 changes: 2 additions & 2 deletions tests/logout.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { test, expect } from '@playwright/test';
import { logIn } from '../test-utils/utils';
import { LoginPage } from '../pages/login.page';

test.describe('User logout', () => {
test('successful logout', async ({ page }) => {
// Act
await logIn(page);
await new LoginPage(page).loginSuccesfully();
await page.getByTestId('logout-button').click();

// Assert
Expand Down
77 changes: 28 additions & 49 deletions tests/payment.spec.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,32 @@
import { test, expect, Page } from '@playwright/test';
import { logIn } from '../test-utils/utils';
import { LoginPage } from '../pages/login.page';
import { paymentData } from '../test-data/payment.data';
import { PaymentPage } from '../pages/payment.page';

test.describe('User payments (from menu)', () => {
test.describe('User payments from menu', () => {
test.beforeEach(async ({ page }) => {
await logIn(page);
await new LoginPage(page).loginSuccesfully();
await page.getByRole('link', { name: 'płatności' }).click();
})

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(receiverAccount);
await page.getByTestId('form_amount').fill(amountOfPayment);
await page.getByTestId('form_title').fill(titleOfPayment);
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';
const userAccount = paymentData.userAccount;
const paymentReceiver = paymentData.paymentReceiver;
const receiverAccount = paymentData.reciverAccount;
const amountOfPayment = paymentData.amountOfPayment;
const titleOfPayment = paymentData.titleOfPayment;
const userEmail = paymentData.userEmail;

// Act
await fillPaymentForm(
page,
await new PaymentPage(page).fillPaymentForm(
userAccount,
paymentReceiver,
reciverAccount,
receiverAccount,
amountOfPayment,
titleOfPayment,
userEmail
);
)
await page.getByRole('button', { name: 'wykonaj przelew' }).click();

// Assert
Expand All @@ -58,16 +39,15 @@ test.describe('User payments (from menu)', () => {

test('unsuccessful payment with missing receiver', async ({ page }) => {
// Arrange
const userAccount = '[KO] konto na życie [13 159,20 PLN] 4141...0000';
const userAccount = paymentData.userAccount;
const paymentReceiver = '';
const receiverAccount = '34 5676 6767 6769 8798 7897 9878';
const amountOfPayment = '350';
const titleOfPayment = 'na prezent';
const userEmail = 'jan.demobankowy@gmail.com';
const receiverAccount = paymentData.reciverAccount;
const amountOfPayment = paymentData.amountOfPayment;
const titleOfPayment = paymentData.titleOfPayment;
const userEmail = paymentData.userEmail;

// Act
await fillPaymentForm(
page,
await new PaymentPage(page).fillPaymentForm(
userAccount,
paymentReceiver,
receiverAccount,
Expand All @@ -83,16 +63,15 @@ test.describe('User payments (from menu)', () => {

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 userAccount = paymentData.userAccount;
const paymentReceiver = paymentData.paymentReceiver;
const receiverAccount = '';
const amountOfPayment = '350';
const titleOfPayment = 'na prezent';
const userEmail = 'jan.demobankowy@gmail.com';
const amountOfPayment = paymentData.amountOfPayment;
const titleOfPayment = paymentData.titleOfPayment;
const userEmail = paymentData.userEmail;

// Act
await fillPaymentForm(
page,
await new PaymentPage(page).fillPaymentForm(
userAccount,
paymentReceiver,
receiverAccount,
Expand All @@ -105,4 +84,4 @@ test.describe('User payments (from menu)', () => {
await expect(page.getByTestId('error-widget-2-transfer-account'))
.toContainText('pole wymagane');
});
});
});
8 changes: 4 additions & 4 deletions tests/session.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { test, expect, Page } from '@playwright/test';
import { logIn } from '../test-utils/utils';
import { LoginPage } from '../pages/login.page';

test.describe('session time', () => {
test.beforeEach(async ({ page }) => {
await logIn(page)
await new LoginPage(page).loginSuccesfully()
});

async function getSessionLeftMinutes(page: Page) {
Expand All @@ -29,5 +29,5 @@ test.describe('session time', () => {
await page.waitForTimeout(1500)
const timeAfter = await getSessionLeft(page)
await expect(timeAfter).toBe('09:59')
})
})
});
});
4 changes: 2 additions & 2 deletions tests/transfer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { test, expect, Page } from '@playwright/test';
import { logIn } from '../test-utils/utils';
import { LoginPage } from '../pages/login.page';

test.describe('User quick money transfer', () => {
test.beforeEach(async ({ page }) => {
await logIn(page)
await new LoginPage(page).loginSuccesfully()
});

async function readBalance(page: Page) {
Expand Down