mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
feat: annotation layers CRUD list view (#11432)
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
/**
|
||||
* 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 { styledMount as mount } from 'spec/helpers/theming';
|
||||
|
||||
import AnnotationLayersList from 'src/views/CRUD/annotationlayers/AnnotationLayersList';
|
||||
import SubMenu from 'src/components/Menu/SubMenu';
|
||||
import ListView from 'src/components/ListView';
|
||||
// import Filters from 'src/components/ListView/Filters';
|
||||
// import DeleteModal from 'src/components/DeleteModal';
|
||||
// import Button from 'src/components/Button';
|
||||
// import IndeterminateCheckbox from 'src/components/IndeterminateCheckbox';
|
||||
import waitForComponentToPaint from 'spec/helpers/waitForComponentToPaint';
|
||||
// import { act } from 'react-dom/test-utils';
|
||||
|
||||
// store needed for withToasts(AnnotationLayersList)
|
||||
const mockStore = configureStore([thunk]);
|
||||
const store = mockStore({});
|
||||
|
||||
const layersInfoEndpoint = 'glob:*/api/v1/annotation_layer/_info*';
|
||||
const layersEndpoint = 'glob:*/api/v1/annotation_layer/?*';
|
||||
// const layerEndpoint = 'glob:*/api/v1/annotation_layer/*';
|
||||
// const templatesRelatedEndpoint = 'glob:*/api/v1/annotation_layer/related/*';
|
||||
|
||||
const mocklayers = [...new Array(3)].map((_, i) => ({
|
||||
changed_on_delta_humanized: `${i} day(s) ago`,
|
||||
created_by: {
|
||||
first_name: `user`,
|
||||
last_name: `${i}`,
|
||||
},
|
||||
created_on: new Date().toISOString,
|
||||
changed_on: new Date().toISOString,
|
||||
id: i,
|
||||
name: `layer ${i}`,
|
||||
desc: 'layer description',
|
||||
}));
|
||||
|
||||
fetchMock.get(layersInfoEndpoint, {
|
||||
permissions: ['can_delete'],
|
||||
});
|
||||
fetchMock.get(layersEndpoint, {
|
||||
result: mocklayers,
|
||||
layers_count: 3,
|
||||
});
|
||||
|
||||
/* fetchMock.delete(layerEndpoint, {});
|
||||
fetchMock.delete(layersEndpoint, {});
|
||||
|
||||
fetchMock.get(layersRelatedEndpoint, {
|
||||
created_by: {
|
||||
count: 0,
|
||||
result: [],
|
||||
},
|
||||
}); */
|
||||
|
||||
describe('AnnotationLayersList', () => {
|
||||
const wrapper = mount(<AnnotationLayersList />, { context: { store } });
|
||||
|
||||
beforeAll(async () => {
|
||||
await waitForComponentToPaint(wrapper);
|
||||
});
|
||||
|
||||
it('renders', () => {
|
||||
expect(wrapper.find(AnnotationLayersList)).toExist();
|
||||
});
|
||||
|
||||
it('renders a SubMenu', () => {
|
||||
expect(wrapper.find(SubMenu)).toExist();
|
||||
});
|
||||
|
||||
it('renders a ListView', () => {
|
||||
expect(wrapper.find(ListView)).toExist();
|
||||
});
|
||||
|
||||
it('fetches layers', () => {
|
||||
const callsQ = fetchMock.calls(/annotation_layer\/\?q/);
|
||||
expect(callsQ).toHaveLength(1);
|
||||
expect(callsQ[0][0]).toMatchInlineSnapshot(
|
||||
`"http://localhost/api/v1/annotation_layer/?q=(order_column:name,order_direction:desc,page:0,page_size:25)"`,
|
||||
);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user