villebro commented on a change in pull request #12655:
URL: https://github.com/apache/superset/pull/12655#discussion_r562432969
##########
File path: superset-frontend/spec/fixtures/mockDashboardLayout.js
##########
@@ -189,6 +189,49 @@ export const dashboardLayoutWithTabs = {
future: [],
};
+export const dashboardLayoutWithTabsCombined = {
Review comment:
Could we have a more descriptive name here: how is this functionally
different from `dashboardLayoutWithTabs`?
##########
File path:
superset-frontend/spec/javascripts/dashboard/components/nativeFilters/FilterScope_spec.tsx
##########
@@ -0,0 +1,110 @@
+/**
+ * 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 { Provider } from 'react-redux';
+import { render, screen, fireEvent } from 'spec/helpers/testing-library';
+import { mockStoreWithTabsCombined } from 'spec/fixtures/mockStore';
+import { Form, FormInstance } from 'src/common/components';
+import { NativeFiltersForm } from
'src/dashboard/components/nativeFilters/types';
+import FilterConfigForm from
'src/dashboard/components/nativeFilters/FilterConfigForm';
+
+describe('FilterScope', () => {
+ const save = jest.fn();
+ let form: FormInstance<NativeFiltersForm>;
+ const mockedProps = {
+ filterId: 'DefaultFilterId',
+ restore: jest.fn(),
+ parentFilters: [],
+ save,
+ };
+
+ const MockModal = ({ scope }: { scope: object | undefined }) => {
+ const [newForm] = Form.useForm<NativeFiltersForm>();
+ form = newForm;
+ if (scope) {
+ form.setFieldsValue({
+ filters: {
+ [mockedProps.filterId]: {
+ scope,
+ },
+ },
+ });
+ }
+ return (
+ <Provider store={mockStoreWithTabsCombined}>
+ <Form form={form}>
+ <FilterConfigForm form={form} {...mockedProps} />
+ </Form>
+ </Provider>
+ );
+ };
+
+ const getWrapper = (scope?: object) => {
+ render(<MockModal scope={scope} />);
+ };
+
+ const getTreeSwitcher = (order = 0) =>
+ document.querySelectorAll('.ant-tree-switcher')[order];
Review comment:
Would be nice to add a `data-test` to the Tree switcher.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]