-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: update account_creation.spec.js, login_page.js and registration…
…_page.js
- Loading branch information
Chris Kouvaras
committed
Mar 18, 2024
1 parent
3d3b623
commit 4d48585
Showing
5 changed files
with
251 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
const { test, expect } = require('@playwright/test'); | ||
|
||
class AddContactsPage { | ||
constructor(page) { | ||
this.page = page; | ||
} | ||
|
||
async open() { | ||
await this.page.goto('https://thinking-tester-contact-list.herokuapp.com/addContact'); | ||
await expect(this.page).toHaveTitle(/Add Contact/); | ||
await expect(this.page.locator('h1')).toHaveText('Add Contact'); | ||
await expect(this.page).toHaveURL('https://thinking-tester-contact-list.herokuapp.com/addContact'); | ||
} | ||
|
||
async addNewContact(dataArray) { | ||
|
||
const locatorsArray = ['First Name', 'Last Name', 'yyyy-MM-dd', 'example@email.com', '8005551234', 'Address 1', 'Address 2', 'City', 'State or Province', 'Postal Code', 'Country'] | ||
|
||
await expect(this.page).toHaveTitle(/Add Contact/); | ||
await expect(this.page.locator('h1')).toHaveText('Add Contact'); | ||
await expect(this.page.getByRole('button', { name: 'Logout' })).toBeAttached() | ||
await expect(this.page.getByRole('button', { name: 'Submit' })).toBeAttached() | ||
await expect(this.page.getByRole('button', { name: 'Cancel' })).toBeAttached() | ||
|
||
for (let i = 0; i < dataArray.length; i++) { | ||
|
||
await this.page.getByPlaceholder(locatorsArray[i]).fill(dataArray[i]) | ||
|
||
} | ||
|
||
} | ||
|
||
async submitNewContact(isSuccessful) { | ||
|
||
await this.page.getByRole('button', { name: 'Submit' }).click(); | ||
|
||
if (isSuccessful) { | ||
|
||
await expect(this.page.getByText('Contact validation failed')).not.toBeAttached(); | ||
await expect(this.page).toHaveURL('https://thinking-tester-contact-list.herokuapp.com/contactList'); | ||
} | ||
|
||
else { | ||
|
||
await expect(this.page.getByText('Contact validation failed')).toBeAttached(); | ||
await expect(this.page).toHaveURL('https://thinking-tester-contact-list.herokuapp.com/addContact'); | ||
|
||
} | ||
|
||
} | ||
|
||
async clickLogoutButton() { | ||
await this.page.getByRole('button', { name: 'Logout' }).click(); | ||
await expect(this.page).toHaveTitle(/Contact List App/); | ||
await expect(this.page).toHaveURL('https://thinking-tester-contact-list.herokuapp.com'); | ||
|
||
} | ||
|
||
async cancelAddContactForm() { | ||
|
||
await this.page.getByRole('button', { name: 'Cancel' }).click(); | ||
await expect(this.page).toHaveURL('https://thinking-tester-contact-list.herokuapp.com/contactList'); | ||
|
||
} | ||
|
||
} | ||
|
||
module.exports = AddContactsPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
const { test, expect } = require('@playwright/test'); | ||
|
||
class ContactsPage { | ||
constructor(page) { | ||
this.page = page; | ||
} | ||
|
||
async open() { | ||
await this.page.goto('https://thinking-tester-contact-list.herokuapp.com/contactList'); | ||
await expect(this.page).toHaveTitle(/My Contacts/); | ||
await expect(this.page.locator('h1')).toHaveText('Contact List'); | ||
await expect(this.page).toHaveURL('https://thinking-tester-contact-list.herokuapp.com/contactList'); | ||
|
||
} | ||
|
||
async assertContactsPage() { | ||
await expect(this.page).toHaveTitle(/My Contacts/); | ||
await expect(this.page).toHaveURL('https://thinking-tester-contact-list.herokuapp.com/contactList'); | ||
await expect(this.page.locator('h1')).toHaveText('Contact List'); | ||
await expect(this.page.getByRole('button', { name: 'Logout' })).toBeAttached() | ||
await expect(this.page.getByRole('button', { name: 'Add a New Contact' })).toBeAttached() | ||
await expect(this.page.locator('div.contacts')).toBeVisible(); | ||
|
||
} | ||
async clickLogoutButton() { | ||
await this.page.getByRole('button', { name: 'Logout' }).click(); | ||
await expect(this.page).toHaveTitle(/Contact List App/); | ||
await expect(this.page).toHaveURL('https://thinking-tester-contact-list.herokuapp.com'); | ||
} | ||
|
||
async clickAddANewContact() { | ||
await this.page.getByRole('button', { name: 'Add a New Contact' }).click(); | ||
await expect(this.page).toHaveTitle(/Add Contact/); | ||
await expect(this.page).toHaveURL('https://thinking-tester-contact-list.herokuapp.com/addContact'); | ||
} | ||
async verifyContactRow(dataArray) { | ||
await expect(this.page.locator('h1')).toHaveText('Contact List'); | ||
|
||
for (let i = 0; i < dataArray.length; i++) { | ||
await expect(this.page.getByText(dataArray[i], { exact: false })).toBeVisible(); | ||
} | ||
|
||
} | ||
} | ||
|
||
module.exports = ContactsPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,46 @@ | ||
const { test, expect } = require('@playwright/test'); | ||
|
||
class LoginPage { | ||
constructor(page) { | ||
this.page = page; | ||
} | ||
|
||
async open() { | ||
await this.page.goto('https://thinking-tester-contact-list.herokuapp.com/'); | ||
await expect(this.page).toHaveTitle(/Contact List App/); | ||
await expect(this.page.locator('h1')).toHaveText('Contact List App'); | ||
constructor(page) { | ||
this.page = page; | ||
} | ||
|
||
async open() { | ||
await this.page.goto('https://thinking-tester-contact-list.herokuapp.com/'); | ||
await expect(this.page).toHaveTitle(/Contact List App/); | ||
await expect(this.page.locator('h1')).toHaveText('Contact List App'); | ||
await expect(this.page).toHaveURL('https://thinking-tester-contact-list.herokuapp.com'); | ||
} | ||
|
||
async clickRegisterButton() { | ||
await this.page.getByRole('button', { name: 'Sign up' }).click(); | ||
await expect(this.page).toHaveTitle(/Add User/); | ||
await expect(this.page).toHaveURL('https://thinking-tester-contact-list.herokuapp.com/addUser'); | ||
} | ||
|
||
async assertLoggedOut() { | ||
await expect(this.page).toHaveTitle(/Contact List App/); | ||
await expect(this.page.getByText('Logout')).not.toBeAttached(); | ||
await expect(this.page).toHaveURL('https://thinking-tester-contact-list.herokuapp.com'); | ||
} | ||
|
||
async logIn(email, password, isSuccessful) { | ||
await this.page.fill('input[placeholder="Email"]', email); | ||
await this.page.fill('input[placeholder="Password"]', password); | ||
await this.page.getByRole('button', { name: 'Submit' }).click(); | ||
|
||
if (isSuccessful) { | ||
await expect(this.page.getByText('Incorrect username or password')).not.toBeAttached(); | ||
await expect(this.page).toHaveURL('https://thinking-tester-contact-list.herokuapp.com/contactList'); | ||
} | ||
async clickRegisterButton() { | ||
await this.page.getByRole('button', { name: 'Sign up' }).click(); | ||
await expect(this.page).toHaveTitle(/Add User/); | ||
|
||
else { | ||
await expect(this.page.getByText('Incorrect username or password')).toBeAttached(); | ||
await expect(this.page).toHaveURL('https://thinking-tester-contact-list.herokuapp.com'); | ||
} | ||
|
||
} | ||
|
||
module.exports = LoginPage; | ||
|
||
} | ||
|
||
module.exports = LoginPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters