diff --git a/examples/full/.testRun.ts b/examples/full/.testRun.ts index 59deff3..d8a8cd7 100644 --- a/examples/full/.testRun.ts +++ b/examples/full/.testRun.ts @@ -2,6 +2,7 @@ export { testRun }; import { test, expect, run, fetchHtml, page, getServerUrl, autoRetry, partRegex } from "@brillout/test-e2e"; import assert from "node:assert"; +const dataHk = partRegex`data-hk="${/[0-9-]+/}"`; let isProd: boolean; @@ -41,6 +42,8 @@ function testRun(cmd: `pnpm run ${"dev" | "preview"}`) { }); testNavigationBetweenWithSSRAndWithoutSSR(); + + testHeadComponent(); } function testNavigationBetweenWithSSRAndWithoutSSR() { @@ -105,10 +108,8 @@ function testUrl({ expect(html).toContain(text); } - const dataHkHash = /[0-9-]+/; - expect(getTitle(html)).toBe(title); - expect(html).toMatch(partRegex``); + expect(html).toMatch(partRegex``); if (!description) description = "Demo showcasing Vike + Solid"; expect(html).toMatch(partRegex``); @@ -123,6 +124,30 @@ function testUrl({ }); } +function testHeadComponent() { + test("Head Component (HTML)", async () => { + const html = await fetchHtml("/images"); + expect(html).toMatch( + partRegex``, + ); + expect(html).toMatch( + partRegex``, + ); + }); + test("Head Component (Hydration)", async () => { + await page.goto(getServerUrl() + "/"); + await testCounter(); + ensureWasClientSideRouted("/pages/index"); + await page.click('a:has-text("Head Component")'); + await testCounter(); + ensureWasClientSideRouted("/pages/index"); + }); +} + function getTitle(html: string) { const title = html.match(/(.*?)<\/title>/i)?.[1]; return title;