Skip to content
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

Tests #144

Open
wants to merge 38 commits into
base: main
Choose a base branch
from
Open

Tests #144

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f0858e9
update dependencies
sharma-shray Jun 18, 2024
5e7bc62
Merge pull request #1 from sharma-shray/upd-dep
sharma-shray Jun 18, 2024
2238509
Playwright init, tests
sharma-shray Jun 19, 2024
03e567b
Merge pull request #2 from sharma-shray/plw
sharma-shray Jun 19, 2024
93ef160
Home page links tests
sharma-shray Jun 21, 2024
8f15511
Merge pull request #3 from sharma-shray/link-tests
sharma-shray Jun 21, 2024
5a8b0f2
About page tests
sharma-shray Jun 22, 2024
15447eb
Merge pull request #4 from sharma-shray/about-tests
sharma-shray Jun 22, 2024
b1d3c8d
blog page tests
sharma-shray Jun 25, 2024
3c28f12
Merge pull request #5 from sharma-shray/blog-tests
sharma-shray Jun 25, 2024
61b2e92
blog/sample tests
sharma-shray Jun 26, 2024
bea3da2
Merge pull request #6 from sharma-shray/design-tests
sharma-shray Jun 26, 2024
9e804f2
using page tests
sharma-shray Jun 27, 2024
64e32cf
Merge pull request #7 from sharma-shray/using-test
sharma-shray Jun 27, 2024
a63ead2
shop page tests
sharma-shray Jul 1, 2024
97393b7
Merge pull request #8 from sharma-shray/shop-tests
sharma-shray Jul 1, 2024
e7000cd
Login page tests
sharma-shray Jul 2, 2024
11caad5
Merge pull request #9 from sharma-shray/login-tests
sharma-shray Jul 2, 2024
abe5083
Product page tests
sharma-shray Jul 3, 2024
df64179
Merge pull request #10 from sharma-shray/product-tests
sharma-shray Jul 3, 2024
146e3f8
Signup page tests
sharma-shray Jul 4, 2024
b4f4053
Merge pull request #11 from sharma-shray/signup-tests
sharma-shray Jul 4, 2024
3074a02
Favorite page tests
sharma-shray Jul 8, 2024
8318417
Merge pull request #12 from sharma-shray/favorite-tests
sharma-shray Jul 8, 2024
3238c1b
Cart page tests
sharma-shray Jul 9, 2024
00a059b
Merge pull request #13 from sharma-shray/cart-tests
sharma-shray Jul 9, 2024
28116ab
Order confirm, faq page tests
sharma-shray Jul 11, 2024
a14f673
Merge pull request #14 from sharma-shray/faq-tests
sharma-shray Jul 11, 2024
3f3c727
Support page test
sharma-shray Jul 12, 2024
1f6a88f
Merge pull request #15 from sharma-shray/support-tests
sharma-shray Jul 12, 2024
afcc615
shop, account page tests
sharma-shray Jul 15, 2024
084c6ed
Merge pull request #16 from sharma-shray/account-test
sharma-shray Jul 15, 2024
c6fde9f
Login page input fields tests
sharma-shray Jul 17, 2024
992dd91
Merge pull request #17 from sharma-shray/login-input-tests
sharma-shray Jul 17, 2024
bf6ec41
Cart menu tests actions
sharma-shray Jul 18, 2024
1ebdb41
Merge pull request #18 from sharma-shray/cart-actions-tests
sharma-shray Jul 18, 2024
f2559e6
actions tests2
sharma-shray Jul 19, 2024
d47f880
Merge pull request #19 from sharma-shray/actions-tests2
sharma-shray Jul 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 184 additions & 0 deletions cart.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
import { test, expect } from '@playwright/test';

