Skip to content

Commit 4b237e6

Browse files
committed
Update Categories.spec.ts
1 parent 4621f73 commit 4b237e6

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed
Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,35 @@
11
import { test, expect } from '@playwright/test';
22

3-
test.describe('Categories', () => {
4-
test('should navigate to categories page and verify content', async ({ page }) => {
5-
// Start from homepage
3+
test.describe('Categories Navigation', () => {
4+
test.beforeEach(async ({ page }) => {
65
await page.goto('http://localhost:3000/');
7-
8-
// Click on Categories link in navigation
9-
await page.getByRole('link', { name: 'KATEGORIER' }).click();
10-
11-
// Verify URL
12-
await expect(page).toHaveURL('http://localhost:3000/kategorier');
13-
14-
// Verify page title
15-
await expect(page.locator('h1')).toContainText('Kategorier');
16-
17-
// Verify categories section exists
18-
await expect(page.locator('section')).toBeVisible();
196
});
207

21-
test('should navigate back to home from categories', async ({ page }) => {
22-
// Start from categories page
23-
await page.goto('http://localhost:3000/kategorier');
24-
25-
// Click on home/logo link
8+
test('should navigate through category pages', async ({ page }) => {
9+
// Navigate to categories page
10+
await page.getByRole('link', { name: 'Kategorier' }).click();
11+
await expect(page).toHaveURL(/.*\/kategorier/);
12+
13+
// Click a category and verify navigation
14+
await page.getByRole('link', { name: 'Clothing' }).click();
15+
await expect(page).toHaveURL(/.*\/kategori\/clothing/);
16+
17+
// Go back to categories
18+
await page.getByRole('link', { name: 'Kategorier' }).click();
19+
await expect(page).toHaveURL(/.*\/kategorier/);
20+
21+
// Try another category
22+
await page.getByRole('link', { name: 'Tshirts' }).click();
23+
await expect(page).toHaveURL(/.*\/kategori\/tshirts/);
24+
});
25+
26+
test('should navigate between categories and home', async ({ page }) => {
27+
// Go to categories
28+
await page.getByRole('link', { name: 'Kategorier' }).click();
29+
await expect(page).toHaveURL(/.*\/kategorier/);
30+
31+
// Go back home
2632
await page.getByRole('link', { name: 'NETTBUTIKK' }).click();
27-
28-
// Verify we're back on homepage
2933
await expect(page).toHaveURL('http://localhost:3000/');
3034
});
3135
});

0 commit comments

Comments
 (0)