1
0

wasm-split.spec.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // @ts-check
  2. const { test, expect } = require("@playwright/test");
  3. test("wasm-split page is functional", async ({ page }) => {
  4. // Wait for the dev server to load
  5. await page.goto("http://localhost:8001");
  6. // Make sure the local button works - no broken wasm
  7. const counter = page.locator("#counter-display");
  8. await expect(counter).toContainText("Count: 1");
  9. await page.locator("#increment-counter").click();
  10. await expect(counter).toContainText("Count: 2");
  11. // Make sure the global button works - no broken wasm
  12. const counterGlobal = page.locator("#global-counter");
  13. await expect(counterGlobal).toContainText("Global Counter: 0");
  14. await page.locator("#increment-counter-global").click();
  15. await expect(counterGlobal).toContainText("Global Counter: 1");
  16. // Fire one of the wasm modules to load. Should update the counter and add some text
  17. const addBodyTextButton = page.locator("#add-body-text");
  18. await addBodyTextButton.click();
  19. await expect(counterGlobal).toContainText("Global Counter: 2");
  20. const outputBox = page.locator("#output-box");
  21. await expect(outputBox).toContainText("Rendered!");
  22. // The other wasm module
  23. const addBodyElementButton = page.locator("#add-body-element");
  24. await addBodyElementButton.click();
  25. await expect(counterGlobal).toContainText("Global Counter: 4");
  26. await expect(outputBox).toContainText("Some inner div");
  27. // Load the gzip and brotli modules
  28. const gzipButton = page.locator("#gzip-it");
  29. await gzipButton.click();
  30. await expect(counterGlobal).toContainText("Global Counter: 7");
  31. const brotliButton = page.locator("#brotli-it");
  32. await brotliButton.click();
  33. await expect(counterGlobal).toContainText("Global Counter: 11");
  34. // Ignore the requests in CI
  35. // Load the other router module
  36. const childRouteButton = page.locator("#link-child");
  37. await childRouteButton.click();
  38. const nestedChildCounter = page.locator("#nested-child-count");
  39. await expect(nestedChildCounter).toContainText("Count: hello");
  40. await page.locator("#nested-child-add-world").click();
  41. await expect(nestedChildCounter).toContainText("Count: hello world");
  42. });