66from examples .apps .routing_navigation .home_store import main as home_store
77from examples .apps .routing_navigation .initial_route import main as initial_route
88from examples .apps .routing_navigation .pop_view_confirm import main as pop_view_confirm
9+ from examples .apps .routing_navigation .pop_views_until import main as pop_views_until
910from examples .apps .routing_navigation .route_change_event import (
1011 main as route_change_event ,
1112)
1213
1314
1415@pytest .mark .parametrize (
1516 "flet_app_function" ,
16- [{"flet_app_main" : initial_route . main }],
17+ [{"flet_app_main" : initial_route }],
1718 indirect = True ,
1819)
1920@pytest .mark .asyncio (loop_scope = "function" )
@@ -24,7 +25,7 @@ async def test_initial_route(flet_app_function: ftt.FletTestApp):
2425
2526@pytest .mark .parametrize (
2627 "flet_app_function" ,
27- [{"flet_app_main" : route_change_event . main }],
28+ [{"flet_app_main" : route_change_event }],
2829 indirect = True ,
2930)
3031@pytest .mark .asyncio (loop_scope = "function" )
@@ -39,7 +40,7 @@ async def test_route_change_event(flet_app_function: ftt.FletTestApp):
3940
4041@pytest .mark .parametrize (
4142 "flet_app_function" ,
42- [{"flet_app_main" : home_store . main }],
43+ [{"flet_app_main" : home_store }],
4344 indirect = True ,
4445)
4546@pytest .mark .asyncio (loop_scope = "function" )
@@ -75,7 +76,7 @@ async def test_home_store(flet_app_function: ftt.FletTestApp):
7576
7677@pytest .mark .parametrize (
7778 "flet_app_function" ,
78- [{"flet_app_main" : pop_view_confirm . main }],
79+ [{"flet_app_main" : pop_view_confirm }],
7980 indirect = True ,
8081)
8182@pytest .mark .asyncio (loop_scope = "function" )
@@ -133,7 +134,7 @@ async def test_pop_view_confirm(flet_app_function: ftt.FletTestApp):
133134
134135@pytest .mark .parametrize (
135136 "flet_app_function" ,
136- [{"flet_app_main" : drawer_navigation . main }],
137+ [{"flet_app_main" : drawer_navigation }],
137138 indirect = True ,
138139)
139140@pytest .mark .asyncio (loop_scope = "function" )
@@ -185,3 +186,61 @@ async def test_drawer_navigation(flet_app_function: ftt.FletTestApp):
185186 # Verify home view
186187 home_text = await flet_app_function .tester .find_by_text ("Welcome to Home Page" )
187188 assert home_text .count == 1
189+
190+
191+ @pytest .mark .parametrize (
192+ "flet_app_function" ,
193+ [{"flet_app_main" : pop_views_until }],
194+ indirect = True ,
195+ )
196+ @pytest .mark .asyncio (loop_scope = "function" )
197+ async def test_pop_views_until (flet_app_function : ftt .FletTestApp ):
198+ # Verify initial view
199+ button = await flet_app_function .tester .find_by_text_containing ("Start flow" )
200+ assert button .count == 1
201+ result_text = await flet_app_function .tester .find_by_text ("No result yet" )
202+ assert result_text .count == 1
203+
204+ # Navigate to Step 1
205+ await flet_app_function .tester .tap (button )
206+ await flet_app_function .tester .pump_and_settle ()
207+ step1_text = await flet_app_function .tester .find_by_text ("Step 1 of the flow" )
208+ assert step1_text .count == 1
209+
210+ # Navigate to Step 2
211+ step2_button = await flet_app_function .tester .find_by_text_containing (
212+ "Go to Step 2"
213+ )
214+ assert step2_button .count == 1
215+ await flet_app_function .tester .tap (step2_button )
216+ await flet_app_function .tester .pump_and_settle ()
217+ step2_text = await flet_app_function .tester .find_by_text ("Step 2 of the flow" )
218+ assert step2_text .count == 1
219+
220+ # Navigate to Step 3
221+ step3_button = await flet_app_function .tester .find_by_text_containing (
222+ "Go to Step 3"
223+ )
224+ assert step3_button .count == 1
225+ await flet_app_function .tester .tap (step3_button )
226+ await flet_app_function .tester .pump_and_settle ()
227+ final_text = await flet_app_function .tester .find_by_text ("Flow complete!" )
228+ assert final_text .count == 1
229+
230+ # Click "Finish and go Home" — triggers pop_views_until
231+ finish_button = await flet_app_function .tester .find_by_text_containing (
232+ "Finish and go Home"
233+ )
234+ assert finish_button .count == 1
235+ await flet_app_function .tester .tap (finish_button )
236+ await flet_app_function .tester .pump_and_settle ()
237+
238+ # Verify back at Home with result
239+ result_text = await flet_app_function .tester .find_by_text (
240+ "Result: Flow completed!"
241+ )
242+ assert result_text .count == 1
243+
244+ # Verify we can start the flow again
245+ button = await flet_app_function .tester .find_by_text_containing ("Start flow" )
246+ assert button .count == 1
0 commit comments