-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* fix conflicts * fix conflicts * fix conflicts * fix conflicts * refactor test specs * revert changes in .vscode/settings.json --------- Co-authored-by: PollySt <[email protected]>
- Loading branch information
Showing
9 changed files
with
156 additions
and
55 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 |
---|---|---|
@@ -1,4 +1,7 @@ | ||
export const PRODUCT_NAME = process.env.PLAYWRIGHT_PRODUCT_NAME; | ||
export const PRODUCT_OUTOFSTOCK = process.env.PLAYWRIGHT_PRODUCT_NAME_OUTOFSTOCK; | ||
export const PRODUCT_COLOR_OUTOFSTOCK = process.env.PLAYWRIGHT_PRODUCT_COLOR_OUTOFSTOCK; | ||
export const PRODUCT_SIZE_OUTOFSTOCK = process.env.PLAYWRIGHT_PRODUCT_SIZE_OUTOFSTOCK; | ||
export const HOMEPAGE_ENDPOINT = '/'; | ||
export const COLLECTION_NAME = process.env.PLAYWRIGHT_COLLECTION_NAME; | ||
export const COLLECTIONS_ENDPOINT = '/collections/'; |
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 was deleted.
Oops, something went wrong.
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,132 @@ | ||
import { test } from '../fixtures'; | ||
import { | ||
COLLECTION_NAME, | ||
COLLECTIONS_ENDPOINT, | ||
PRODUCT_COLOR_OUTOFSTOCK, | ||
PRODUCT_NAME, | ||
PRODUCT_OUTOFSTOCK, | ||
PRODUCT_SIZE_OUTOFSTOCK | ||
} from '../constants'; | ||
import { expect } from 'playwright/test'; | ||
|
||
test.describe('Shopping cart', () => { | ||
test.beforeEach('Navigate to the Collections page', async ({ page }) => { | ||
if (!COLLECTION_NAME) { | ||
test.skip(!COLLECTION_NAME, 'PLAYWRIGHT_COLLECTION_NAME was not defined'); | ||
return; | ||
} | ||
await page.goto(COLLECTIONS_ENDPOINT + COLLECTION_NAME); | ||
}); | ||
|
||
test('User is able to add product to cart', async ({ page, collectionsPage, shoppingCart, productPage }) => { | ||
if (!PRODUCT_NAME) { | ||
test.skip(!PRODUCT_NAME, 'PLAYWRIGHT_PRODUCT_NAME was not defined'); | ||
return; | ||
} | ||
|
||
await collectionsPage.getProductByName(PRODUCT_NAME).click(); | ||
await expect(page.getByLabel('Breadcrumb')).toContainText(PRODUCT_NAME); | ||
|
||
const productPrice = await productPage.productPrice().innerText(); | ||
|
||
await productPage.addToCartBtn().click(); | ||
await expect(page.getByText('Shopping cart')).toBeVisible(); | ||
await expect(shoppingCart.shoppingCartItems()).toHaveCount(1); | ||
await expect(shoppingCart.shoppingCartItems()).toContainText(PRODUCT_NAME); | ||
await expect(shoppingCart.cartTotalPrice()).toContainText(productPrice); | ||
}); | ||
|
||
test('Checkout phase', async ({ page, shoppingCart, collectionsPage, productPage }) => { | ||
if (!PRODUCT_NAME) { | ||
test.skip(!PRODUCT_NAME, 'PLAYWRIGHT_PRODUCT_NAME was not defined'); | ||
return; | ||
} | ||
|
||
await collectionsPage.getProductByName(PRODUCT_NAME).click(); | ||
await productPage.addToCartBtn().click(); | ||
await expect(page.getByText('Shopping cart')).toBeVisible(); | ||
await expect(shoppingCart.shoppingCartItems()).toContainText(PRODUCT_NAME); | ||
|
||
await page.goto('/?shopify_checkout_action=success'); | ||
|
||
await page.waitForURL('/'); | ||
await page.getByText('Successfully checked out').waitFor(); | ||
await expect(shoppingCart.cartItemsCount()).toContainText('0'); | ||
}); | ||
|
||
test('Verify clicking on the cart icon opens shopping cart', async ({ shoppingCart }) => { | ||
await shoppingCart.cartIcon().click(); | ||
await shoppingCart.cartDialog().waitFor(); | ||
await expect(shoppingCart.cartDialog()).toContainText('Your cart is empty'); | ||
}); | ||
|
||
test('Adjust the number of items', async ({ shoppingCart, page, collectionsPage, productPage }) => { | ||
if (!PRODUCT_NAME) { | ||
test.skip(!PRODUCT_NAME, 'PLAYWRIGHT_PRODUCT_NAME was not defined'); | ||
return; | ||
} | ||
|
||
await collectionsPage.getProductByName(PRODUCT_NAME).click(); | ||
await page.getByLabel('Breadcrumb').waitFor(); | ||
|
||
const productPrice = await productPage.productPrice().innerText(); | ||
const convertedPrice = parseFloat(productPrice.replace('$', '')); | ||
|
||
await productPage.addToCartBtn().click(); | ||
await shoppingCart.cartDialog().waitFor(); | ||
await expect(shoppingCart.shoppingCartItems()).toHaveCount(1); | ||
await expect(shoppingCart.cartTotalPrice()).toContainText(productPrice); | ||
|
||
await shoppingCart.addItemBtn().click(); | ||
await shoppingCart.addItemBtn().click(); | ||
await expect(shoppingCart.cartTotalPrice()).toContainText(String(convertedPrice * 3)); | ||
|
||
await shoppingCart.reduceItemBtn().click(); | ||
await expect(shoppingCart.cartTotalPrice()).toContainText(String(convertedPrice * 2)); | ||
}); | ||
|
||
test('Remove items from the cart', async ({ shoppingCart, page, collectionsPage, productPage }) => { | ||
if (!PRODUCT_NAME) { | ||
test.skip(!PRODUCT_NAME, 'PLAYWRIGHT_PRODUCT_NAME was not defined'); | ||
return; | ||
} | ||
|
||
await collectionsPage.getProductByName(PRODUCT_NAME).click(); | ||
await page.getByLabel('Breadcrumb').waitFor(); | ||
|
||
const productPrice = await productPage.productPrice().innerText(); | ||
|
||
await productPage.addToCartBtn().click(); | ||
await shoppingCart.cartDialog().waitFor(); | ||
await expect(shoppingCart.shoppingCartItems()).toHaveCount(1); | ||
await expect(shoppingCart.cartTotalPrice()).toContainText(productPrice); | ||
|
||
await shoppingCart.removeCartItemBtn().click(); | ||
await expect(shoppingCart.cartDialog()).toContainText('Your cart is empty'); | ||
await expect(shoppingCart.shoppingCartItems()).toHaveCount(0); | ||
}); | ||
|
||
test('Verify out of stock products cannot be added to cart', async ({ page, collectionsPage, productPage }) => { | ||
if (!PRODUCT_OUTOFSTOCK) { | ||
test.skip(!PRODUCT_OUTOFSTOCK, 'PLAYWRIGHT_PRODUCT_NAME_OUTOFSTOCK was not defined'); | ||
return; | ||
} | ||
if (!PRODUCT_COLOR_OUTOFSTOCK) { | ||
test.skip(!PRODUCT_COLOR_OUTOFSTOCK, 'PLAYWRIGHT_PRODUCT_COLOR_OUTOFSTOCK was not defined'); | ||
return; | ||
} | ||
if (!PRODUCT_SIZE_OUTOFSTOCK) { | ||
test.skip(!PRODUCT_SIZE_OUTOFSTOCK, 'PLAYWRIGHT_PRODUCT_SIZE_OUTOFSTOCK was not defined'); | ||
return; | ||
} | ||
|
||
await collectionsPage.getProductByName(PRODUCT_OUTOFSTOCK).click(); | ||
await page.getByLabel('Breadcrumb').waitFor(); | ||
|
||
await productPage.colorPicker(PRODUCT_COLOR_OUTOFSTOCK).click(); | ||
await productPage.sizePickerDisabled().getByText(PRODUCT_SIZE_OUTOFSTOCK, { exact: true }).click(); | ||
|
||
await expect(page.getByText('Out of stock')).toBeVisible(); | ||
await expect(productPage.addToCartBtn()).toBeDisabled(); | ||
}); | ||
}); |
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
e47de82
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.
Successfully deployed to the following URLs:
penny – ./
penny-takeshape.vercel.app
penny-ecommerce.vercel.app
penny-git-main-takeshape.vercel.app
penny-demo.takeshape.io