forked from apache/superset
-
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.
feat: annotation layers modal + filters (apache#11494)
- Loading branch information
Showing
8 changed files
with
457 additions
and
34 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
superset-frontend/spec/javascripts/views/CRUD/annotationlayers/AnnotationLayerModal_spec.jsx
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,89 @@ | ||
/** | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
import React from 'react'; | ||
import thunk from 'redux-thunk'; | ||
import configureStore from 'redux-mock-store'; | ||
import fetchMock from 'fetch-mock'; | ||
import AnnotationLayerModal from 'src/views/CRUD/annotationlayers/AnnotationLayerModal'; | ||
import Modal from 'src/common/components/Modal'; | ||
import waitForComponentToPaint from 'spec/helpers/waitForComponentToPaint'; | ||
import { styledMount as mount } from 'spec/helpers/theming'; | ||
|
||
const mockData = { id: 1, name: 'test', descr: 'test description' }; | ||
const FETCH_ANNOTATION_LAYER_ENDPOINT = 'glob:*/api/v1/annotation_layer/*'; | ||
const ANNOTATION_LAYER_PAYLOAD = { result: mockData }; | ||
|
||
fetchMock.get(FETCH_ANNOTATION_LAYER_ENDPOINT, ANNOTATION_LAYER_PAYLOAD); | ||
|
||
const mockStore = configureStore([thunk]); | ||
const store = mockStore({}); | ||
|
||
const mockedProps = { | ||
addDangerToast: () => {}, | ||
onLayerAdd: jest.fn(() => []), | ||
onHide: () => {}, | ||
show: true, | ||
layer: mockData, | ||
}; | ||
|
||
async function mountAndWait(props = mockedProps) { | ||
const mounted = mount(<AnnotationLayerModal show {...props} />, { | ||
context: { store }, | ||
}); | ||
await waitForComponentToPaint(mounted); | ||
|
||
return mounted; | ||
} | ||
|
||
describe('AnnotationLayerModal', () => { | ||
let wrapper; | ||
|
||
beforeAll(async () => { | ||
wrapper = await mountAndWait(); | ||
}); | ||
|
||
it('renders', () => { | ||
expect(wrapper.find(AnnotationLayerModal)).toExist(); | ||
}); | ||
|
||
it('renders a Modal', () => { | ||
expect(wrapper.find(Modal)).toExist(); | ||
}); | ||
|
||
it('renders add header when no layer is included', async () => { | ||
const addWrapper = await mountAndWait({}); | ||
expect( | ||
addWrapper.find('[data-test="annotation-layer-modal-title"]').text(), | ||
).toEqual('Add Annotation Layer'); | ||
}); | ||
|
||
it('renders edit header when layer prop is included', () => { | ||
expect( | ||
wrapper.find('[data-test="annotation-layer-modal-title"]').text(), | ||
).toEqual('Edit Annotation Layer Properties'); | ||
}); | ||
|
||
it('renders input element for name', () => { | ||
expect(wrapper.find('input[name="name"]')).toExist(); | ||
}); | ||
|
||
it('renders textarea element for description', () => { | ||
expect(wrapper.find('textarea[name="descr"]')).toExist(); | ||
}); | ||
}); |
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
Oops, something went wrong.