-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update tests to work with sample data
- Loading branch information
1 parent
4751e09
commit c388a3c
Showing
7 changed files
with
41 additions
and
37 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ node_modules/ | |
test-results/ | ||
playwright-report/ | ||
hyva/ | ||
.idea/ | ||
.idea/ | ||
|
||
.env |
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,17 @@ | ||
|
||
export default class PaypalPopup { | ||
constructor(popup) { | ||
this.popup = popup; | ||
} | ||
|
||
async acceptPayment() { | ||
await this.popup.getByPlaceholder('Email').fill('[email protected]'); | ||
if(await this.popup.getByRole('button', { name: 'Next' }).isVisible()) { | ||
await this.popup.getByRole('button', {name: 'Next'}).click(); | ||
} | ||
await this.popup.getByPlaceholder('Password').fill('h5Hc/b8M'); | ||
await this.popup.getByRole('button', { name: 'Log In' }).click(); | ||
|
||
await this.popup.getByTestId('submit-button-initial').click(); | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import {expect, test} from '@playwright/test'; | ||
import VisitCheckoutPayment from "./Pages/VisitCheckoutPayment"; | ||
import PaypalPopup from "./Components/PaypalPopup"; | ||
|
||
test('Can place an order using PayPal', async ({ page, browser }) => { | ||
const visitCheckoutPayment = new VisitCheckoutPayment(page); | ||
|
@@ -8,22 +9,17 @@ test('Can place an order using PayPal', async ({ page, browser }) => { | |
await page.getByLabel('PayPal', { exact: true }).click(); | ||
|
||
await expect(page.locator('#rvvup-paypal-button-container')).toBeVisible(); | ||
await page.waitForTimeout(2000); | ||
|
||
page.on('popup', async popup => { | ||
await popup.waitForLoadState(); | ||
|
||
await popup.getByPlaceholder('Email').fill('[email protected]'); | ||
await popup.getByPlaceholder('Password').fill('h5Hc/b8M'); | ||
|
||
await popup.getByRole('button', { name: 'Log In' }).click(); | ||
await popup.getByRole('button', { name: 'Complete Purchase' }).click(); | ||
}); | ||
|
||
const paypalFrame = page.frameLocator('#rvvup-paypal-button-container iframe:first-of-type') | ||
const popupPromise = page.waitForEvent('popup'); | ||
const paypalFrame = page.frameLocator('#rvvup-paypal-button-container iframe').first(); | ||
await paypalFrame.getByRole('link', { name: 'PayPal' }).click(); | ||
|
||
await new PaypalPopup(await popupPromise).acceptPayment(); | ||
|
||
await expect(page.locator('#payment-method-view-rvvup_PAYPAL')) | ||
.not.toContainText('You are currently paying with PayPal. If you want to cancel this process'); | ||
await expect(page.frameLocator('#rvvup-modal iframe').getByText("Payment being processed")).toBeVisible(); | ||
|
||
await page.waitForURL("**/checkout/onepage/success/"); | ||
|
||
|
@@ -35,28 +31,18 @@ test('Can place an order from the product page using PayPal', async ({ page }) = | |
|
||
await page.goto('./joust-duffle-bag.html'); | ||
|
||
page.on('popup', async popup => { | ||
await popup.waitForLoadState(); | ||
|
||
await popup.getByPlaceholder('Email').fill('[email protected]'); | ||
await popup.getByRole('button', { name: 'Next' }).click(); | ||
|
||
await popup.getByPlaceholder('Password').fill('h5Hc/b8M'); | ||
await popup.getByRole('button', { name: 'Log In' }).click(); | ||
|
||
await popup.getByRole('button', { name: 'Continue to review order' }).click(); | ||
}); | ||
|
||
const paypalFrame = page.frameLocator('.rvvup-paypal-express-button-container iframe:first-of-type') | ||
const popupPromise = page.waitForEvent('popup'); | ||
const paypalFrame = page.frameLocator('.rvvup-paypal-express-button-container iframe').first(); | ||
await paypalFrame.getByRole('link', { name: 'PayPal' }).click(); | ||
await new PaypalPopup(await popupPromise).acceptPayment(); | ||
|
||
await page.waitForURL("**/checkout/"); | ||
|
||
await page.getByLabel('Phone number').fill('+447500000000'); | ||
|
||
await page.getByLabel('Fixed').click(); | ||
|
||
visitCheckoutPayment.loadersShouldBeHidden(); | ||
await visitCheckoutPayment.loadersShouldBeHidden(); | ||
|
||
await page.getByRole('button', { name: 'Proceed to review & payments' }).click(); | ||
|
||
|
@@ -69,6 +55,7 @@ test('Can place an order from the product page using PayPal', async ({ page }) = | |
await expect(children.length).toBe(1); | ||
|
||
await page.getByRole('button', { name: 'Place order' }).click(); | ||
await expect(page.frameLocator('#rvvup-modal iframe').getByText("Payment being processed")).toBeVisible(); | ||
await page.waitForURL("**/checkout/onepage/success/"); | ||
await expect(page.getByRole('heading', { name: 'Thank you for your purchase!' })).toBeVisible(); | ||
}); |