Skip to content

Commit 9cfc3ec

Browse files
committed
Merge branch 'main' into machow-feat-data-grid-polars
* main: api(playwright): Code review of complete playwright API (posit-dev#1501) fix: Move `www/shared/py-shiny` to `www/py-shiny` (posit-dev#1499)
2 parents dd2f867 + bdb5935 commit 9cfc3ec

File tree

36 files changed

+152
-162
lines changed

36 files changed

+152
-162
lines changed

js/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ process.argv.forEach((val, index) => {
1010
}
1111
});
1212

13-
const outDir = "../shiny/www/shared/py-shiny";
13+
const outDir = "../shiny/www/py-shiny";
1414

1515
async function bundle_helper(
1616
options: BuildOptions

shiny/playwright/controller/_controls.py

Lines changed: 55 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,14 +1174,14 @@ def expect_page_mode(self, value: str, *, timeout: Timeout = None):
11741174
)
11751175
return self
11761176

1177-
def expect_wc_attribute(self, value: str, *, timeout: Timeout = None):
1177+
def expect_attribute(self, value: str, *, timeout: Timeout = None):
11781178
"""
1179-
Expect the `wc` attribute of the input dark mode to have a specific value.
1179+
Expect the attribute named `attribute` of the input dark mode to have a specific value.
11801180
11811181
Parameters
11821182
----------
11831183
value
1184-
The expected value of the `wc` attribute.
1184+
The expected value of the `attribute` attribute.
11851185
timeout
11861186
The maximum time to wait for the expectation to be fulfilled. Defaults to `None`.
11871187
"""
@@ -1398,7 +1398,8 @@ def set(self, value: bool, *, timeout: Timeout = None, **kwargs: object) -> None
13981398
value, timeout=timeout, **kwargs # pyright: ignore[reportArgumentType]
13991399
)
14001400

1401-
def toggle(self, *, timeout: Timeout = None, **kwargs: object) -> None:
1401+
# TODO-karan-test: Convert usage of _toggle() to set()
1402+
def _toggle(self, *, timeout: Timeout = None, **kwargs: object) -> None:
14021403
"""
14031404
Toggles the input checkbox.
14041405
@@ -1480,6 +1481,7 @@ def __init__(
14801481
)
14811482

14821483

1484+
# TODO-future: Move class methods to a separate module
14831485
class _MultipleDomItems:
14841486
@staticmethod
14851487
def assert_arr_is_unique(
@@ -1811,7 +1813,7 @@ def __init__(
18111813

18121814
def set(
18131815
self,
1814-
# Allow `selected` to be a single Pattern to perform matching against many items
1816+
# TODO-future: Allow `selected` to be a single Pattern to perform matching against many items
18151817
selected: list[str],
18161818
*,
18171819
timeout: Timeout = None,
@@ -2072,19 +2074,6 @@ class InputFile(
20722074
Playwright `Locator` of the progress bar.
20732075
"""
20742076

