You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2022/08/22 13:22:07 UTC
[GitHub] [superset] geido opened a new pull request, #21148: chore: Drill to detail Modal tests
geido opened a new pull request, #21148:
URL: https://github.com/apache/superset/pull/21148
### SUMMARY
This PR adds RTL tests for the drill to detail modal originally implemented in this PR https://github.com/apache/superset/pull/20728
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N.A.
### TESTING INSTRUCTIONS
All the tests should succeed
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] codecov[bot] commented on pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
codecov[bot] commented on PR #21148:
URL: https://github.com/apache/superset/pull/21148#issuecomment-1222386920
# [Codecov](https://codecov.io/gh/apache/superset/pull/21148?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
> Merging [#21148](https://codecov.io/gh/apache/superset/pull/21148?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (6806d34) into [master](https://codecov.io/gh/apache/superset/commit/394d62ee51b6feb6e23c2b24505ee469460db146?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (394d62e) will **decrease** coverage by `11.63%`.
> The diff coverage is `n/a`.
```diff
@@ Coverage Diff @@
## master #21148 +/- ##
===========================================
- Coverage 66.27% 54.64% -11.64%
===========================================
Files 1770 1770
Lines 67524 67524
Branches 7178 7178
===========================================
- Hits 44754 36897 -7857
- Misses 20936 28793 +7857
Partials 1834 1834
```
| Flag | Coverage Δ | |
|---|---|---|
| hive | `?` | |
| mysql | `?` | |
| postgres | `?` | |
| presto | `53.06% <ø> (ø)` | |
| python | `57.45% <ø> (-24.04%)` | :arrow_down: |
| sqlite | `?` | |
| unit | `50.72% <ø> (ø)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
| [Impacted Files](https://codecov.io/gh/apache/superset/pull/21148?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [superset/utils/dashboard\_import\_export.py](https://codecov.io/gh/apache/superset/pull/21148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdXRpbHMvZGFzaGJvYXJkX2ltcG9ydF9leHBvcnQucHk=) | `0.00% <0.00%> (-100.00%)` | :arrow_down: |
| [superset/key\_value/commands/update.py](https://codecov.io/gh/apache/superset/pull/21148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL3VwZGF0ZS5weQ==) | `0.00% <0.00%> (-88.89%)` | :arrow_down: |
| [superset/key\_value/commands/delete.py](https://codecov.io/gh/apache/superset/pull/21148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL2RlbGV0ZS5weQ==) | `0.00% <0.00%> (-85.30%)` | :arrow_down: |
| [superset/db\_engines/hive.py](https://codecov.io/gh/apache/superset/pull/21148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGJfZW5naW5lcy9oaXZlLnB5) | `0.00% <0.00%> (-85.19%)` | :arrow_down: |
| [superset/key\_value/commands/delete\_expired.py](https://codecov.io/gh/apache/superset/pull/21148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQva2V5X3ZhbHVlL2NvbW1hbmRzL2RlbGV0ZV9leHBpcmVkLnB5) | `0.00% <0.00%> (-80.77%)` | :arrow_down: |
| [superset/dashboards/commands/importers/v0.py](https://codecov.io/gh/apache/superset/pull/21148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGFzaGJvYXJkcy9jb21tYW5kcy9pbXBvcnRlcnMvdjAucHk=) | `15.62% <0.00%> (-76.25%)` | :arrow_down: |
| [superset/datasets/commands/update.py](https://codecov.io/gh/apache/superset/pull/21148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGF0YXNldHMvY29tbWFuZHMvdXBkYXRlLnB5) | `25.00% <0.00%> (-69.05%)` | :arrow_down: |
| [superset/datasets/commands/create.py](https://codecov.io/gh/apache/superset/pull/21148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGF0YXNldHMvY29tbWFuZHMvY3JlYXRlLnB5) | `29.41% <0.00%> (-68.63%)` | :arrow_down: |
| [superset/datasets/commands/importers/v0.py](https://codecov.io/gh/apache/superset/pull/21148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvZGF0YXNldHMvY29tbWFuZHMvaW1wb3J0ZXJzL3YwLnB5) | `24.03% <0.00%> (-67.45%)` | :arrow_down: |
| [superset/views/datasource/utils.py](https://codecov.io/gh/apache/superset/pull/21148/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3VwZXJzZXQvdmlld3MvZGF0YXNvdXJjZS91dGlscy5weQ==) | `26.66% <0.00%> (-66.67%)` | :arrow_down: |
| ... and [279 more](https://codecov.io/gh/apache/superset/pull/21148/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
:mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] github-actions[bot] commented on pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21148:
URL: https://github.com/apache/superset/pull/21148#issuecomment-1228391284
Storybook has completed and can be viewed at
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] geido commented on a diff in pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
geido commented on code in PR #21148:
URL: https://github.com/apache/superset/pull/21148#discussion_r954991064
##########
superset-frontend/src/components/Chart/DrillDetailModal.test.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 { render, screen, waitFor } from 'spec/helpers/testing-library';
+import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore';
+import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries';
+import { QueryFormData } from '@superset-ui/core';
+import fetchMock from 'fetch-mock';
+import userEvent from '@testing-library/user-event';
+import DrillDetailModal from './DrillDetailModal';
+
+const chart = chartQueries[sliceId];
+const setup = (overrides: Record<string, any> = {}) => {
+ const store = getMockStoreWithNativeFilters();
+ const props = {
+ chartId: sliceId,
+ initialFilters: [],
+ formData: chart.form_data as unknown as QueryFormData,
+ ...overrides,
+ };
+ return render(<DrillDetailModal {...props} />, {
+ useRedux: true,
+ useRouter: true,
+ store,
+ });
+};
+const waitForRender = (overrides: Record<string, any> = {}) =>
+ waitFor(() => setup(overrides));
Review Comment:
In general, I think there is a lot of reusable helpers that we can create for this RTL tests. This could be an interesting project in order to enforce/suggest certain standards in writing RTL tests. CC @rusackas
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] geido commented on a diff in pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
geido commented on code in PR #21148:
URL: https://github.com/apache/superset/pull/21148#discussion_r954960264
##########
superset-frontend/src/components/Chart/DrillDetailModal.test.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 { render, screen, waitFor } from 'spec/helpers/testing-library';
+import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore';
+import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries';
+import { QueryFormData } from '@superset-ui/core';
+import fetchMock from 'fetch-mock';
+import userEvent from '@testing-library/user-event';
+import DrillDetailModal from './DrillDetailModal';
+
+const chart = chartQueries[sliceId];
+const setup = (overrides: Record<string, any> = {}) => {
+ const store = getMockStoreWithNativeFilters();
+ const props = {
+ chartId: sliceId,
+ initialFilters: [],
+ formData: chart.form_data as unknown as QueryFormData,
+ ...overrides,
+ };
+ return render(<DrillDetailModal {...props} />, {
+ useRedux: true,
+ useRouter: true,
+ store,
+ });
+};
+const waitForRender = (overrides: Record<string, any> = {}) =>
+ waitFor(() => setup(overrides));
Review Comment:
@kgabryje in this component there are several async events that would fire warnings in the console if we don't wait for the component to be fully loaded. Hence the reason for this.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] kgabryje commented on a diff in pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
kgabryje commented on code in PR #21148:
URL: https://github.com/apache/superset/pull/21148#discussion_r954997908
##########
superset-frontend/src/components/Chart/DrillDetailModal.test.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 { render, screen, waitFor } from 'spec/helpers/testing-library';
+import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore';
+import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries';
+import { QueryFormData } from '@superset-ui/core';
+import fetchMock from 'fetch-mock';
+import userEvent from '@testing-library/user-event';
+import DrillDetailModal from './DrillDetailModal';
+
+const chart = chartQueries[sliceId];
+const setup = (overrides: Record<string, any> = {}) => {
+ const store = getMockStoreWithNativeFilters();
+ const props = {
+ chartId: sliceId,
+ initialFilters: [],
+ formData: chart.form_data as unknown as QueryFormData,
+ ...overrides,
+ };
+ return render(<DrillDetailModal {...props} />, {
+ useRedux: true,
+ useRouter: true,
+ store,
+ });
+};
+const waitForRender = (overrides: Record<string, any> = {}) =>
+ waitFor(() => setup(overrides));
Review Comment:
Ok, approving this PR 👍 Do you think though that other tests would benefit from using this pattern? Should we use it to decrease the number of warnings?
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] michael-s-molina commented on a diff in pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
michael-s-molina commented on code in PR #21148:
URL: https://github.com/apache/superset/pull/21148#discussion_r955350853
##########
superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx:
##########
@@ -0,0 +1,109 @@
+/**
+ * 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 { render, screen } from 'spec/helpers/testing-library';
+import userEvent from '@testing-library/user-event';
+import TableControls from './TableControls';
+
+const setFilters = jest.fn();
+const onReload = jest.fn();
+const setup = (overrides: Record<string, any> = {}) => {
+ const props = {
+ filters: [],
+ setFilters,
+ onReload,
+ loading: false,
+ totalCount: 0,
+ ...overrides,
+ };
+ return render(<TableControls {...props} />);
+};
+test('should render', async () => {
Review Comment:
```suggestion
test('should render', () => {
```
##########
superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx:
##########
@@ -0,0 +1,109 @@
+/**
+ * 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 { render, screen } from 'spec/helpers/testing-library';
+import userEvent from '@testing-library/user-event';
+import TableControls from './TableControls';
+
+const setFilters = jest.fn();
+const onReload = jest.fn();
+const setup = (overrides: Record<string, any> = {}) => {
+ const props = {
+ filters: [],
+ setFilters,
+ onReload,
+ loading: false,
+ totalCount: 0,
+ ...overrides,
+ };
+ return render(<TableControls {...props} />);
+};
+test('should render', async () => {
+ const { container } = setup();
+ expect(container).toBeInTheDocument();
+});
+
+test('should show 0 rows', () => {
+ setup();
+ expect(screen.getByText('0 rows')).toBeInTheDocument();
+});
+
+test('should show the correct amount of rows', () => {
+ setup({
+ totalCount: 10,
+ });
+ expect(screen.getByText('10 rows')).toBeInTheDocument();
+});
+
+test('should render the reload button', () => {
+ setup();
+ expect(screen.getByRole('button', { name: 'Reload' })).toBeInTheDocument();
+});
+
+test('should show the loading indicator', async () => {
Review Comment:
```suggestion
test('should show the loading indicator', () => {
```
##########
superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx:
##########
@@ -0,0 +1,109 @@
+/**
+ * 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 { render, screen } from 'spec/helpers/testing-library';
+import userEvent from '@testing-library/user-event';
+import TableControls from './TableControls';
+
+const setFilters = jest.fn();
+const onReload = jest.fn();
+const setup = (overrides: Record<string, any> = {}) => {
+ const props = {
+ filters: [],
+ setFilters,
+ onReload,
+ loading: false,
+ totalCount: 0,
+ ...overrides,
+ };
+ return render(<TableControls {...props} />);
+};
+test('should render', async () => {
+ const { container } = setup();
+ expect(container).toBeInTheDocument();
+});
+
+test('should show 0 rows', () => {
+ setup();
+ expect(screen.getByText('0 rows')).toBeInTheDocument();
+});
+
+test('should show the correct amount of rows', () => {
+ setup({
+ totalCount: 10,
+ });
+ expect(screen.getByText('10 rows')).toBeInTheDocument();
+});
+
+test('should render the reload button', () => {
+ setup();
+ expect(screen.getByRole('button', { name: 'Reload' })).toBeInTheDocument();
+});
+
+test('should show the loading indicator', async () => {
+ setup({
+ loading: true,
+ });
+ expect(screen.getByText('Loading...')).toBeInTheDocument();
+});
+
+test('should call onreload', async () => {
Review Comment:
```suggestion
test('should call onreload', () => {
```
##########
superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx:
##########
@@ -0,0 +1,109 @@
+/**
+ * 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 { render, screen } from 'spec/helpers/testing-library';
+import userEvent from '@testing-library/user-event';
+import TableControls from './TableControls';
+
+const setFilters = jest.fn();
+const onReload = jest.fn();
+const setup = (overrides: Record<string, any> = {}) => {
+ const props = {
+ filters: [],
+ setFilters,
+ onReload,
+ loading: false,
+ totalCount: 0,
+ ...overrides,
+ };
+ return render(<TableControls {...props} />);
+};
+test('should render', async () => {
+ const { container } = setup();
+ expect(container).toBeInTheDocument();
+});
+
+test('should show 0 rows', () => {
+ setup();
+ expect(screen.getByText('0 rows')).toBeInTheDocument();
+});
+
+test('should show the correct amount of rows', () => {
+ setup({
+ totalCount: 10,
+ });
+ expect(screen.getByText('10 rows')).toBeInTheDocument();
+});
+
+test('should render the reload button', () => {
+ setup();
+ expect(screen.getByRole('button', { name: 'Reload' })).toBeInTheDocument();
+});
+
+test('should show the loading indicator', async () => {
+ setup({
+ loading: true,
+ });
+ expect(screen.getByText('Loading...')).toBeInTheDocument();
+});
+
+test('should call onreload', async () => {
+ setup();
+ userEvent.click(screen.getByRole('button', { name: 'Reload' }));
+ expect(onReload).toHaveBeenCalledTimes(1);
+});
+
+test('should render with filters', async () => {
Review Comment:
```suggestion
test('should render with filters', () => {
```
##########
superset-frontend/src/dashboard/components/DrillDetailPane/TableControls.test.tsx:
##########
@@ -0,0 +1,109 @@
+/**
+ * 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 { render, screen } from 'spec/helpers/testing-library';
+import userEvent from '@testing-library/user-event';
+import TableControls from './TableControls';
+
+const setFilters = jest.fn();
+const onReload = jest.fn();
+const setup = (overrides: Record<string, any> = {}) => {
+ const props = {
+ filters: [],
+ setFilters,
+ onReload,
+ loading: false,
+ totalCount: 0,
+ ...overrides,
+ };
+ return render(<TableControls {...props} />);
+};
+test('should render', async () => {
+ const { container } = setup();
+ expect(container).toBeInTheDocument();
+});
+
+test('should show 0 rows', () => {
+ setup();
+ expect(screen.getByText('0 rows')).toBeInTheDocument();
+});
+
+test('should show the correct amount of rows', () => {
+ setup({
+ totalCount: 10,
+ });
+ expect(screen.getByText('10 rows')).toBeInTheDocument();
+});
+
+test('should render the reload button', () => {
+ setup();
+ expect(screen.getByRole('button', { name: 'Reload' })).toBeInTheDocument();
+});
+
+test('should show the loading indicator', async () => {
+ setup({
+ loading: true,
+ });
+ expect(screen.getByText('Loading...')).toBeInTheDocument();
+});
+
+test('should call onreload', async () => {
+ setup();
+ userEvent.click(screen.getByRole('button', { name: 'Reload' }));
+ expect(onReload).toHaveBeenCalledTimes(1);
+});
+
+test('should render with filters', async () => {
+ setup({
+ filters: [
+ {
+ col: 'platform',
+ op: '==',
+ val: 'GB',
+ },
+ {
+ col: 'lang',
+ op: '==',
+ val: 'IT',
+ },
+ ],
+ });
+ expect(screen.getByText('platform')).toBeInTheDocument();
+ expect(screen.getByText('GB')).toBeInTheDocument();
+ expect(screen.getByText('lang')).toBeInTheDocument();
+ expect(screen.getByText('IT')).toBeInTheDocument();
+});
+
+test('should remove the filters on close', async () => {
Review Comment:
```suggestion
test('should remove the filters on close', () => {
```
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] geido commented on a diff in pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
geido commented on code in PR #21148:
URL: https://github.com/apache/superset/pull/21148#discussion_r954991064
##########
superset-frontend/src/components/Chart/DrillDetailModal.test.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 { render, screen, waitFor } from 'spec/helpers/testing-library';
+import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore';
+import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries';
+import { QueryFormData } from '@superset-ui/core';
+import fetchMock from 'fetch-mock';
+import userEvent from '@testing-library/user-event';
+import DrillDetailModal from './DrillDetailModal';
+
+const chart = chartQueries[sliceId];
+const setup = (overrides: Record<string, any> = {}) => {
+ const store = getMockStoreWithNativeFilters();
+ const props = {
+ chartId: sliceId,
+ initialFilters: [],
+ formData: chart.form_data as unknown as QueryFormData,
+ ...overrides,
+ };
+ return render(<DrillDetailModal {...props} />, {
+ useRedux: true,
+ useRouter: true,
+ store,
+ });
+};
+const waitForRender = (overrides: Record<string, any> = {}) =>
+ waitFor(() => setup(overrides));
Review Comment:
In general, I think there are a lot of reusable helpers that we can create for these RTL tests. This could be an interesting project in order to enforce/suggest certain standards in writing RTL tests. CC @rusackas
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] kgabryje commented on a diff in pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
kgabryje commented on code in PR #21148:
URL: https://github.com/apache/superset/pull/21148#discussion_r954963623
##########
superset-frontend/src/components/Chart/DrillDetailModal.test.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 { render, screen, waitFor } from 'spec/helpers/testing-library';
+import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore';
+import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries';
+import { QueryFormData } from '@superset-ui/core';
+import fetchMock from 'fetch-mock';
+import userEvent from '@testing-library/user-event';
+import DrillDetailModal from './DrillDetailModal';
+
+const chart = chartQueries[sliceId];
+const setup = (overrides: Record<string, any> = {}) => {
+ const store = getMockStoreWithNativeFilters();
+ const props = {
+ chartId: sliceId,
+ initialFilters: [],
+ formData: chart.form_data as unknown as QueryFormData,
+ ...overrides,
+ };
+ return render(<DrillDetailModal {...props} />, {
+ useRedux: true,
+ useRouter: true,
+ store,
+ });
+};
+const waitForRender = (overrides: Record<string, any> = {}) =>
+ waitFor(() => setup(overrides));
Review Comment:
Oh that's interesting. Does it mean that we should use this pattern in other components too? Maybe this should be a helper function in `spec/helpers`?
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] github-actions[bot] commented on pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21148:
URL: https://github.com/apache/superset/pull/21148#issuecomment-1228428020
Storybook has completed and can be viewed at
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] geido merged pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
geido merged PR #21148:
URL: https://github.com/apache/superset/pull/21148
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] michael-s-molina commented on a diff in pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
michael-s-molina commented on code in PR #21148:
URL: https://github.com/apache/superset/pull/21148#discussion_r955349889
##########
superset-frontend/src/components/Chart/DrillDetailModal.test.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 { render, screen, waitFor } from 'spec/helpers/testing-library';
+import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore';
+import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries';
+import { QueryFormData } from '@superset-ui/core';
+import fetchMock from 'fetch-mock';
+import userEvent from '@testing-library/user-event';
+import DrillDetailModal from './DrillDetailModal';
+
+const chart = chartQueries[sliceId];
+const setup = (overrides: Record<string, any> = {}) => {
+ const store = getMockStoreWithNativeFilters();
+ const props = {
+ chartId: sliceId,
+ initialFilters: [],
+ formData: chart.form_data as unknown as QueryFormData,
+ ...overrides,
+ };
+ return render(<DrillDetailModal {...props} />, {
+ useRedux: true,
+ useRouter: true,
+ store,
+ });
+};
+const waitForRender = (overrides: Record<string, any> = {}) =>
+ waitFor(() => setup(overrides));
Review Comment:
You can also use `findBy` in many of these tests if you want to wait for the async operations. [findBy](https://testing-library.com/docs/dom-testing-library/api-async/#findby-queries) is essentially the combination of `getBy` and `waitFor`. So this:
```
test('should render the title', async () => {
await waitForRender();
expect(
screen.getByText(`Drill to detail: ${chart.form_data.slice_name}`),
).toBeInTheDocument();
});
```
Could be written as:
```
test('should render the title', async () => {
setup();
expect(
await screen.findByText(`Drill to detail: ${chart.form_data.slice_name}`),
).toBeInTheDocument();
});
```
Either way, the important thing is to account for the async nature of the component as you did.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] geido commented on a diff in pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
geido commented on code in PR #21148:
URL: https://github.com/apache/superset/pull/21148#discussion_r954960264
##########
superset-frontend/src/components/Chart/DrillDetailModal.test.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 { render, screen, waitFor } from 'spec/helpers/testing-library';
+import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore';
+import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries';
+import { QueryFormData } from '@superset-ui/core';
+import fetchMock from 'fetch-mock';
+import userEvent from '@testing-library/user-event';
+import DrillDetailModal from './DrillDetailModal';
+
+const chart = chartQueries[sliceId];
+const setup = (overrides: Record<string, any> = {}) => {
+ const store = getMockStoreWithNativeFilters();
+ const props = {
+ chartId: sliceId,
+ initialFilters: [],
+ formData: chart.form_data as unknown as QueryFormData,
+ ...overrides,
+ };
+ return render(<DrillDetailModal {...props} />, {
+ useRedux: true,
+ useRouter: true,
+ store,
+ });
+};
+const waitForRender = (overrides: Record<string, any> = {}) =>
+ waitFor(() => setup(overrides));
Review Comment:
@kgabryje in this component there are several async events that would fire warnings during the test runs if we don't wait for the component to be fully loaded. Hence the reason for this.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] github-actions[bot] commented on pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21148:
URL: https://github.com/apache/superset/pull/21148#issuecomment-1226195874
Storybook has completed and can be viewed at
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] kgabryje commented on a diff in pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
kgabryje commented on code in PR #21148:
URL: https://github.com/apache/superset/pull/21148#discussion_r954955425
##########
superset-frontend/src/components/Chart/DrillDetailModal.test.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 { render, screen, waitFor } from 'spec/helpers/testing-library';
+import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore';
+import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries';
+import { QueryFormData } from '@superset-ui/core';
+import fetchMock from 'fetch-mock';
+import userEvent from '@testing-library/user-event';
+import DrillDetailModal from './DrillDetailModal';
+
+const chart = chartQueries[sliceId];
+const setup = (overrides: Record<string, any> = {}) => {
+ const store = getMockStoreWithNativeFilters();
+ const props = {
+ chartId: sliceId,
+ initialFilters: [],
+ formData: chart.form_data as unknown as QueryFormData,
+ ...overrides,
+ };
+ return render(<DrillDetailModal {...props} />, {
+ useRedux: true,
+ useRouter: true,
+ store,
+ });
+};
+const waitForRender = (overrides: Record<string, any> = {}) =>
+ waitFor(() => setup(overrides));
Review Comment:
Is it really needed? Don't we always wait for render by default?
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] github-actions[bot] commented on pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21148:
URL: https://github.com/apache/superset/pull/21148#issuecomment-1228375421
Storybook has completed and can be viewed at
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] github-actions[bot] commented on pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21148:
URL: https://github.com/apache/superset/pull/21148#issuecomment-1228438551
Storybook has completed and can be viewed at
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] github-actions[bot] commented on pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #21148:
URL: https://github.com/apache/superset/pull/21148#issuecomment-1228487868
Storybook has completed and can be viewed at
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
[GitHub] [superset] geido commented on a diff in pull request #21148: chore: Drill to detail Modal tests
Posted by GitBox <gi...@apache.org>.
geido commented on code in PR #21148:
URL: https://github.com/apache/superset/pull/21148#discussion_r954979496
##########
superset-frontend/src/components/Chart/DrillDetailModal.test.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 { render, screen, waitFor } from 'spec/helpers/testing-library';
+import { getMockStoreWithNativeFilters } from 'spec/fixtures/mockStore';
+import chartQueries, { sliceId } from 'spec/fixtures/mockChartQueries';
+import { QueryFormData } from '@superset-ui/core';
+import fetchMock from 'fetch-mock';
+import userEvent from '@testing-library/user-event';
+import DrillDetailModal from './DrillDetailModal';
+
+const chart = chartQueries[sliceId];
+const setup = (overrides: Record<string, any> = {}) => {
+ const store = getMockStoreWithNativeFilters();
+ const props = {
+ chartId: sliceId,
+ initialFilters: [],
+ formData: chart.form_data as unknown as QueryFormData,
+ ...overrides,
+ };
+ return render(<DrillDetailModal {...props} />, {
+ useRedux: true,
+ useRouter: true,
+ store,
+ });
+};
+const waitForRender = (overrides: Record<string, any> = {}) =>
+ waitFor(() => setup(overrides));
Review Comment:
@kgabryje not sure if it is worth creating a function that takes a component and wraps it in a waitFor while also taking eventual overrides but if you think it can help I am happy to create it in a separate PR.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org