1
0

web.spec.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // @ts-check
  2. const { test, expect, defineConfig } = require('@playwright/test');
  3. test('button click', async ({ page }) => {
  4. await page.goto('http://localhost:8080');
  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:8080');
  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:8080');
  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:8080');
  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:8080');
  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:8080');
  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:8080');
  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:8080');
  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