sadpandajoe commented on code in PR #38776:
URL: https://github.com/apache/superset/pull/38776#discussion_r2968200059


##########
superset-frontend/src/SqlLab/components/TableExploreTree/TableExploreTree.test.tsx:
##########
@@ -74,6 +79,7 @@ beforeEach(() => {
 afterEach(() => {
   jest.clearAllMocks();
   fetchMock.clearHistory();
+  cleanupExtensions();

Review Comment:
   Pre-existing issue — the `beforeEach` at line 58 re-registers all 4 routes 
every test, so the stale route from the loading-skeleton test is overwritten 
before the next test runs. The route leak is technically real but benign here. 
Out of scope for this PR (no behavioral change to TableExploreTree tests).



##########
superset-frontend/src/SqlLab/extensionContracts.test.tsx:
##########
@@ -0,0 +1,92 @@
+/**
+ * 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';
+
+afterEach(cleanupExtensions);
+
+test('disposing a registered view removes it from rendering', () => {
+  const disposable = views.registerView(
+    { id: 'dispose-test', name: 'Dispose Test' },
+    ViewLocations.sqllab.statusBar,

Review Comment:
   Intentional — this test exercises the raw `views.registerView().dispose()` 
contract directly. Using `registerTestView` would hide the dispose call behind 
the helper's `afterEach` cleanup, which is exactly what we're testing. The 
`cleanupExtensions()` in `afterEach` handles cleanup if the assertion throws 
before `dispose()` runs.



##########
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:
   Duplicate of earlier comment — see reply above. Intentional design: testing 
the raw dispose contract.



-- 
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]

Reply via email to