From a63a37c3912cb52277af799fb5d062773ba158f4 Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Thu, 19 Mar 2026 07:57:00 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20[testing=20improvement]=20Add=20?= =?UTF-8?q?Playwright=20validation=20for=20JSON-LD=20structured=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: xRahul <1639945+xRahul@users.noreply.github.com> --- tests/structured-data.spec.ts | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 tests/structured-data.spec.ts diff --git a/tests/structured-data.spec.ts b/tests/structured-data.spec.ts new file mode 100644 index 00000000..da55d599 --- /dev/null +++ b/tests/structured-data.spec.ts @@ -0,0 +1,33 @@ +import { test, expect } from '@playwright/test'; + +test('has valid structured data', async ({ page }) => { + await page.goto('/'); + + const scriptTag = page.locator('script[type="application/ld+json"]'); + await expect(scriptTag).toBeAttached(); + + const scriptContent = await scriptTag.textContent(); + expect(scriptContent).not.toBeNull(); + + const data = JSON.parse(scriptContent as string); + + expect(data['@context']).toBe('http://schema.org'); + expect(data['@type']).toBe('Person'); + expect(data.name).toBe('Rahul Jain'); + expect(data.jobTitle).toBe('Senior Software Engineer'); + expect(data.url).toBe('https://rahulja.in'); + + const expectedSameAs = [ + 'https://www.linkedin.com/in/xrahuljain', + 'https://github.com/xRahul', + 'https://www.facebook.com/xRahulJain', + 'https://twitter.com/xRahulJain', + 'http://stackoverflow.com/users/1435626/rahul', + ]; + + expect(Array.isArray(data.sameAs)).toBe(true); + + for (const url of expectedSameAs) { + expect(data.sameAs).toContain(url); + } +});