|
1 | 1 | import { test, expect } from '@playwright/test'; |
2 | 2 |
|
| 3 | +// ── Meta & SEO ── |
| 4 | + |
3 | 5 | test('homepage has Mellea title', async ({ page }) => { |
4 | 6 | await page.goto('/'); |
5 | 7 | await expect(page).toHaveTitle(/Mellea/); |
6 | 8 | }); |
7 | 9 |
|
8 | | -test('hero heading is visible', async ({ page }) => { |
| 10 | +test('homepage has meta description', async ({ page }) => { |
9 | 11 | await page.goto('/'); |
10 | | - await expect(page.getByRole('heading', { name: /Mellea/i, level: 1 })).toBeVisible(); |
| 12 | + const desc = page.locator('meta[name="description"]'); |
| 13 | + await expect(desc).toHaveAttribute('content', /.+/); |
11 | 14 | }); |
12 | 15 |
|
13 | | -test('install command is visible', async ({ page }) => { |
| 16 | +test('homepage has canonical URL', async ({ page }) => { |
14 | 17 | await page.goto('/'); |
15 | | - await expect(page.getByText('uv pip install mellea')).toBeVisible(); |
| 18 | + const canonical = page.locator('link[rel="canonical"]'); |
| 19 | + await expect(canonical).toHaveAttribute('href', /\/$/); |
| 20 | +}); |
| 21 | + |
| 22 | +// ── Header / Navigation ── |
| 23 | + |
| 24 | +test('header logo links to homepage', async ({ page }) => { |
| 25 | + await page.goto('/'); |
| 26 | + const logo = page.getByRole('banner').getByRole('link', { name: /Mellea/i }); |
| 27 | + await expect(logo).toBeVisible(); |
| 28 | + await expect(logo).toHaveAttribute('href', '/'); |
16 | 29 | }); |
17 | 30 |
|
18 | 31 | test('nav links are present', async ({ page }) => { |
19 | 32 | await page.goto('/'); |
20 | 33 | const header = page.getByRole('banner'); |
| 34 | + await expect(header.getByRole('link', { name: 'Docs' })).toBeVisible(); |
21 | 35 | await expect(header.getByRole('link', { name: 'Blog' })).toBeVisible(); |
22 | 36 | await expect(header.getByRole('link', { name: 'GitHub' })).toBeVisible(); |
| 37 | + await expect(header.getByRole('link', { name: /Get Started/ })).toBeVisible(); |
| 38 | +}); |
| 39 | + |
| 40 | +test('external nav links open in new tab', async ({ page }) => { |
| 41 | + await page.goto('/'); |
| 42 | + const header = page.getByRole('banner'); |
| 43 | + for (const name of ['Docs', 'GitHub']) { |
| 44 | + const link = header.getByRole('link', { name }); |
| 45 | + await expect(link).toHaveAttribute('target', '_blank'); |
| 46 | + await expect(link).toHaveAttribute('rel', /noopener/); |
| 47 | + } |
| 48 | +}); |
| 49 | + |
| 50 | +// ── Hero Section ── |
| 51 | + |
| 52 | +test('hero heading is visible', async ({ page }) => { |
| 53 | + await page.goto('/'); |
| 54 | + await expect(page.getByRole('heading', { name: /Mellea/i, level: 1 })).toBeVisible(); |
| 55 | +}); |
| 56 | + |
| 57 | +test('install command is visible with copy button', async ({ page }) => { |
| 58 | + await page.goto('/'); |
| 59 | + await expect(page.getByText('uv pip install mellea')).toBeVisible(); |
| 60 | + await expect(page.getByLabel('Copy install command')).toBeVisible(); |
| 61 | +}); |
| 62 | + |
| 63 | +test('hero has Get Started CTA', async ({ page }) => { |
| 64 | + await page.goto('/'); |
| 65 | + const hero = page.locator('.hero'); |
| 66 | + await expect(hero.getByRole('link', { name: /Get Started/ })).toBeVisible(); |
| 67 | +}); |
| 68 | + |
| 69 | +test('GitHub stats section renders', async ({ page }) => { |
| 70 | + await page.goto('/'); |
| 71 | + const stats = page.locator('.gh-stats'); |
| 72 | + await expect(stats).toBeVisible(); |
| 73 | + await expect(stats.getByText(/View on GitHub/)).toBeVisible(); |
| 74 | +}); |
| 75 | + |
| 76 | +// ── Feature Strip ── |
| 77 | + |
| 78 | +test('feature strip has multiple items', async ({ page }) => { |
| 79 | + await page.goto('/'); |
| 80 | + const items = page.locator('.feature-strip .feature-item'); |
| 81 | + const count = await items.count(); |
| 82 | + expect(count).toBeGreaterThanOrEqual(3); |
| 83 | +}); |
| 84 | + |
| 85 | +// ── How It Works Section ── |
| 86 | + |
| 87 | +test('how it works section renders with heading', async ({ page }) => { |
| 88 | + await page.goto('/'); |
| 89 | + await expect(page.getByRole('heading', { name: /How it works/i })).toBeVisible(); |
| 90 | +}); |
| 91 | + |
| 92 | +test('feature cards are visible with learn more links', async ({ page }) => { |
| 93 | + await page.goto('/'); |
| 94 | + const cards = page.locator('.feature-card'); |
| 95 | + const count = await cards.count(); |
| 96 | + expect(count).toBeGreaterThanOrEqual(4); |
| 97 | + |
| 98 | + // Each card has a heading and a learn-more link |
| 99 | + for (const card of await cards.all()) { |
| 100 | + await expect(card.getByRole('heading')).toBeVisible(); |
| 101 | + const link = card.getByRole('link', { name: /Learn more/ }); |
| 102 | + await expect(link).toHaveAttribute('target', '_blank'); |
| 103 | + } |
| 104 | +}); |
| 105 | + |
| 106 | +// ── Code Showcase ── |
| 107 | + |
| 108 | +test('code showcase renders with tabs', async ({ page }) => { |
| 109 | + await page.goto('/'); |
| 110 | + const tabs = page.locator('[role="tab"]'); |
| 111 | + const count = await tabs.count(); |
| 112 | + expect(count).toBeGreaterThanOrEqual(2); |
| 113 | +}); |
| 114 | + |
| 115 | +test('code showcase tab switching changes code panel', async ({ page }) => { |
| 116 | + await page.goto('/'); |
| 117 | + const panel = page.locator('[role="tabpanel"]'); |
| 118 | + const tabs = page.locator('[role="tab"]'); |
| 119 | + |
| 120 | + // Get initial panel text |
| 121 | + const firstContent = await panel.textContent(); |
| 122 | + |
| 123 | + // Click second tab — panel content should change |
| 124 | + await tabs.nth(1).click(); |
| 125 | + const secondContent = await panel.textContent(); |
| 126 | + expect(secondContent).not.toBe(firstContent); |
| 127 | +}); |
| 128 | + |
| 129 | +test('code showcase has copy button', async ({ page }) => { |
| 130 | + await page.goto('/'); |
| 131 | + await expect(page.getByLabel('Copy code')).toBeVisible(); |
23 | 132 | }); |
24 | 133 |
|
25 | | -test('recent blog posts section is visible', async ({ page }) => { |
| 134 | +test('active tab shows description and learn more link', async ({ page }) => { |
| 135 | + await page.goto('/'); |
| 136 | + const activeItem = page.locator('.showcase-item--active'); |
| 137 | + await expect(activeItem.locator('.showcase-item-desc')).toBeVisible(); |
| 138 | + await expect(activeItem.getByRole('link', { name: /Learn more/ })).toBeVisible(); |
| 139 | +}); |
| 140 | + |
| 141 | +// ── Recent Blog Posts ── |
| 142 | + |
| 143 | +test('recent blog posts section has heading and cards', async ({ page }) => { |
26 | 144 | await page.goto('/'); |
27 | 145 | await expect(page.getByText('From the blog')).toBeVisible(); |
| 146 | + const cards = page.locator('.blog-grid .blog-card'); |
| 147 | + const count = await cards.count(); |
| 148 | + expect(count).toBeGreaterThanOrEqual(1); |
| 149 | +}); |
| 150 | + |
| 151 | +// ── Vision / CTA Section ── |
| 152 | + |
| 153 | +test('vision section has closing CTAs', async ({ page }) => { |
| 154 | + await page.goto('/'); |
| 155 | + const vision = page.locator('.vision-section'); |
| 156 | + await expect(vision).toBeVisible(); |
| 157 | + await expect(vision.getByRole('link', { name: /Get Started/ })).toBeVisible(); |
| 158 | + await expect(vision.getByRole('link', { name: /GitHub/ })).toBeVisible(); |
| 159 | +}); |
| 160 | + |
| 161 | +// ── Footer ── |
| 162 | + |
| 163 | +test('footer is visible with copyright and links', async ({ page }) => { |
| 164 | + await page.goto('/'); |
| 165 | + const footer = page.getByRole('contentinfo'); |
| 166 | + await expect(footer).toBeVisible(); |
| 167 | + await expect(footer).toContainText(/© \d{4}/); |
| 168 | + await expect(footer.getByRole('link', { name: 'Blog' })).toBeVisible(); |
| 169 | + await expect(footer.getByRole('link', { name: 'Docs' })).toBeVisible(); |
| 170 | + await expect(footer.getByRole('link', { name: 'GitHub' })).toBeVisible(); |
| 171 | +}); |
| 172 | + |
| 173 | +// ── Skip Link (Accessibility) ── |
| 174 | + |
| 175 | +test('skip-to-content link exists', async ({ page }) => { |
| 176 | + await page.goto('/'); |
| 177 | + const skip = page.locator('a.skip-link'); |
| 178 | + await expect(skip).toHaveCount(1); |
| 179 | + await expect(skip).toHaveAttribute('href', '#main-content'); |
28 | 180 | }); |
0 commit comments