Skip to content

Commit 45830ae

Browse files
committed
Add date range picker theme integration test
Introduces a new integration test for the DateRangePicker theme on macOS, including a golden screenshot for visual regression. This ensures custom theme properties are correctly applied and rendered.
1 parent 26a8956 commit 45830ae

2 files changed

Lines changed: 54 additions & 0 deletions

File tree

61.6 KB
Loading
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
import datetime
2+
3+
import pytest
4+
import pytest_asyncio
5+
6+
import flet as ft
7+
import flet.testing as ftt
8+
9+
10+
# Create a new flet_app instance for each test method
11+
@pytest_asyncio.fixture(scope="function", autouse=True)
12+
def flet_app(flet_app_function):
13+
return flet_app_function
14+
15+
16+
@pytest.mark.asyncio(loop_scope="function")
17+
async def test_date_picker_theme(flet_app: ftt.FletTestApp, request):
18+
flet_app.page.theme = ft.Theme(
19+
date_picker_theme=ft.DatePickerTheme(
20+
bgcolor=ft.Colors.GREEN_200,
21+
range_picker_bgcolor=ft.Colors.GREEN_100,
22+
range_picker_elevation=10,
23+
range_picker_header_foreground_color=ft.Colors.GREEN_900,
24+
range_picker_header_headline_text_style=ft.TextStyle(italic=True),
25+
range_picker_shape=ft.BeveledRectangleBorder(
26+
radius=20,
27+
side=ft.BorderSide(5, color=ft.Colors.PURPLE),
28+
),
29+
range_picker_header_help_text_style=ft.TextStyle(color=ft.Colors.GREEN_800),
30+
range_selection_bgcolor=ft.Colors.YELLOW_200,
31+
range_selection_overlay_color=ft.Colors.YELLOW_400,
32+
)
33+
)
34+
35+
dp = ft.DateRangePicker(
36+
current_date=datetime.datetime(year=2025, month=8, day=15),
37+
first_date=datetime.datetime(year=2000, month=10, day=1),
38+
last_date=datetime.datetime(year=2025, month=10, day=1),
39+
start_value=datetime.datetime(year=2000, month=10, day=7),
40+
end_value=datetime.datetime(year=2000, month=10, day=15),
41+
)
42+
flet_app.page.enable_screenshots = True
43+
flet_app.page.window.width = 400
44+
flet_app.page.window.height = 600
45+
flet_app.page.show_dialog(dp)
46+
flet_app.page.update()
47+
await flet_app.tester.pump_and_settle()
48+
49+
flet_app.assert_screenshot(
50+
"theme1",
51+
await flet_app.page.take_screenshot(
52+
pixel_ratio=flet_app.screenshots_pixel_ratio
53+
),
54+
)

0 commit comments

Comments
 (0)