web.spec.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // @ts-check
  2. const { test, expect, defineConfig } = require("@playwright/test");
  3. test("button click", async ({ page }) => {
  4. await page.goto("http://localhost:9999");
  5. // Expect the page to contain the counter text.
  6. const main = page.locator("#main");
  7. await expect(main).toContainText("hello axum! 0");
  8. // Click the increment button.
  9. let button = page.locator("button.increment-button");
  10. await button.click();
  11. // Expect the page to contain the updated counter text.
  12. await expect(main).toContainText("hello axum! 1");
  13. });
  14. test("svg", async ({ page }) => {
  15. await page.goto("http://localhost:9999");
  16. // Expect the page to contain the svg.
  17. const svg = page.locator("svg");
  18. // Expect the svg to contain the circle.
  19. const circle = svg.locator("circle");
  20. await expect(circle).toHaveAttribute("cx", "50");
  21. await expect(circle).toHaveAttribute("cy", "50");
  22. await expect(circle).toHaveAttribute("r", "40");
  23. await expect(circle).toHaveAttribute("stroke", "green");
  24. await expect(circle).toHaveAttribute("fill", "yellow");
  25. });
  26. test("raw attribute", async ({ page }) => {
  27. await page.goto("http://localhost:9999");
  28. // Expect the page to contain the div with the raw attribute.
  29. const div = page.locator("div.raw-attribute-div");
  30. await expect(div).toHaveAttribute("raw-attribute", "raw-attribute-value");
  31. });
  32. test("hidden attribute", async ({ page }) => {
  33. await page.goto("http://localhost:9999");
  34. // Expect the page to contain the div with the hidden attribute.
  35. const div = page.locator("div.hidden-attribute-div");
  36. await expect(div).toHaveAttribute("hidden", "true");
  37. });
  38. test("dangerous inner html", async ({ page }) => {
  39. await page.goto("http://localhost:9999");
  40. // Expect the page to contain the div with the dangerous inner html.
  41. const div = page.locator("div.dangerous-inner-html-div");
  42. await expect(div).toContainText("hello dangerous inner html");
  43. });
  44. test("input value", async ({ page }) => {
  45. await page.goto("http://localhost:9999");
  46. // Expect the page to contain the input with the value.
  47. const input = page.locator("input");
  48. await expect(input).toHaveValue("hello input");
  49. });
  50. test("style", async ({ page }) => {
  51. await page.goto("http://localhost:9999");
  52. // Expect the page to contain the div with the style.
  53. const div = page.locator("div.style-div");
  54. await expect(div).toHaveText("colored text");
  55. await expect(div).toHaveCSS("color", "rgb(255, 0, 0)");
  56. });
  57. test("eval", async ({ page }) => {
  58. await page.goto("http://localhost:9999");
  59. // Expect the page to contain the div with the eval and have no text.
  60. const div = page.locator("div.eval-result");
  61. await expect(div).toHaveText("");
  62. // Click the button to run the eval.
  63. let button = page.locator("button.eval-button");
  64. await button.click();
  65. // Check that the title changed.
  66. await expect(page).toHaveTitle("Hello from Dioxus Eval!");
  67. // Check that the div has the eval value.
  68. await expect(div).toHaveText("returned eval value");
  69. });
  70. // Shutdown the li