1
0

web-hash-routing.spec.js 989 B

12345678910111213141516171819202122232425262728293031
  1. // @ts-check
  2. const { test, expect } = require("@playwright/test");
  3. test("redirect", async ({ page }) => {
  4. // Going to the root url should redirect to /other.
  5. await page.goto("http://localhost:2021");
  6. // Expect the page to the text Other
  7. const main = page.locator("#other");
  8. await expect(main).toContainText("Other");
  9. // Expect the url to be /#/other
  10. await expect(page).toHaveURL("http://localhost:2021/#/other");
  11. });
  12. test("links", async ({ page }) => {
  13. await page.goto("http://localhost:2021/#/other");
  14. // Expect clicking the link to /other/123 to navigate to /other/123
  15. const link = page.locator("a[href='/#/other/123']");
  16. await link.click();
  17. await expect(page).toHaveURL("http://localhost:2021/#/other/123");
  18. });
  19. test("fallback", async ({ page }) => {
  20. await page.goto("http://localhost:2021/#/my/404/route");
  21. // Expect the page to contain the text Fallback
  22. const main = page.locator("#not-found");
  23. await expect(main).toContainText("NotFound");
  24. });