11import { expect } from '@playwright/test' ;
2+ import type { E2EPage } from '@utils/test/playwright' ;
23import { test } from '@utils/test/playwright' ;
34
45test . describe ( 'datetime: minmax' , ( ) => {
@@ -47,6 +48,7 @@ test.describe('datetime: minmax', () => {
4748 expect ( nextButton ) . toBeDisabled ( ) ;
4849 expect ( prevButton ) . toBeEnabled ( ) ;
4950 } ) ;
51+
5052 test ( 'datetime: minmax months disabled' , async ( { page } ) => {
5153 await page . goto ( '/src/components/datetime/test/minmax' ) ;
5254 const calendarMonths = page . locator ( 'ion-datetime#inside .calendar-month' ) ;
@@ -67,6 +69,7 @@ test.describe('datetime: minmax', () => {
6769 expect ( navButtons . nth ( 0 ) ) . toHaveAttribute ( 'disabled' , '' ) ;
6870 expect ( navButtons . nth ( 1 ) ) . toHaveAttribute ( 'disabled' , '' ) ;
6971 } ) ;
72+
7073 test ( 'datetime: min including day should not disable month' , async ( { page } ) => {
7174 await page . goto ( '/src/components/datetime/test/minmax' ) ;
7275 await page . waitForSelector ( '.datetime-ready' ) ;
@@ -77,6 +80,7 @@ test.describe('datetime: minmax', () => {
7780 expect ( calendarMonths . nth ( 1 ) ) . not . toHaveClass ( / c a l e n d a r - m o n t h - d i s a b l e d / ) ;
7881 expect ( calendarMonths . nth ( 2 ) ) . not . toHaveClass ( / c a l e n d a r - m o n t h - d i s a b l e d / ) ;
7982 } ) ;
83+
8084 test . describe ( 'when the datetime does not have a value' , ( ) => {
8185 test ( 'all time values should be available for selection' , async ( { page } ) => {
8286 /**
@@ -105,4 +109,29 @@ test.describe('datetime: minmax', () => {
105109 expect ( await minutes . count ( ) ) . toBe ( 60 ) ;
106110 } ) ;
107111 } ) ;
112+
113+ test . describe ( 'setting value outside bounds should show in-bounds month' , ( ) => {
114+ const testDisplayedMonth = async ( page : E2EPage , content : string ) => {
115+ await page . setContent ( content ) ;
116+ await page . waitForSelector ( '.datetime-ready' ) ;
117+
118+ const calendarMonthYear = page . locator ( 'ion-datetime .calendar-month-year' ) ;
119+ expect ( calendarMonthYear ) . toHaveText ( 'June 2021' ) ;
120+ } ;
121+
122+ test ( 'when min is defined' , async ( { page } ) => {
123+ await testDisplayedMonth ( page , `<ion-datetime min="2021-06-01" value="2021-05-01"></ion-datetime>` ) ;
124+ } ) ;
125+
126+ test ( 'when max is defined' , async ( { page } ) => {
127+ await testDisplayedMonth ( page , `<ion-datetime max="2021-06-30" value="2021-07-01"></ion-datetime>` ) ;
128+ } ) ;
129+
130+ test ( 'when both min and max are defined' , async ( { page } ) => {
131+ await testDisplayedMonth (
132+ page ,
133+ `<ion-datetime min="2021-06-01" max="2021-06-30" value="2021-05-01"></ion-datetime>`
134+ ) ;
135+ } ) ;
136+ } ) ;
108137} ) ;
0 commit comments