Test de la persistence des fitres (toutes pages)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
import datetime
|
||||
import uuid
|
||||
|
||||
import dash_bootstrap_components as dbc
|
||||
import polars as pl
|
||||
@@ -421,18 +420,16 @@ clientside_callback(
|
||||
|
||||
@callback(
|
||||
Output("acheteur-hidden-columns", "data", allow_duplicate=True),
|
||||
Output("filter-cleanup-trigger-acheteur", "data", allow_duplicate=True),
|
||||
Input("acheteur_column_list", "selected_rows"),
|
||||
prevent_initial_call=True,
|
||||
)
|
||||
def update_hidden_columns_from_checkboxes(selected_columns):
|
||||
trigger_cleanup = str(uuid.uuid4())
|
||||
if selected_columns:
|
||||
selected_columns = [columns[i] for i in selected_columns]
|
||||
hidden_columns = [col for col in columns if col not in selected_columns]
|
||||
return hidden_columns, trigger_cleanup
|
||||
return hidden_columns
|
||||
else:
|
||||
return [], trigger_cleanup
|
||||
return []
|
||||
|
||||
|
||||
@callback(
|
||||
|
||||
+11
-2
@@ -3,6 +3,7 @@ import os
|
||||
|
||||
import polars as pl
|
||||
import pytest
|
||||
from selenium.webdriver.chrome.options import Options
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
@@ -10,9 +11,10 @@ def test_data():
|
||||
data = [
|
||||
{
|
||||
"uid": "1",
|
||||
"acheteur_nom": "Acheteur 1",
|
||||
"id": "1",
|
||||
"acheteur_nom": "ACHETEUR 1",
|
||||
"acheteur_id": "a1",
|
||||
"titulaire_nom": "Titulaire 1",
|
||||
"titulaire_nom": "TITULAIRE 1",
|
||||
"titulaire_id": "t1",
|
||||
"montant": 10,
|
||||
"dateNotification": datetime.date(2025, 1, 1),
|
||||
@@ -24,6 +26,7 @@ def test_data():
|
||||
"titulaire_departement_code": "35",
|
||||
"titulaire_departement_nom": "Ille-et-Vilaine",
|
||||
"titulaire_commune_nom": "Rennes",
|
||||
"titulaire_distance": 10,
|
||||
"titulaire_typeIdentifiant": "SIRET",
|
||||
"objet": "Objet test",
|
||||
"dureeRestanteMois": 12,
|
||||
@@ -39,3 +42,9 @@ def test_data():
|
||||
|
||||
pl.DataFrame(data).write_parquet("tests/test.parquet")
|
||||
yield path
|
||||
|
||||
|
||||
def pytest_setup_options():
|
||||
options = Options()
|
||||
options.add_argument("--window-size=1200,800")
|
||||
return options
|
||||
|
||||
+49
-17
@@ -1,3 +1,5 @@
|
||||
from time import sleep
|
||||
|
||||
from dash.testing.composite import DashComposite
|
||||
from selenium.webdriver import Keys
|
||||
from selenium.webdriver.common.by import By
|
||||
@@ -10,22 +12,52 @@ def test_001_logo_and_search(dash_duo: DashComposite):
|
||||
dash_duo.start_server(app)
|
||||
dash_duo.wait_for_text_to_equal(".logo > h1", "decp.info", timeout=4)
|
||||
assert dash_duo.find_element(".logo > h1").text == "decp.info"
|
||||
search_bar: WebElement = dash_duo.find_element("#search")
|
||||
search_bar.click()
|
||||
search_bar.send_keys("A")
|
||||
search_bar.send_keys(Keys.ENTER)
|
||||
|
||||
dash_duo.wait_for_element("#results_acheteur_datatable")
|
||||
result_table_acheteurs: WebElement = dash_duo.find_element(
|
||||
"#results_acheteur_datatable tbody"
|
||||
)
|
||||
for org_type in ["acheteur", "titulaire"]:
|
||||
name = f"{org_type.upper()} 1"
|
||||
search_bar: WebElement = dash_duo.find_element("#search")
|
||||
|
||||
assert (
|
||||
len(result_table_acheteurs.find_elements(by=By.TAG_NAME, value="tr")) == 2
|
||||
) # header row + 1 result
|
||||
assert (
|
||||
result_table_acheteurs.find_element(
|
||||
by=By.CSS_SELECTOR, value='td[data-dash-column="acheteur_nom"]'
|
||||
).text
|
||||
== "Acheteur 1"
|
||||
)
|
||||
dash_duo.clear_input(search_bar)
|
||||
|
||||
search_bar.send_keys(name)
|
||||
search_bar.send_keys(Keys.ENTER)
|
||||
|
||||
dash_duo.wait_for_element(f"#results_{org_type}_datatable", timeout=2)
|
||||
result_table: WebElement = dash_duo.find_element(
|
||||
f"#results_{org_type}_datatable tbody"
|
||||
)
|
||||
|
||||
assert len(result_table.find_elements(by=By.TAG_NAME, value="tr")) == 2, (
|
||||
"The search should return only one result"
|
||||
) # header row + 1 result
|
||||
assert (
|
||||
result_table.find_element(
|
||||
by=By.CSS_SELECTOR, value=f'td[data-dash-column="{org_type}_nom"]'
|
||||
).text
|
||||
== name
|
||||
), f"The search result should have the right {org_type} name"
|
||||
|
||||
|
||||
def test_002_filter_persistence(dash_duo: DashComposite):
|
||||
from src.app import app
|
||||
|
||||
dash_duo.start_server(app)
|
||||
dash_duo.wait_for_text_to_equal(".logo > h1", "decp.info", timeout=4)
|
||||
|
||||
def open_page_and_check_filter_input():
|
||||
dash_duo.wait_for_page(f"{dash_duo.server_url}/{page}")
|
||||
filter_input_selector = (
|
||||
'.marches_table th[data-dash-column="uid"] input[type="text"]'
|
||||
)
|
||||
dash_duo.wait_for_element(filter_input_selector, timeout=2)
|
||||
_filter_input: WebElement = dash_duo.find_element(filter_input_selector)
|
||||
return _filter_input
|
||||
|
||||
for page in ["tableau", "acheteurs/a1", "titulaires/t1"]:
|
||||
print("page:", page)
|
||||
filter_input = open_page_and_check_filter_input()
|
||||
filter_input.send_keys("11") # a UID that doesn't exist
|
||||
filter_input.send_keys(Keys.ENTER)
|
||||
sleep(1)
|
||||
filter_input = open_page_and_check_filter_input()
|
||||
assert filter_input.get_attribute("value") == "11"
|
||||
|
||||
Reference in New Issue
Block a user