test('Cart page | All elements in header exist', async ({ page }) => {
await page.goto('http://localhost:5000/cart/');

const headerContainer = page.locator('div.cart-module--headerContainer--33826');
await expect(headerContainer).toBeVisible();

const shoppingContainer = headerContainer.locator('div.cart-module--shoppingContainer--cdac8');
await expect(shoppingContainer).toBeVisible();

const shopLink = shoppingContainer.locator('a.cart-module--shopLink--a0151');
await expect(shopLink).toBeVisible();
await expect(shopLink).toHaveAttribute('href', '/shop/');

const shopLinkSvg = shopLink.locator('svg');
await expect(shopLinkSvg).toBeVisible();
await expect(shopLinkSvg).toHaveAttribute('width', '15');
await expect(shopLinkSvg).toHaveAttribute('height', '15');

const continueShoppingSpan = shopLink.locator('span.cart-module--continueShopping--f2529');
await expect(continueShoppingSpan).toBeVisible();
await expect(continueShoppingSpan).toHaveText('Continue Shopping');

const brandContainer = headerContainer.locator('div.Brand-module--root--7bb0e');
await expect(brandContainer).toBeVisible();
await expect(brandContainer).toHaveAttribute('role', 'presentation');

const brandSvg = brandContainer.locator('svg');
await expect(brandSvg).toBeVisible();
await expect(brandSvg).toHaveAttribute('width', '127');
await expect(brandSvg).toHaveAttribute('height', '24');

const loginContainer = headerContainer.locator('div.cart-module--loginContainer--120bb');
await expect(loginContainer).toBeVisible();

// Check for the login link
const loginLink = loginContainer.locator('a');
await expect(loginLink).toBeVisible();
await expect(loginLink).toHaveAttribute('href', '/login/');
await expect(loginLink).toHaveText('Login');
});

test('Cart page | Order Summary', async ({ page }) => {
await page.goto('http://localhost:5000/cart/');

const orderSummary = page.locator('div.OrderSummary-module--orderSummary--2151a');
await expect(orderSummary).toBeVisible();

const orderSummaryTitle = orderSummary.locator('span.OrderSummary-module--title--ac4fb');
await expect(orderSummaryTitle).toBeVisible();
await expect(orderSummaryTitle).toHaveText('order summary');

const calculationContainer = orderSummary.locator('div.OrderSummary-module--calculationContainer--0cca1');
await expect(calculationContainer).toBeVisible();

const labelContainers = calculationContainer.locator('div.OrderSummary-module--labelContainer--bdd63');
await expect(labelContainers).toHaveCount(3);

await expect(labelContainers.nth(0).locator('span').first()).toHaveText('Subtotal');
await expect(labelContainers.nth(0).locator('span').nth(1)).toHaveText('$440.00');

await expect(labelContainers.nth(1).locator('span').first()).toHaveText('Shipping');
await expect(labelContainers.nth(1).locator('span').nth(1)).toHaveText('---');

await expect(labelContainers.nth(2).locator('span').first()).toHaveText('Tax');
await expect(labelContainers.nth(2).locator('span').nth(1)).toHaveText('$0.00');

const couponContainer = orderSummary.locator('div.OrderSummary-module--couponContainer--13bed');
await expect(couponContainer).toBeVisible();

const couponCodeLabel = couponContainer.locator('span').nth(0);
await expect(couponCodeLabel).toBeVisible();
await expect(couponCodeLabel).toHaveText('Coupon Code');

const couponInputField = couponContainer.locator('input#couponInput').nth(0);
await expect(couponInputField).toBeVisible();
await expect(couponInputField).toHaveAttribute('name', 'couponInput');

const couponInputIcon = couponContainer.locator('div.FormInputField-module--iconContainer--9d2a4').nth(0).locator('svg');
await expect(couponInputIcon).toBeVisible();
await expect(couponInputIcon).toHaveAttribute('width', '15');
await expect(couponInputIcon).toHaveAttribute('height', '15');

const giftCardLabel = couponContainer.locator('span').nth(1);
await expect(giftCardLabel).toBeVisible();
await expect(giftCardLabel).toHaveText('Gift Card');

const giftCardInputField = couponContainer.locator('input#couponInput').nth(1);
await expect(giftCardInputField).toBeVisible();
await expect(giftCardInputField).toHaveAttribute('name', 'couponInput');

const giftCardInputIcon = couponContainer.locator('div.FormInputField-module--iconContainer--9d2a4').nth(1).locator('svg');
await expect(giftCardInputIcon).toBeVisible();
await expect(giftCardInputIcon).toHaveAttribute('width', '15');
await expect(giftCardInputIcon).toHaveAttribute('height', '15');

const totalContainer = orderSummary.locator('div.OrderSummary-module--totalContainer--491aa');
await expect(totalContainer).toBeVisible();

const totalAmount = totalContainer.locator('span').nth(1);
await expect(totalAmount).toBeVisible();
await expect(totalAmount).toHaveText('$440.00');
});


