Enabling func to be compliant with mobile viewport
This commit is contained in:
parent
d6c643a39b
commit
4219b60e31
|
@ -0,0 +1,5 @@
|
|||
export const isDesktopViewPort = (page) => {
|
||||
const size = page.viewportSize()
|
||||
|
||||
return size.width >= 600
|
||||
}
|
|
@ -34,6 +34,7 @@ export class CheckoutPage {
|
|||
}
|
||||
|
||||
continueToCheckout = async () => {
|
||||
|
||||
await this.continueToCheckoutButton.waitFor()
|
||||
await this.continueToCheckoutButton.click()
|
||||
await this.page.waitForURL(/\/login/, {timeout: 3000})
|
||||
|
|
|
@ -1,9 +1,13 @@
|
|||
import { isDesktopViewPort } from "../Utils/isDesktopViewport.js"
|
||||
|
||||
export class Navigation {
|
||||
constructor(page){
|
||||
this.page = page
|
||||
this.basketCounter = page.locator('[data-qa="header-basket-count"]')
|
||||
this.checkoutLink = page.getByRole('link', { name: 'Checkout' })
|
||||
|
||||
this.mobileBurgerButton = page.locator('[data-qa="burger-button"]')
|
||||
|
||||
}
|
||||
|
||||
getBasketCount = async () => {
|
||||
|
@ -13,6 +17,12 @@ export class Navigation {
|
|||
}
|
||||
|
||||
goToCheckout = async () => {
|
||||
|
||||
if(!isDesktopViewPort(this.page)) {
|
||||
await this.mobileBurgerButton.waitFor()
|
||||
await this.mobileBurgerButton.click()
|
||||
}
|
||||
|
||||
this.checkoutLink.waitFor()
|
||||
|
||||
await this.checkoutLink.click()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { expect } from "@playwright/test"
|
||||
import { Navigation } from "./Navigation.js"
|
||||
import { isDesktopViewPort } from "../Utils/isDesktopViewport.js"
|
||||
|
||||
export class ProductsPage {
|
||||
|
||||
|
@ -22,14 +23,23 @@ export class ProductsPage {
|
|||
|
||||
await expect(specificAddButton).toHaveText("Add to Basket")
|
||||
const navigation = new Navigation(this.page)
|
||||
const basketCountBefore = await navigation.getBasketCount()
|
||||
|
||||
// only desktop viewport
|
||||
let basketCountBefore
|
||||
if (isDesktopViewPort(this.page)) {
|
||||
basketCountBefore = await navigation.getBasketCount()
|
||||
}
|
||||
|
||||
await specificAddButton.click()
|
||||
|
||||
await expect(specificAddButton).toHaveText("Remove from Basket")
|
||||
const basketCountAfter = await navigation.getBasketCount()
|
||||
|
||||
expect(basketCountAfter).toBeGreaterThan(basketCountBefore)
|
||||
// only desktop viewport
|
||||
if(isDesktopViewPort(this.page)) {
|
||||
const basketCountAfter = await navigation.getBasketCount()
|
||||
expect(basketCountAfter).toBeGreaterThan(basketCountBefore)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sortByCheapest = async () => {
|
||||
|
|
|
@ -46,12 +46,12 @@ const config = {
|
|||
|
||||
/* Configure projects for major browsers */
|
||||
projects: [
|
||||
{
|
||||
name: 'chromium',
|
||||
use: {
|
||||
...devices['Desktop Chrome'],
|
||||
},
|
||||
},
|
||||
// {
|
||||
// name: 'chromium',
|
||||
// use: {
|
||||
// ...devices['Desktop Chrome'],
|
||||
// },
|
||||
// },
|
||||
|
||||
// {
|
||||
// name: 'firefox',
|
||||
|
@ -68,18 +68,18 @@ const config = {
|
|||
// },
|
||||
|
||||
/* Test against mobile viewports. */
|
||||
// {
|
||||
// name: 'Mobile Chrome',
|
||||
// use: {
|
||||
// ...devices['Pixel 5'],
|
||||
// },
|
||||
// },
|
||||
// {
|
||||
// name: 'Mobile Safari',
|
||||
// use: {
|
||||
// ...devices['iPhone 12'],
|
||||
// },
|
||||
// },
|
||||
{
|
||||
name: 'Mobile Chrome',
|
||||
use: {
|
||||
...devices['Pixel 5'],
|
||||
},
|
||||
},
|
||||
// {
|
||||
// name: 'Mobile Safari',
|
||||
// use: {
|
||||
// ...devices['iPhone 12'],
|
||||
// },
|
||||
// },
|
||||
|
||||
/* Test against branded browsers. */
|
||||
// {
|
||||
|
|
Loading…
Reference in New Issue