Test de la persistence des fitres (toutes pages)
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import datetime
|
import datetime
|
||||||
import uuid
|
|
||||||
|
|
||||||
import dash_bootstrap_components as dbc
|
import dash_bootstrap_components as dbc
|
||||||
import polars as pl
|
import polars as pl
|
||||||
@@ -421,18 +420,16 @@ clientside_callback(
|
|||||||
|
|
||||||
@callback(
|
@callback(
|
||||||
Output("acheteur-hidden-columns", "data", allow_duplicate=True),
|
Output("acheteur-hidden-columns", "data", allow_duplicate=True),
|
||||||
Output("filter-cleanup-trigger-acheteur", "data", allow_duplicate=True),
|
|
||||||
Input("acheteur_column_list", "selected_rows"),
|
Input("acheteur_column_list", "selected_rows"),
|
||||||
prevent_initial_call=True,
|
prevent_initial_call=True,
|
||||||
)
|
)
|
||||||
def update_hidden_columns_from_checkboxes(selected_columns):
|
def update_hidden_columns_from_checkboxes(selected_columns):
|
||||||
trigger_cleanup = str(uuid.uuid4())
|
|
||||||
if selected_columns:
|
if selected_columns:
|
||||||
selected_columns = [columns[i] for i in selected_columns]
|
selected_columns = [columns[i] for i in selected_columns]
|
||||||
hidden_columns = [col for col in columns if col not 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:
|
else:
|
||||||
return [], trigger_cleanup
|
return []
|
||||||
|
|
||||||
|
|
||||||
@callback(
|
@callback(
|
||||||
|
|||||||
+11
-2
@@ -3,6 +3,7 @@ import os
|
|||||||
|
|
||||||
import polars as pl
|
import polars as pl
|
||||||
import pytest
|
import pytest
|
||||||
|
from selenium.webdriver.chrome.options import Options
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture(scope="session", autouse=True)
|
@pytest.fixture(scope="session", autouse=True)
|
||||||
@@ -10,9 +11,10 @@ def test_data():
|
|||||||
data = [
|
data = [
|
||||||
{
|
{
|
||||||
"uid": "1",
|
"uid": "1",
|
||||||
"acheteur_nom": "Acheteur 1",
|
"id": "1",
|
||||||
|
"acheteur_nom": "ACHETEUR 1",
|
||||||
"acheteur_id": "a1",
|
"acheteur_id": "a1",
|
||||||
"titulaire_nom": "Titulaire 1",
|
"titulaire_nom": "TITULAIRE 1",
|
||||||
"titulaire_id": "t1",
|
"titulaire_id": "t1",
|
||||||
"montant": 10,
|
"montant": 10,
|
||||||
"dateNotification": datetime.date(2025, 1, 1),
|
"dateNotification": datetime.date(2025, 1, 1),
|
||||||
@@ -24,6 +26,7 @@ def test_data():
|
|||||||
"titulaire_departement_code": "35",
|
"titulaire_departement_code": "35",
|
||||||
"titulaire_departement_nom": "Ille-et-Vilaine",
|
"titulaire_departement_nom": "Ille-et-Vilaine",
|
||||||
"titulaire_commune_nom": "Rennes",
|
"titulaire_commune_nom": "Rennes",
|
||||||
|
"titulaire_distance": 10,
|
||||||
"titulaire_typeIdentifiant": "SIRET",
|
"titulaire_typeIdentifiant": "SIRET",
|
||||||
"objet": "Objet test",
|
"objet": "Objet test",
|
||||||
"dureeRestanteMois": 12,
|
"dureeRestanteMois": 12,
|
||||||
@@ -39,3 +42,9 @@ def test_data():
|
|||||||
|
|
||||||
pl.DataFrame(data).write_parquet("tests/test.parquet")
|
pl.DataFrame(data).write_parquet("tests/test.parquet")
|
||||||
yield path
|
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 dash.testing.composite import DashComposite
|
||||||
from selenium.webdriver import Keys
|
from selenium.webdriver import Keys
|
||||||
from selenium.webdriver.common.by import By
|
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.start_server(app)
|
||||||
dash_duo.wait_for_text_to_equal(".logo > h1", "decp.info", timeout=4)
|
dash_duo.wait_for_text_to_equal(".logo > h1", "decp.info", timeout=4)
|
||||||
assert dash_duo.find_element(".logo > h1").text == "decp.info"
|
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")
|
for org_type in ["acheteur", "titulaire"]:
|
||||||
result_table_acheteurs: WebElement = dash_duo.find_element(
|
name = f"{org_type.upper()} 1"
|
||||||
"#results_acheteur_datatable tbody"
|
search_bar: WebElement = dash_duo.find_element("#search")
|
||||||
)
|
|
||||||
|
|
||||||
assert (
|
dash_duo.clear_input(search_bar)
|
||||||
len(result_table_acheteurs.find_elements(by=By.TAG_NAME, value="tr")) == 2
|
|
||||||
) # header row + 1 result
|
search_bar.send_keys(name)
|
||||||
assert (
|
search_bar.send_keys(Keys.ENTER)
|
||||||
result_table_acheteurs.find_element(
|
|
||||||
by=By.CSS_SELECTOR, value='td[data-dash-column="acheteur_nom"]'
|
dash_duo.wait_for_element(f"#results_{org_type}_datatable", timeout=2)
|
||||||
).text
|
result_table: WebElement = dash_duo.find_element(
|
||||||
== "Acheteur 1"
|
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