Skip to content

Commit 624573d

Browse files
committed
test(datetime): update naming, screenshot config, remove unnecessary tests
1 parent b857c1d commit 624573d

File tree

2 files changed

+53
-84
lines changed

2 files changed

+53
-84
lines changed
Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,51 @@
11
import { expect } from '@playwright/test';
22
import { configs, test } from '@utils/test/playwright';
33

4-
configs().forEach(({ title, screenshot, config }) => {
5-
test.describe(title('datetime: ShowDaysOutsideCustomMonth'), () => {
6-
test('with custom-grid should not have any visual regressions', async ({ page }) => {
4+
/**
5+
* This behavior does not vary across directions
6+
*/
7+
configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
8+
test.describe(title('datetime: show adjacent days'), () => {
9+
test('should not have visual regressions', async ({ page }) => {
710
await page.goto('/src/components/datetime/test/show-adjacent-days', config);
8-
const customGrid = page.locator('#custom-grid');
9-
await expect(customGrid).toHaveScreenshot(screenshot(`customGrid-with-adjacent-days`));
11+
const datetime = page.locator('#default');
12+
await expect(datetime).toHaveScreenshot(screenshot(`datetime-show-adjacent-days`));
1013
});
1114

12-
test('should set the first day of the week correctly', async ({ page }) => {
15+
test('should not have visual regressions with a custom styled calendar', async ({ page }) => {
1316
await page.goto('/src/components/datetime/test/show-adjacent-days', config);
14-
const customDatetime = page.locator('#custom-calendar-days');
15-
await expect(customDatetime).toHaveScreenshot(screenshot(`custom-calendar-with-adjacent-days`));
17+
const datetime = page.locator('#custom-calendar-days');
18+
await expect(datetime).toHaveScreenshot(screenshot(`datetime-show-adjacent-days-custom-calendar`));
1619
});
1720

18-
test('with specific date disabled should not have any visual regressions', async ({ page }) => {
21+
test('should not have visual regressions with specific date disabled', async ({ page }) => {
1922
await page.goto('/src/components/datetime/test/show-adjacent-days', config);
20-
const specificDateDisabled = page.locator('#specificDate');
21-
await expect(specificDateDisabled).toHaveScreenshot(screenshot(`specificDate-with-adjacent-days`));
23+
const datetime = page.locator('#specificDate');
24+
await expect(datetime).toHaveScreenshot(screenshot(`datetime-show-adjacent-days-specific-date-disabled`));
2225
});
2326

24-
test('with weekends disabled should not have any visual regressions', async ({ page }) => {
27+
test('should not have visual regressions with weekends disabled', async ({ page }) => {
2528
await page.goto('/src/components/datetime/test/show-adjacent-days', config);
26-
const weekendsDisabled = page.locator('#weekends');
27-
await expect(weekendsDisabled).toHaveScreenshot(screenshot(`weekendsDisabled-with-adjacent-days`));
29+
const datetime = page.locator('#weekends');
30+
await expect(datetime).toHaveScreenshot(screenshot(`datetime-show-adjacent-days-weekends-disabled`));
2831
});
2932

30-
test('with date range disabled should not have any visual regressions', async ({ page }) => {
33+
test('should not have visual regressions with date range disabled', async ({ page }) => {
3134
await page.goto('/src/components/datetime/test/show-adjacent-days', config);
32-
const dateRangeDisabled = page.locator('#dateRange');
33-
await expect(dateRangeDisabled).toHaveScreenshot(screenshot(`dateRangeDisabled-with-adjacent-days`));
35+
const datetime = page.locator('#dateRange');
36+
await expect(datetime).toHaveScreenshot(screenshot(`datetime-show-adjacent-days-date-range-disabled`));
3437
});
3538

36-
test('with month disabled should not have any visual regressions', async ({ page }) => {
39+
test('should not have visual regressions with month disabled', async ({ page }) => {
3740
await page.goto('/src/components/datetime/test/show-adjacent-days', config);
38-
const monthDisabled = page.locator('#month');
39-
await expect(monthDisabled).toHaveScreenshot(screenshot(`monthDisabled-with-adjacent-days`));
41+
const datetime = page.locator('#month');
42+
await expect(datetime).toHaveScreenshot(screenshot(`datetime-show-adjacent-days-month-disabled`));
4043
});
4144

42-
test('with specific display should not have any visual regressions', async ({ page }) => {
45+
test('should not have visual regressions with display specified', async ({ page }) => {
4346
await page.goto('/src/components/datetime/test/show-adjacent-days', config);
44-
const display = page.locator('#display');
45-
await expect(display).toHaveScreenshot(screenshot(`display-with-adjacent-days`));
47+
const datetime = page.locator('#display');
48+
await expect(datetime).toHaveScreenshot(screenshot(`datetime-show-adjacent-days-display`));
4649
});
4750
});
4851
});

core/src/components/datetime/test/show-adjacent-days/index.html

Lines changed: 27 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="en" dir="ltr">
33
<head>
44
<meta charset="UTF-8" />
5-
<title>Datetime - Custom</title>
5+
<title>Datetime - Show Adjacent Days</title>
66
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0" />
77
<link href="../../../../../css/ionic.bundle.css" rel="stylesheet" />
88
<link href="../../../../../scripts/testing/styles.css" rel="stylesheet" />
@@ -33,47 +33,6 @@
3333
}
3434
}
3535

36-
/*
37-
* Custom Datetime Time / Wheel Parts
38-
* -------------------------------------------
39-
*/
40-
41-
.custom-grid-wheel {
42-
--background: rgb(245, 235, 247);
43-
--background-rgb: 245, 235, 247;
44-
}
45-
46-
.custom-grid-wheel::part(time-button) {
47-
color: rgb(128, 30, 171);
48-
}
49-
50-
.custom-grid-wheel::part(time-button active) {
51-
background-color: rgb(248, 215, 255);
52-
}
53-
54-
.custom-grid-wheel {
55-
--wheel-highlight-background: rgb(218, 216, 255);
56-
--wheel-highlight-border-radius: 16px;
57-
--wheel-fade-background-rgb: 245, 235, 247;
58-
}
59-
60-
ion-picker {
61-
--highlight-background: rgb(218, 216, 255);
62-
--highlight-border-radius: 16px;
63-
--fade-background-rgb: 245, 235, 247;
64-
65-
background-color: rgb(245, 235, 247);
66-
}
67-
.custom-grid-wheel::part(wheel-item),
68-
ion-picker-column-option {
69-
color: rgb(255, 134, 154);
70-
}
71-
72-
.custom-grid-wheel::part(wheel-item active),
73-
ion-picker-column-option.option-active {
74-
color: rgb(128, 30, 171);
75-
}
76-
7736
/*
7837
* Custom Datetime Day Parts
7938
* -------------------------------------------
@@ -142,46 +101,61 @@
142101
<ion-app>
143102
<ion-header translucent="true">
144103
<ion-toolbar>
145-
<ion-title>Datetime - ShowDaysOutsideCustomMonth</ion-title>
104+
<ion-title>Datetime - Show Adjacent Days</ion-title>
146105
</ion-toolbar>
147106
</ion-header>
148107
<ion-content class="ion-padding">
149108
<div class="grid">
150109
<div class="grid-item">
151-
<h2>Grid Style</h2>
152-
<ion-datetime id="custom-grid" value="2020-03-14T14:23:00.000Z" class="custom-grid-wheel"></ion-datetime>
110+
<h2>Inline Grid</h2>
111+
<ion-datetime show-adjacent-days="true" value="2020-03-14T14:23:00.000Z"></ion-datetime>
153112
</div>
154113

155114
<div class="grid-item">
156-
<h2>Grid Style</h2>
157-
<ion-datetime id="custom-calendar-days" value="2023-06-15" presentation="date"></ion-datetime>
115+
<h2>Inline Grid: Custom Styles</h2>
116+
<ion-datetime
117+
show-adjacent-days="true"
118+
id="custom-calendar-days"
119+
value="2023-06-15"
120+
presentation="date"
121+
></ion-datetime>
158122
</div>
159123
</div>
160124

161125
<div class="grid">
162126
<div class="grid-item">
163127
<h2>Disable Specific Date</h2>
164-
<ion-datetime id="specificDate" value="2021-10-01" showAdjacentDays="true"></ion-datetime>
128+
<ion-datetime
129+
show-adjacent-days="true"
130+
id="specificDate"
131+
value="2021-10-01"
132+
showAdjacentDays="true"
133+
></ion-datetime>
165134
</div>
166135

167136
<div class="grid-item">
168137
<h2>Disable Weekends</h2>
169-
<ion-datetime id="weekends" value="2021-10-01"></ion-datetime>
138+
<ion-datetime show-adjacent-days="true" id="weekends" value="2021-10-01"></ion-datetime>
170139
</div>
171140

172141
<div class="grid-item">
173142
<h2>Disable Date Range</h2>
174-
<ion-datetime id="dateRange" value="2021-10-01"></ion-datetime>
143+
<ion-datetime show-adjacent-days="true" id="dateRange" value="2021-10-01"></ion-datetime>
175144
</div>
176145

177146
<div class="grid-item">
178147
<h2>Disable Month</h2>
179-
<ion-datetime id="month" value="2021-10-01"></ion-datetime>
148+
<ion-datetime show-adjacent-days="true" id="month" value="2021-10-01"></ion-datetime>
180149
</div>
181150

182151
<div class="grid-item">
183152
<h2>Change firstDayOfWeek</h2>
184-
<ion-datetime id="firstDayOfWeek" first-day-of-week="1" value="2022-05-03"></ion-datetime>
153+
<ion-datetime
154+
show-adjacent-days="true"
155+
id="firstDayOfWeek"
156+
first-day-of-week="1"
157+
value="2022-05-03"
158+
></ion-datetime>
185159
<button onclick="increase()">Increase firstDayOfWeek</button>
186160
<div>
187161
<span>FirstDayOfWeek: <span id="start-of-week">1</span></span>
@@ -202,7 +176,7 @@ <h2>Change firstDayOfWeek</h2>
202176
<option value="cover">cover</option>
203177
</select>
204178
<br /><br />
205-
<ion-datetime id="display" value="2022-02-22T16:30:00"></ion-datetime>
179+
<ion-datetime show-adjacent-days="true" id="display" value="2022-02-22T16:30:00"></ion-datetime>
206180
</div>
207181
</ion-content>
208182
</ion-app>
@@ -248,8 +222,6 @@ <h2>Change firstDayOfWeek</h2>
248222

249223
return true;
250224
};
251-
customGrid.showAdjacentDays = true;
252-
customDatetime.showAdjacentDays = true;
253225

254226
const specificDateDisabled = document.querySelector('#specificDate');
255227
specificDateDisabled.isDateEnabled = (dateIsoString) => {
@@ -260,7 +232,6 @@ <h2>Change firstDayOfWeek</h2>
260232
}
261233
return true;
262234
};
263-
specificDateDisabled.showAdjacentDays = true;
264235

265236
const weekendsDisabled = document.querySelector('#weekends');
266237
weekendsDisabled.isDateEnabled = (dateIsoString) => {
@@ -271,7 +242,6 @@ <h2>Change firstDayOfWeek</h2>
271242
}
272243
return true;
273244
};
274-
weekendsDisabled.showAdjacentDays = true;
275245

276246
const dateRangeDisabled = document.querySelector('#dateRange');
277247
dateRangeDisabled.isDateEnabled = (dateIsoString) => {
@@ -284,7 +254,6 @@ <h2>Change firstDayOfWeek</h2>
284254
}
285255
return true;
286256
};
287-
dateRangeDisabled.showAdjacentDays = true;
288257

289258
const monthDisabled = document.querySelector('#month');
290259
monthDisabled.isDateEnabled = (dateIsoString) => {
@@ -295,10 +264,8 @@ <h2>Change firstDayOfWeek</h2>
295264
}
296265
return true;
297266
};
298-
monthDisabled.showAdjacentDays = true;
299267

300268
const firstDayOfWeek = document.querySelector('#firstDayOfWeek');
301-
firstDayOfWeek.showAdjacentDays = true;
302269
function increase() {
303270
firstDayOfWeek.firstDayOfWeek = firstDayOfWeek.firstDayOfWeek + 1;
304271

@@ -307,7 +274,6 @@ <h2>Change firstDayOfWeek</h2>
307274
}
308275

309276
const display = document.querySelector('#display');
310-
display.showAdjacentDays = true;
311277

312278
const mutationObserver = new MutationObserver(() => {
313279
window.dispatchEvent(new CustomEvent('ionWorkingPartsDidChange'));

0 commit comments

Comments
 (0)