-
Notifications
You must be signed in to change notification settings - Fork 12
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
add manager tests #4
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,58 @@ const { expect } = require('@playwright/test'); | |
|
||
export class AddCustomerPage { | ||
constructor(page) { | ||
this.page = page; | ||
this.page = page; | ||
this.firstNameInputField = page.getByPlaceholder('First Name'); | ||
this.lastNameInputField = page.getByPlaceholder('Last Name'); | ||
this.postCodeInputField = page.getByPlaceholder('Post Code'); | ||
this.addCustomerButton = page.getByRole('form').getByRole('button', { name: 'Add Customer' }); | ||
this.customersButton = page.getByRole('button', { name: 'Customers' }); | ||
|
||
this.lastRow = page.getByRole('row').last(); | ||
this.accountNumberCell = this.lastRow.getByRole('cell').nth(3); | ||
} | ||
|
||
async open() { | ||
await this.page.goto('/angularJs-protractor/BankingProject/#/manager/addCust'); | ||
} | ||
|
||
async fillFirstNameInputField(value) { | ||
await this.firstNameInputField.fill(value); | ||
} | ||
|
||
async fillLastNameInputField(value) { | ||
await this.lastNameInputField.fill(value); | ||
} | ||
|
||
async fillPostCodeInputField(value) { | ||
await this.postCodeInputField.fill(value); | ||
} | ||
|
||
async clickAddCustomerButton() { | ||
await this.addCustomerButton.click(); | ||
} | ||
|
||
async reload() { | ||
await this.page.reload(); | ||
} | ||
|
||
async clickCustomersButton() { | ||
await this.customersButton.click(); | ||
} | ||
|
||
async assertCustomersTableContainsFirstName(value) { | ||
await expect(this.lastRow).toContainText(value); | ||
} | ||
|
||
async assertCustomersTableContainsLastName(value) { | ||
await expect(this.lastRow).toContainText(value); | ||
Comment on lines
+48
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar to the previous comment, |
||
} | ||
|
||
async assertCustomersTableContainsPostalCode(value) { | ||
await expect(this.lastRow).toContainText(value); | ||
Comment on lines
+52
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method |
||
} | ||
|
||
async assertAccountNumberInCustomersTableIsEmpty() { | ||
await expect(this.accountNumberCell).toBeEmpty(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,56 @@ const { expect } = require('@playwright/test'); | |
|
||
export class CustomersListPage { | ||
constructor(page) { | ||
this.page = page; | ||
this.page = page; | ||
this.lastRow = page.getByRole('row').last(); | ||
this.accountNumberCell = this.lastRow.getByRole('cell').nth(3); | ||
Comment on lines
+6
to
+7
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of |
||
this.searchField = this.page.getByPlaceholder('Search Customer'); | ||
|
||
this.firstRow = page.getByRole('row').nth(1); | ||
this.firstNameCell = this.firstRow.getByRole('cell').nth(0); | ||
|
||
this.lastNameCell = this.firstRow.getByRole('cell').nth(1); | ||
|
||
this.postCodeCell = this.firstRow.getByRole('cell').nth(2); | ||
Comment on lines
+10
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of |
||
} | ||
|
||
async open() { | ||
await this.page.goto('/angularJs-protractor/BankingProject/#/manager/list'); | ||
} | ||
|
||
async clickDeleteButton(value) { | ||
await this.page.getByRole('row', { name: value }).getByRole('button').click(); | ||
} | ||
|
||
async assertCustomerRowIsNotPresentInTable(value) { | ||
await expect(this.page.getByRole('row', { name: value })).toHaveCount(0); | ||
} | ||
|
||
async reload() { | ||
await this.page.reload(); | ||
} | ||
|
||
async assertCustomerRowHasAccountNumber(value) { | ||
await expect(this.accountNumberCell).not.toBeEmpty(); | ||
Comment on lines
+34
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The method |
||
} | ||
|
||
async fillSearchField(value) { | ||
await this.searchField.fill(value); | ||
} | ||
|
||
async assertCustomerRowHasFirstName(value) { | ||
await expect(this.firstNameCell).toContainText(value); | ||
} | ||
|
||
async assertCustomerTableContainsSingleRow() { | ||
await expect(this.page.getByRole('row')).toHaveCount(2); | ||
} | ||
|
||
async assertCustomerRowHasLastName(value) { | ||
await expect(this.lastNameCell).toContainText(value); | ||
} | ||
|
||
async assertCustomerRowHasPostCode(value) { | ||
await expect(this.postCodeCell).toContainText(value); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,42 @@ | ||
const { expect } = require('@playwright/test'); | ||
|
||
export class AddCustomerPage { | ||
export class OpenAccountPage { | ||
constructor(page) { | ||
this.page = page; | ||
this.currencyDropDown = page.getByTestId('currency'); | ||
this.customerDropDown = page.getByTestId('userSelect'); | ||
this.processButton = page.getByRole('button', { name: 'Process' }); | ||
this.customersButton = page.getByRole('button', { name: 'Customers' }); | ||
|
||
this.lastRow = page.getByRole('row').last(); | ||
this.accountNumberCell = this.lastRow.getByRole('cell').nth(3); | ||
Comment on lines
+11
to
+12
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The use of |
||
} | ||
|
||
async open() { | ||
await this.page.goto('/angularJs-protractor/BankingProject/#/manager/openAccount'); | ||
} | ||
|
||
async setCurrency(value) { | ||
await this.currencyDropDown.selectOption(value); | ||
} | ||
|
||
async assertCurrencyDropDownHasText(value) { | ||
await expect(this.currencyDropDown).toHaveValue(value); | ||
} | ||
|
||
async selectCustomer(value) { | ||
await this.customerDropDown.selectOption(value); | ||
} | ||
|
||
async clickProcessButton() { | ||
await this.processButton.click(); | ||
} | ||
|
||
async reload() { | ||
await this.page.reload(); | ||
} | ||
|
||
async clickCustomersButton() { | ||
await this.customersButton.click(); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { test } from '@playwright/test'; | ||
import { faker } from '@faker-js/faker'; | ||
import { AddCustomerPage } from '../../../src/pages/manager/AddCustomerPage'; | ||
|
||
test('Assert manager can add new customer', async ({ page }) => { | ||
/* | ||
|
@@ -25,4 +26,22 @@ usage: | |
|
||
2. Do not rely on the customer row id for the steps 8-11. Use the ".last()" locator to get the last row. | ||
*/ | ||
|
||
const addCustomerPage = new AddCustomerPage(page); | ||
const firstName = faker.person.firstName(); | ||
const lastName = faker.person.lastName(); | ||
const postCode = faker.location.zipCode(); | ||
|
||
await addCustomerPage.open(); | ||
await addCustomerPage.fillFirstNameInputField(firstName); | ||
await addCustomerPage.fillLastNameInputField(lastName); | ||
await addCustomerPage.fillPostCodeInputField(postCode); | ||
await addCustomerPage.clickAddCustomerButton(); | ||
await addCustomerPage.reload(); | ||
|
||
await addCustomerPage.clickCustomersButton(); | ||
await addCustomerPage.assertCustomersTableContainsFirstName(firstName); | ||
await addCustomerPage.assertCustomersTableContainsLastName(lastName); | ||
await addCustomerPage.assertCustomersTableContainsPostalCode(postCode); | ||
Comment on lines
+43
to
+45
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The assertions for checking the first name, last name, and postal code rely on the last row being the newly added customer. This might not be reliable if the table is sorted or updated dynamically. Consider implementing a more robust way to verify the customer details. |
||
await addCustomerPage.assertAccountNumberInCustomersTableIsEmpty(); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,11 @@ | ||
import { test } from '@playwright/test'; | ||
import { faker } from '@faker-js/faker'; | ||
import { AddCustomerPage } from '../../../src/pages/manager/AddCustomerPage'; | ||
import { CustomersListPage } from '../../../src/pages/manager/CustomersListPage'; | ||
|
||
const firstName = faker.person.firstName(); | ||
const lastName = faker.person.lastName(); | ||
const postCode = faker.location.zipCode(); | ||
|
||
test.beforeEach( async ({ page }) => { | ||
/* | ||
|
@@ -11,6 +17,13 @@ test.beforeEach( async ({ page }) => { | |
5. Click [Add Customer]. | ||
*/ | ||
|
||
const addCustomerPage = new AddCustomerPage(page); | ||
|
||
await addCustomerPage.open(); | ||
await addCustomerPage.fillFirstNameInputField(firstName); | ||
await addCustomerPage.fillLastNameInputField(lastName); | ||
await addCustomerPage.fillPostCodeInputField(postCode); | ||
await addCustomerPage.clickAddCustomerButton(); | ||
}); | ||
|
||
test('Assert manager can delete customer', async ({ page }) => { | ||
|
@@ -22,6 +35,12 @@ Test: | |
4. Reload the page. | ||
5. Assert customer row is not present in the table. | ||
*/ | ||
const customersListPage = new CustomersListPage(page); | ||
const fullName = firstName + ' ' + lastName + ' ' + postCode; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
|
||
|
||
await customersListPage.open(); | ||
await customersListPage.clickDeleteButton(fullName); | ||
await customersListPage.assertCustomerRowIsNotPresentInTable(fullName); | ||
await customersListPage.reload(); | ||
await customersListPage.assertCustomerRowIsNotPresentInTable(fullName); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
import { test } from '@playwright/test'; | ||
import { faker } from '@faker-js/faker'; | ||
import { AddCustomerPage } from '../../../src/pages/manager/AddCustomerPage'; | ||
import { OpenAccountPage } from '../../../src/pages/manager/OpenAccountPage'; | ||
import { CustomersListPage } from '../../../src/pages/manager/CustomersListPage'; | ||
|
||
const firstName = faker.person.firstName(); | ||
const lastName = faker.person.lastName(); | ||
const postCode = faker.location.zipCode(); | ||
|
||
|
||
test.beforeEach( async ({ page }) => { | ||
/* | ||
|
@@ -12,6 +20,14 @@ test.beforeEach( async ({ page }) => { | |
6. Reload the page (This is a simplified step to close the popup). | ||
*/ | ||
|
||
const addCustomerPage = new AddCustomerPage(page); | ||
|
||
await addCustomerPage.open(); | ||
await addCustomerPage.fillFirstNameInputField(firstName); | ||
await addCustomerPage.fillLastNameInputField(lastName); | ||
await addCustomerPage.fillPostCodeInputField(postCode); | ||
await addCustomerPage.clickAddCustomerButton(); | ||
await addCustomerPage.reload(); | ||
}); | ||
|
||
test('Assert manager can add new customer', async ({ page }) => { | ||
|
@@ -28,4 +44,19 @@ Test: | |
Tips: | ||
1. Do not rely on the customer row id for the step 13. Use the ".last()" locator to get the last row. | ||
*/ | ||
|
||
const openAccountPage = new OpenAccountPage(page); | ||
|
||
await openAccountPage.open(); | ||
await openAccountPage.selectCustomer(firstName + ' ' + lastName); | ||
await openAccountPage.setCurrency('Dollar'); | ||
await openAccountPage.clickProcessButton(); | ||
await openAccountPage.reload(); | ||
await openAccountPage.clickCustomersButton(); | ||
|
||
const customersListPage = new CustomersListPage(page); | ||
await customersListPage.open(); | ||
const fullName = firstName + ' ' + lastName + ' ' + postCode; | ||
|
||
await customersListPage.assertCustomerRowHasAccountNumber(fullName); | ||
Comment on lines
+59
to
+61
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The |
||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method
assertCustomersTableContainsFirstName
assumes that the last row in the table is the newly added customer. This might not be reliable if the table is sorted or updated dynamically. Consider searching for the specific row containing the expected first name.