|
1 | 1 | import * as path from "@std/path"; |
2 | 2 | import { expect } from "@std/expect"; |
3 | | -import { waitForText, withBrowser } from "../../fresh/tests/test_utils.tsx"; |
| 3 | +import { |
| 4 | + waitFor, |
| 5 | + waitForText, |
| 6 | + withBrowser, |
| 7 | +} from "../../fresh/tests/test_utils.tsx"; |
4 | 8 | import { |
5 | 9 | DEMO_DIR, |
6 | 10 | FIXTURE_DIR, |
@@ -350,3 +354,50 @@ Deno.test({ |
350 | 354 | sanitizeOps: false, |
351 | 355 | sanitizeResources: false, |
352 | 356 | }); |
| 357 | + |
| 358 | +Deno.test({ |
| 359 | + name: "vite dev - client side <Head>", |
| 360 | + fn: async () => { |
| 361 | + await launchDevServer(DEMO_DIR, async (address) => { |
| 362 | + await withBrowser(async (page) => { |
| 363 | + await page.goto(`${address}/tests/head_counter`, { |
| 364 | + waitUntil: "networkidle2", |
| 365 | + }); |
| 366 | + |
| 367 | + await page.locator(".ready").wait(); |
| 368 | + await page.locator("button").click(); |
| 369 | + await waitForText(page, ".result", "Count: 1"); |
| 370 | + |
| 371 | + await waitFor(async () => { |
| 372 | + const title = await page.evaluate(() => document.title); |
| 373 | + expect(title).toEqual("Count: 1"); |
| 374 | + return true; |
| 375 | + }); |
| 376 | + |
| 377 | + await page.goto(`${address}/tests/head_meta`, { |
| 378 | + waitUntil: "networkidle2", |
| 379 | + }); |
| 380 | + |
| 381 | + await page.locator(".ready").wait(); |
| 382 | + |
| 383 | + // await new Promise((r) => setTimeout(r, 200000)); |
| 384 | + await waitFor(async () => { |
| 385 | + const custom = await page |
| 386 | + .locator("meta[name='custom']") |
| 387 | + // deno-lint-ignore no-explicit-any |
| 388 | + .evaluate((el: any) => el.content); |
| 389 | + expect(custom).toEqual("ok"); |
| 390 | + |
| 391 | + const custom2 = await page |
| 392 | + .locator("meta[name='custom-new']") |
| 393 | + // deno-lint-ignore no-explicit-any |
| 394 | + .evaluate((el: any) => el.content); |
| 395 | + expect(custom2).toEqual("ok"); |
| 396 | + return true; |
| 397 | + }); |
| 398 | + }); |
| 399 | + }); |
| 400 | + }, |
| 401 | + sanitizeOps: false, |
| 402 | + sanitizeResources: false, |
| 403 | +}); |
0 commit comments