@@ -17,61 +17,76 @@ def test_dynamic_navs(page: Page, local_app: ShinyAppProc) -> None:
1717 addfoo = controller .InputActionButton (page , "addFoo" )
1818 addfoo .click ()
1919 controller .NavsetTab (page , "tabs" ).expect_nav_titles (
20- ["Hello" , "Foo" , "Foo-1" , "Static 1 " , "Static 2 " ]
20+ ["Hello" , "Foo" , "Foo-1" , "Static1 " , "Static2 " ]
2121 )
22+ # Test Foo-1 tab is added
23+ navpanel = controller .NavPanel (page , "tabs" , "Foo" ).loc .filter (has_text = "Foo-1" )
24+ expect (navpanel ).to_have_text ("Foo-1" )
2225
2326 # Click hide-tab to hide the Foo tabs
2427 hidetab = controller .InputActionButton (page , "hideTab" )
2528 hidetab .click ()
2629
2730 # Expect the Foo tabs to be hidden
28- expect (
29- page .get_by_role ("presentation" ).filter (has_text = "This is the Foo tab" )
30- ).to_be_hidden ()
31- expect (page .get_by_role ("presentation" ).filter (has_text = "Foo-" )).to_be_hidden ()
31+ navpanel = controller .NavPanel (page , "tabs" , "Foo" ).loc .filter (has_text = "Foo-1" )
32+ expect (navpanel ).to_be_hidden ()
33+ navpanel = controller .NavPanel (page , "tabs" , "Foo" ).loc .filter (
34+ has_text = "This is the Foo tab"
35+ )
36+ expect (navpanel ).to_be_hidden ()
3237
3338 # Click show-tab to show the Foo tabs again
3439 showtab = controller .InputActionButton (page , "showTab" )
3540 showtab .click ()
3641
3742 # Expect the Foo tabs to be visible again
38- expect (
39- page . get_by_role ( "presentation" ). filter ( has_text = "This is the Foo tab" )
40- ). not_to_be_hidden ()
41- expect (page . get_by_role ( "presentation" ). filter ( has_text = "Foo-" )). not_to_be_hidden ( )
43+ navpanel2 = controller . NavPanel ( page , "tabs" , "Foo" ). loc . first
44+ expect ( navpanel2 ). to_be_visible ( timeout = 10000 )
45+ navpanel3 = controller . NavPanel ( page , "tabs" , "Foo" ). loc . last
46+ expect (navpanel3 ). to_be_visible ( timeout = 10000 )
4247
4348 # Click remove-foo to remove the Foo tabs
4449 removefoo = controller .InputActionButton (page , "removeFoo" )
4550 removefoo .click ()
4651 controller .NavsetTab (page , "tabs" ).expect_nav_titles (
47- ["Hello" , "Static 1 " , "Static 2 " ]
52+ ["Hello" , "Static1 " , "Static2 " ]
4853 )
4954
5055 # Click add to add a dynamic tab
5156 add = controller .InputActionButton (page , "add" )
5257 add .click ()
5358 controller .NavsetTab (page , "tabs" ).expect_nav_titles (
54- ["Hello" , "Static 1 " , "Dynamic-1" , "Static 2 " ]
59+ ["Hello" , "Static1 " , "Dynamic-1" , "Static2 " ]
5560 )
5661
5762 # Click add again to add another dynamic tab
5863 add .click ()
5964 controller .NavsetTab (page , "tabs" ).expect_nav_titles (
60- ["Hello" , "Static 1 " , "Dynamic-1" , "Dynamic-2" , "Static 2 " ]
65+ ["Hello" , "Static1 " , "Dynamic-1" , "Dynamic-2" , "Static2 " ]
6166 )
6267
68+ page .get_by_role ("button" , name = "Menu" , exact = True ).click ()
69+
70+ navpanel3 = controller .NavPanel (page , "tabs" , "s1" ).loc
71+ expect (navpanel3 ).to_be_visible (timeout = 20000 )
72+
6373 # Click hide-menu to hide the static menu
6474 hidemenu = controller .InputActionButton (page , "hideMenu" )
6575 hidemenu .click ()
6676
6777 # Expect the Menu to be hidden
68- expect (page .get_by_role ("presentation" ).filter (has_text = "Static" )).to_be_hidden ()
78+ navpanel3 = controller .NavPanel (page , "tabs" , "s1" ).loc
79+ expect (navpanel3 ).to_be_hidden ()
6980
7081 # Click show-menu to show the static menu again
7182 showmenu = controller .InputActionButton (page , "showMenu" )
7283 showmenu .click ()
7384
7485 # Expect the Menu to be visible again
75- expect (
76- page .get_by_role ("presentation" ).filter (has_text = "Static" )
77- ).not_to_be_hidden ()
86+ expect (page .get_by_role ("button" , name = "Menu" , exact = True )).to_be_visible (
87+ timeout = 10000
88+ )
89+ # Click the Menu button to show the static menu
90+ page .get_by_role ("button" , name = "Menu" , exact = True ).click ()
91+ navpanel3 = controller .NavPanel (page , "tabs" , "s1" ).loc
92+ expect (navpanel3 ).to_be_visible (timeout = 20000 )
0 commit comments