-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhomepage.spec.ts
More file actions
59 lines (44 loc) · 1.89 KB
/
homepage.spec.ts
File metadata and controls
59 lines (44 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { test, expect } from '@playwright/test';
test.describe('Homepage @monitor', () => {
const BASE = process.env.ENVIRONMENT_URL || '';
test('loads with correct title and branding', async ({ page }) => {
await page.goto(`${BASE}/`);
await expect(page).toHaveTitle(/Raccoon Records/);
const logo = page.getByTestId('logo');
await expect(logo).toBeVisible();
await expect(logo).toContainText('Raccoon Records');
});
test('displays the record catalog', async ({ page }) => {
await page.goto(`${BASE}/`);
const grid = page.getByTestId('record-grid');
const cards = grid.getByTestId('record-card');
await expect(cards.first()).toBeVisible();
const count = await cards.count();
expect(count).toBeGreaterThanOrEqual(6);
});
test('each record card shows title, artist, and price', async ({ page }) => {
await page.goto(`${BASE}/`);
const firstCard = page.getByTestId('record-card').first();
await expect(firstCard).toBeVisible();
await expect(firstCard.locator('.record-title')).not.toBeEmpty();
await expect(firstCard.locator('.record-artist')).not.toBeEmpty();
await expect(firstCard.locator('.record-price')).toContainText('$');
});
test('shows genre filter buttons', async ({ page }) => {
await page.goto(`${BASE}/`);
const filters = page.getByTestId('genre-filters');
await expect(filters).toBeVisible();
const allBtn = filters.getByText('All');
await expect(allBtn).toHaveClass(/active/);
const buttons = filters.locator('.filter-btn');
await expect
.poll(async () => buttons.count(), { timeout: 15_000 })
.toBeGreaterThan(1);
});
test('cart button is visible with empty badge', async ({ page }) => {
await page.goto(`${BASE}/`);
const cartBtn = page.getByTestId('cart-button');
await expect(cartBtn).toBeVisible();
await expect(cartBtn).toContainText('Cart');
});
});