import { test, expect } from '@playwright/test'; test.describe('Structural - homepage', () => { test('homepage: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('homepage: heading hierarchy is valid', async ({ page }) => { await page.goto('/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - about', () => { test('about: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/about/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('about: heading hierarchy is valid', async ({ page }) => { await page.goto('/about/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - about_partners', () => { }); test.describe('Structural - countries_AFG', () => { }); test.describe('Structural - countries_AGO', () => { test('countries_AGO: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/AGO/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_AGO: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/AGO/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_ALB', () => { test('countries_ALB: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/ALB/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_ALB: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/ALB/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_AND', () => { }); test.describe('Structural - countries_ARG', () => { test('countries_ARG: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/ARG/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_ARG: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/ARG/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_ARM', () => { }); test.describe('Structural - countries_ATG', () => { }); test.describe('Structural - countries_AUS', () => { test('countries_AUS: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/AUS/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_AUS: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/AUS/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_AUT', () => { test('countries_AUT: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/AUT/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_AUT: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/AUT/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_AZE', () => { }); test.describe('Structural - countries_BDI', () => { }); test.describe('Structural - countries_BEL', () => { test('countries_BEL: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/BEL/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_BEL: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/BEL/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_BEN', () => { }); test.describe('Structural - countries_BFA', () => { test('countries_BFA: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/BFA/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_BFA: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/BFA/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_BGD', () => { test('countries_BGD: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/BGD/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_BGD: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/BGD/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_BGR', () => { test('countries_BGR: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/BGR/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_BGR: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/BGR/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_BHR', () => { test('countries_BHR: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/BHR/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_BHR: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/BHR/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_BHS', () => { }); test.describe('Structural - countries_BIH', () => { test('countries_BIH: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/BIH/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_BIH: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/BIH/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_BLR', () => { test('countries_BLR: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/BLR/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_BLR: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/BLR/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_BLZ', () => { }); test.describe('Structural - countries_BOL', () => { test('countries_BOL: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/BOL/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_BOL: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/BOL/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_BRA', () => { test('countries_BRA: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/BRA/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_BRA: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/BRA/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_BRB', () => { test('countries_BRB: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/BRB/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_BRB: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/BRB/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_BRN', () => { }); test.describe('Structural - countries_BTN', () => { }); test.describe('Structural - countries_BWA', () => { test('countries_BWA: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/BWA/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_BWA: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/BWA/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_CAF', () => { }); test.describe('Structural - countries_CAN', () => { test('countries_CAN: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/CAN/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_CAN: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/CAN/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_CHL', () => { }); test.describe('Structural - countries_CHN', () => { test('countries_CHN: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/CHN/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_CHN: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/CHN/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_COL', () => { test('countries_COL: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/COL/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_COL: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/COL/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_COM', () => { }); test.describe('Structural - countries_CPV', () => { }); test.describe('Structural - countries_DZA', () => { test('countries_DZA: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/countries/DZA/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('countries_DZA: heading hierarchy is valid', async ({ page }) => { await page.goto('/countries/DZA/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - countries_KHM', () => { }); test.describe('Structural - countries_TCD', () => { }); test.describe('Structural - custom_compare', () => { }); test.describe('Structural - data_explorer', () => { test('data_explorer: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/data-explorer/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('data_explorer: heading hierarchy is valid', async ({ page }) => { await page.goto('/data-explorer/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - ghg_emissions', () => { test('ghg_emissions: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/ghg-emissions/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('ghg_emissions: heading hierarchy is valid', async ({ page }) => { await page.goto('/ghg-emissions/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - lts_explore', () => { test('lts_explore: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/lts-explore/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); }); test.describe('Structural - ndc_overview', () => { }); test.describe('Structural - ndc_search', () => { test('ndc_search: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/ndc-search/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); }); test.describe('Structural - ndcs_sdg', () => { test('ndcs_sdg: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/ndcs-sdg/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); }); test.describe('Structural - pathways', () => { test('pathways: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/pathways/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('pathways: heading hierarchy is valid', async ({ page }) => { await page.goto('/pathways/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - lts_country_AND', () => { test('lts_country_AND: reproduces GT semantic landmarks', async ({ page }) => { await page.goto('/lts/country/AND/'); expect(await page.locator('footer, [role="contentinfo"]').first().count(), 'footer landmark present in GT').toBeGreaterThan(0); }); test('lts_country_AND: heading hierarchy is valid', async ({ page }) => { await page.goto('/lts/country/AND/'); const headingLevels = await page.evaluate(() => { const headings = document.querySelectorAll('h1, h2, h3, h4, h5, h6'); return Array.from(headings).map(h => parseInt(h.tagName.substring(1))); }); if (headingLevels.length > 1) { for (let i = 1; i < headingLevels.length; i++) { const jump = headingLevels[i] - headingLevels[i-1]; expect(jump).toBeLessThanOrEqual(2); } } }); }); test.describe('Structural - Consistency', () => { test('header links are consistent across pages', async ({ page }) => { const headerLinksByPage: string[][] = []; { await page.goto('/'); const links = await page.locator('header a, nav a').allTextContents(); headerLinksByPage.push(links.map(l => l.trim()).filter(l => l.length > 0)); } { await page.goto('/about/'); const links = await page.locator('header a, nav a').allTextContents(); headerLinksByPage.push(links.map(l => l.trim()).filter(l => l.length > 0)); } { await page.goto('/about/partners/'); const links = await page.locator('header a, nav a').allTextContents(); headerLinksByPage.push(links.map(l => l.trim()).filter(l => l.length > 0)); } { await page.goto('/countries/AFG/'); const links = await page.locator('header a, nav a').allTextContents(); headerLinksByPage.push(links.map(l => l.trim()).filter(l => l.length > 0)); } if (headerLinksByPage.length >= 2 && headerLinksByPage[0].length > 0) { const first = new Set(headerLinksByPage[0]); for (let i = 1; i < headerLinksByPage.length; i++) { const current = new Set(headerLinksByPage[i]); const overlap = [...first].filter(l => current.has(l)); if (first.size > 0) { expect(overlap.length / first.size).toBeGreaterThanOrEqual(0.5); } } } }); });