test('Cart page | checkout button redirect to confirm page', async ({ page }) => {
await page.goto('http://localhost:5000/cart/');

// Check for the checkout button
const checkoutButton = page.getByRole('button', { name: 'checkout' })
await expect(checkoutButton).toBeVisible();

await Promise.all([
page.waitForNavigation(),
checkoutButton.click()
]);

await page.goto('http://localhost:5000/orderConfirm/');
});


test('Cart page | Order confirm page elements exist', async ({ page }) => {

await page.goto('http://localhost:5000/orderConfirm/');

// root div
const rootDiv = page.locator('.accountSuccess-module--root--e132d');
await expect(rootDiv).toBeVisible();

await expect(rootDiv.locator('h1')).toHaveText('Thank You!');

await expect(rootDiv.locator('p')).toHaveText('We are now processing your order. If you have any concerns feel free to email us at [email protected]');

const actionContainer = rootDiv.locator('.accountSuccess-module--actionContainer--25abb');
await expect(actionContainer).toBeVisible();

// ActionCard
const actionCards = actionContainer.locator('.ActionCard-module--root--0dba6');
await expect(actionCards).toHaveCount(4);

// Order Status
const orderStatusCard = actionCards.nth(0);
await expect(orderStatusCard.locator('.ActionCard-module--actionName--fe65b')).toHaveText('Order Status');
await expect(orderStatusCard.locator('.ActionCard-module--link--94d11')).toHaveText('Check your order status');

// Shop ActionCard
const shopCard = actionCards.nth(1);
await expect(shopCard.locator('.ActionCard-module--actionName--fe65b')).toHaveText('Shop');
await expect(shopCard.locator('.ActionCard-module--link--94d11')).toHaveText('Continue Shopping');

// FAQs
const faqsCard = actionCards.nth(2);
await expect(faqsCard.locator('.ActionCard-module--actionName--fe65b')).toHaveText('FAQs');
await expect(faqsCard.locator('.ActionCard-module--link--94d11')).toHaveText('Check out FAQs page');

const contactUsCard = actionCards.nth(3);
await expect(contactUsCard.locator('.ActionCard-module--actionName--fe65b')).toHaveText('Contact Us');
await expect(contactUsCard.locator('.ActionCard-module--link--94d11')).toHaveText('Reach out to us');
});

test('Order Confirm page | Footer elements', async ({ page }) => {
await page.goto('http://localhost:5000/orderConfirm/');

await expect(page.locator('.Footer-module--footerLinks--1a995 >> a[href="/about/"]')).toBeVisible();
await expect(page.locator('.Footer-module--footerLinks--1a995 >> a[href="/blog/"]')).toBeVisible();
await expect(page.locator('.Footer-module--footerLinks--1a995 >> a[href="/support/#policy"]')).toBeVisible();

await expect(page.locator('.Footer-module--footerLinks--1a995 >> a[href="/faq/"]')).toBeVisible();
await expect(page.locator('.Footer-module--footerLinks--1a995 >> a[href="/support/#contact"]')).toBeVisible();
await expect(page.locator('.Footer-module--footerLinks--1a995 >> a[href="/support/#returns"]')).toBeVisible();
await expect(page.locator('.Footer-module--footerLinks--1a995 >> a[href="/how-to-use/"]')).toBeVisible();

// newsletter section
await expect(page.locator('input[name="newsLetterInput"]')).toBeVisible();
await expect(page.locator('.Footer-module--promoMessage--b609e')).toBeVisible();

// social media icons
const socialIcons = page.locator('.Footer-module--socialIconContainer--ac360');
await expect(socialIcons.nth(0)).toBeVisible();
await expect(socialIcons.nth(1)).toBeVisible();
await expect(socialIcons.nth(2)).toBeVisible();
await expect(socialIcons.nth(3)).toBeVisible();
});
70 changes: 70 additions & 0 deletions faq.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { test, expect } from '@playwright/test';

