File tree 3 files changed +29
-2
lines changed
features/timezone-buddy/components
3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,29 @@ test.describe("Availablity", () => {
88
88
await expect ( await page . getByTitle ( deleteButtonTitle ) . isVisible ( ) ) . toBe ( false ) ;
89
89
} ) ;
90
90
91
+ test ( "Can create date override on current day in a negative timezone" , async ( { page } ) => {
92
+ await page . getByTestId ( "schedules" ) . first ( ) . click ( ) ;
93
+ // set time zone to New York
94
+ await page
95
+ . locator ( "#availability-form div" )
96
+ . filter ( { hasText : "TimezoneEurope/London" } )
97
+ . locator ( "svg" )
98
+ . click ( ) ;
99
+ await page . locator ( "[id=timeZone-lg-viewport]" ) . fill ( "New" ) ;
100
+ await page . getByTestId ( "select-option-America/New_York" ) . click ( ) ;
101
+
102
+ // Add override for today
103
+ await page . getByTestId ( "add-override" ) . click ( ) ;
104
+ await page . locator ( '[id="modal-title"]' ) . waitFor ( ) ;
105
+ await page . locator ( '[data-testid="day"][data-disabled="false"]' ) . first ( ) . click ( ) ;
106
+ await page . getByTestId ( "add-override-submit-btn" ) . click ( ) ;
107
+ await page . getByTestId ( "dialog-rejection" ) . click ( ) ;
108
+
109
+ await page . locator ( '[form="availability-form"][type="submit"]' ) . click ( ) ;
110
+ await page . reload ( ) ;
111
+ await expect ( page . locator ( '[data-testid="date-overrides-list"] > li' ) ) . toHaveCount ( 1 ) ;
112
+ } ) ;
113
+
91
114
test ( "Schedule listing" , async ( { page } ) => {
92
115
await test . step ( "Can add a new schedule" , async ( ) => {
93
116
await page . getByTestId ( "new-schedule" ) . click ( ) ;
Original file line number Diff line number Diff line change @@ -194,6 +194,7 @@ export function AvailabilityEditSheetForm(props: Props & { data: Data; isPending
194
194
id = "timezone"
195
195
isDisabled = { ! hasEditPermission || ! data . hasDefaultSchedule }
196
196
value = { watchTimezone ?? "Europe/London" }
197
+ data-testid = "timezone-select"
197
198
onChange = { ( event ) => {
198
199
if ( event ) form . setValue ( "timeZone" , event . value , { shouldDirty : true } ) ;
199
200
} }
Original file line number Diff line number Diff line change @@ -37,8 +37,11 @@ export function transformAvailabilityForClient(schedule: ScheduleWithAvailabilit
37
37
38
38
export function transformDateOverridesForClient ( schedule : ScheduleWithAvailabilities , timeZone : string ) {
39
39
return schedule . availability . reduce ( ( acc , override ) => {
40
- // only iff future date override
41
- if ( ! override . date || dayjs . tz ( override . date , timeZone ) . isBefore ( dayjs ( ) , "day" ) ) {
40
+ // only if future date override
41
+ const currentUtcOffset = dayjs ( ) . tz ( timeZone ) . utcOffset ( ) ;
42
+ const currentTimeInTz = dayjs ( ) . utc ( ) . add ( currentUtcOffset , "minute" ) ;
43
+
44
+ if ( ! override . date || dayjs ( override . date ) . isBefore ( currentTimeInTz , "day" ) ) {
42
45
return acc ;
43
46
}
44
47
const newValue = {
You can’t perform that action at this time.
0 commit comments