Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt committed Dec 4, 2024
1 parent 4e4c82b commit 30fb6bd
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions panel/tests/ui/widgets/test_tabulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,35 @@ def test_tabulator_selection_on_multi_index(page, pagination):
wait_until(lambda: widget.selection == [0, 16], page)


def test_tabulator_selection_add_filter(page):
# https://github.com/holoviz/panel/issues/7505
df = pd.DataFrame(
{"col": ["a", "aa", "b", "bb", "bbb"]},
index=["idx0", "idx1", "idx2", "idx3", "idx4"],
)
w_col = Select(value="b", options=["a", "b"])
widget = Tabulator(df, selectable=1)

def f(df, pattern):
return df[df['col'].str.contains(pattern)]

widget.add_filter(bind(f, pattern=w_col))

serve_component(page, widget)

# Click on the first row of the index column to select the row
rows = page.locator('.tabulator-row')
c0 = page.locator('text="idx2"')
c0.wait_for()
c0.click()
wait_until(lambda: widget.selection == [2], page)
assert 'tabulator-selected' in rows.first.get_attribute('class')

Check failure on line 1612 in panel/tests/ui/widgets/test_tabulator.py

View workflow job for this annotation

GitHub Actions / ui:test-ui:ubuntu-latest

test_tabulator_selection_add_filter AssertionError: assert 'tabulator-selected' in 'tabulator-row tabulator-selectable tabulator-row-odd' + where 'tabulator-row tabulator-selectable tabulator-row-odd' = get_attribute('class') + where get_attribute = <Locator frame=<Frame name= url='http://localhost:34845/'> selector='.tabulator-row >> nth=0'>.get_attribute + where <Locator frame=<Frame name= url='http://localhost:34845/'> selector='.tabulator-row >> nth=0'> = <Locator frame=<Frame name= url='http://localhost:34845/'> selector='.tabulator-row'>.first

Check failure on line 1612 in panel/tests/ui/widgets/test_tabulator.py

View workflow job for this annotation

GitHub Actions / ui:test-ui:ubuntu-latest

test_tabulator_selection_add_filter AssertionError: assert 'tabulator-selected' in 'tabulator-row tabulator-selectable tabulator-row-odd' + where 'tabulator-row tabulator-selectable tabulator-row-odd' = get_attribute('class') + where get_attribute = <Locator frame=<Frame name= url='http://localhost:39103/'> selector='.tabulator-row >> nth=0'>.get_attribute + where <Locator frame=<Frame name= url='http://localhost:39103/'> selector='.tabulator-row >> nth=0'> = <Locator frame=<Frame name= url='http://localhost:39103/'> selector='.tabulator-row'>.first

Check failure on line 1612 in panel/tests/ui/widgets/test_tabulator.py

View workflow job for this annotation

GitHub Actions / ui:test-ui:ubuntu-latest

test_tabulator_selection_add_filter AssertionError: assert 'tabulator-selected' in 'tabulator-row tabulator-selectable tabulator-row-odd' + where 'tabulator-row tabulator-selectable tabulator-row-odd' = get_attribute('class') + where get_attribute = <Locator frame=<Frame name= url='http://localhost:46137/'> selector='.tabulator-row >> nth=0'>.get_attribute + where <Locator frame=<Frame name= url='http://localhost:46137/'> selector='.tabulator-row >> nth=0'> = <Locator frame=<Frame name= url='http://localhost:46137/'> selector='.tabulator-row'>.first

Check failure on line 1612 in panel/tests/ui/widgets/test_tabulator.py

View workflow job for this annotation

GitHub Actions / ui:test-ui:ubuntu-latest

