Bläddra i källkod

add test for shared and individual pages

Rodja Trappe 2 år sedan
förälder
incheckning
66fb9811e9
1 ändrade filer med 29 tillägg och 5 borttagningar
  1. 29 5
      tests/test_pages.py

+ 29 - 5
tests/test_pages.py

@@ -1,9 +1,11 @@
+from uuid import uuid4
+
 from nicegui import ui
 
 from .user import User
 
 
-async def test_title(user: User):
+def test_title(user: User):
     @ui.page('/', title='My Custom Title')
     def page():
         ui.label('some content')
@@ -12,7 +14,7 @@ async def test_title(user: User):
     user.should_see('My Custom Title')
 
 
-async def test_route_with_custom_path(user: User):
+def test_route_with_custom_path(user: User):
     @ui.page('/test_route')
     def page():
         ui.label('page with custom path')
@@ -21,7 +23,7 @@ async def test_route_with_custom_path(user: User):
     user.should_see('page with custom path')
 
 
-async def test_auto_index_page_with_link_to_subpage(user: User):
+def test_auto_index_page_with_link_to_subpage(user: User):
     ui.link('link to subpage', '/subpage')
 
     @ui.page('/subpage')
@@ -33,7 +35,7 @@ async def test_auto_index_page_with_link_to_subpage(user: User):
     user.should_see('the subpage')
 
 
-async def test_link_to_page_by_passing_function(user: User):
+def test_link_to_page_by_passing_function(user: User):
     @ui.page('/subpage')
     def page():
         ui.label('the subpage')
@@ -45,7 +47,7 @@ async def test_link_to_page_by_passing_function(user: User):
     user.should_see('the subpage')
 
 
-async def test_creating_new_page_after_startup(user: User):
+def test_creating_new_page_after_startup(user: User):
     user.start_server()
 
     @ui.page('/late_page')
@@ -54,3 +56,25 @@ async def test_creating_new_page_after_startup(user: User):
 
     user.open('/late_page')
     user.should_see('page created after startup')
+
+def test_shared_and_individual_pages(user: User):
+
+    @ui.page('/individual_page')
+    def individual_page():
+        ui.label(f'your individual page with uuid {uuid4()}')
+
+    @ui.page('/shared_page', shared=True)
+    def shared_page():
+        ui.label(f'a shared page with uuid {uuid4()}')
+
+    user.open('/shared_page')
+    uuid1 = user.find('a shared page').text.split(' ')[-1]
+    user.open('/shared_page')
+    uuid2 = user.find('a shared page').text.split(' ')[-1]
+    assert uuid1 == uuid2
+
+    user.open('/individual_page')
+    uuid1 = user.find('your individual page').text.split(' ')[-1]
+    user.open('/individual_page')
+    uuid2 = user.find('your individual page').text.split(' ')[-1]
+    assert uuid1 != uuid2