|
7 | 7 | home_store, |
8 | 8 | initial_route, |
9 | 9 | pop_view_confirm, |
| 10 | + pop_views_until, |
10 | 11 | route_change_event, |
11 | 12 | ) |
12 | 13 |
|
@@ -185,3 +186,59 @@ async def test_drawer_navigation(flet_app_function: ftt.FletTestApp): |
185 | 186 | # Verify home view |
186 | 187 | home_text = await flet_app_function.tester.find_by_text("Welcome to Home Page") |
187 | 188 | assert home_text.count == 1 |
| 189 | + |
| 190 | + |
| 191 | +@pytest.mark.parametrize( |
| 192 | + "flet_app_function", |
| 193 | + [{"flet_app_main": pop_views_until.main}], |
| 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("Result: Flow completed!") |
| 240 | + assert result_text.count == 1 |
| 241 | + |
| 242 | + # Verify we can start the flow again |
| 243 | + button = await flet_app_function.tester.find_by_text_containing("Start flow") |
| 244 | + assert button.count == 1 |
0 commit comments