RecreationBench / web /streamora.example /tests /static /structure.agent_gen.spec.ts
VoyagerXHF's picture
Upload folder using huggingface_hub (part 75)
0e0e768 verified
Raw History Blame Contribute Delete
15.4 kB
import { test, expect } from '@playwright/test';
const BASE = 'http://localhost:8100';
test.describe('Homepage structural tests', () => {
test('homepage has nav element', async ({ page }) => {
await page.goto(`${BASE}/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const navElements = page.locator('nav');
const count = await navElements.count();
expect(count).toBeGreaterThanOrEqual(1);
});
test('homepage has html lang attribute', async ({ page }) => {
await page.goto(`${BASE}/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const lang = await page.locator('html').getAttribute('lang');
expect(lang).toBeTruthy();
expect(lang).toContain('en');
});
test('homepage has viewport meta tag', async ({ page }) => {
await page.goto(`${BASE}/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const viewport = await page.locator('meta[name="viewport"]').getAttribute('content');
expect(viewport).toBeTruthy();
expect(viewport).toContain('width=device-width');
});
test('homepage has meta description', async ({ page }) => {
await page.goto(`${BASE}/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const desc = await page.locator('meta[name="description"]').getAttribute('content');
expect(desc).toBeTruthy();
expect(desc!.length).toBeGreaterThan(20);
});
test('homepage has OpenGraph meta tags', async ({ page }) => {
await page.goto(`${BASE}/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const ogTitle = await page.locator('meta[property="og:title"]').getAttribute('content');
expect(ogTitle).toBeTruthy();
const ogType = await page.locator('meta[property="og:type"]').getAttribute('content');
expect(ogType).toBeTruthy();
});
test('homepage h1 appears exactly once', async ({ page }) => {
await page.goto(`${BASE}/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const h1Count = await page.locator('h1').count();
expect(h1Count).toBe(1);
});
test('homepage has form element for search', async ({ page }) => {
await page.goto(`${BASE}/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const forms = page.locator('form');
const count = await forms.count();
expect(count).toBeGreaterThanOrEqual(1);
});
test('homepage has unordered lists for navigation', async ({ page }) => {
await page.goto(`${BASE}/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const navUls = page.locator('nav ul');
const count = await navUls.count();
expect(count).toBeGreaterThanOrEqual(1);
});
});
test.describe('About page structural tests', () => {
test('about page has exactly one h1', async ({ page }) => {
await page.goto(`${BASE}/about.html`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const h1Count = await page.locator('h1').count();
expect(h1Count).toBe(1);
});
test('about page has nav element with menu links', async ({ page }) => {
await page.goto(`${BASE}/about.html`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const navLinks = page.locator('nav a');
const count = await navLinks.count();
expect(count).toBeGreaterThanOrEqual(4);
});
test('about page has h4 headings for feature sections', async ({ page }) => {
await page.goto(`${BASE}/about.html`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const h4Count = await page.locator('h4').count();
expect(h4Count).toBeGreaterThanOrEqual(5);
});
});
test.describe('Support page structural tests', () => {
test('support page uses semantic header element', async ({ page }) => {
await page.goto(`${BASE}/support/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const headers = page.locator('header');
const count = await headers.count();
expect(count).toBeGreaterThanOrEqual(1);
});
test('support page uses semantic nav element', async ({ page }) => {
await page.goto(`${BASE}/support/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const navs = page.locator('nav');
const count = await navs.count();
expect(count).toBeGreaterThanOrEqual(1);
});
test('support page uses semantic footer element', async ({ page }) => {
await page.goto(`${BASE}/support/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const footers = page.locator('footer');
const count = await footers.count();
expect(count).toBeGreaterThanOrEqual(1);
});
test('support page has article element', async ({ page }) => {
await page.goto(`${BASE}/support/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const articles = page.locator('article');
const count = await articles.count();
expect(count).toBeGreaterThanOrEqual(1);
});
test('support page has role attributes for accessibility', async ({ page }) => {
await page.goto(`${BASE}/support/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const mainRole = page.locator('[role="main"]');
const count = await mainRole.count();
expect(count).toBeGreaterThanOrEqual(1);
});
});
test.describe('Community page structural tests', () => {
test('community page uses semantic header element', async ({ page }) => {
await page.goto(`${BASE}/community/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const headers = page.locator('header');
const count = await headers.count();
expect(count).toBeGreaterThanOrEqual(1);
});
test('community page uses semantic nav element', async ({ page }) => {
await page.goto(`${BASE}/community/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const navs = page.locator('nav');
const count = await navs.count();
expect(count).toBeGreaterThanOrEqual(1);
});
test('community page uses semantic main element', async ({ page }) => {
await page.goto(`${BASE}/community/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const mains = page.locator('main');
const count = await mains.count();
expect(count).toBeGreaterThanOrEqual(1);
});
test('community page uses semantic footer element', async ({ page }) => {
await page.goto(`${BASE}/community/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const footers = page.locator('footer');
const count = await footers.count();
expect(count).toBeGreaterThanOrEqual(1);
});
test('community page has section elements', async ({ page }) => {
await page.goto(`${BASE}/community/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const sections = page.locator('section');
const count = await sections.count();
expect(count).toBeGreaterThanOrEqual(1);
});
test('community page has form elements for login', async ({ page }) => {
await page.goto(`${BASE}/community/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const forms = page.locator('form');
const count = await forms.count();
expect(count).toBeGreaterThanOrEqual(1);
});
});
test.describe('Cross-page consistent header/footer', () => {
test('homepage and about page share the same nav structure', async ({ page }) => {
await page.goto(`${BASE}/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const homeNavLinks = await page.locator('nav a[href*="about.html"]').count();
await page.goto(`${BASE}/about.html`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const aboutNavLinks = await page.locator('nav a[href*="about.html"]').count();
expect(homeNavLinks).toBeGreaterThanOrEqual(1);
expect(aboutNavLinks).toBeGreaterThanOrEqual(1);
});
test('marketing pages share footer with terms and privacy links', async ({ page }) => {
const marketingPages = ['/', '/about.html', '/download.html', '/premiere.html'];
for (const path of marketingPages) {
await page.goto(`${BASE}${path}`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const termsLink = await page.locator('a[href*="terms.html"]').count();
const privacyLink = await page.locator('a[href*="privacy.html"]').count();
expect(termsLink).toBeGreaterThanOrEqual(1);
expect(privacyLink).toBeGreaterThanOrEqual(1);
}
});
test('marketing pages share nav with download link', async ({ page }) => {
const pages = ['/', '/about.html', '/premiere.html'];
for (const path of pages) {
await page.goto(`${BASE}${path}`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const downloadLink = await page.locator('nav a[href*="download.html"]').count();
expect(downloadLink).toBeGreaterThanOrEqual(1);
}
});
test('community pages share footer with privacy and terms links', async ({ page }) => {
const communityPages = ['/community/', '/community/blogs/', '/community/staff/'];
for (const path of communityPages) {
await page.goto(`${BASE}${path}`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const privacyLink = await page.locator('a[href*="privacy.html"]').count();
const termsLink = await page.locator('a[href*="terms.html"]').count();
expect(privacyLink).toBeGreaterThanOrEqual(1);
expect(termsLink).toBeGreaterThanOrEqual(1);
}
});
});
test.describe('Device pages structural tests', () => {
test('device pages have exactly one h1', async ({ page }) => {
const devicePages = [
'/streamora-for-android.html',
'/streamora-for-android-tv.html',
'/streamora-for-appletv.html',
'/streamora-for-fire-tv.html',
'/streamora-for-ios.html',
'/streamora-for-roku.html',
];
for (const path of devicePages) {
await page.goto(`${BASE}${path}`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const h1Count = await page.locator('h1').count();
expect(h1Count).toBe(1);
}
});
test('device pages have nav element', async ({ page }) => {
const devicePages = [
'/streamora-for-chromecast.html',
'/streamora-for-lg-smart-tv.html',
'/streamora-for-samsung-smart-tv.html',
];
for (const path of devicePages) {
await page.goto(`${BASE}${path}`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const navCount = await page.locator('nav').count();
expect(navCount).toBeGreaterThanOrEqual(1);
}
});
test('device pages have image elements', async ({ page }) => {
await page.goto(`${BASE}/streamora-for-android-tv.html`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const imgCount = await page.locator('img').count();
expect(imgCount).toBeGreaterThanOrEqual(3);
});
});
test.describe('Responsive structural tests', () => {
test('homepage at mobile width has no horizontal overflow', async ({ page }) => {
await page.setViewportSize({ width: 375, height: 812 });
await page.goto(`${BASE}/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const scrollWidth = await page.evaluate(() => document.documentElement.scrollWidth);
expect(scrollWidth).toBeLessThanOrEqual(400);
});
test('privacy page at mobile width has no horizontal overflow', async ({ page }) => {
await page.setViewportSize({ width: 375, height: 812 });
await page.goto(`${BASE}/privacy.html`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const scrollWidth = await page.evaluate(() => document.documentElement.scrollWidth);
expect(scrollWidth).toBeLessThanOrEqual(400);
});
test('terms page at mobile width has no horizontal overflow', async ({ page }) => {
await page.setViewportSize({ width: 375, height: 812 });
await page.goto(`${BASE}/terms.html`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const scrollWidth = await page.evaluate(() => document.documentElement.scrollWidth);
expect(scrollWidth).toBeLessThanOrEqual(400);
});
test('connect page at mobile width has no horizontal overflow', async ({ page }) => {
await page.setViewportSize({ width: 375, height: 812 });
await page.goto(`${BASE}/connect.html`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const scrollWidth = await page.evaluate(() => document.documentElement.scrollWidth);
expect(scrollWidth).toBeLessThanOrEqual(400);
});
test('Android TV page at mobile width has no horizontal overflow', async ({ page }) => {
await page.setViewportSize({ width: 375, height: 812 });
await page.goto(`${BASE}/streamora-for-android-tv.html`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const scrollWidth = await page.evaluate(() => document.documentElement.scrollWidth);
expect(scrollWidth).toBeLessThanOrEqual(950);
});
});
test.describe('Heading hierarchy tests', () => {
test('about page has proper h1 to h4 hierarchy', async ({ page }) => {
await page.goto(`${BASE}/about.html`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const h1Count = await page.locator('h1').count();
const h4Count = await page.locator('h4').count();
expect(h1Count).toBeGreaterThanOrEqual(1);
expect(h4Count).toBeGreaterThanOrEqual(1);
});
test('premiere page has h1 and h3 headings', async ({ page }) => {
await page.goto(`${BASE}/premiere.html`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const h1Count = await page.locator('h1').count();
const h3Count = await page.locator('h3').count();
expect(h1Count).toBeGreaterThanOrEqual(1);
expect(h3Count).toBeGreaterThanOrEqual(3);
});
test('privacy page has h1 and h3 sections', async ({ page }) => {
await page.goto(`${BASE}/privacy.html`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const h1Count = await page.locator('h1').count();
const h3Count = await page.locator('h3').count();
expect(h1Count).toBeGreaterThanOrEqual(1);
expect(h3Count).toBeGreaterThanOrEqual(5);
});
test('support page has h1 and h2 headings', async ({ page }) => {
await page.goto(`${BASE}/support/`);
await page.waitForLoadState('networkidle');
await page.waitForTimeout(2000);
const h1Count = await page.locator('h1').count();
const h2Count = await page.locator('h2').count();
expect(h1Count).toBeGreaterThanOrEqual(1);
expect(h2Count).toBeGreaterThanOrEqual(2);
});
});