clean up test
This commit is contained in:
parent
7c7ef6fb35
commit
93e35346c4
@ -7,6 +7,14 @@ from playwright.sync_api import Page
|
|||||||
|
|
||||||
from reflex.testing import AppHarness
|
from reflex.testing import AppHarness
|
||||||
|
|
||||||
|
expected_col_headers = ["Name", "Age", "Location"]
|
||||||
|
expected_row_headers = ["John", "Jane", "Joe"]
|
||||||
|
expected_cells_data = [
|
||||||
|
["30", "New York"],
|
||||||
|
["31", "San Fransisco"],
|
||||||
|
["32", "Los Angeles"],
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def Table():
|
def Table():
|
||||||
"""App using table component."""
|
"""App using table component."""
|
||||||
@ -73,20 +81,20 @@ def test_table(page: Page, table_app: AppHarness):
|
|||||||
table_app: Harness for Table app
|
table_app: Harness for Table app
|
||||||
page: Playwright page instance
|
page: Playwright page instance
|
||||||
"""
|
"""
|
||||||
assert table_app.app_instance is not None, "app is not running"
|
|
||||||
assert table_app.frontend_url is not None, "frontend url is not available"
|
assert table_app.frontend_url is not None, "frontend url is not available"
|
||||||
|
|
||||||
page.goto(table_app.frontend_url)
|
page.goto(table_app.frontend_url)
|
||||||
table = page.get_by_role("table")
|
table = page.get_by_role("table")
|
||||||
|
|
||||||
|
# Check column headers
|
||||||
headers = table.get_by_role("columnheader").all_inner_texts()
|
headers = table.get_by_role("columnheader").all_inner_texts()
|
||||||
assert headers == ["Name", "Age", "Location"]
|
assert headers == expected_col_headers
|
||||||
|
|
||||||
rows = [
|
# Check rows headers
|
||||||
row.split("\t")
|
rows = table.get_by_role("rowheader").all_inner_texts()
|
||||||
for row in table.locator("tbody").all_inner_texts()[0].splitlines()
|
assert rows == expected_row_headers
|
||||||
]
|
|
||||||
|
|
||||||
assert rows[0] == ["John", "30", "New York"]
|
# Check cells
|
||||||
assert rows[1] == ["Jane", "31", "San Fransisco"]
|
rows = table.get_by_role("cell").all_inner_texts()
|
||||||
assert rows[2] == ["Joe", "32", "Los Angeles"]
|
for i, expected_row in enumerate(expected_cells_data):
|
||||||
|
assert [rows[idx := i * 2], rows[idx + 1]] == expected_row
|
||||||
|
Loading…
Reference in New Issue
Block a user