1
0

liveview.spec.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // @ts-check
  2. const { test, expect } = require('@playwright/test');
  3. test('button click', async ({ page }) => {
  4. await page.goto('http://127.0.0.1:3030');
  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. await page.getByRole('button', { name: 'Increment' }).click();
  10. // Expect the page to contain the updated counter text.
  11. await expect(main).toContainText('hello axum! 1');
  12. });
  13. test('svg', async ({ page }) => {
  14. await page.goto('http://127.0.0.1:3030');
  15. // Expect the page to contain the svg.
  16. const svg = page.locator('svg');
  17. // Expect the svg to contain the circle.
  18. const circle = svg.locator('circle');
  19. await expect(circle).toHaveAttribute('cx', '50');
  20. await expect(circle).toHaveAttribute('cy', '50');
  21. await expect(circle).toHaveAttribute('r', '40');
  22. await expect(circle).toHaveAttribute('stroke', 'green');
  23. await expect(circle).toHaveAttribute('fill', 'yellow');
  24. });
  25. test('raw attribute', async ({ page }) => {
  26. await page.goto('http://127.0.0.1:3030');
  27. // Expect the page to contain the div with the raw attribute.
  28. const div = page.locator('div.raw-attribute-div');
  29. await expect(div).toHaveAttribute('raw-attribute', 'raw-attribute-value');
  30. });
  31. test('hidden attribute', async ({ page }) => {
  32. await page.goto('http://127.0.0.1:3030');
  33. // Expect the page to contain the div with the hidden attribute.
  34. const div = page.locator('div.hidden-attribute-div');
  35. await expect(div).toHaveAttribute('hidden', 'true');
  36. });
  37. test('dangerous inner html', async ({ page }) => {
  38. await page.goto('http://127.0.0.1:3030');
  39. // Expect the page to contain the div with the dangerous inner html.
  40. const div = page.locator('div.dangerous-inner-html-div');
  41. await expect(div).toContainText('hello dangerous inner html');
  42. });
  43. test('input value', async ({ page }) => {
  44. await page.goto('http://127.0.0.1:3030');
  45. // Expect the page to contain the input with the value.
  46. const input = page.locator('input');
  47. await expect(input).toHaveValue('hello input');
  48. });
  49. test('style', async ({ page }) => {
  50. await page.goto('http://127.0.0.1:3030');
  51. // Expect the page to contain the div with the style.
  52. const div = page.locator('div.style-div');
  53. await expect(div).toHaveText('colored text');
  54. await expect(div).toHaveCSS('color', 'rgb(255, 0, 0)');
  55. });