-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds tests for application creation (#357)
* Remove unnecessary memoization Signed-off-by: Eugene Lee <[email protected]> * Add tests for create page Signed-off-by: Eugene Lee <[email protected]>
- Loading branch information
1 parent
6b6c6d3
commit feb3983
Showing
10 changed files
with
16,164 additions
and
64 deletions.
There are no files selected for viewing
11,198 changes: 11,198 additions & 0 deletions
11,198
...lity/public/components/application_analytics/__tests__/__snapshots__/create.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
786 changes: 786 additions & 0 deletions
786
.../public/components/application_analytics/__tests__/__snapshots__/log_config.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
2,105 changes: 2,105 additions & 0 deletions
2,105
...lic/components/application_analytics/__tests__/__snapshots__/service_config.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
1,545 changes: 1,545 additions & 0 deletions
1,545
...ublic/components/application_analytics/__tests__/__snapshots__/trace_config.test.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
201 changes: 201 additions & 0 deletions
201
dashboards-observability/public/components/application_analytics/__tests__/create.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,201 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { configure } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import { CreateApp } from '../components/create'; | ||
import { coreStartMock } from '../../../../test/__mocks__/coreMocks'; | ||
import DSLService from 'public/services/requests/dsl'; | ||
import { render } from '@testing-library/react'; | ||
|
||
describe('Create Page', () => { | ||
configure({ adapter: new Adapter() }); | ||
|
||
it('renders empty', () => { | ||
const core = coreStartMock; | ||
const setQuery = jest.fn(); | ||
const setFilters = jest.fn(); | ||
const setStartTime = jest.fn(); | ||
const setEndTime = jest.fn(); | ||
const dslService = { | ||
http: jest.fn(), | ||
fetch: jest.fn(), | ||
fetchIndices: jest.fn(), | ||
fetchFields: jest.fn() | ||
} as unknown as DSLService; | ||
const utils = render( | ||
<CreateApp | ||
http={core.http} | ||
chrome={core.chrome} | ||
parentBreadcrumb={{ text: 'test', href: 'test#/' }} | ||
query="" | ||
setQuery={setQuery} | ||
filters={[]} | ||
setFilters={setFilters} | ||
startTime="now-5m" | ||
setStartTime={setStartTime} | ||
endTime="now" | ||
setEndTime={setEndTime} | ||
indicesExist={true} | ||
dslService={dslService} | ||
/> | ||
); | ||
|
||
expect(utils).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders with query', () => { | ||
const core = coreStartMock; | ||
const setQuery = jest.fn(); | ||
const setFilters = jest.fn(); | ||
const setStartTime = jest.fn(); | ||
const setEndTime = jest.fn(); | ||
const dslService = { | ||
http: jest.fn(), | ||
fetch: jest.fn(), | ||
fetchIndices: jest.fn(), | ||
fetchFields: jest.fn() | ||
} as unknown as DSLService; | ||
const utils = render( | ||
<CreateApp | ||
http={core.http} | ||
chrome={core.chrome} | ||
parentBreadcrumb={{ text: 'test', href: 'test#/' }} | ||
query="source = openserach_dashboard_sample_logs" | ||
setQuery={setQuery} | ||
filters={[]} | ||
setFilters={setFilters} | ||
startTime="now-5m" | ||
setStartTime={setStartTime} | ||
endTime="now" | ||
setEndTime={setEndTime} | ||
indicesExist={true} | ||
dslService={dslService} | ||
/> | ||
); | ||
utils.getByText('Log Source').click(); | ||
utils.getByText('Clear').click(); | ||
utils.getByText('Cancel').click(); | ||
|
||
expect(utils).toMatchSnapshot(); | ||
}); | ||
|
||
it('can clear query', () => { | ||
const core = coreStartMock; | ||
const setQuery = jest.fn(); | ||
const setFilters = jest.fn(); | ||
const setStartTime = jest.fn(); | ||
const setEndTime = jest.fn(); | ||
const dslService = { | ||
http: jest.fn(), | ||
fetch: jest.fn(), | ||
fetchIndices: jest.fn(), | ||
fetchFields: jest.fn() | ||
} as unknown as DSLService; | ||
const utils = render( | ||
<CreateApp | ||
http={core.http} | ||
chrome={core.chrome} | ||
parentBreadcrumb={{ text: 'test', href: 'test#/' }} | ||
query="source = openserach_dashboard_sample_logs" | ||
setQuery={setQuery} | ||
filters={[]} | ||
setFilters={setFilters} | ||
startTime="now-5m" | ||
setStartTime={setStartTime} | ||
endTime="now" | ||
setEndTime={setEndTime} | ||
indicesExist={true} | ||
dslService={dslService} | ||
/> | ||
); | ||
utils.getByText('Log Source').click(); | ||
utils.getByText('Clear').click(); | ||
utils.getByText('Clear').click(); | ||
|
||
expect(utils).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders with one service selected', () => { | ||
const core = coreStartMock; | ||
const setQuery = jest.fn(); | ||
const setFilters = jest.fn(); | ||
const setStartTime = jest.fn(); | ||
const setEndTime = jest.fn(); | ||
const dslService = { | ||
http: jest.fn(), | ||
fetch: jest.fn(), | ||
fetchIndices: jest.fn(), | ||
fetchFields: jest.fn() | ||
} as unknown as DSLService; | ||
const serviceFilters = [{ | ||
field: 'serviceName', | ||
operator: 'is', | ||
value: 'User', | ||
inverted: false, | ||
disabled: false | ||
}]; | ||
const utils = render( | ||
<CreateApp | ||
http={core.http} | ||
chrome={core.chrome} | ||
parentBreadcrumb={{ text: 'test', href: 'test#/' }} | ||
query="" | ||
setQuery={setQuery} | ||
filters={serviceFilters} | ||
setFilters={setFilters} | ||
startTime="now-5m" | ||
setStartTime={setStartTime} | ||
endTime="now" | ||
setEndTime={setEndTime} | ||
indicesExist={true} | ||
dslService={dslService} | ||
/> | ||
); | ||
utils.getByText('Select services & entities to include in this application').click(); | ||
|
||
expect(utils).toMatchSnapshot(); | ||
}); | ||
it('renders with one trace selected', () => { | ||
const core = coreStartMock; | ||
const setQuery = jest.fn(); | ||
const setFilters = jest.fn(); | ||
const setStartTime = jest.fn(); | ||
const setEndTime = jest.fn(); | ||
const dslService = { | ||
http: jest.fn(), | ||
fetch: jest.fn(), | ||
fetchIndices: jest.fn(), | ||
fetchFields: jest.fn() | ||
} as unknown as DSLService; | ||
const traceFilters = [{ | ||
field: 'traceGroup', | ||
operator: 'is', | ||
value: 'test.auto', | ||
inverted: false, | ||
disabled: false | ||
}]; | ||
const utils = render( | ||
<CreateApp | ||
http={core.http} | ||
chrome={core.chrome} | ||
parentBreadcrumb={{ text: 'test', href: 'test#/' }} | ||
query="" | ||
setQuery={setQuery} | ||
filters={traceFilters} | ||
setFilters={setFilters} | ||
startTime="now-5m" | ||
setStartTime={setStartTime} | ||
endTime="now" | ||
setEndTime={setEndTime} | ||
indicesExist={true} | ||
dslService={dslService} | ||
/> | ||
); | ||
|
||
expect(utils).toMatchSnapshot(); | ||
}); | ||
}); |
85 changes: 85 additions & 0 deletions
85
...oards-observability/public/components/application_analytics/__tests__/log_config.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,85 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { configure, mount } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import { LogConfig } from '../components/config_components/log_config'; | ||
import { coreStartMock } from '../../../../test/__mocks__/coreMocks'; | ||
import DSLService from 'public/services/requests/dsl'; | ||
|
||
describe('Log Config component', () => { | ||
configure({ adapter: new Adapter() }); | ||
|
||
it('renders empty log config', () => { | ||
const core = coreStartMock; | ||
const setQuery = jest.fn(); | ||
const setFilters = jest.fn(); | ||
const setStartTime = jest.fn(); | ||
const setEndTime = jest.fn(); | ||
const setIsFlyoutVisible = jest.fn(); | ||
const dslService = { | ||
http: jest.fn(), | ||
fetch: jest.fn(), | ||
fetchIndices: jest.fn(), | ||
fetchFields: jest.fn() | ||
} as unknown as DSLService; | ||
const wrapper = mount( | ||
<LogConfig | ||
http={core.http} | ||
chrome={core.chrome} | ||
parentBreadcrumb={{ text: 'test', href: 'test#/' }} | ||
query="" | ||
setQuery={setQuery} | ||
filters={[]} | ||
setFilters={setFilters} | ||
startTime="now-5m" | ||
setStartTime={setStartTime} | ||
endTime="now" | ||
setEndTime={setEndTime} | ||
indicesExist={true} | ||
dslService={dslService} | ||
setIsFlyoutVisible={setIsFlyoutVisible} | ||
/> | ||
); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders with query', () => { | ||
const core = coreStartMock; | ||
const setQuery = jest.fn(); | ||
const setFilters = jest.fn(); | ||
const setStartTime = jest.fn(); | ||
const setEndTime = jest.fn(); | ||
const setIsFlyoutVisible = jest.fn(); | ||
const dslService = { | ||
http: jest.fn(), | ||
fetch: jest.fn(), | ||
fetchIndices: jest.fn(), | ||
fetchFields: jest.fn() | ||
} as unknown as DSLService; | ||
const wrapper = mount( | ||
<LogConfig | ||
http={core.http} | ||
chrome={core.chrome} | ||
parentBreadcrumb={{ text: 'test', href: 'test#/' }} | ||
query="source = openserach_dashboard_sample_logs" | ||
setQuery={setQuery} | ||
filters={[]} | ||
setFilters={setFilters} | ||
startTime="now-5m" | ||
setStartTime={setStartTime} | ||
endTime="now" | ||
setEndTime={setEndTime} | ||
indicesExist={true} | ||
dslService={dslService} | ||
setIsFlyoutVisible={setIsFlyoutVisible} | ||
/> | ||
); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); |
94 changes: 94 additions & 0 deletions
94
...s-observability/public/components/application_analytics/__tests__/service_config.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,94 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import React from 'react'; | ||
import { configure, mount } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import { ServiceConfig } from '../components/config_components/service_config'; | ||
import { coreStartMock } from '../../../../test/__mocks__/coreMocks'; | ||
import DSLService from 'public/services/requests/dsl'; | ||
|
||
describe('Service Config component', () => { | ||
configure({ adapter: new Adapter() }); | ||
|
||
it('renders empty service config', () => { | ||
const core = coreStartMock; | ||
const setQuery = jest.fn(); | ||
const setFilters = jest.fn(); | ||
const setStartTime = jest.fn(); | ||
const setEndTime = jest.fn(); | ||
const setSelectedServices = jest.fn(); | ||
const dslService = { | ||
http: jest.fn(), | ||
fetch: jest.fn(), | ||
fetchIndices: jest.fn(), | ||
fetchFields: jest.fn() | ||
} as unknown as DSLService; | ||
const wrapper = mount( | ||
<ServiceConfig | ||
http={core.http} | ||
chrome={core.chrome} | ||
parentBreadcrumb={{ text: 'test', href: 'test#/' }} | ||
query="" | ||
setQuery={setQuery} | ||
filters={[]} | ||
setFilters={setFilters} | ||
startTime="now-5m" | ||
setStartTime={setStartTime} | ||
endTime="now" | ||
setEndTime={setEndTime} | ||
indicesExist={true} | ||
dslService={dslService} | ||
selectedServices={[]} | ||
setSelectedServices={setSelectedServices} | ||
/> | ||
); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders with one service selected', () => { | ||
const core = coreStartMock; | ||
const setQuery = jest.fn(); | ||
const setFilters = jest.fn(); | ||
const setStartTime = jest.fn(); | ||
const setEndTime = jest.fn(); | ||
const setSelectedServices = jest.fn(); | ||
const dslService = { | ||
http: jest.fn(), | ||
fetch: jest.fn(), | ||
fetchIndices: jest.fn(), | ||
fetchFields: jest.fn() | ||
} as unknown as DSLService; | ||
const serviceFilter = [{ | ||
field: 'serviceName', | ||
operator: 'is', | ||
value: 'User', | ||
inverted: false, | ||
disabled: false | ||
}]; | ||
const wrapper = mount( | ||
<ServiceConfig | ||
http={core.http} | ||
chrome={core.chrome} | ||
parentBreadcrumb={{ text: 'test', href: 'test#/' }} | ||
query="" | ||
setQuery={setQuery} | ||
filters={serviceFilter} | ||
setFilters={setFilters} | ||
startTime="now-5m" | ||
setStartTime={setStartTime} | ||
endTime="now" | ||
setEndTime={setEndTime} | ||
indicesExist={true} | ||
dslService={dslService} | ||
selectedServices={[]} | ||
setSelectedServices={setSelectedServices} | ||
/> | ||
); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
}); |
Oops, something went wrong.