forked from opensearch-project/OpenSearch-Dashboards
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix for quickrange to use datemath to parse datetime strings (opensea…
…rch-project#6782) provides a formatting util function meant to convert quick range time (such as 'now-15m') to datetimes that can be understood. Signed-off-by: Paul Sebastian <paulstn@amazon.com> --------- Signed-off-by: Paul Sebastian <paulstn@amazon.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
- Loading branch information
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