-
Notifications
You must be signed in to change notification settings - Fork 109
feat(ui-select,ui-date-time-input): rework DateTimeInput and replace DateInput v1 with DateInput v2 in DateTimeInput #2518
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ToMESSKa
wants to merge
1
commit into
master
Choose a base branch
from
INSTUI-4791-time-date-input-rework-multi-version
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -39,8 +39,11 @@ describe('<DateInput/>', () => { | |
| cy.mount( | ||
| <DateTimeInput | ||
| description="date time description" | ||
| prevMonthLabel="Previous month" | ||
| nextMonthLabel="Next month" | ||
| screenReaderLabels={{ | ||
| calendarIcon: 'Choose date', | ||
| prevMonthButton: 'Previous month', | ||
| nextMonthButton: 'Next month' | ||
| }} | ||
| dateRenderLabel="date-input label" | ||
| timeRenderLabel="time-input label" | ||
| invalidDateTimeMessage="whoops" | ||
|
|
@@ -56,43 +59,40 @@ describe('<DateInput/>', () => { | |
| cy.contains('time-input label') | ||
| cy.contains('Thursday, January 18, 2018 1:30 PM') | ||
|
|
||
| cy.get('input[id^="Selectable_"]').as('dateInput') | ||
| cy.get('input[id^="TextInput_"]').as('dateInput') | ||
| cy.get('input[id^="Select_"]').as('timeInput') | ||
|
|
||
| cy.get('@dateInput').should('have.value', 'January 18, 2018') | ||
| cy.get('@dateInput').should('have.value', '1/18/2018') | ||
| cy.get('@timeInput').should('have.value', '1:30 PM') | ||
|
|
||
| cy.get('@dateInput').clear().blur() | ||
|
|
||
| cy.get('@timeInput').should('have.value', '') | ||
| cy.wrap(onChange).should('have.been.called') | ||
|
|
||
| cy.get('@dateInput').realClick().wait(100) | ||
| cy.contains('button', 'Choose date').realClick().wait(100) | ||
|
|
||
| cy.contains('button', '22').realClick().wait(100) | ||
|
|
||
| cy.contains('button', '22') | ||
| .realClick() | ||
| .wait(100) | ||
| .then(($btn) => { | ||
| const selectedDateId = $btn.attr('id')! | ||
| const selectedDateValue = DateTime.parse( | ||
| selectedDateId, | ||
| cy.wrap(onChange) | ||
| .should('have.been.called') | ||
| .then((spy) => { | ||
| const selectedDateId: string = spy.lastCall.args[1] | ||
| const selectedDateValue = new Date(selectedDateId).toLocaleDateString( | ||
| 'en-US', | ||
| 'US/Eastern' | ||
| ).format('LL') | ||
| { | ||
| timeZone: 'US/Eastern', | ||
| calendar: 'gregory', | ||
| numberingSystem: 'latn' | ||
| } | ||
| ) | ||
|
|
||
| cy.get('@dateInput').should('have.value', selectedDateValue) | ||
| cy.get('@timeInput').should('have.value', '4:16 PM') | ||
|
|
||
| cy.wrap(onChange) | ||
| .should('have.been.called') | ||
| .then((spy) => { | ||
| const lastCallFirstArg = spy.lastCall.args[1] | ||
|
|
||
| const lastCallDatePart = lastCallFirstArg.split('T')[0] | ||
| const expectedDatePart = selectedDateId.split('T')[0] | ||
| const lastCallDatePart = selectedDateId.split('T')[0] | ||
|
|
||
| expect(lastCallDatePart).to.equal(expectedDatePart) | ||
| }) | ||
| expect(lastCallDatePart).to.include('-22') | ||
| }) | ||
| }) | ||
|
|
||
|
|
@@ -103,16 +103,19 @@ describe('<DateInput/>', () => { | |
| <DateTimeInput | ||
| description="date_time" | ||
| dateRenderLabel="date-input" | ||
| prevMonthLabel="Previous month" | ||
| nextMonthLabel="Next month" | ||
| screenReaderLabels={{ | ||
| calendarIcon: 'Open calendar', | ||
| prevMonthButton: 'Previous month', | ||
| nextMonthButton: 'Next month' | ||
| }} | ||
| timeRenderLabel="time-input" | ||
| invalidDateTimeMessage="whoops" | ||
| locale="en-US" | ||
| timezone="US/Eastern" | ||
| onChange={onChange} | ||
| /> | ||
| ) | ||
| cy.get('input[id^="Selectable_"]').as('dateInput') | ||
| cy.get('input[id^="TextInput_"]').as('dateInput') | ||
| cy.get('@dateInput').realClick().wait(100) | ||
| cy.get('@dateInput').type('Not a date{enter}') | ||
| cy.get('@dateInput').blur() | ||
|
|
@@ -128,8 +131,11 @@ describe('<DateInput/>', () => { | |
| cy.mount( | ||
| <DateTimeInput | ||
| description="date_time" | ||
| prevMonthLabel="Previous month" | ||
| nextMonthLabel="Next month" | ||
| screenReaderLabels={{ | ||
| calendarIcon: 'Open calendar', | ||
| prevMonthButton: 'Previous month', | ||
| nextMonthButton: 'Next month' | ||
| }} | ||
| dateRenderLabel="date-input" | ||
| timeRenderLabel="time-input" | ||
| invalidDateTimeMessage="whoops" | ||
|
|
@@ -140,9 +146,9 @@ describe('<DateInput/>', () => { | |
| disabledDateTimeMessage={errorMsg} | ||
| /> | ||
| ) | ||
| cy.get('input[id^="Selectable_"]').as('dateInput') | ||
| cy.get('input[id^="TextInput_"]').as('dateInput') | ||
| cy.get('body').should('contain', errorMsg) | ||
| cy.get('@dateInput').clear().type(`05/18/2017{enter}`) | ||
| cy.get('@dateInput').clear().type(`05/18/2017`).blur() | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DateInput v1 had an Enter key handler. In v2 there's no such handler, so the .blur() is used. |
||
|
|
||
| cy.get('body').should('not.contain', errorMsg) | ||
| }) | ||
|
|
@@ -160,8 +166,11 @@ describe('<DateInput/>', () => { | |
| cy.mount( | ||
| <DateTimeInput | ||
| description="date_time" | ||
| prevMonthLabel="Previous month" | ||
| nextMonthLabel="Next month" | ||
| screenReaderLabels={{ | ||
| calendarIcon: 'Open calendar', | ||
| prevMonthButton: 'Previous month', | ||
| nextMonthButton: 'Next month' | ||
| }} | ||
| dateRenderLabel="date-input" | ||
| timeRenderLabel="time-input" | ||
| invalidDateTimeMessage="whoops" | ||
|
|
@@ -172,9 +181,9 @@ describe('<DateInput/>', () => { | |
| disabledDateTimeMessage={errorMsg} | ||
| /> | ||
| ) | ||
| cy.get('input[id^="Selectable_"]').as('dateInput') | ||
| cy.get('input[id^="TextInput_"]').as('dateInput') | ||
| cy.get('body').should('contain', errorMsgText) | ||
| cy.get('@dateInput').clear().type(`May 18, 2022{enter}`) | ||
| cy.get('@dateInput').clear().type(`May 18, 2022`).blur() | ||
|
|
||
| cy.get('body').should('not.contain', errorMsgText) | ||
| }) | ||
|
|
@@ -187,8 +196,11 @@ describe('<DateInput/>', () => { | |
| const props = { | ||
| description: 'date_time', | ||
| dateRenderLabel: 'date-input', | ||
| prevMonthLabel: 'Previous month', | ||
| nextMonthLabel: 'Next month', | ||
| screenReaderLabels: { | ||
| calendarIcon: 'Open calendar', | ||
| prevMonthButton: 'Previous month', | ||
| nextMonthButton: 'Next month' | ||
| }, | ||
| timeRenderLabel: 'time-input', | ||
| invalidDateTimeMessage: 'whoops', | ||
| locale, | ||
|
|
@@ -197,10 +209,10 @@ describe('<DateInput/>', () => { | |
|
|
||
| cy.mount(<DateTimeInput {...props} value={dateTime.toISOString()} />) | ||
|
|
||
| cy.get('input[id^="Selectable_"]').as('dateInput') | ||
| cy.get('input[id^="TextInput_"]').as('dateInput') | ||
| cy.get('input[id^="Select_"]').as('timeInput') | ||
|
|
||
| cy.get('@dateInput').should('have.value', 'May 1, 2017') | ||
| cy.get('@dateInput').should('have.value', '5/1/2017') | ||
| cy.get('@timeInput').should('have.value', '1:30 PM') | ||
| cy.get('body').should('contain', 'May 1, 2017 1:30 PM') | ||
|
|
||
|
|
@@ -215,11 +227,11 @@ describe('<DateInput/>', () => { | |
| const newDateStr = '2022-03-29T19:00Z' | ||
| cy.mount(<DateTimeInput {...props} value={newDateStr} />) | ||
|
|
||
| cy.get('@dateInput').should('have.value', 'March 29, 2022') | ||
| cy.get('@dateInput').should('have.value', '3/29/2022') | ||
| cy.get('@timeInput').should('have.value', '3:00 PM') | ||
| cy.get('body').should('contain', 'March 29, 2022 3:00 PM') | ||
|
|
||
| cy.get('@dateInput').clear().type('{esc}') | ||
| cy.get('@dateInput').clear().blur() | ||
|
|
||
| cy.get('@dateInput').should('have.value', '') | ||
| cy.get('@timeInput').should('have.value', '') | ||
|
|
@@ -234,8 +246,11 @@ describe('<DateInput/>', () => { | |
| <DateTimeInput | ||
| description="date_time" | ||
| dateRenderLabel="date-input" | ||
| prevMonthLabel="Previous month" | ||
| nextMonthLabel="Next month" | ||
| screenReaderLabels={{ | ||
| calendarIcon: 'Open calendar', | ||
| prevMonthButton: 'Previous month', | ||
| nextMonthButton: 'Next month' | ||
| }} | ||
| timeRenderLabel="time-input" | ||
| invalidDateTimeMessage="whoops" | ||
| locale="en-US" | ||
|
|
@@ -244,12 +259,12 @@ describe('<DateInput/>', () => { | |
| allowNonStepInput={true} | ||
| /> | ||
| ) | ||
| cy.get('input[id^="Selectable_"]').as('dateInput') | ||
| cy.get('input[id^="TextInput_"]').as('dateInput') | ||
| cy.get('input[id^="Select_"]').as('timeInput') | ||
|
|
||
| cy.get('@timeInput').clear().type(`7:34 PM`) | ||
|
|
||
| cy.get('@dateInput').clear().type(`May 1, 2017{enter}`) | ||
| cy.get('@dateInput').clear().type(`May 1, 2017`).blur() | ||
|
|
||
| cy.wrap(onChange) | ||
| .should('have.been.called') | ||
|
|
@@ -268,16 +283,19 @@ describe('<DateInput/>', () => { | |
| <DateTimeInput | ||
| description="date_time" | ||
| dateRenderLabel="date-input" | ||
| prevMonthLabel="Previous month" | ||
| nextMonthLabel="Next month" | ||
| screenReaderLabels={{ | ||
| calendarIcon: 'Open calendar', | ||
| prevMonthButton: 'Previous month', | ||
| nextMonthButton: 'Next month' | ||
| }} | ||
| timeRenderLabel="time-input" | ||
| invalidDateTimeMessage="whoops" | ||
| locale={locale} | ||
| timezone={timezone} | ||
| initialTimeForNewDate="05:05" | ||
| /> | ||
| ) | ||
| cy.get('input[id^="Selectable_"]').as('dateInput') | ||
| cy.get('input[id^="TextInput_"]').as('dateInput') | ||
| cy.get('input[id^="Select_"]').as('timeInput') | ||
|
|
||
| cy.get('@dateInput').clear().type(`May 1, 2017{enter}`) | ||
|
|
||
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In DateInput v2 no id is set on day buttons, so I get the ISO date from the onChange spy.