2075-
# id: str,
2076-
# label: TagChild,
2077-
# *,
2078-
# multiple: bool = False,
2079-
# accept: Optional[Union[str, list[str]]] = None,
2080-
# width: Optional[str] = None,
2081-
# button_label: str = "Browse...",
2082-
# placeholder: str = "No file selected",
2083-
# capture: Optional[Literal["environment", "user"]] = None,
2084-
# with page.expect_file_chooser() as fc_info:
2085-
# page.get_by_text("Upload").click()
2086-
# file_chooser = fc_info.value
2087-
# file_chooser.set_files("myfile.pdf")
20882077
def __init__(
20892078
self,
20902079
page: Page,
@@ -3697,7 +3686,12 @@ class _OutputImageBase(_OutputInlineContainerM, _OutputBase):
36973686
Playwright `Locator` of the image.
36983687
"""
36993688

3700-
def __init__(self, page: Page, id: str, loc_classes: str = "") -> None:
3689+
def __init__(
3690+
self,
3691+
page: Page,
3692+
id: str,
3693+
loc_classes: str = "",
3694+
) -> None:
37013695
"""
37023696
Initializes an image output.
37033697
@@ -3904,20 +3898,6 @@ def expect_empty(self, value: bool, *, timeout: Timeout = None) -> None:
39043898
else:
39053899
self.expect.not_to_be_empty(timeout=timeout)
39063900

3907-
def expect_text(self, value: str, *, timeout: Timeout = None) -> None:
3908-
"""
3909-
Asserts that the output has the expected text.
3910-
3911-
Parameters
3912-
----------
3913-
value
3914-
The expected text.
3915-
timeout
3916-
The maximum time to wait for the text to appear. Defaults to `None`.
3917-
"""
3918-
3919-
self.expect.to_have_text(value, timeout=timeout)
3920-
39213901

39223902
# When making selectors, use `xpath` so that direct decendents can be checked
39233903
class OutputTable(_OutputBase):
@@ -4022,7 +4002,7 @@ def expect_column_text(
40224002
timeout=timeout,
40234003
)
40244004

4025-
def expect_n_col(
4005+
def expect_ncol(
40264006
self,
40274007
value: int,
40284008
*,
@@ -4046,7 +4026,7 @@ def expect_n_col(
40464026
timeout=timeout,
40474027
)
40484028

4049-
def expect_n_row(
4029+
def expect_nrow(
40504030
self,
40514031
value: int,
40524032
*,
@@ -4188,9 +4168,9 @@ def set(self, open: bool, *, timeout: Timeout = None) -> None:
41884168
The maximum time to wait for the sidebar to open or close. Defaults to `None`.
41894169
"""
41904170
if open ^ (self.loc_handle.get_attribute("aria-expanded") == "true"):
4191-
self.toggle(timeout=timeout)
4171+
self._toggle(timeout=timeout)
41924172

4193-
def toggle(self, *, timeout: Timeout = None) -> None:
4173+
def _toggle(self, *, timeout: Timeout = None) -> None:
41944174
"""
41954175
Toggles the sidebar open or closed.
41964176
@@ -4782,7 +4762,7 @@ def expect_panels(
47824762

47834763
def set(
47844764
self,
4785-
selected: str | list[str],
4765+
open: str | list[str],
47864766
*,
47874767
timeout: Timeout = None,
47884768
) -> None:
@@ -4791,13 +4771,13 @@ def set(
47914771
47924772
Parameters
47934773
----------
4794-
selected
4795-
The selected accordion panel(s).
4774+
open
4775+
The open accordion panel(s).
47964776
timeout
47974777
The maximum time to wait for the accordion panel to be visible and interactable. Defaults to `None`.
47984778
"""
4799-
if isinstance(selected, str):
4800-
selected = [selected]
4779+
if isinstance(open, str):
4780+
open = [open]
48014781
for element in self.loc.element_handles():
48024782
element.wait_for_element_state(state="visible", timeout=timeout)
48034783
element.scroll_into_view_if_needed(timeout=timeout)
@@ -4806,9 +4786,7 @@ def set(
48064786
raise ValueError(
48074787
"Accordion panel does not have a `data-value` attribute"
48084788
)
4809-
self.accordion_panel(elem_value).set(
4810-
elem_value in selected, timeout=timeout
4811-
)
4789+
self.accordion_panel(elem_value).set(elem_value in open, timeout=timeout)
48124790

48134791
def accordion_panel(
48144792
self,
@@ -4955,9 +4933,9 @@ def set(self, open: bool, *, timeout: Timeout = None) -> None:
49554933
self.loc.scroll_into_view_if_needed(timeout=timeout)
49564934
expect_not_to_have_class(self.loc_body, "collapsing", timeout=timeout)
49574935
if self._loc_body_visible.count() != int(open):
4958-
self.toggle(timeout=timeout)
4936+
self._toggle(timeout=timeout)
49594937

4960-
def toggle(self, *, timeout: Timeout = None) -> None:
4938+
def _toggle(self, *, timeout: Timeout = None) -> None:
49614939
"""
49624940
Toggles the state of the control.
49634941
@@ -5156,9 +5134,9 @@ def set(self, open: bool, timeout: Timeout = None) -> None:
51565134
The maximum time to wait for the popover to be visible and interactable. Defaults to `None`.
51575135
"""
51585136
if open ^ self.get_loc_overlay_body(timeout=timeout).count() > 0:
5159-
self.toggle()
5137+
self._toggle()
51605138

5161-
def toggle(self, timeout: Timeout = None) -> None:
5139+
def _toggle(self, timeout: Timeout = None) -> None:
51625140
"""
51635141
Toggles the state of the popover.
51645142
@@ -5227,11 +5205,11 @@ def set(self, open: bool, timeout: Timeout = None) -> None:
52275205
The maximum time to wait for the tooltip to be visible and interactable. Defaults to `None`.
52285206
"""
52295207
if open ^ self.get_loc_overlay_body(timeout=timeout).count() > 0:
5230-
self.toggle(timeout=timeout)
5208+
self._toggle(timeout=timeout)
52315209
if not open:
52325210
self.get_loc_overlay_body(timeout=timeout).click()
52335211

5234-
def toggle(self, timeout: Timeout = None) -> None:
5212+
def _toggle(self, timeout: Timeout = None) -> None:
52355213
"""
52365214
Toggles the state of the tooltip.
52375215
@@ -5304,7 +5282,9 @@ def get_loc_active_content(self, *, timeout: Timeout = None) -> Locator:
53045282
f"div.tab-content[data-tabsetid='{datatab_id}'] > div.tab-pane.active"
53055283
)
53065284

5307-
def expect_content(self, value: PatternOrStr, *, timeout: Timeout = None) -> None:
5285+
def _expect_content_text(
5286+
self, value: PatternOrStr, *, timeout: Timeout = None
5287+
) -> None:
53085288
"""
53095289
Expects the control to have the specified content.
53105290
@@ -5439,7 +5419,9 @@ def expect_active(self, value: bool, *, timeout: Timeout = None) -> None:
54395419
"""
54405420
_expect_class_value(self.loc, "active", value, timeout=timeout)
54415421

5442-
def expect_content(self, value: PatternOrStr, *, timeout: Timeout = None) -> None:
5422+
def _expect_content_text(
5423+
self, value: PatternOrStr, *, timeout: Timeout = None
5424+
) -> None:
54435425
"""
54445426
Expects the nav item content to have the specified text.
54455427
@@ -5876,7 +5858,7 @@ def cell_locator(self, row: int, col: int) -> Locator:
58765858
)
58775859

58785860
# TODO-barret; Should this be called `expect_row_count()`?
5879-
def expect_n_row(self, value: int, *, timeout: Timeout = None):
5861+
def expect_nrow(self, value: int, *, timeout: Timeout = None):
58805862
"""
58815863
Expects the number of rows in the data frame.
58825864
@@ -5891,7 +5873,7 @@ def expect_n_row(self, value: int, *, timeout: Timeout = None):
58915873
value, timeout=timeout
58925874
)
58935875

5894-
def expect_selected_n_row(self, value: int, *, timeout: Timeout = None):
5876+
def expect_selected_num_rows(self, value: int, *, timeout: Timeout = None):
58955877
"""
58965878
Expects the number of selected rows in the data frame.
58975879
@@ -5953,7 +5935,7 @@ def expect_selected_rows(self, rows: list[int], *, timeout: Timeout = None):
59535935
# Could not find the reason why. Raising the original error.
59545936
raise e
59555937

5956-
def expect_row_focus_state(
5938+
def _expect_row_focus_state(
59575939
self, in_focus: bool = True, *, row: int, timeout: Timeout = None
59585940
):
59595941
"""
@@ -6077,7 +6059,7 @@ def _cell_scroll_if_needed(self, *, row: int, col: int, timeout: Timeout):
60776059
break
60786060
cell.scroll_into_view_if_needed(timeout=timeout)
60796061

6080-
def expect_column_label(
6062+
def _expect_column_label(
60816063
self,
60826064
value: ListPatternOrStr,
60836065
*,
@@ -6103,7 +6085,7 @@ def expect_column_label(
61036085
timeout=timeout,
61046086
)
61056087

6106-
def expect_n_col(
6088+
def expect_ncol(
61076089
self,
61086090
value: int,
61096091
*,
@@ -6231,7 +6213,7 @@ def expect_class_state(
62316213
"Invalid state. Select one of 'success', 'failure', 'saving', 'editing', 'ready'"
62326214
)
62336215

6234-
def edit_cell(
6216+
def _edit_cell_no_save(
62356217
self,
62366218
text: str,
62376219
*,
@@ -6421,13 +6403,15 @@ def set_filter(
64216403
"Invalid filter value. Must be a string or a tuple/list of two numbers."
64226404
)
64236405

6424-
def save_cell(
6406+
def set_cell(
64256407
self,
64266408
text: str,
64276409
*,
64286410
row: int,
64296411
col: int,
6430-
save_key: str,
6412+
finish_key: (
6413+
Literal["Enter", "Shift+Enter", "Tab", "Shift+Tab", "Escape"] | None
6414+
) = None,
64316415
timeout: Timeout = None,
64326416
) -> None:
64336417
"""
@@ -6441,11 +6425,17 @@ def save_cell(
64416425
The row number of the cell.
64426426
col
64436427
The column number of the cell.
6428+
finish_key
6429+
The key to save the value of the cell. If `None` (the default), no key will
6430+
be pressed and instead the page body will be clicked.
64446431
timeout
64456432
The maximum time to wait for the action to complete. Defaults to `None`.
64466433
"""
6447-
self.edit_cell(text, row=row, col=col, timeout=timeout)
6448-
self.cell_locator(row=row, col=col).locator("> textarea").press(save_key)
6434+
self._edit_cell_no_save(text, row=row, col=col, timeout=timeout)
6435+
if finish_key is None:
6436+
self.page.locator("body").click()
6437+
else:
6438+
self.cell_locator(row=row, col=col).locator("> textarea").press(finish_key)
64496439

64506440
def expect_cell_title(
64516441
self,
@@ -6456,7 +6446,8 @@ def expect_cell_title(
64566446
timeout: Timeout = None,
64576447
) -> None:
64586448
"""
6459-
Expects the validation message of the cell in the data frame.
6449+
Expects the validation message of the cell in the data frame, which will be in
6450+
the `title` attribute of the element.
64606451
64616452
Parameters
64626453
----------

shiny/ui/_html_deps_py_shiny.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def data_frame_deps() -> HTMLDependency:
2121
version=__version__,
2222
source={
2323
"package": "shiny",
24-
"subdir": "www/shared/py-shiny/data-frame",
24+
"subdir": "www/py-shiny/data-frame",
2525
},
2626
script={"src": "data-frame.js", "type": "module"},
2727
)
@@ -33,7 +33,7 @@ def chat_deps() -> list[HTMLDependency]:
3333
version=__version__,
3434
source={
3535
"package": "shiny",
36-
"subdir": "www/shared/py-shiny/chat",
36+
"subdir": "www/py-shiny/chat",
3737
},
3838
script={"src": "chat.js", "type": "module"},
3939
stylesheet={"href": "chat.css"},
@@ -46,7 +46,7 @@ def autoresize_dependency() -> HTMLDependency:
4646
return HTMLDependency(
4747
"shiny-textarea-autoresize",
4848
__version__,
49-
source={"package": "shiny", "subdir": "www/shared/py-shiny/text-area"},
49+
source={"package": "shiny", "subdir": "www/py-shiny/text-area"},
5050
script={"src": "textarea-autoresize.js", "type": "module"},
5151
stylesheet={"href": "textarea-autoresize.css"},
5252
)
@@ -56,7 +56,7 @@ def page_output_dependency() -> HTMLDependency:
5656
return HTMLDependency(
5757
"shiny-page-output",
5858
__version__,
59-
source={"package": "shiny", "subdir": "www/shared/py-shiny/page-output"},
59+
source={"package": "shiny", "subdir": "www/py-shiny/page-output"},
6060
script={"src": "page-output.js", "type": "module"},
6161
)
6262

@@ -65,7 +65,7 @@ def spin_dependency() -> HTMLDependency:
6565
return HTMLDependency(
6666
"shiny-spin",
6767
__version__,
68-
source={"package": "shiny", "subdir": "www/shared/py-shiny/spin"},
68+
source={"package": "shiny", "subdir": "www/py-shiny/spin"},
6969
stylesheet={"href": "spin.css"},
7070
)
7171

File renamed without changes.

0 commit comments

Comments
 (0)