53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
import { test, expect } from '@playwright/test';
|
|
|
|
test.describe('Homepage', () => {
|
|
test('loads and displays hero content', async ({ page }) => {
|
|
await page.goto('/');
|
|
|
|
await expect(page.locator('main')).toBeVisible();
|
|
await expect(page.getByText(/GGI HCM|Top biến động giá|Khu vực xu hướng/i).first()).toBeVisible();
|
|
});
|
|
|
|
test('has correct page title', async ({ page }) => {
|
|
await page.goto('/');
|
|
|
|
await expect(page).toHaveTitle(/GoodGo/i);
|
|
});
|
|
|
|
test('renders without critical console errors', async ({ page }) => {
|
|
const criticalErrors: string[] = [];
|
|
page.on('console', (msg) => {
|
|
if (msg.type() === 'error') {
|
|
const text = msg.text();
|
|
// Ignore known non-critical errors in test environment
|
|
if (
|
|
text.includes('mapbox') ||
|
|
text.includes('NEXT_PUBLIC_MAPBOX_TOKEN') ||
|
|
text.includes('hydration') ||
|
|
text.includes('Content Security Policy') ||
|
|
text.includes('401') ||
|
|
text.includes('Unauthorized')
|
|
) {
|
|
return;
|
|
}
|
|
criticalErrors.push(text);
|
|
}
|
|
});
|
|
|
|
await page.goto('/');
|
|
await page.waitForLoadState('networkidle');
|
|
|
|
expect(criticalErrors).toHaveLength(0);
|
|
});
|
|
|
|
test('is responsive — mobile viewport', async ({ page }) => {
|
|
await page.setViewportSize({ width: 375, height: 667 });
|
|
await page.goto('/');
|
|
|
|
const main = page.locator('main');
|
|
await expect(main).toBeVisible();
|
|
|
|
await expect(page.getByText(/GGI HCM|Top biến động giá|Khu vực xu hướng/i).first()).toBeVisible();
|
|
});
|
|
});
|