test_tabulator_selection_add_filter AssertionError: assert 'tabulator-selected' in 'tabulator-row tabulator-selectable tabulator-row-odd' + where 'tabulator-row tabulator-selectable tabulator-row-odd' = get_attribute('class') + where get_attribute = <Locator frame=<Frame name= url='http://localhost:37901/'> selector='.tabulator-row >> nth=0'>.get_attribute + where <Locator frame=<Frame name= url='http://localhost:37901/'> selector='.tabulator-row >> nth=0'> = <Locator frame=<Frame name= url='http://localhost:37901/'> selector='.tabulator-row'>.first

Check failure on line 1612 in panel/tests/ui/widgets/test_tabulator.py

View workflow job for this annotation

GitHub Actions / ui:test-ui:macos-latest

test_tabulator_selection_add_filter AssertionError: assert 'tabulator-selected' in 'tabulator-row tabulator-selectable tabulator-row-odd' + where 'tabulator-row tabulator-selectable tabulator-row-odd' = get_attribute('class') + where get_attribute = <Locator frame=<Frame name= url='http://localhost:54531/'> selector='.tabulator-row >> nth=0'>.get_attribute + where <Locator frame=<Frame name= url='http://localhost:54531/'> selector='.tabulator-row >> nth=0'> = <Locator frame=<Frame name= url='http://localhost:54531/'> selector='.tabulator-row'>.first

Check failure on line 1612 in panel/tests/ui/widgets/test_tabulator.py

View workflow job for this annotation

GitHub Actions / ui:test-ui:macos-latest

test_tabulator_selection_add_filter AssertionError: assert 'tabulator-selected' in 'tabulator-row tabulator-selectable tabulator-row-odd' + where 'tabulator-row tabulator-selectable tabulator-row-odd' = get_attribute('class') + where get_attribute = <Locator frame=<Frame name= url='http://localhost:56532/'> selector='.tabulator-row >> nth=0'>.get_attribute + where <Locator frame=<Frame name= url='http://localhost:56532/'> selector='.tabulator-row >> nth=0'> = <Locator frame=<Frame name= url='http://localhost:56532/'> selector='.tabulator-row'>.first

Check failure on line 1612 in panel/tests/ui/widgets/test_tabulator.py

View workflow job for this annotation

GitHub Actions / ui:test-ui:macos-latest

test_tabulator_selection_add_filter AssertionError: assert 'tabulator-selected' in 'tabulator-row tabulator-selectable tabulator-row-odd' + where 'tabulator-row tabulator-selectable tabulator-row-odd' = get_attribute('class') + where get_attribute = <Locator frame=<Frame name= url='http://localhost:58513/'> selector='.tabulator-row >> nth=0'>.get_attribute + where <Locator frame=<Frame name= url='http://localhost:58513/'> selector='.tabulator-row >> nth=0'> = <Locator frame=<Frame name= url='http://localhost:58513/'> selector='.tabulator-row'>.first

Check failure on line 1612 in panel/tests/ui/widgets/test_tabulator.py

View workflow job for this annotation

GitHub Actions / ui:test-ui:macos-latest

test_tabulator_selection_add_filter AssertionError: assert 'tabulator-selected' in 'tabulator-row tabulator-selectable tabulator-row-odd' + where 'tabulator-row tabulator-selectable tabulator-row-odd' = get_attribute('class') + where get_attribute = <Locator frame=<Frame name= url='http://localhost:60492/'> selector='.tabulator-row >> nth=0'>.get_attribute + where <Locator frame=<Frame name= url='http://localhost:60492/'> selector='.tabulator-row >> nth=0'> = <Locator frame=<Frame name= url='http://localhost:60492/'> selector='.tabulator-row'>.first
for i in range(1, rows.count()):
assert 'tabulator-selected' not in rows.nth(i).get_attribute('class')
expected_selected = df.loc[['idx2'], :]
assert widget.selected_dataframe.equals(expected_selected)


@pytest.mark.parametrize('embed_content', [False, True])
def test_tabulator_row_content(page, df_mixed, embed_content):
widget = Tabulator(
Expand Down

0 comments on commit 30fb6bd

Please sign in to comment.