-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
554 additions
and
49 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
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
1 change: 0 additions & 1 deletion
1
tests/auths/createAccount.spec.ts → tests/auth/createAccount.spec.ts
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
File renamed without changes.
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,50 @@ | ||
import { test, expect, Page } from '@playwright/test'; | ||
|
||
test.describe('Categories Tests', () => { | ||
const baseURL = 'http://localhost:3100'; | ||
let page: Page; | ||
|
||
test.beforeAll(async ({ browser }) => { | ||
const context = await browser.newContext(); | ||
page = await context.newPage(); | ||
await page.goto(baseURL, { waitUntil: 'domcontentloaded' }); | ||
}); | ||
|
||
test.skip ('Validate categories section', async () => { | ||
const categories = [ | ||
'Vehicles & Equipment', | ||
'Beauty & Personal care', | ||
'Home & Garden', | ||
'Baby & Toddler Toys', | ||
'Fashion', | ||
]; | ||
|
||
const categoryMenu = page.locator('div:has-text("All Categories")'); | ||
await expect(categoryMenu).toBeVisible(); | ||
|
||
for (const category of categories) { | ||
const categoryLocator = page.locator(`text=${category}`); | ||
await expect(categoryLocator).toBeVisible(); | ||
await categoryLocator.hover(); | ||
} | ||
}); | ||
|
||
test('Verify promotional banner for Women section', async () => { | ||
const promoText = 'BUY TWO, Get FOR WOMEN Get up to 30% Off'; | ||
const promoBanner = page.locator(`text=${promoText}`).first(); | ||
const shopNowButton = page.locator('text=SHOP NOW'); | ||
|
||
if (await promoBanner.count() > 0) { | ||
await expect(promoBanner).toBeVisible(); | ||
await expect(shopNowButton).toBeVisible(); | ||
await shopNowButton.click(); | ||
await expect(page).toHaveURL(/.*shop/);} | ||
// } else { | ||
// console.warn('Promotional banner not found. Skipping test.'); | ||
// } | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await page.close(); | ||
}); | ||
}); |
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,86 @@ | ||
import { test, expect } from "@playwright/test"; | ||
|
||
test.describe("Header Tests", () => { | ||
test.beforeEach(async ({ page }) => { | ||
// Navigate to the homepage | ||
await page.goto("http://localhost:3100"); | ||
}); | ||
|
||
test.skip("Logo should navigate to the homepage", async ({ page }) => { | ||
// Click on the logo | ||
await page.locator('img[alt="Kwek Market"]').click(); | ||
|
||
// Assert the page URL is the homepage | ||
await expect(page).toHaveURL("http://localhost:3100"); | ||
}); | ||
|
||
|
||
|
||
test.skip("Search bar should allow input and search", async ({ page }) => { | ||
const searchBar = page.locator('input[placeholder="I\'m searching for..."]'); | ||
const searchButton = page.locator('button:has-text("Search")'); | ||
|
||
// Type into the search bar | ||
await searchBar.fill("Test Query"); | ||
|
||
// Click the search button | ||
await searchButton.click({ timeout: 30000 }); | ||
|
||
// Wait for navigation to complete | ||
await page.waitForNavigation({ timeout: 30000 }); | ||
|
||
// Assert the URL contains the search query | ||
await expect(page).toHaveURL(/.*search.*/); // Update the regex based on your site's search functionality | ||
|
||
// Assert that no results are found | ||
const noResultsMessage = page.locator('text=No items found'); // Update the selector based on your site's implementation | ||
await expect(noResultsMessage).toBeVisible({ timeout: 30000 }); | ||
}); | ||
|
||
|
||
|
||
test("Wishlist icon should navigate to wishlist page", async ({ page }) => { | ||
// Find the element with the text 'saved' and click on it | ||
const savedLink = page.locator('text=saved'); | ||
await savedLink.waitFor({ state: 'visible', timeout: 30000 }); // Ensure the element is visible | ||
await savedLink.click({ timeout: 30000 }); | ||
|
||
// Assert the page URL is the wishlist page | ||
await expect(page).toHaveURL("http://localhost:3100/wishlist"); | ||
|
||
// Pause the test to keep the browser open | ||
// await page.pause(); | ||
}); | ||
|
||
test("Cart icon should navigate to cart page", async ({ page }) => { | ||
// Click on the cart icon | ||
const cartLink = page.locator('text=cart'); | ||
await cartLink.waitFor({ state: 'visible', timeout: 30000 }); // Ensure the element is visible | ||
await cartLink.click({ timeout: 30000 }); | ||
|
||
// Assert the page URL is the cart page | ||
await expect(page).toHaveURL("http://localhost:3100/cart"); | ||
|
||
// Pause the test to keep the browser open | ||
await page.pause(); | ||
}); | ||
|
||
test("Shortcut items should have correct counters", async ({ page }) => { | ||
// Check the wishlist counter | ||
const wishlistCounter = page.locator('a[href="/wishlist"] .tw-absolute'); | ||
await expect(wishlistCounter).toHaveText("0"); | ||
|
||
// Check the cart counter | ||
const cartCounter = page.locator('a[href="/cart"] .tw-absolute'); | ||
await expect(cartCounter).toHaveText("0"); | ||
}); | ||
|
||
test("Sign In link should navigate to login page", async ({ page }) => { | ||
// Click on the Sign In link | ||
const signInLink = page.locator('a[href="/login"]'); | ||
await signInLink.click(); | ||
|
||
// Assert the page URL is the login page | ||
await expect(page).toHaveURL("http://localhost:3100/login"); | ||
}); | ||
}); |
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,34 @@ | ||
import { test, expect, Page } from '@playwright/test'; | ||
|
||
test.describe('Social Media Tests', () => { | ||
const baseURL = 'http://localhost:3100'; | ||
let page: Page; | ||
|
||
test.beforeAll(async ({ browser }) => { | ||
const context = await browser.newContext(); | ||
page = await context.newPage(); | ||
await page.goto(baseURL, { waitUntil: 'domcontentloaded' }); | ||
}); | ||
|
||
test.skip('Hover on social media links', async () => { | ||
const socialLinks = ['Facebook', 'Instagram', 'Twitter']; | ||
|
||
const socialSection = page.locator('.Footer_social__mdVIK'); | ||
for (const social of socialLinks) { | ||
const socialLink = socialSection.locator(`text=${social}`); | ||
await expect(socialLink).toBeVisible(); | ||
await socialLink.hover(); | ||
} | ||
}); | ||
|
||
test('Hover on missing social media links', async () => { | ||
const socialSection = page.locator('.Footer_social__mdVIK'); | ||
const missingLink = socialSection.locator('text=Snapchat'); | ||
|
||
await expect(missingLink).toHaveCount(0); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await page.close(); | ||
}); | ||
}); |
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 @@ | ||
import { test, expect, Page } from '@playwright/test'; | ||
|
||
test.describe.skip('Subscription Tests', () => { | ||
const baseURL = 'http://localhost:3100'; | ||
let page: Page; | ||
|
||
test.beforeAll(async ({ browser }) => { | ||
const context = await browser.newContext(); | ||
page = await context.newPage(); | ||
await page.goto(baseURL, { waitUntil: 'domcontentloaded' }); | ||
}); | ||
|
||
test('Email subscription with valid email', async () => { | ||
const emailInput = page.locator('input[placeholder="Enter your email address..."]'); | ||
const subscribeButton = page.locator('button:has-text("Subscribe")'); | ||
|
||
await emailInput.fill('[email protected]'); | ||
await subscribeButton.click(); | ||
|
||
const successMessage = page.locator('text=Subscription Successful'); | ||
await expect(successMessage).toBeVisible(); | ||
}); | ||
|
||
test('Email subscription with empty input', async () => { | ||
const subscribeButton = page.locator('button:has-text("Subscribe")'); | ||
await subscribeButton.click(); | ||
|
||
const errorMessage = page.locator('text=Please enter a valid email address'); | ||
await expect(errorMessage).toBeVisible(); | ||
}); | ||
|
||
test('Email subscription with invalid format', async () => { | ||
const emailInput = page.locator('input[placeholder="Enter your email address..."]'); | ||
const subscribeButton = page.locator('button:has-text("Subscribe")'); | ||
|
||
await emailInput.fill('invalid-email'); | ||
await subscribeButton.click(); | ||
|
||
const errorMessage = page.locator('text=Please enter a valid email address'); | ||
await expect(errorMessage).toBeVisible(); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await page.close(); | ||
}); | ||
}); |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.