Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
| onChange={(ranges) => append({ ranges })} | ||
| Trigger={ | ||
| <Button color="secondary" StartIcon={Icon.FiPlus}> | ||
| <Button color="secondary" StartIcon={Icon.FiPlus} data-testid="add-override"> |
| render={({ field }) => ( | ||
| <EditableHeading isReady={!isLoading} {...field} data-testid="availablity-title" /> | ||
| )} |
| const { date, setQuery: setSelectedDate } = useRouterQuery("date"); | ||
| const selectedDate = dayjs(date); | ||
| const formattedSelectedDate = selectedDate.format("YYYY-MM-DD"); |
There was a problem hiding this comment.
Use URL instead of state for dates
| const overrides = | ||
| data?.dateOverrides.reduce((acc, override) => { | ||
| if ( | ||
| formattedSelectedDate !== dayjs(override.start).format("YYYY-MM-DD") && | ||
| formattedSelectedDate !== dayjs(override.end).format("YYYY-MM-DD") | ||
| ) | ||
| return acc; | ||
| acc.push({ ...override, source: "Date override" }); | ||
| return acc; | ||
| }, [] as IBusySlot[]) || []; |
There was a problem hiding this comment.
Filter overrides specific to the selected date
| {t("your_day_starts_at")} {convertMinsToHrsMins(user.startTime)} | ||
| </div> | ||
| </div> | ||
| {isLoading ? ( |
There was a problem hiding this comment.
I'm starting to dislike ternaries for these use cases.
There was a problem hiding this comment.
I agree. It makes the code very confusing if ternary is more than 1 level
| ); | ||
|
|
||
| if (data && (data.busy.length > 0 || overrides.length > 0)) | ||
| return [...data.busy, ...overrides] |
There was a problem hiding this comment.
Reusing this for both override and busy times
| }); | ||
| }); | ||
|
|
||
| test("Availablity pages", async ({ page }) => { |
There was a problem hiding this comment.
Added basic adding availability test
| }); | ||
|
|
||
| test("Date Overrides", async ({ page }) => { | ||
| await test.step("Can add a date override", async () => { |
| await page.locator('[form="availability-form"][type="submit"]').click(); | ||
| }); | ||
|
|
||
| await test.step("Date override is displayed in troubleshooter", async () => { |
There was a problem hiding this comment.
Check the added override actually works
hariombalhara
left a comment
There was a problem hiding this comment.
Looks good. Except the troubleshooter issue which is a separate bug and not related to Date Overrides.
| }); | ||
|
|
||
| test("Date Overrides", async ({ page }) => { | ||
| await test.step("Can add a date override", async () => { |
There was a problem hiding this comment.
Didn't know you can break tests logically like this.👍
| {t("your_day_starts_at")} {convertMinsToHrsMins(user.startTime)} | ||
| </div> | ||
| </div> | ||
| {isLoading ? ( |
There was a problem hiding this comment.
I agree. It makes the code very confusing if ternary is more than 1 level
| ); | ||
|
|
||
| const overrides = | ||
| data?.dateOverrides.reduce((acc, override) => { |
There was a problem hiding this comment.
Date overrides aren't shown in troubleshooter if there are more than 1 availabilities and date override is used in second one.
This seems to be due to the reason that getUserAvailability picks the first availability/schedule(because eventTypeId isn't provided)
If a default schedule is set, I think that's used.
This seems to be a bug in troubleshooter flow and not specific to Date overrides.
cc @emrysal
Also, I am confused as to if troubleshooter is expected to troubleshoot one schedule or all the schedules of user in general.
There was a problem hiding this comment.
Sounds like a job for a followup

What does this PR do?
Type of change
How should this be tested?
yarn e2e apps/web/playwright/availability.e2e.ts