LayoutControl and Control tests, update Expanding Controls doc#6262
Open
InesaFitsner wants to merge 23 commits intomainfrom
Open
LayoutControl and Control tests, update Expanding Controls doc#6262InesaFitsner wants to merge 23 commits intomainfrom
InesaFitsner wants to merge 23 commits intomainfrom
Conversation
Move alignment and margin integration tests into core layout test file and remove the old type-specific test files. Adds screenshot tests: test_align_inside_stack, test_align_inside_container, test_margin_around, and test_margin_bottom_right in sdk/python/packages/flet/integration_tests/controls/core/test_layout_control.py and deletes sdk/python/packages/flet/integration_tests/controls/types/test_align.py and test_margin.py to centralize layout-related tests.
Add new integration tests and golden images for LayoutControl covering position (right+bottom), position constraint combinations, and aspect_ratio precedence over explicit width/height. Update LayoutControl aspect_ratio docstring to explicitly note that when aspect_ratio is set, width and height on the same control are ignored for the final rendered size. These changes improve test coverage and documentation of sizing behavior.
Add and update macOS golden images for layout_control and introduce numeric-value tests for rotate and scale. New PNGs added (align_inside_container/stack, margin_around, margin_bottom_right, rotate_numeric_value, scale_numeric_value) and several existing goldens updated (flip, matrix4_*, offset, rotate, scale). Also add test_rotate_numeric_value and test_scale_numeric_value in test_layout_control.py to validate numeric rotate/scale rendering.
Increase the scale of the LayoutControl in the integration test from 1.18 to 2.5 and update the macOS golden image to match the new rendering. This adjusts the snapshot to reflect the larger scaled content in the test.
Introduce test_animate_position to animate a Container's position and capture a screenshot, adding the corresponding golden (animate_position.png). Rename aspect_ratio_precedence_over_explicit_size.png to aspect_ratio.png and remove the obsolete aspect_ratio_and_explicit_size_precedence.png. Update test_layout_control.py to include test_animate_position and a separate test_aspect_ratio; includes a TODO noting the test framework needs improvement for capturing multiple animation frames.
Add integration tests for control visibility (test_visible and test_parent_not_visible_child_visible) that assert control screenshots using flet.testing with ThemeMode.LIGHT. Also add corresponding golden images for macOS: parent_not_visible_child_visible.png and visible.png under the controls/core/golden/macos/control directory.
Add front-matter and example images to the expanding-controls cookbook, update example code for clarity, and include image references. Add three new golden PNGs for macOS expand-row scenarios and corresponding integration tests (test_expand_row_remaining_space, test_expand_row_proportions_1_3_1, test_expand_row_equal_split) in test_control.py to validate rendering.
Introduce an integration test (test_expand_loose_row) in test_control.py to validate Row/Container expand_loose behavior. The test renders three rows: a strict expand, a loose expand, and a loose expand with longer text, sets the page theme to LIGHT, and asserts a screenshot. Also add the corresponding golden image expand_loose_row.png used for the visual assertion.
Add four new example scripts demonstrating expanding controls (expand_example_1.py, expand_example_2.py, expand_example_3.py, expand_loose_example_1.py) under sdk/python/examples/apps/expand. Update the expanding-controls.md cookbook to include an examples frontmatter entry and replace large inline code samples with include directives that reference the new example files, keeping existing images and explanatory text.
Fix incorrect attribute names in sdk/python/examples/apps/expand/expand_loose_example_1.py by replacing ft.border with ft.Border and ft.border_radius with ft.BorderRadius to match the Flet API and prevent AttributeError at runtime.
Wrap each example's Row in a bordered Container with fixed width, padding and corner radius. Example 1: replaced top-level Row with a 480px wide Container that holds the text field and Join button. Example 2: replaced simple expand containers with a 500px container containing a spaced Row of colored, fixed-height, rounded child Containers with expand factors (1,3,1). Example 3: added padding and border to the outer container, applied border radius and center alignment to inner cards, and adjusted the green shade from GREEN_100 to GREEN_200. These changes improve visual framing and spacing of the expand examples.
Register expand examples package and make examples import-safe by adding __init__.py and guarding ft.run calls with if __name__ == "__main__". Update cookbook doc image references to point to the new golden examples path. Add three golden screenshots and an integration test (test_expand.py) that asserts screenshots for the three expand examples. These changes enable importing the example modules for automated tests and keep docs in sync with the new image locations.
Refactor expand example to a ft.control Message component using dataclass-style fields and init(), remove direct window sizing, and wrap the chat ListView in a fixed-size Container. Update cookbook to reference the new example image path and add the golden PNG asset. Extend integration tests to include a screenshot test for expand_loose_example_1.
Add an async integration test (test_disabled_propagates_to_children) that renders an enabled and a disabled parent column (each containing Text, TextField, and Button) and asserts a screenshot to verify that the disabled state propagates to child controls. Also add the corresponding macOS golden image disabled_propagates_to_children.png.
Add two integration tests for tooltip behavior: test_tooltip_property (verifies finding a control by its tooltip text) and test_tooltip_hover_screenshot (renders an IconButton with a Tooltip, performs a hover, captures a screenshot and asserts against a golden). Also add the golden screenshot asset sdk/python/packages/flet/integration_tests/controls/core/golden/macos/control/tooltip_hover_screenshot.png.
Add a new async integration test that verifies rendering of a Tooltip with custom properties by taking a screenshot. The test sets theme to LIGHT, enables screenshots, resizes the page, adds an IconButton with a customized Tooltip (colors, padding, text style, offset, decoration, etc.), hovers the button and asserts the resulting screenshot. Also adds the corresponding golden screenshot image for macOS.
Add test_badge to sdk/python/packages/flet/integration_tests/controls/core/test_control.py to verify badge rendering on FilledIconButton (string badge and ft.Badge with custom label, bgcolor, text_color, alignment, and offset) under the LIGHT theme using assert_control_screenshot. Include the corresponding golden image at sdk/python/packages/flet/integration_tests/controls/core/golden/macos/control/badge.png for screenshot comparison.
Introduce test_opacity integration test that renders three Containers with opacity values 1.0, 0.6 and 0.25 (light theme) and asserts a screenshot. Also add the corresponding macOS golden image opacity.png used for visual regression testing.
Add an integration test (test_rtl) to sdk/python/packages/flet/integration_tests/controls/core/test_control.py that verifies Row RTL behavior by comparing rendered output to a new golden image. The test renders two boxed rows (one default, one with rtl=True) and asserts a screenshot; theme_mode is set to LIGHT. Also add the corresponding golden image at golden/macos/control/rtl.png.
Add an integration test (test_col) that verifies ResponsiveRow column sizing and responsiveness using several Container controls with different `col` configurations. The test sets light theme and captures a screenshot for visual regression. Also add the corresponding golden image (golden/macos/control/col.png).
Rename expand example scripts and their golden images to more descriptive names (e.g. expand_example_1 -> expand_textfield_in_row, expand_example_2 -> expand_row_proportional_1_3_1, expand_example_3 -> expand_row_equal_split, expand_loose_example_1 -> expand_loose_chat_messages). Update the cookbook docs to reference the new example filenames and images. Remove obsolete golden screenshots for several expand cases and delete related screenshot-based tests in test_control.py. Update integration test mappings and test function names in test_expand.py to use the renamed example modules and image names.
Extract tooltip-related tests from sdk/.../test_control.py into a new sdk/.../test_tooltip.py and remove the duplicated test implementations from test_control.py. Rename/move golden screenshots into the tooltip golden folder to match the new test location. Also update client/pubspec.lock (dependency lock file updated). This refactors tests for clearer organization and aligns assets with their tests.
Deploying flet-examples with
|
| Latest commit: |
a392e8f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://79cfa3e3.flet-examples.pages.dev |
| Branch Preview URL: | https://layout-control-tests.flet-examples.pages.dev |
Deploying flet-docs with
|
| Latest commit: |
a392e8f
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://27ee2cd2.flet-docs.pages.dev |
| Branch Preview URL: | https://layout-control-tests.flet-docs.pages.dev |
ndonkoHenri
reviewed
Mar 5, 2026
Contributor
There was a problem hiding this comment.
These examples dont seem like belonging to "apps" in my opinion.
Will suggest:
- move these files into
examples/controls/control/expand/folder - remove
expand_prefix on their file names - then move the test functions into
integration_tests/controls/core/test_control.py, similar totest_layout_control.py
ndonkoHenri
reviewed
Mar 5, 2026
|
|
||
|
|
||
| @pytest.mark.asyncio(loop_scope="function") | ||
| async def test_tooltip_property(flet_app_function: ftt.FletTestApp): |
Contributor
There was a problem hiding this comment.
Remove tooltip_ in test functions in this file.
ndonkoHenri
reviewed
Mar 5, 2026
|
|
||
|
|
||
| @pytest.mark.asyncio(loop_scope="function") | ||
| async def test_tooltip_hover_screenshot(flet_app_function: ftt.FletTestApp, request): |
Contributor
There was a problem hiding this comment.
Why have "screenshot" in the function names (here and in the one below)? Remove?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Test Code
# Test code for the review of this PRType of change
Checklist
Screenshots
Additional details
Summary by Sourcery
Add visual integration tests for core control layout, tooltips, and examples, and refresh expanding controls documentation to use new example apps and clarify aspect ratio behavior.
New Features:
Enhancements:
Documentation:
Tests: