michael-s-molina commented on code in PR #22064: URL: https://github.com/apache/superset/pull/22064#discussion_r1021577750
########## superset-frontend/src/dashboard/components/nativeFilters/FilterBar/HorizontalFilterBar.test.tsx: ########## @@ -0,0 +1,105 @@ +/** + * 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 { NativeFilterType } from '@superset-ui/core'; +import React from 'react'; +import { render, screen, waitFor } from 'spec/helpers/testing-library'; +import HorizontalBar from './Horizontal'; + +const defaultProps = { + actions: null, + canEdit: true, + dashboardId: 1, + dataMaskSelected: {}, + filterValues: [], + isInitialized: true, + onSelectionChange: jest.fn(), +}; + +const renderWrapper = (overrideProps?: Record<string, any>) => + waitFor(() => + render(<HorizontalBar {...defaultProps} {...overrideProps} />, { + useRedux: true, + }), + ); + +it('should render', async () => { + const { container } = await renderWrapper(); + expect(container).toBeInTheDocument(); +}); + +it('should not render the empty message', async () => { + await renderWrapper({ + filterValues: [ + { + id: 'test', + type: NativeFilterType.NATIVE_FILTER, + }, + ], + }); + expect( + screen.queryByText('No filters are currently added to this dashboard.'), + ).not.toBeInTheDocument(); +}); + +it('should render the empty message', async () => { + await renderWrapper(); + expect( + screen.getByText('No filters are currently added to this dashboard.'), + ).toBeInTheDocument(); +}); + +it('should render the gear icon', async () => { + await renderWrapper(); + expect(screen.getByRole('img', { name: 'gear' })).toBeInTheDocument(); +}); + +it('should not render the gear icon', async () => { + await renderWrapper({ + canEdit: false, + }); + + expect(screen.queryByRole('img', { name: 'gear' })).not.toBeInTheDocument(); +}); + +it('should not render the loading icon', async () => { + await renderWrapper(); + expect( + screen.queryByRole('status', { name: 'Loading' }), + ).not.toBeInTheDocument(); +}); + +it('should render the loading icon', async () => { + await renderWrapper({ + isInitialized: false, + }); + expect(screen.getByRole('status', { name: 'Loading' })).toBeInTheDocument(); +}); + +it('should render Add/Edit Filters', async () => { Review Comment: ```suggestion test('should render Add/Edit Filters', async () => { ``` ########## superset-frontend/src/dashboard/components/nativeFilters/FilterBar/HorizontalFilterBar.test.tsx: ########## @@ -0,0 +1,105 @@ +/** + * 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 { NativeFilterType } from '@superset-ui/core'; +import React from 'react'; +import { render, screen, waitFor } from 'spec/helpers/testing-library'; +import HorizontalBar from './Horizontal'; + +const defaultProps = { + actions: null, + canEdit: true, + dashboardId: 1, + dataMaskSelected: {}, + filterValues: [], + isInitialized: true, + onSelectionChange: jest.fn(), +}; + +const renderWrapper = (overrideProps?: Record<string, any>) => + waitFor(() => + render(<HorizontalBar {...defaultProps} {...overrideProps} />, { + useRedux: true, + }), + ); + +it('should render', async () => { Review Comment: ```suggestion test('should render', async () => { ``` ########## superset-frontend/src/dashboard/components/nativeFilters/FilterBar/HorizontalFilterBar.test.tsx: ########## @@ -0,0 +1,105 @@ +/** + * 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 { NativeFilterType } from '@superset-ui/core'; +import React from 'react'; +import { render, screen, waitFor } from 'spec/helpers/testing-library'; +import HorizontalBar from './Horizontal'; + +const defaultProps = { + actions: null, + canEdit: true, + dashboardId: 1, + dataMaskSelected: {}, + filterValues: [], + isInitialized: true, + onSelectionChange: jest.fn(), +}; + +const renderWrapper = (overrideProps?: Record<string, any>) => + waitFor(() => + render(<HorizontalBar {...defaultProps} {...overrideProps} />, { + useRedux: true, + }), + ); + +it('should render', async () => { + const { container } = await renderWrapper(); + expect(container).toBeInTheDocument(); +}); + +it('should not render the empty message', async () => { + await renderWrapper({ + filterValues: [ + { + id: 'test', + type: NativeFilterType.NATIVE_FILTER, + }, + ], + }); + expect( + screen.queryByText('No filters are currently added to this dashboard.'), + ).not.toBeInTheDocument(); +}); + +it('should render the empty message', async () => { + await renderWrapper(); + expect( + screen.getByText('No filters are currently added to this dashboard.'), + ).toBeInTheDocument(); +}); + +it('should render the gear icon', async () => { + await renderWrapper(); + expect(screen.getByRole('img', { name: 'gear' })).toBeInTheDocument(); +}); + +it('should not render the gear icon', async () => { + await renderWrapper({ + canEdit: false, + }); + + expect(screen.queryByRole('img', { name: 'gear' })).not.toBeInTheDocument(); +}); + +it('should not render the loading icon', async () => { Review Comment: ```suggestion test('should not render the loading icon', async () => { ``` ########## superset-frontend/src/dashboard/components/nativeFilters/FilterBar/HorizontalFilterBar.test.tsx: ########## @@ -0,0 +1,105 @@ +/** + * 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 { NativeFilterType } from '@superset-ui/core'; +import React from 'react'; +import { render, screen, waitFor } from 'spec/helpers/testing-library'; +import HorizontalBar from './Horizontal'; + +const defaultProps = { + actions: null, + canEdit: true, + dashboardId: 1, + dataMaskSelected: {}, + filterValues: [], + isInitialized: true, + onSelectionChange: jest.fn(), +}; + +const renderWrapper = (overrideProps?: Record<string, any>) => + waitFor(() => + render(<HorizontalBar {...defaultProps} {...overrideProps} />, { + useRedux: true, + }), + ); + +it('should render', async () => { + const { container } = await renderWrapper(); + expect(container).toBeInTheDocument(); +}); + +it('should not render the empty message', async () => { + await renderWrapper({ + filterValues: [ + { + id: 'test', + type: NativeFilterType.NATIVE_FILTER, + }, + ], + }); + expect( + screen.queryByText('No filters are currently added to this dashboard.'), + ).not.toBeInTheDocument(); +}); + +it('should render the empty message', async () => { + await renderWrapper(); + expect( + screen.getByText('No filters are currently added to this dashboard.'), + ).toBeInTheDocument(); +}); + +it('should render the gear icon', async () => { Review Comment: ```suggestion test('should render the gear icon', async () => { ``` ########## superset-frontend/src/dashboard/components/nativeFilters/FilterBar/HorizontalFilterBar.test.tsx: ########## @@ -0,0 +1,105 @@ +/** + * 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 { NativeFilterType } from '@superset-ui/core'; +import React from 'react'; +import { render, screen, waitFor } from 'spec/helpers/testing-library'; +import HorizontalBar from './Horizontal'; + +const defaultProps = { + actions: null, + canEdit: true, + dashboardId: 1, + dataMaskSelected: {}, + filterValues: [], + isInitialized: true, + onSelectionChange: jest.fn(), +}; + +const renderWrapper = (overrideProps?: Record<string, any>) => + waitFor(() => + render(<HorizontalBar {...defaultProps} {...overrideProps} />, { + useRedux: true, + }), + ); + +it('should render', async () => { + const { container } = await renderWrapper(); + expect(container).toBeInTheDocument(); +}); + +it('should not render the empty message', async () => { + await renderWrapper({ + filterValues: [ + { + id: 'test', + type: NativeFilterType.NATIVE_FILTER, + }, + ], + }); + expect( + screen.queryByText('No filters are currently added to this dashboard.'), + ).not.toBeInTheDocument(); +}); + +it('should render the empty message', async () => { + await renderWrapper(); + expect( + screen.getByText('No filters are currently added to this dashboard.'), + ).toBeInTheDocument(); +}); + +it('should render the gear icon', async () => { + await renderWrapper(); + expect(screen.getByRole('img', { name: 'gear' })).toBeInTheDocument(); +}); + +it('should not render the gear icon', async () => { Review Comment: ```suggestion test('should not render the gear icon', async () => { ``` ########## superset-frontend/src/dashboard/components/nativeFilters/FilterBar/HorizontalFilterBar.test.tsx: ########## @@ -0,0 +1,105 @@ +/** + * 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 { NativeFilterType } from '@superset-ui/core'; +import React from 'react'; +import { render, screen, waitFor } from 'spec/helpers/testing-library'; +import HorizontalBar from './Horizontal'; + +const defaultProps = { + actions: null, + canEdit: true, + dashboardId: 1, + dataMaskSelected: {}, + filterValues: [], + isInitialized: true, + onSelectionChange: jest.fn(), +}; + +const renderWrapper = (overrideProps?: Record<string, any>) => + waitFor(() => + render(<HorizontalBar {...defaultProps} {...overrideProps} />, { + useRedux: true, + }), + ); + +it('should render', async () => { + const { container } = await renderWrapper(); + expect(container).toBeInTheDocument(); +}); + +it('should not render the empty message', async () => { + await renderWrapper({ + filterValues: [ + { + id: 'test', + type: NativeFilterType.NATIVE_FILTER, + }, + ], + }); + expect( + screen.queryByText('No filters are currently added to this dashboard.'), + ).not.toBeInTheDocument(); +}); + +it('should render the empty message', async () => { Review Comment: ```suggestion test('should render the empty message', async () => { ``` ########## superset-frontend/src/dashboard/components/nativeFilters/FilterBar/HorizontalFilterBar.test.tsx: ########## @@ -0,0 +1,105 @@ +/** + * 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 { NativeFilterType } from '@superset-ui/core'; +import React from 'react'; +import { render, screen, waitFor } from 'spec/helpers/testing-library'; +import HorizontalBar from './Horizontal'; + +const defaultProps = { + actions: null, + canEdit: true, + dashboardId: 1, + dataMaskSelected: {}, + filterValues: [], + isInitialized: true, + onSelectionChange: jest.fn(), +}; + +const renderWrapper = (overrideProps?: Record<string, any>) => + waitFor(() => + render(<HorizontalBar {...defaultProps} {...overrideProps} />, { + useRedux: true, + }), + ); + +it('should render', async () => { + const { container } = await renderWrapper(); + expect(container).toBeInTheDocument(); +}); + +it('should not render the empty message', async () => { Review Comment: ```suggestion test('should not render the empty message', async () => { ``` ########## superset-frontend/src/dashboard/components/nativeFilters/FilterBar/HorizontalFilterBar.test.tsx: ########## @@ -0,0 +1,105 @@ +/** + * 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 { NativeFilterType } from '@superset-ui/core'; +import React from 'react'; +import { render, screen, waitFor } from 'spec/helpers/testing-library'; +import HorizontalBar from './Horizontal'; + +const defaultProps = { + actions: null, + canEdit: true, + dashboardId: 1, + dataMaskSelected: {}, + filterValues: [], + isInitialized: true, + onSelectionChange: jest.fn(), +}; + +const renderWrapper = (overrideProps?: Record<string, any>) => + waitFor(() => + render(<HorizontalBar {...defaultProps} {...overrideProps} />, { + useRedux: true, + }), + ); + +it('should render', async () => { + const { container } = await renderWrapper(); + expect(container).toBeInTheDocument(); +}); + +it('should not render the empty message', async () => { + await renderWrapper({ + filterValues: [ + { + id: 'test', + type: NativeFilterType.NATIVE_FILTER, + }, + ], + }); + expect( + screen.queryByText('No filters are currently added to this dashboard.'), + ).not.toBeInTheDocument(); +}); + +it('should render the empty message', async () => { + await renderWrapper(); + expect( + screen.getByText('No filters are currently added to this dashboard.'), + ).toBeInTheDocument(); +}); + +it('should render the gear icon', async () => { + await renderWrapper(); + expect(screen.getByRole('img', { name: 'gear' })).toBeInTheDocument(); +}); + +it('should not render the gear icon', async () => { + await renderWrapper({ + canEdit: false, + }); + + expect(screen.queryByRole('img', { name: 'gear' })).not.toBeInTheDocument(); +}); + +it('should not render the loading icon', async () => { + await renderWrapper(); + expect( + screen.queryByRole('status', { name: 'Loading' }), + ).not.toBeInTheDocument(); +}); + +it('should render the loading icon', async () => { Review Comment: ```suggestion test('should render the loading icon', async () => { ``` ########## superset-frontend/src/dashboard/components/nativeFilters/FilterBar/HorizontalFilterBar.test.tsx: ########## @@ -0,0 +1,105 @@ +/** + * 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 { NativeFilterType } from '@superset-ui/core'; +import React from 'react'; +import { render, screen, waitFor } from 'spec/helpers/testing-library'; +import HorizontalBar from './Horizontal'; + +const defaultProps = { + actions: null, + canEdit: true, + dashboardId: 1, + dataMaskSelected: {}, + filterValues: [], + isInitialized: true, + onSelectionChange: jest.fn(), +}; + +const renderWrapper = (overrideProps?: Record<string, any>) => + waitFor(() => + render(<HorizontalBar {...defaultProps} {...overrideProps} />, { + useRedux: true, + }), + ); + +it('should render', async () => { + const { container } = await renderWrapper(); + expect(container).toBeInTheDocument(); +}); + +it('should not render the empty message', async () => { + await renderWrapper({ + filterValues: [ + { + id: 'test', + type: NativeFilterType.NATIVE_FILTER, + }, + ], + }); + expect( + screen.queryByText('No filters are currently added to this dashboard.'), + ).not.toBeInTheDocument(); +}); + +it('should render the empty message', async () => { + await renderWrapper(); + expect( + screen.getByText('No filters are currently added to this dashboard.'), + ).toBeInTheDocument(); +}); + +it('should render the gear icon', async () => { + await renderWrapper(); + expect(screen.getByRole('img', { name: 'gear' })).toBeInTheDocument(); +}); + +it('should not render the gear icon', async () => { + await renderWrapper({ + canEdit: false, + }); + + expect(screen.queryByRole('img', { name: 'gear' })).not.toBeInTheDocument(); +}); + +it('should not render the loading icon', async () => { + await renderWrapper(); + expect( + screen.queryByRole('status', { name: 'Loading' }), + ).not.toBeInTheDocument(); +}); + +it('should render the loading icon', async () => { + await renderWrapper({ + isInitialized: false, + }); + expect(screen.getByRole('status', { name: 'Loading' })).toBeInTheDocument(); +}); + +it('should render Add/Edit Filters', async () => { + await renderWrapper(); + expect(screen.getByText('Add/Edit Filters')).toBeInTheDocument(); +}); + +it('should not render Add/Edit Filters', async () => { Review Comment: ```suggestion test('should not render Add/Edit Filters', async () => { ``` -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
