-
Notifications
You must be signed in to change notification settings - Fork 832
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
Add seconds to DateTimePicker view #1961
Add seconds to DateTimePicker view #1961
Conversation
JamesMHenderson
commented
Jul 6, 2020
- Add seconds as an available view in DateTimePickerView
- Use DateTimePickerView type as the type for views and openTo
- Change typography variant depending on whether seconds are being displayed or not
- set number of grid elements depending on seconds view
- [ x ] I have followed (at least) the PR section of the contributing guide.
Test summaryRun details
View run in Cypress Dashboard ➡️ This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard |
bc37e4c
to
17a4e46
Compare
17a4e46
to
a53a800
Compare
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.
This PR missing a test case.
a53a800
to
8bd6e61
Compare
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.
Please fix all CI errors
@dmtrKovalenko the CI was failing from the branch, I branched off 32a3a18. How would I go about fixing the CI errors as they were not introduced by these changes? |
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.
Please rebase on the next
branch
justify="center" | ||
alignItems="flex-end" | ||
direction={rtl ? 'row-reverse' : 'row'} | ||
> | ||
<ToolbarButton | ||
variant="h3" | ||
variant={timeTypographyText} |
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.
This could be an opportunity to fix the <hx>
DOM output
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.
What do you mean by this?
|
||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
component = mount( |
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.
Please prefer testing-library for this
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.
I've based my test on existing tests which are using enzyme, is it prefered that the tests use testing-library over being consistent with the existing tests?
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.
@JamesMHenderson the objective is to, step by step, be all in on testing-library. It requires all new tests to use it. This holds for all our codebase (core, pickers, etc). For instance, on the pickers side #1933.
leftArrowIcon="keyboard_arrow_left" | ||
rightArrowIcon="keyboard_arrow_right" | ||
dateRangeIcon="date_range" | ||
timeIcon="access_time" |
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.
This is not required and shouldn't work in the first place
leftArrowIcon="keyboard_arrow_left" | |
rightArrowIcon="keyboard_arrow_right" | |
dateRangeIcon="date_range" | |
timeIcon="access_time" |
8bd6e61
to
ccbd2fb
Compare
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/mui-org/material-ui-pickers/hgkprmjpe |
ccbd2fb
to
68d0c54
Compare
- Add seconds as an available view in DateTimePickerView - Use DateTimePickerView type as the type for views and openTo - Change typography variant depending on whether seconds are being displayed or not - set number of grid elements depending on seconds view
68d0c54
to
fcde662
Compare
); | ||
|
||
await waitFor(() => screen.getByRole('dialog')); | ||
expect(getByMuiTest('seconds').firstChild?.textContent).toBe('05'); |
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.
expect(getByMuiTest('seconds').firstChild?.textContent).toBe('05'); | |
expect(getByMuiTest('seconds')).to.have.text('05'); |
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.
I don't think this is valid
I get a type error with this change. Property 'to' does not exist on type 'JestMatchersShape , Matchers , string | null>>'.
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.
Oh right, It's probably because we miss
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.
Ok, forget about it, we will have it resolved by merging the repository in the main one.
fireEvent.click(getByMuiTest('seconds')); | ||
|
||
expect(getByText(getByMuiTest('seconds'), '05')).toHaveClass( | ||
'MuiPickersToolbarText-toolbarBtnSelected' |
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.
Oh nice, I'm adding this case to #1845.
className={classes.separator} | ||
/> | ||
|
||
<ToolbarButton |
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.
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.
I agree with you, but I'm not sure what the best approach would be for this. Would it be best to pick this sort of change up seperately from this pull request as it would be a significant refactor?
onClick={() => setOpenView('seconds')} | ||
selected={openView === 'seconds'} | ||
value={date ? utils.format(date, 'seconds') : '--'} | ||
typographyClassName={classes.timeTypography} |
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.
typographyClassName={classes.timeTypography} | |
className={classes.timeTypography} |
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.
The Toolbar button has a prop typography class which is passed in to add the class to the typography component in the ToolbarButton, rather than adding the class to the Button directly.
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.
Yeah, there is an opportunity here to flatten the DOM structure '
<ToolbarButton | ||
tabIndex={-1} | ||
variant={timeTypographyText} | ||
data-mui-test="seconds" |
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.
Considering we want to move to data-testid
in the whole codebase, I suggest we start here
data-mui-test="seconds" | |
data-testid="seconds" |
cc @mui-org/core-team.
Hi fella any progress on this pull request? Anything i might be able to help with? Id love to implement this change into the app im working on, so if i can be of any help id be able to give some time! |
@eglavin We are moving the date picker components into the lab. We will archive this repository once done. Any effort will need to be rebased from the main repository. |
@JamesMHenderson Thanks for working on this problem. I'm closing as we have moved the component to https://github.com/mui-org/material-ui. |