|
| 1 | +import { test, expect } from '@playwright/test'; |
| 2 | + |
| 3 | +test.describe('Categories Navigation', () => { |
| 4 | + test.beforeEach(async ({ page }) => { |
| 5 | + await page.goto('http://localhost:3000/'); |
| 6 | + }); |
| 7 | + |
| 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('http://localhost:3000/kategorier'); |
| 12 | + |
| 13 | + // Click a category and verify navigation |
| 14 | + await page.getByRole('link', { name: 'Clothing' }).click(); |
| 15 | + await expect(page).toHaveURL(/^http:\/\/localhost:3000\/kategori\/clothing/); |
| 16 | + |
| 17 | + // Go back to categories |
| 18 | + await page.getByRole('link', { name: 'Kategorier' }).click(); |
| 19 | + await expect(page).toHaveURL('http://localhost:3000/kategorier'); |
| 20 | + |
| 21 | + // Try another category |
| 22 | + await page.getByRole('link', { name: 'Tshirts' }).click(); |
| 23 | + await expect(page).toHaveURL(/^http:\/\/localhost:3000\/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('http://localhost:3000/kategorier'); |
| 30 | + |
| 31 | + // Go back home |
| 32 | + await page.getByRole('link', { name: 'NETTBUTIKK' }).click(); |
| 33 | + await expect(page).toHaveURL('http://localhost:3000/'); |
| 34 | + }); |
| 35 | +}); |
0 commit comments