Copilot commented on code in PR #38776: URL: https://github.com/apache/superset/pull/38776#discussion_r2968190590
########## superset-frontend/src/SqlLab/extensionContracts.test.tsx: ########## @@ -0,0 +1,97 @@ +/** + * 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 { views } from 'src/core'; +import PanelToolbar from 'src/components/PanelToolbar'; +import StatusBar from 'src/SqlLab/components/StatusBar'; +import { ViewLocations } from 'src/SqlLab/contributions'; +import { + registerTestView, + registerToolbarAction, + cleanupExtensions, +} from 'src/SqlLab/test-utils/extensionTestHelpers'; + +let consoleErrorSpy: jest.SpyInstance; + +afterEach(() => { + cleanupExtensions(); + if (consoleErrorSpy) { + consoleErrorSpy.mockRestore(); + } +}); + +test('disposing a registered view removes it from rendering', () => { + const disposable = views.registerView( + { id: 'dispose-test', name: 'Dispose Test' }, + ViewLocations.sqllab.statusBar, Review Comment: This test registers a view directly via `views.registerView` and relies on manually calling `disposable.dispose()` later. If an assertion fails before dispose is reached, the view registration can leak into subsequent tests. Use `registerTestView(...)` (it returns a disposable) or ensure disposal in a `try/finally` so cleanup is guaranteed even on failures. ```suggestion const disposable = registerTestView( ViewLocations.sqllab.statusBar, 'dispose-test', 'Dispose Test', ``` ########## superset-frontend/src/SqlLab/components/AppLayout/AppLayout.test.tsx: ########## @@ -94,10 +99,20 @@ test('calls setWidth on sidebar resize when not hidden', async () => { await waitFor(() => expect(setWidth).toHaveBeenCalled()); }); +test('right sidebar is hidden when no extensions registered', () => { + const { queryByText } = render(<AppLayout {...defaultProps} />, { + useRedux: true, + initialState, + }); + // No right sidebar content — the third Splitter.Panel is conditionally omitted + expect(queryByText('Right Sidebar Content')).not.toBeInTheDocument(); Review Comment: The "right sidebar is hidden" test only asserts that specific contributed text is absent, which would still pass if the right sidebar panel is rendered but empty. To actually verify the contract (third Splitter.Panel omitted), assert the panel count stays at 2 (or explicitly assert the right sidebar container/panel is not rendered). ```suggestion const { queryByText, getAllByTestId } = render( <AppLayout {...defaultProps} />, { useRedux: true, initialState, }, ); // No right sidebar content — the third Splitter.Panel is conditionally omitted expect(queryByText('Right Sidebar Content')).not.toBeInTheDocument(); // Ensure only the two expected panels (main layout) are rendered expect(getAllByTestId('mock-panel')).toHaveLength(2); ``` -- 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]
