Skip to content

Conversation

@FeodorFitsner
Copy link
Contributor

@FeodorFitsner FeodorFitsner commented Aug 19, 2025

Summary by Sourcery

Add layout parsing and improve control expand logic, guard unbounded constraints, and unify Python integration test framework with new screenshot API

New Features:

  • Introduce layout parsing utility (parseExpand/getExpand) and export it in flet.dart
  • Add unbounded height checks with LayoutBuilder and ErrorControl in TabBarView, GridView, ListView, and NavigationRail controls
  • Support expand_screenshot flag in Python FletTestApp for full-page screenshot capture

Bug Fixes:

  • Guard before_update assertion in DataCell and ExpansionTile to check Control instance before asserting visibility

Enhancements:

  • Refactor expand handling in TextFieldControl, CupertinoTextFieldControl, DropdownM2Control, and base_controls using getExpand
  • Standardise Python integration tests by adding pytest_asyncio fixtures, removing redundant theme_mode setups, configuring window size, and using assert_screenshot with take_screenshot
  • Update FletTestApp to auto-set theme_mode and adjust screenshot control instantiation

Build:

  • Add pytest_asyncio >=1.1.0 to Python test dependencies

Tests:

  • Remove and skip failing reference image tests for Image and CircleAvatar
  • Add over 30 new integration tests covering controls like GridView, NavigationDrawer, MenuBar, Chip, VerticalDivider, Tabs, ListView, NavigationRail, various Cupertino pickers, and others

OwenMcDonnell and others added 30 commits August 13, 2025 23:54
also fix bug with using str for DataCell content and formatting
Fixed bug with String title
Introduces a new layout utility for parsing 'expand' properties and refactors controls to use it for consistent expand logic. Adds error handling for unbounded horizontal GridView and ListView, updates related integration tests, and includes new golden images for horizontal views.

Fix #5555
InesaFitsner and others added 13 commits August 18, 2025 09:56
Tabs test doesn't work
Added bounded height check to TabBarViewControl to prevent rendering errors when height is unbounded. Updated integration test to wrap TabBarView in a Container and use expand_screenshot for more reliable screenshot comparison. Modified FletTestApp to support expand_screenshot option. Added new golden image for macOS tabs basic test.
Eliminates redundant assignments of `flet_app.page.theme_mode = ft.ThemeMode.LIGHT` from all integration test files. This streamlines test setup and avoids unnecessary theme configuration, relying on default or externally set theme modes.
Updated the visibility assertion in DataCell.before_update to check if content is an instance of Control before asserting its visibility. This prevents errors when content is not a Control.
Changed the test image source in test_draw_url_image to a new URL and updated the canvas dimensions. The corresponding golden image was also updated to reflect these changes.
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We've reviewed this pull request using the Sourcery rules engine

@ndonkoHenri ndonkoHenri requested a review from Copilot August 19, 2025 20:32
@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Aug 19, 2025

Deploying flet-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 332e1b5
Status: ✅  Deploy successful!
Preview URL: https://d507580f.flet-docs.pages.dev
Branch Preview URL: https://v1-integration-tests-p2.flet-docs.pages.dev

View logs

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces integration tests for various controls and enhances the Flet testing framework with improved screenshot capabilities and layout parsing utilities. It standardizes the Python integration test framework by adding pytest_asyncio fixtures, automatically setting theme mode to light, and providing a unified screenshot API with expand support.

  • Adds layout parsing utilities (parseExpand/getExpand) and exports them in flet.dart for consistent expand property handling
  • Implements unbounded height checks with LayoutBuilder and ErrorControl for TabBarView, GridView, ListView, and NavigationRail controls to prevent layout issues
  • Standardizes Python integration tests by removing redundant theme_mode setups, adding pytest_asyncio fixtures, and using consistent screenshot methodology

Reviewed Changes

Copilot reviewed 84 out of 133 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
sdk/python/packages/flet/src/flet/testing/flet_test_app.py Adds auto theme_mode setting and expand_screenshot parameter to assert_control_screenshot
sdk/python/packages/flet/src/flet/controls/material/expansion_tile.py Guards before_update assertion with Control instance check
sdk/python/packages/flet/src/flet/controls/material/datatable.py Guards before_update assertion with Control instance check
sdk/python/packages/flet/pyproject.toml Adds pytest_asyncio dependency for async test support
packages/flet/lib/src/utils/layout.dart Introduces parseExpand utility and getExpand extension method
packages/flet/lib/src/controls/*.dart Updates expand handling to use new getExpand utility and adds unbounded height checks
sdk/python/packages/flet/integration_tests/controls/test_*.py Over 30 new integration test files with standardized structure

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

height=120,
[
fc.Image(
src="https://raw.githubusercontent.com/flet-dev/media/refs/heads/main/pictures/minion.png",
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard-coding external URLs in tests can lead to flaky tests if the external resource becomes unavailable. Consider using a local test asset or mocking the image loading behavior.

Suggested change
src="https://raw.githubusercontent.com/flet-dev/media/refs/heads/main/pictures/minion.png",
src="52-100x100.png",

Copilot uses AI. Check for mistakes.
# ft.Container(
# content=ft.Text("This is Tab 2"),
# alignment=ft.Alignment.CENTER,
# ),
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented-out code should be removed rather than left in the codebase. If this code is needed for future reference, consider using version control history or adding a TODO comment explaining why it's preserved.

Suggested change
# ),

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,30 @@
# @pytest.mark.asyncio(loop_scope="module")
Copy link

Copilot AI Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This entire file contains only commented-out code. If this test is not needed, the file should be removed. If it's for future implementation, consider adding a clear TODO comment or removing the file until it's ready.

Copilot uses AI. Check for mistakes.
InesaFitsner and others added 4 commits August 19, 2025 13:36
Added detailed docstrings to each attribute of the PopupMenuTheme class to clarify their purpose and usage, improving code documentation and developer understanding.
Corrects the function name typo from 'test_menu_ber_basic' to 'test_menu_bar_basic' in test_menu_bar.py. Removes commented-out code from test_tabs.py for improved readability and maintainability.
@FeodorFitsner FeodorFitsner merged commit c3e9abb into main Aug 19, 2025
4 checks passed
@FeodorFitsner FeodorFitsner deleted the v1-integration-tests-p2 branch August 19, 2025 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants