-
Notifications
You must be signed in to change notification settings - Fork 918
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
…6834) provides a formatting util function meant to convert quick range time (such as 'now-15m') to datetimes that can be understood. --------- (cherry picked from commit 347639f) Signed-off-by: Paul Sebastian <[email protected]> Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
- Loading branch information
1 parent
e77b19e
commit e128383
Showing
3 changed files
with
55 additions
and
1 deletion.
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,2 @@ | ||
fix: | ||
- Quickrange selection fix ([#6782](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6782)) |
31 changes: 31 additions & 0 deletions
31
src/plugins/data/common/data_frames/data_frame_utils.test.ts
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,31 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { TimeRange } from '../types'; | ||
import { formatTimePickerDate } from './utils'; | ||
|
||
describe('Data Frame Utils', () => { | ||
describe('formatTimePickerDate function', () => { | ||
Date.now = jest.fn(() => new Date('2024-05-04T12:30:00.000Z')); | ||
|
||
test('should return a correctly formatted date', () => { | ||
const range = { from: 'now-15m', to: 'now' } as TimeRange; | ||
const formattedDate = formatTimePickerDate(range, 'YYYY-MM-DD HH:mm:ss.SSS'); | ||
expect(formattedDate).toStrictEqual({ | ||
fromDate: '2024-05-04 12:15:00.000', | ||
toDate: '2024-05-04 12:30:00.000', | ||
}); | ||
}); | ||
|
||
test('should indicate invalid when given bad dates', () => { | ||
const range = { from: 'fake', to: 'date' } as TimeRange; | ||
const formattedDate = formatTimePickerDate(range, 'YYYY-MM-DD HH:mm:ss.SSS'); | ||
expect(formattedDate).toStrictEqual({ | ||
fromDate: 'Invalid date', | ||
toDate: 'Invalid date', | ||
}); | ||
}); | ||
}); | ||
}); |
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