-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Consider user timezone when displaying indicator for active date in date picker. * Use moment.utc for date time utils to make them predictable. * Fix linter hint * Adding changelog. * Updating tests. * Define time zone provided for calendar in search date picker. * Adding test * Updating prop types. * Fix typo.
- Loading branch information
Showing
6 changed files
with
99 additions
and
42 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
type = "fixed" | ||
message = "Fix timezone issue with date picker, which resulted in highlighting the wrong selected day." | ||
|
||
issues = ["16096"] | ||
pulls = ["16973"] |
50 changes: 50 additions & 0 deletions
50
graylog2-web-interface/src/components/common/DatePicker.test.tsx
This file contains 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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (C) 2020 Graylog, Inc. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the Server Side Public License, version 1, | ||
* as published by MongoDB, Inc. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* Server Side Public License for more details. | ||
* | ||
* You should have received a copy of the Server Side Public License | ||
* along with this program. If not, see | ||
* <http://www.mongodb.com/licensing/server-side-public-license>. | ||
*/ | ||
import React from 'react'; | ||
import { render, screen } from 'wrappedTestingLibrary'; | ||
|
||
import { alice } from 'fixtures/users'; | ||
|
||
import DatePicker from './DatePicker'; | ||
|
||
const mockCurrentUser = alice.toBuilder() | ||
.timezone('Europe/Berlin') | ||
.build(); | ||
|
||
jest.mock('hooks/useCurrentUser', () => () => mockCurrentUser); | ||
|
||
describe('DatePicker', () => { | ||
describe('should consider user time zone when displaying selected date', () => { | ||
it('for beginning of day (date with user tz)', async () => { | ||
render(<DatePicker date="2023-10-19T00:00:00.000+02:00" onChange={() => {}} />); | ||
|
||
expect(await screen.findByText('19')).toHaveAttribute('aria-selected', 'true'); | ||
}); | ||
|
||
it('for end of day (date with user tz)', async () => { | ||
render(<DatePicker date="2023-10-19T00:00:00.000+02:00" onChange={() => {}} />); | ||
|
||
expect(await screen.findByText('19')).toHaveAttribute('aria-selected', 'true'); | ||
}); | ||
|
||
it('for end of day (date with UTC tz)', async () => { | ||
render(<DatePicker date="2023-10-19T23:59:00.000+00:00" onChange={() => {}} />); | ||
|
||
expect(await screen.findByText('20')).toHaveAttribute('aria-selected', 'true'); | ||
}); | ||
}); | ||
}); |
This file contains 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 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 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 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