Files
newz-qwen-9b/frontend/playwright/e2e/home.spec.ts
T

65 lines
2.1 KiB
TypeScript

import { test, expect } from '@playwright/test';
test.describe('Home Page E2E Tests', () => {
test('loads home page successfully', async ({ page }) => {
await page.goto('/');
const title = page.getByText('newzy');
await expect(title).toBeVisible();
});
test('renders navigation links with proper href attributes', async ({ page }) => {
await page.goto('/');
const homeLink = page.getByRole('link', { name: /home/i });
const articlesLink = page.getByRole('link', { name: /articles/i });
const categoriesLink = page.getByRole('link', { name: /categories/i });
await expect(homeLink).toHaveAttribute('href', '/');
await expect(articlesLink).toHaveAttribute('href', '/articles');
await expect(categoriesLink).toHaveAttribute('href', '/categories');
});
test('renders article grid with content', async ({ page }) => {
await page.goto('/');
const articleCard = page.locator('.article-card');
await expect(articleCard).toBeVisible();
});
test('passes accessibility checks for navigation', async ({ page }) => {
await page.goto('/');
const navLinks = page.locator('.nav a');
await expect(navLinks).toHaveCount(3);
for (const link of await navLinks.all()) {
await expect(link).toBeAccessible();
}
});
test('verifies react-router links navigate without full reload', async ({ page }) => {
await page.goto('/');
const articlesLink = page.getByRole('link', { name: /articles/i });
await articlesLink.click();
// Client-side navigation should happen without full page reload
const url = page.url();
expect(url).toContain('/articles');
});
test('page structure contains expected elements', async ({ page }) => {
await page.goto('/');
// Check for layout components
const header = page.locator('header');
const mainContent = page.locator('main.content-area');
const footer = page.locator('.footer-section');
await expect(header).toBeVisible();
await expect(mainContent).toBeVisible();
await expect(footer).toBeVisible();
});
});