@@ -2552,62 +2552,143 @@ def toggle(self, *, timeout: Timeout = None) -> None:
2552
2552
2553
2553
2554
2554
class _CardBodyP (_InputBaseP , Protocol ):
2555
+ """
2556
+ Represents the body of a card control.
2557
+ """
2558
+
2555
2559
loc_body : Locator
2560
+ """
2561
+ The locator for the body element of the card control.
2562
+ """
2556
2563
2557
2564
2558
2565
class _CardBodyM :
2566
+ """Represents a card body element with additional methods for testing."""
2567
+
2559
2568
def expect_body (
2560
2569
self : _CardBodyP ,
2561
2570
text : PatternOrStr | list [PatternOrStr ],
2562
2571
* ,
2563
2572
timeout : Timeout = None ,
2564
2573
) -> None :
2565
- """Note: If testing against multiple elements, text should be an array"""
2574
+ """Expect the card body element to have the specified text.
2575
+
2576
+ Parameters
2577
+ ----------
2578
+ text
2579
+ The expected text or a list of expected texts.
2580
+ timeout
2581
+ The maximum time to wait for the text to appear. Defaults to None.
2582
+ """
2566
2583
playwright_expect (self .loc ).to_have_text (
2567
2584
text ,
2568
2585
timeout = timeout ,
2569
2586
)
2570
2587
2571
2588
2572
2589
class _CardFooterLayoutP (_InputBaseP , Protocol ):
2590
+ """
2591
+ Represents the layout of the footer in a card.
2592
+ """
2593
+
2573
2594
loc_footer : Locator
2595
+ """
2596
+ The locator for the footer element.
2597
+ """
2574
2598
2575
2599
2576
2600
class _CardFooterM :
2601
+ """
2602
+ Represents the footer section of a card.
2603
+ """
2604
+
2577
2605
def expect_footer (
2578
2606
self : _CardFooterLayoutP ,
2579
2607
text : PatternOrStr ,
2580
2608
* ,
2581
2609
timeout : Timeout = None ,
2582
2610
) -> None :
2611
+ """
2612
+ Asserts that the footer section of the card has the expected text.
2613
+
2614
+ Parameters
2615
+ ----------
2616
+ text
2617
+ The expected text in the footer section.
2618
+ timeout
2619
+ The maximum time to wait for the footer text to appear. Defaults to None.
2620
+ """
2583
2621
playwright_expect (self .loc_footer ).to_have_text (
2584
2622
text ,
2585
2623
timeout = timeout ,
2586
2624
)
2587
2625
2588
2626
2589
2627
class _CardFullScreenLayoutP (_OutputBaseP , Protocol ):
2628
+ """
2629
+ Represents a card full-screen layout for the Playwright controls.
2630
+ """
2631
+
2590
2632
loc_title : Locator
2633
+ """
2634
+ The locator for the title element.
2635
+ """
2591
2636
_loc_fullscreen : Locator
2637
+ """
2638
+ The locator for the full-screen element.
2639
+ """
2592
2640
_loc_close_button : Locator
2641
+ """
2642
+ The locator for the close button element.
2643
+ """
2593
2644
2594
2645
2595
2646
class _CardFullScreenM :
2647
+ """
2648
+ Represents a class for managing full screen functionality of a card.
2649
+ """
2650
+
2596
2651
def open_full_screen (
2597
2652
self : _CardFullScreenLayoutP , * , timeout : Timeout = None
2598
2653
) -> None :
2654
+ """
2655
+ Opens the card in full screen mode.
2656
+
2657
+ Parameters
2658
+ ----------
2659
+ timeout
2660
+ The maximum time to wait for the card to open in full screen mode. Defaults to None.
2661
+ """
2599
2662
self .loc_title .hover (timeout = timeout )
2600
2663
self ._loc_fullscreen .wait_for (state = "visible" , timeout = timeout )
2601
2664
self ._loc_fullscreen .click (timeout = timeout )
2602
2665
2603
2666
def close_full_screen (
2604
2667
self : _CardFullScreenLayoutP , * , timeout : Timeout = None
2605
2668
) -> None :
2669
+ """
2670
+ Closes the card from full screen mode.
2671
+
2672
+ Parameters
2673
+ ----------
2674
+ timeout
2675
+ The maximum time to wait for the card to close from full screen mode. Defaults to None.
2676
+ """
2606
2677
self ._loc_close_button .click (timeout = timeout )
2607
2678
2608
2679
def expect_full_screen (
2609
2680
self : _CardFullScreenLayoutP , open : bool , * , timeout : Timeout = None
2610
2681
) -> None :
2682
+ """
2683
+ Verifies if the card is expected to be in full screen mode.
2684
+
2685
+ Parameters
2686
+ ----------
2687
+ open
2688
+ True if the card is expected to be in full screen mode, False otherwise.
2689
+ timeout
2690
+ The maximum time to wait for the verification. Defaults to None.
2691
+ """
2611
2692
playwright_expect (self ._loc_close_button ).to_have_count (
2612
2693
int (open ), timeout = timeout
2613
2694
)
@@ -2618,24 +2699,44 @@ class ValueBox(
2618
2699
_CardFullScreenM ,
2619
2700
_InputWithContainer ,
2620
2701
):
2621
- # title: TagChild,
2622
- # value: TagChild,
2623
- # *args: TagChild | TagAttrs,
2624
- # showcase: TagChild = None,
2625
- # showcase_layout: ((TagChild, Tag) -> CardItem) | None = None,
2626
- # full_screen: bool = False,
2627
- # theme_color: str | None = "primary",
2628
- # height: CssUnit | None = None,
2629
- # max_height: CssUnit | None = None,
2630
- # fill: bool = True,
2631
- # class_: str | None = None,
2632
- # **kwargs: TagAttrValue
2702
+ """
2703
+ ValueBox control for shiny.ui.value_box - https://shiny.posit.co/py/api/core/ui.value_box.html
2704
+ """
2705
+
2706
+ loc : Locator
2707
+ """
2708
+ Locator for the value box's value
2709
+ """
2710
+ loc_showcase : Locator
2711
+ """
2712
+ Locator for the value box showcase
2713
+ """
2714
+ loc_title : Locator
2715
+ """
2716
+ Locator for the value box title
2717
+ """
2718
+ loc_body : Locator
2719
+ """
2720
+ Locator for the value box body
2721
+ """
2722
+
2633
2723
def __init__ (self , page : Page , id : str ) -> None :
2724
+ """
2725
+ Initializes a new instance of the ValueBox class.
2726
+
2727
+ Parameters
2728
+ ----------
2729
+ page
2730
+ The Playwright page object.
2731
+ id
2732
+ The ID of the value box.
2733
+
2734
+ """
2634
2735
super ().__init__ (
2635
2736
page ,
2636
2737
id = id ,
2637
2738
loc_container = f"div#{ id } .bslib-value-box" ,
2638
- loc = "> div > .value-box-grid" ,
2739
+ loc = "> div.card-body > .value-box-grid, > div.card-body " ,
2639
2740
)
2640
2741
value_box_grid = self .loc
2641
2742
self .loc_showcase = value_box_grid .locator ("> .value-box-showcase" )
@@ -2657,14 +2758,35 @@ def __init__(self, page: Page, id: str) -> None:
2657
2758
)
2658
2759
2659
2760
def expect_height (self , value : StyleValue , * , timeout : Timeout = None ) -> None :
2660
- expect_to_have_style (self .loc_container , "height" , value , timeout = timeout )
2761
+ """
2762
+ Expects the value box to have a specific height.
2763
+
2764
+ Parameters
2765
+ ----------
2766
+ value
2767
+ The expected height value.
2768
+ timeout
2769
+ The maximum time to wait for the expectation to pass. Defaults to None.
2770
+ """
2771
+ expect_to_have_style (self .loc_container , "max-height" , value , timeout = timeout )
2661
2772
2662
2773
def expect_title (
2663
2774
self ,
2664
2775
text : PatternOrStr ,
2665
2776
* ,
2666
2777
timeout : Timeout = None ,
2667
2778
) -> None :
2779
+ """
2780
+ Expects the value box title to have a specific text.
2781
+
2782
+ Parameters
2783
+ ----------
2784
+ text
2785
+ The expected text pattern or string.
2786
+ timeout
2787
+ The maximum time to wait for the expectation to pass. Defaults to None.
2788
+
2789
+ """
2668
2790
playwright_expect (self .loc_title ).to_have_text (
2669
2791
text ,
2670
2792
timeout = timeout ,
@@ -2676,6 +2798,16 @@ def expect_value(
2676
2798
* ,
2677
2799
timeout : Timeout = None ,
2678
2800
) -> None :
2801
+ """
2802
+ Expects the value box value to have a specific text.
2803
+
2804
+ Parameters
2805
+ ----------
2806
+ text
2807
+ The expected text pattern or string.
2808
+ timeout
2809
+ The maximum time to wait for the expectation to pass. Defaults to None.
2810
+ """
2679
2811
playwright_expect (self .loc ).to_have_text (
2680
2812
text ,
2681
2813
timeout = timeout ,
@@ -2687,15 +2819,38 @@ def expect_body(
2687
2819
* ,
2688
2820
timeout : Timeout = None ,
2689
2821
) -> None :
2690
- """Note: If testing against multiple elements, text should be an array"""
2822
+ """
2823
+ Expects the value box body to have specific text.
2824
+
2825
+ Parameters
2826
+ ----------
2827
+ text
2828
+ The expected text pattern or list of patterns/strings.
2829
+ Note: If testing against multiple elements, text should be an array
2830
+ timeout
2831
+ The maximum time to wait for the expectation to pass. Defaults to None.
2832
+ """
2691
2833
playwright_expect (self .loc_body ).to_have_text (
2692
2834
text ,
2693
2835
timeout = timeout ,
2694
2836
)
2695
2837
2696
- # hard to test since it can be customized by user
2697
- # def expect_showcase_layout(self, layout, *, timeout: Timeout = None) -> None:
2698
- # raise NotImplementedError()
2838
+ def expect_full_screen_available (
2839
+ self , available : bool , * , timeout : Timeout = None
2840
+ ) -> None :
2841
+ """
2842
+ Expects the value box to be available for full screen mode.
2843
+
2844
+ Parameters
2845
+ ----------
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.
2850
+ """
2851
+ playwright_expect (self ._loc_fullscreen ).to_have_count (
2852
+ int (available ), timeout = timeout
2853
+ )
2699
2854
2700
2855
2701
2856
class Card (_WidthLocM , _CardFooterM , _CardBodyM , _CardFullScreenM , _InputWithContainer ):
0 commit comments