-
Notifications
You must be signed in to change notification settings - Fork 0
DRAFT DateTimePicker Interactors #7
base: v4
Are you sure you want to change the base?
Conversation
|
Heavy lift here 💪🏻 💪🏻 keep it up! |
src/calendar.ts
Outdated
| return new Promise<number | undefined>((resolve) => | ||
| interactor.perform((element) => { | ||
| const yearString = getYear(element); | ||
| const year = yearString ? parseInt(yearString) : NaN; | ||
| resolve(Number.isNaN(year) ? undefined : year); | ||
| }) | ||
| ); |
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.
perform should really allow you to return a value out of it, I added an issue for this on bigtest: thefrontside/bigtest#914
|
@wKich As I was talking this over with @jnicklas it occured to me that while we can make heroic hacks to make this work in a locale-indepent way, the fact of the matter is that locale (and specifically date, time and month formatting) are a key abstraction to the component. If we think of it that way, then there really is no one true "DatePicker" component, but instead an abstraction Perhaps the simplest thing that could possibly work would be to introduce this same abstraction of the We could do this in practice by providing not a import { createDatePickerInteractor } from 'material-ui-interactors';
const DatePicker = createDatePicker({
get(formattedDate: string): Date {
//parse date
},
set(date: Date): void {
}
});The interface doesn't need to look exactly like this, but you get the idea. We are going to have to fight the demon named "locale" head on at some point, and this will be an incremental step in that direction. What do you think? |
|
@cowboyd, I think it would be enough to pass date-io utils into the
|
Hmm, this is interesting if we look at it from a type perspective, there are two different data types here
|
@wKich Can we make it work if we force users to choose the format before getting the interactor? |
|
Oh, the |
| test.step(renderComponent()).assertion(Calendar({ title: "August 2014" }).exists()) | ||
| .child("filters", (test) => | ||
| test | ||
| .step(renderComponent()) |
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.
Since all the of the steps in this test use the same render, maybe should make the individual actions children of the single parent that does the renderComponent() ?
test/calendar.test.tsx
Outdated
| .assertion(Calendar("18 August 2014").exists()) | ||
| .assertion(Calendar({ title: "August 2014" }).exists()) | ||
| .assertion(Calendar({ month: "August" }).exists()) | ||
| .assertion(Calendar({ year: "2014" }).exists()) | ||
| .assertion(Calendar({ day: 18 }).exists()) | ||
| .assertion(Calendar({ weekDay: "Mo" }).exists()) |
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.
Since all the tests in this file use the same locator, I would assign it once at the top:
const calendar = Calendar("18 August 2014");and then use the assertion form for things like filters:
assertion(calendar.has({ title: "August 2014" }));
PoC API of Date/Time pickers
I think the all set methods have to throw an error if date is beyond min/max date
And if Datepicker is disabled or is readonly
In some cases, datepicker might be configured to allow select only the year or month or day or any combination of these
So in that case I think we have to throw an error if a user is trying to set something that's not allowed
Progress: