-
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: min/max date behaviour with month buttons (#55)
Co-authored-by: F <[email protected]>
- Loading branch information
1 parent
d47a0ea
commit a8081d0
Showing
7 changed files
with
87 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { expect, test } from '@playwright/test'; | ||
|
||
test('month and years availability with min and max date', async ({ page }) => { | ||
await page.goto('/'); | ||
|
||
const NOW = new Date(); | ||
const Y = NOW.getFullYear(); | ||
const M = NOW.getMonth(); | ||
const currentMonthName = NOW.toLocaleDateString('en-us', { month: 'long' }); | ||
|
||
const nextMonth = new Date(Y, M + 1, 1); | ||
const nextMonthName = nextMonth.toLocaleDateString('en-us', { | ||
month: 'long', | ||
}); | ||
|
||
// Previous year should be enabled since we are defining minDate as new Date(Y - 1, 0, 1) | ||
await expect(page.getByRole('button', { name: `${Y - 1}` })).toBeEnabled(); | ||
|
||
// Next year is disabled since we are defining maxDate as new Date() | ||
await expect(page.getByRole('button', { name: `${Y + 1}` })).toBeDisabled(); | ||
|
||
// Current month should be enabled | ||
await expect( | ||
page.getByRole('button', { name: currentMonthName }), | ||
).toBeEnabled(); | ||
|
||
// Next month should be disabled since we are defining maxDate as new Date() | ||
await expect( | ||
page.getByRole('button', { name: nextMonthName }), | ||
).toBeDisabled(); | ||
|
||
await page.getByRole('button', { name: `${Y - 1}` }).click(); | ||
await expect(page.getByRole('button', { name: /january/i })).toBeEnabled(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters