File: test_reactivity.py

package info (click to toggle)
python-trame-client 3.10.4-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 3,128 kB
  • sloc: python: 9,583; javascript: 3,897; sh: 9; makefile: 6
file content (30 lines) | stat: -rw-r--r-- 926 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
from playwright.sync_api import expect
import pytest

from trame_client.utils.testing import assert_snapshot_matches


@pytest.mark.parametrize("server_path", ["examples/test/reactivity.py"])
def test_reactivity(server, page, ref_dir):
    url = f"http://127.0.0.1:{server.port}/"
    page.goto(url)

    assert_snapshot_matches(page, ref_dir, "simple_count_1")

    plus_button = page.locator(".plusButton")
    count_value = page.locator(".countValue")

    expect(count_value).to_have_text("1")
    assert server.get("count") == 1
    plus_button.click()
    expect(count_value).to_have_text("2")
    assert server.get("count") == 2
    plus_button.click()
    plus_button.click()
    expect(count_value).to_have_text("4")
    assert server.get("count") == 4
    plus_button.click()
    expect(count_value).to_have_text("5")
    assert server.get("count") == 5

    assert_snapshot_matches(page, ref_dir, "simple_count_5")