Browse Source

#273 adding test for opening link in new tab

Rodja Trappe 2 years ago
parent
commit
908899e30c
1 changed files with 17 additions and 0 deletions
  1. 17 0
      tests/test_link.py

+ 17 - 0
tests/test_link.py

@@ -17,3 +17,20 @@ def test_local_target_linking_on_sub_pages(screen: Screen):
     screen.click('goto target')
     screen.should_contain('the target')
     screen.should_not_contain('main page')
+
+
+def test_opening_link_in_new_tab(screen: Screen):
+    @ui.page('/sub')
+    def subpage():
+        ui.label('the sub-page')
+
+    ui.link('open sub-page in new tab', '/sub', new_tab=True)
+
+    screen.open('/')
+    screen.click('open sub-page')
+    screen.switch_to(1)
+    screen.should_contain('the sub-page')
+    screen.should_not_contain('open sub-page')
+    screen.switch_to(0)
+    screen.should_not_contain('the sub-page')
+    screen.should_contain('open sub-page')