test('Faq page | Footer elements', async ({ page }) => {
await page.goto('http://localhost:5000/faq/');

await expect(page.locator('.Footer-module--footerLinks--1a995 >> a[href="/about/"]')).toBeVisible();
await expect(page.locator('.Footer-module--footerLinks--1a995 >> a[href="/blog/"]')).toBeVisible();
await expect(page.locator('.Footer-module--footerLinks--1a995 >> a[href="/support/#policy"]')).toBeVisible();

await expect(page.locator('.Footer-module--footerLinks--1a995 >> a[href="/faq/"]')).toBeVisible();
await expect(page.locator('.Footer-module--footerLinks--1a995 >> a[href="/support/#contact"]')).toBeVisible();
await expect(page.locator('.Footer-module--footerLinks--1a995 >> a[href="/support/#returns"]')).toBeVisible();
await expect(page.locator('.Footer-module--footerLinks--1a995 >> a[href="/how-to-use/"]')).toBeVisible();

// newsletter section
await expect(page.locator('input[name="newsLetterInput"]')).toBeVisible();
await expect(page.locator('.Footer-module--promoMessage--b609e')).toBeVisible();

// social media icons
const socialIcons = page.locator('.Footer-module--socialIconContainer--ac360');
await expect(socialIcons.nth(0)).toBeVisible();
await expect(socialIcons.nth(1)).toBeVisible();
await expect(socialIcons.nth(2)).toBeVisible();
await expect(socialIcons.nth(3)).toBeVisible();
});


test('Faq page | FAQ banner', async ({ page }) => {
await page.goto('http://localhost:5000/faq/');

const timeout = 10000;

const bannerRoot = page.locator('.Banner-module--root--d0b7f');
await expect(bannerRoot).toBeVisible({ timeout });

const bannerContent = bannerRoot.locator('.Banner-module--content--07f4d');
await expect(bannerContent).toBeVisible({ timeout });

await expect(bannerContent.locator('h2')).toHaveText('Frequently Asked Questions', { timeout });
});

test('Shop page | Header elements exist', async ({ page }) => {
await page.goto('http://localhost:5000/faq/');

const mainContainer = page.locator('div.Container-module--container--6761c >> nth=0');
await expect(mainContainer).toBeVisible();

const header = mainContainer.locator('div.Header-module--header--aa06a');
await expect(header).toBeVisible();

const navLinks = header.locator('nav a.Header-module--navLink--2a5b8');
await expect(navLinks.nth(0)).toHaveText('Shop');
await expect(navLinks.nth(1)).toHaveText('journal');
await expect(navLinks.nth(2)).toHaveText('About');

const brandLogo = header.locator('div.Brand-module--root--7bb0e');
await expect(brandLogo).toBeVisible();

const searchButton = header.locator('button[aria-label="Search"]');
await expect(searchButton).toBeVisible();

const favoritesLink = header.locator('a[aria-label="Favorites"]');
await expect(favoritesLink).toBeVisible();

const ordersLink = header.locator('a[aria-label="Orders"]');
await expect(ordersLink).toBeVisible();

const cartButton = header.locator('button[aria-label="Cart"]');
await expect(cartButton).toBeVisible();
});
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
"plop": "plop"
},
"dependencies": {
"gatsby": "^5.13.3",
"gatsby-adapter-netlify": "^1.1.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"gatsby": "^5.13.6",
"gatsby-adapter-netlify": "^1.1.6",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-helmet": "^6.1.0",
"react-slick": "^0.30.2"
},
"devDependencies": {
"plop": "^3.0.5",
"prettier": "^3.2.5"
"plop": "^4.0.1",
"prettier": "^3.3.2"
}
}
Loading