-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[APM] Service overview: Introduce time-series comparison (#88665)
* adding comparision select option * adding time comparison field on some pages * removing unused files * fixing unit test * adding unit tests * enabling comparison for more than 8 days * removing tooltip * refactoring search bar * moving useBreakPoint to common hooks folder, removing useShouldUSeMobileLayout hook * addressing PR comments * addressing PR comments * addressing PR comments * addressing PR comments Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
bfcd990
commit d997f20
Showing
16 changed files
with
344 additions
and
46 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
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
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
27 changes: 0 additions & 27 deletions
27
x-pack/plugins/apm/public/components/app/service_overview/use_should_use_mobile_layout.ts
This file was deleted.
Oops, something went wrong.
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
142 changes: 142 additions & 0 deletions
142
x-pack/plugins/apm/public/components/shared/time_comparison/index.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,142 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import { render } from '@testing-library/react'; | ||
import React, { ReactNode } from 'react'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import { EuiThemeProvider } from '../../../../../observability/public'; | ||
import { MockUrlParamsContextProvider } from '../../../context/url_params_context/mock_url_params_context_provider'; | ||
import { IUrlParams } from '../../../context/url_params_context/types'; | ||
import { | ||
expectTextsInDocument, | ||
expectTextsNotInDocument, | ||
} from '../../../utils/testHelpers'; | ||
import { TimeComparison } from './'; | ||
import * as urlHelpers from '../../shared/Links/url_helpers'; | ||
|
||
function getWrapper(params?: IUrlParams) { | ||
return ({ children }: { children?: ReactNode }) => { | ||
return ( | ||
<MemoryRouter> | ||
<MockUrlParamsContextProvider params={params}> | ||
<EuiThemeProvider>{children}</EuiThemeProvider> | ||
</MockUrlParamsContextProvider> | ||
</MemoryRouter> | ||
); | ||
}; | ||
} | ||
|
||
describe('TimeComparison', () => { | ||
const spy = jest.spyOn(urlHelpers, 'replace'); | ||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
describe('Time range is between 0 - 24 hours', () => { | ||
it('sets default values', () => { | ||
const Wrapper = getWrapper({ | ||
start: '2021-01-28T14:45:00.000Z', | ||
end: '2021-01-28T15:00:00.000Z', | ||
}); | ||
render(<TimeComparison />, { | ||
wrapper: Wrapper, | ||
}); | ||
expect(spy).toHaveBeenCalledWith(expect.anything(), { | ||
query: { | ||
comparisonEnabled: 'true', | ||
comparisonType: 'yesterday', | ||
}, | ||
}); | ||
}); | ||
it('selects yesterday and enables comparison', () => { | ||
const Wrapper = getWrapper({ | ||
start: '2021-01-28T14:45:00.000Z', | ||
end: '2021-01-28T15:00:00.000Z', | ||
comparisonEnabled: true, | ||
comparisonType: 'yesterday', | ||
}); | ||
const component = render(<TimeComparison />, { | ||
wrapper: Wrapper, | ||
}); | ||
expectTextsInDocument(component, ['Yesterday', 'A week ago']); | ||
expect( | ||
(component.getByTestId('comparisonSelect') as HTMLSelectElement) | ||
.selectedIndex | ||
).toEqual(0); | ||
}); | ||
}); | ||
|
||
describe('Time range is between 24 hours - 1 week', () => { | ||
it('sets default values', () => { | ||
const Wrapper = getWrapper({ | ||
start: '2021-01-26T15:00:00.000Z', | ||
end: '2021-01-28T15:00:00.000Z', | ||
}); | ||
render(<TimeComparison />, { | ||
wrapper: Wrapper, | ||
}); | ||
expect(spy).toHaveBeenCalledWith(expect.anything(), { | ||
query: { | ||
comparisonEnabled: 'true', | ||
comparisonType: 'week', | ||
}, | ||
}); | ||
}); | ||
it('selects week and enables comparison', () => { | ||
const Wrapper = getWrapper({ | ||
start: '2021-01-26T15:00:00.000Z', | ||
end: '2021-01-28T15:00:00.000Z', | ||
comparisonEnabled: true, | ||
comparisonType: 'week', | ||
}); | ||
const component = render(<TimeComparison />, { | ||
wrapper: Wrapper, | ||
}); | ||
expectTextsNotInDocument(component, ['Yesterday']); | ||
expectTextsInDocument(component, ['A week ago']); | ||
expect( | ||
(component.getByTestId('comparisonSelect') as HTMLSelectElement) | ||
.selectedIndex | ||
).toEqual(0); | ||
}); | ||
}); | ||
|
||
describe('Time range is greater than 7 days', () => { | ||
it('Shows absolute times without year when within the same year', () => { | ||
const Wrapper = getWrapper({ | ||
start: '2021-01-20T15:00:00.000Z', | ||
end: '2021-01-28T15:00:00.000Z', | ||
comparisonEnabled: true, | ||
comparisonType: 'previousPeriod', | ||
}); | ||
const component = render(<TimeComparison />, { | ||
wrapper: Wrapper, | ||
}); | ||
expect(spy).not.toHaveBeenCalled(); | ||
expectTextsInDocument(component, ['20/01 - 28/01']); | ||
expect( | ||
(component.getByTestId('comparisonSelect') as HTMLSelectElement) | ||
.selectedIndex | ||
).toEqual(0); | ||
}); | ||
|
||
it('Shows absolute times with year when on different year', () => { | ||
const Wrapper = getWrapper({ | ||
start: '2020-12-20T15:00:00.000Z', | ||
end: '2021-01-28T15:00:00.000Z', | ||
comparisonEnabled: true, | ||
comparisonType: 'previousPeriod', | ||
}); | ||
const component = render(<TimeComparison />, { | ||
wrapper: Wrapper, | ||
}); | ||
expect(spy).not.toHaveBeenCalled(); | ||
expectTextsInDocument(component, ['20/12/20 - 28/01/21']); | ||
expect( | ||
(component.getByTestId('comparisonSelect') as HTMLSelectElement) | ||
.selectedIndex | ||
).toEqual(0); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.