1
1
import { expect } from '@playwright/test' ;
2
+ import type { E2EPage } from '@utils/test/playwright' ;
2
3
import { test } from '@utils/test/playwright' ;
3
4
4
5
test . describe ( 'datetime: minmax' , ( ) => {
@@ -47,6 +48,7 @@ test.describe('datetime: minmax', () => {
47
48
expect ( nextButton ) . toBeDisabled ( ) ;
48
49
expect ( prevButton ) . toBeEnabled ( ) ;
49
50
} ) ;
51
+
50
52
test ( 'datetime: minmax months disabled' , async ( { page } ) => {
51
53
await page . goto ( '/src/components/datetime/test/minmax' ) ;
52
54
const calendarMonths = page . locator ( 'ion-datetime#inside .calendar-month' ) ;
@@ -67,6 +69,7 @@ test.describe('datetime: minmax', () => {
67
69
expect ( navButtons . nth ( 0 ) ) . toHaveAttribute ( 'disabled' , '' ) ;
68
70
expect ( navButtons . nth ( 1 ) ) . toHaveAttribute ( 'disabled' , '' ) ;
69
71
} ) ;
72
+
70
73
test ( 'datetime: min including day should not disable month' , async ( { page } ) => {
71
74
await page . goto ( '/src/components/datetime/test/minmax' ) ;
72
75
await page . waitForSelector ( '.datetime-ready' ) ;
@@ -77,6 +80,7 @@ test.describe('datetime: minmax', () => {
77
80
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 / ) ;
78
81
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 / ) ;
79
82
} ) ;
83
+
80
84
test . describe ( 'when the datetime does not have a value' , ( ) => {
81
85
test ( 'all time values should be available for selection' , async ( { page } ) => {
82
86
/**
@@ -105,4 +109,29 @@ test.describe('datetime: minmax', () => {
105
109
expect ( await minutes . count ( ) ) . toBe ( 60 ) ;
106
110
} ) ;
107
111
} ) ;
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
+ } ) ;
108
137
} ) ;
0 commit comments