@@ -351,22 +351,54 @@ def expect_label(
351
351
352
352
353
353
class _WidthLocM :
354
+ """
355
+ A mixin class representing the `loc`'s width.
356
+ This class provides methods to expect the width attribute of an element.
357
+ """
358
+
354
359
def expect_width (
355
360
self : _InputBaseP ,
356
361
value : AttrValue ,
357
362
* ,
358
363
timeout : Timeout = None ,
359
364
) -> None :
365
+ """
366
+ Expect the width attribute of an element to have a specific value.
367
+
368
+ Parameters
369
+ ----------
370
+ value
371
+ The expected value of the width attribute.
372
+ timeout
373
+ The maximum time to wait for the expectation to be fulfilled.
374
+ Defaults to None.
375
+ """
360
376
expect_attr (self .loc , "width" , value = value , timeout = timeout )
361
377
362
378
363
379
class _WidthContainerM :
380
+ """
381
+ A mixin class representing the container's width.
382
+ This class provides methods to expect the width attribute of an element's container.
383
+ """
384
+
364
385
def expect_width (
365
386
self : _InputWithContainerP ,
366
387
value : AttrValue ,
367
388
* ,
368
389
timeout : Timeout = None ,
369
390
) -> None :
391
+ """
392
+ Expect the width attribute of an element's container to have a specific value.
393
+
394
+ Parameters
395
+ ----------
396
+ value
397
+ The expected value of the width attribute.
398
+ timeout
399
+ The maximum time to wait for the expectation to be fulfilled.
400
+ Defaults to None.
401
+ """
370
402
expect_attr (self .loc_container , "width" , value = value , timeout = timeout )
371
403
372
404
@@ -2676,7 +2708,7 @@ def close_full_screen(
2676
2708
"""
2677
2709
self ._loc_close_button .click (timeout = timeout )
2678
2710
2679
- def expect_full_screen (
2711
+ def expect_full_screen_open (
2680
2712
self : _CardFullScreenLayoutP , open : bool , * , timeout : Timeout = None
2681
2713
) -> None :
2682
2714
"""
@@ -2693,31 +2725,48 @@ def expect_full_screen(
2693
2725
int (open ), timeout = timeout
2694
2726
)
2695
2727
2728
+ def expect_full_screen_available (
2729
+ self : _CardFullScreenLayoutP , available : bool , * , timeout : Timeout = None
2730
+ ) -> None :
2731
+ """
2732
+ Expects the card to be available for full screen mode.
2733
+
2734
+ Parameters
2735
+ ----------
2736
+ available
2737
+ True if the value box is expected to be available for full screen mode, False otherwise.
2738
+ timeout
2739
+ The maximum time to wait for the expectation to pass. Defaults to None.
2740
+ """
2741
+ playwright_expect (self ._loc_fullscreen ).to_have_count (
2742
+ int (available ), timeout = timeout
2743
+ )
2744
+
2696
2745
2697
2746
class ValueBox (
2698
2747
_WidthLocM ,
2699
2748
_CardFullScreenM ,
2700
2749
_InputWithContainer ,
2701
2750
):
2702
2751
"""
2703
- ValueBox control for shiny.ui.value_box - https:// shiny.posit.co/py/api/core/ ui.value_box.html
2752
+ ValueBox control for :func:`~ shiny.ui.value_box`
2704
2753
"""
2705
2754
2706
2755
loc : Locator
2707
2756
"""
2708
- Locator for the value box's value
2757
+ ` Locator` for the value box's value
2709
2758
"""
2710
2759
loc_showcase : Locator
2711
2760
"""
2712
- Locator for the value box showcase
2761
+ ` Locator` for the value box showcase
2713
2762
"""
2714
2763
loc_title : Locator
2715
2764
"""
2716
- Locator for the value box title
2765
+ ` Locator` for the value box title
2717
2766
"""
2718
2767
loc_body : Locator
2719
2768
"""
2720
- Locator for the value box body
2769
+ ` Locator` for the value box body
2721
2770
"""
2722
2771
2723
2772
def __init__ (self , page : Page , id : str ) -> None :
@@ -2835,35 +2884,40 @@ def expect_body(
2835
2884
timeout = timeout ,
2836
2885
)
2837
2886
2838
- def expect_full_screen_available (
2839
- self , available : bool , * , timeout : Timeout = None
2840
- ) -> None :
2887
+
2888
+ class Card (_WidthLocM , _CardFooterM , _CardBodyM , _CardFullScreenM , _InputWithContainer ):
2889
+ """
2890
+ Card control for :func:`~shiny.ui.card`
2891
+ """
2892
+
2893
+ loc : Locator
2894
+ """
2895
+ `Locator` for the card's value
2896
+ """
2897
+ loc_title : Locator
2898
+ """
2899
+ `Locator` for the card title
2900
+ """
2901
+ loc_footer : Locator
2902
+ """
2903
+ `Locator` for the card footer
2904
+ """
2905
+ loc_body : Locator
2906
+ """
2907
+ `Locator` for the card body
2908
+ """
2909
+
2910
+ def __init__ (self , page : Page , id : str ) -> None :
2841
2911
"""
2842
- Expects the value box to be available for full screen mode .
2912
+ Initializes a new instance of the Card class .
2843
2913
2844
2914
Parameters
2845
2915
----------
2846
- available
2847
- True if the value box is expected to be available for full screen mode, False otherwise .
2848
- timeout
2849
- The maximum time to wait for the expectation to pass. Defaults to None .
2916
+ page
2917
+ The Playwright page object .
2918
+ id
2919
+ The ID of the card .
2850
2920
"""
2851
- playwright_expect (self ._loc_fullscreen ).to_have_count (
2852
- int (available ), timeout = timeout
2853
- )
2854
-
2855
-
2856
- class Card (_WidthLocM , _CardFooterM , _CardBodyM , _CardFullScreenM , _InputWithContainer ):
2857
- # *args: TagChild | TagAttrs | CardItem,
2858
- # full_screen: bool = False,
2859
- # height: CssUnit | None = None,
2860
- # max_height: CssUnit | None = None,
2861
- # min_height: CssUnit | None = None,
2862
- # fill: bool = True,
2863
- # class_: str | None = None,
2864
- # wrapper: WrapperCallable | MISSING_TYPE | None = MISSING,
2865
- # **kwargs: TagAttrValue
2866
- def __init__ (self , page : Page , id : str ) -> None :
2867
2921
super ().__init__ (
2868
2922
page ,
2869
2923
id = id ,
@@ -2886,14 +2940,25 @@ def __init__(self, page: Page, id: str) -> None:
2886
2940
2887
2941
def expect_header (
2888
2942
self ,
2889
- text : PatternOrStr ,
2943
+ text : PatternOrStr | None ,
2890
2944
* ,
2891
2945
timeout : Timeout = None ,
2892
2946
) -> None :
2893
- playwright_expect (self .loc_title ).to_have_text (
2894
- text ,
2895
- timeout = timeout ,
2896
- )
2947
+ """
2948
+ Expects the card header to have a specific text.
2949
+
2950
+ Parameters
2951
+ ----------
2952
+ text
2953
+ The expected text pattern or string
2954
+ Note: None if the header is expected to not exist.
2955
+ timeout
2956
+ The maximum time to wait for the expectation to pass. Defaults to None.
2957
+ """
2958
+ if text is None :
2959
+ playwright_expect (self .loc_title ).to_have_count (0 , timeout = timeout )
2960
+ else :
2961
+ playwright_expect (self .loc_title ).to_have_text (text , timeout = timeout )
2897
2962
2898
2963
# def expect_body(
2899
2964
# self,
@@ -2908,17 +2973,66 @@ def expect_header(
2908
2973
# timeout=timeout,
2909
2974
# )
2910
2975
2976
+ def expect_footer (
2977
+ self ,
2978
+ text : PatternOrStr | None ,
2979
+ * ,
2980
+ timeout : Timeout = None ,
2981
+ ) -> None :
2982
+ """
2983
+ Expects the card footer to have a specific text.
2984
+
2985
+ Parameters
2986
+ ----------
2987
+ text
2988
+ The expected text pattern or string
2989
+ Note: None if the footer is expected to not exist.
2990
+ timeout
2991
+ The maximum time to wait for the expectation to pass. Defaults to None.
2992
+ """
2993
+ if text is None :
2994
+ playwright_expect (self .loc_footer ).to_have_count (0 , timeout = timeout )
2995
+ else :
2996
+ playwright_expect (self .loc_footer ).to_have_text (text , timeout = timeout )
2997
+
2911
2998
def expect_max_height (self , value : StyleValue , * , timeout : Timeout = None ) -> None :
2999
+ """
3000
+ Expects the card to have a specific maximum height.
3001
+
3002
+ Parameters
3003
+ ----------
3004
+ value
3005
+ The expected maximum height value.
3006
+ timeout
3007
+ The maximum time to wait for the expectation to pass. Defaults to None.
3008
+ """
2912
3009
expect_to_have_style (self .loc_container , "max-height" , value , timeout = timeout )
2913
3010
2914
3011
def expect_min_height (self , value : StyleValue , * , timeout : Timeout = None ) -> None :
3012
+ """
3013
+ Expects the card to have a specific minimum height.
3014
+
3015
+ Parameters
3016
+ ----------
3017
+ value
3018
+ The expected minimum height value.
3019
+ timeout
3020
+ The maximum time to wait for the expectation to pass. Defaults to None.
3021
+ """
2915
3022
expect_to_have_style (self .loc_container , "min-height" , value , timeout = timeout )
2916
3023
2917
3024
def expect_height (self , value : StyleValue , * , timeout : Timeout = None ) -> None :
2918
- expect_to_have_style ( self . loc_container , "height" , value , timeout = timeout )
2919
-
3025
+ """
3026
+ Expects the card to have a specific height.
2920
3027
2921
- # Experimental below
3028
+ Parameters
3029
+ ----------
3030
+ value
3031
+ The expected height value.
3032
+ timeout
3033
+ The maximum time to wait for the expectation to pass. Defaults to None.
3034
+ """
3035
+ expect_to_have_style (self .loc_container , "height" , value , timeout = timeout )
2922
3036
2923
3037
2924
3038
class Accordion (
0 commit comments