yardz commented on a change in pull request #13931: URL: https://github.com/apache/superset/pull/13931#discussion_r607099277
########## File path: superset-frontend/src/dashboard/components/PropertiesModal/PropertiesModal.test.tsx ########## @@ -0,0 +1,319 @@ +/** + * 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 fetchMock from 'fetch-mock'; +import userEvent from '@testing-library/user-event'; +import * as ColorSchemeControlWrapper from 'src/dashboard/components/ColorSchemeControlWrapper'; +import * as FF from 'src/featureFlags'; +import * as SupersetCore from '@superset-ui/core'; +import PropertiesModal from '.'; + +const spyIsFeatureEnabled = jest.spyOn(FF, 'isFeatureEnabled'); +const spyColorSchemeControlWrapper = jest.spyOn( + ColorSchemeControlWrapper, + 'default', +); + +spyColorSchemeControlWrapper.mockImplementation( + () => (<div>ColorSchemeControlWrapper</div>) as any, +); + +fetchMock.get( + 'http://localhost/api/v1/dashboard/related/roles?q=(filter:%27%27)', + { + body: { + count: 6, + result: [ + { + text: 'Admin', + value: 1, + }, + { + text: 'Alpha', + value: 3, + }, + { + text: 'Gamma', + value: 4, + }, + { + text: 'granter', + value: 5, + }, + { + text: 'Public', + value: 2, + }, + { + text: 'sql_lab', + value: 6, + }, + ], + }, + }, +); + +fetchMock.get( + 'http://localhost/api/v1/dashboard/related/owners?q=(filter:%27%27)', + { + body: { + count: 1, + result: [ + { + text: 'Superset Admin', + value: 1, + }, + ], + }, + }, +); + +fetchMock.get('http://localhost/api/v1/dashboard/26', { + body: { + result: { + changed_by: null, + changed_by_name: '', + changed_by_url: '', + changed_on: '2021-03-30T19:30:14.020942', + charts: [ + 'Vaccine Candidates per Country & Stage', + 'Vaccine Candidates per Country', + 'Vaccine Candidates per Country', + 'Vaccine Candidates per Approach & Stage', + 'Vaccine Candidates per Phase', + 'Vaccine Candidates per Phase', + 'Vaccine Candidates per Country & Stage', + 'Filtering Vaccines', + ], + css: '', + dashboard_title: 'COVID Vaccine Dashboard', + id: 26, + json_metadata: + '{"timed_refresh_immune_slices": [], "expanded_slices": {}, "refresh_frequency": 0, "default_filters": "{}", "color_scheme": "supersetColors", "label_colors": {"0": "#D3B3DA", "1": "#9EE5E5", "0. Pre-clinical": "#1FA8C9", "2. Phase II or Combined I/II": "#454E7C", "1. Phase I": "#5AC189", "3. Phase III": "#FF7F44", "4. Authorized": "#666666", "root": "#1FA8C9", "Protein subunit": "#454E7C", "Phase II": "#5AC189", "Pre-clinical": "#FF7F44", "Phase III": "#666666", "Phase I": "#E04355", "Phase I/II": "#FCC700", "Inactivated virus": "#A868B7", "Virus-like particle": "#3CCCCB", "Replicating bacterial vector": "#A38F79", "DNA-based": "#8FD3E4", "RNA-based vaccine": "#A1A6BD", "Authorized": "#ACE1C4", "Non-replicating viral vector": "#FEC0A1", "Replicating viral vector": "#B2B2B2", "Unknown": "#EFA1AA", "Live attenuated virus": "#FDE380", "COUNT(*)": "#D1C6BC"}, "filter_scopes": {"358": {"Country_Name": {"scope": ["ROOT_ID"], "immune": []}, "Product_Category": {"scope": ["ROOT_ID" ], "immune": []}, "Clinical Stage": {"scope": ["ROOT_ID"], "immune": []}}}}', + owners: [], + position_json: Review comment: This is a possibility, but given the lack of typing and organization it is very hard to know where these calls are being reused. I believe that this would be a future improvement, but not within the scope of this PR. Sharing something we don't know where and when it will be used, in the current state of the project seems to me more harmful than good. And we also have the problem that the reviewers of the other codes may not even know about the existence of these mocks... I agree that we need to centralize these things, but I think that now is not the time to do that. -- 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]
