MCPcopy Index your code
hub / github.com/plotly/dash / cells_are_same_width

Function cells_are_same_width

components/dash-table/tests/selenium/test_sizing.py:55–119  ·  view source on GitHub ↗
(test, target_selector, table_selector)

Source from the content-addressed store, hash-verified

53
54
55def cells_are_same_width(test, target_selector, table_selector):
56 # this test is very dependent on the table's implementation details.. we are testing that all the cells are
57 # the same width after all..
58
59 def assertions():
60 target = test.wait_for_element(target_selector)
61 table = test.wait_for_element(table_selector)
62
63 wait.until(
64 lambda: target.size["width"] != 0
65 and abs(target.size["width"] - table.size["width"]) <= 1,
66 3,
67 )
68 target_cells = target.find_elements(
69 By.CSS_SELECTOR, ".cell-1-1 > table > tbody > tr:last-of-type > *"
70 )
71 table_r0c0_cells = table.find_elements(
72 By.CSS_SELECTOR, ".cell-0-0 > table > tbody > tr:last-of-type > *"
73 )
74 table_r0c1_cells = table.find_elements(
75 By.CSS_SELECTOR, ".cell-0-1 > table > tbody > tr:last-of-type > *"
76 )
77 table_r1c0_cells = table.find_elements(
78 By.CSS_SELECTOR, ".cell-1-0 > table > tbody > tr:last-of-type > *"
79 )
80 table_r1c1_cells = table.find_elements(
81 By.CSS_SELECTOR, ".cell-1-1 > table > tbody > tr:last-of-type > *"
82 )
83
84 # make sure the r1c1 fragment contains all the cells
85 assert len(target_cells) == len(table_r1c1_cells)
86
87 # for each cell of each fragment, allow a difference of up to 1px either way since
88 # the resize algorithm can be off by 1px for cycles
89 for i, target_cell in enumerate(target_cells):
90 assert (
91 abs(target_cell.size["width"] - table_r1c1_cells[i].size["width"]) <= 1
92 )
93
94 if len(table_r0c0_cells) != 0:
95 assert (
96 abs(target_cell.size["width"] - table_r0c0_cells[i].size["width"])
97 <= 1
98 )
99
100 if len(table_r0c1_cells) != 0:
101 assert (
102 abs(target_cell.size["width"] - table_r0c1_cells[i].size["width"])
103 <= 1
104 )
105
106 if len(table_r1c0_cells) != 0:
107 assert (
108 abs(target_cell.size["width"] - table_r1c0_cells[i].size["width"])
109 <= 1
110 )
111
112 retry = 0

Calls 1

assertionsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…