|
1 | 1 | import { test, expect } from '@playwright/test';
|
2 | 2 |
|
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 }) => { |
6 | 5 | 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(); |
19 | 6 | });
|
20 | 7 |
|
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 |
26 | 32 | await page.getByRole('link', { name: 'NETTBUTIKK' }).click();
|
27 |
| - |
28 |
| - // Verify we're back on homepage |
29 | 33 | await expect(page).toHaveURL('http://localhost:3000/');
|
30 | 34 | });
|
31 | 35 | });
|
0 commit comments