bito-code-review[bot] commented on code in PR #37141: URL: https://github.com/apache/superset/pull/37141#discussion_r3718428534
########## superset-frontend/src/pages/Home/Home.mobile.test.tsx: ########## @@ -0,0 +1,179 @@ +/** + * 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. + */ + +/** + * Mobile-specific tests for the Home/Welcome page. + * + * These tests verify that certain desktop-only sections are hidden + * on mobile viewports. + */ + +import fetchMock from 'fetch-mock'; +import { render, screen, waitFor } from 'spec/helpers/testing-library'; +import Welcome from 'src/pages/Home'; + +import { mockMobileMatchMedia } from 'spec/helpers/mobileTestUtils'; + +// Enable only the mobile consumption mode flag so the mobile branch renders +jest.mock('@superset-ui/core', () => ({ + ...jest.requireActual('@superset-ui/core'), + isFeatureEnabled: jest.fn( + (flag: string) => flag === 'MOBILE_CONSUMPTION_MODE', + ), +})); + +// Simulate a mobile viewport for the useIsMobile hook +mockMobileMatchMedia(); Review Comment: <!-- Bito Reply --> The update correctly addresses the resource leak by capturing the cleanup function returned by the mock and invoking it within the `afterAll` block. This ensures that the `window.matchMedia` mock is properly restored after the tests complete, preventing potential side effects in subsequent test suites. ########## superset-frontend/src/pages/DashboardList/index.tsx: ########## @@ -177,6 +179,9 @@ const DASHBOARD_COLUMNS_TO_FETCH = [ function DashboardList(props: DashboardListProps) { const { addDangerToast, addSuccessToast, user } = props; + const isNotMobile = !useIsMobile(); Review Comment: <!-- Bito Reply --> The update correctly addresses the reviewer's suggestion by renaming the variable to `isMobile` and aligning the boolean logic with the `useIsMobile()` hook. This change improves code readability by removing the double-negative and simplifying conditional checks. **superset-frontend/src/pages/DashboardList/index.tsx** ``` function DashboardList(props: DashboardListProps) { const { addDangerToast, addSuccessToast, user } = props; const isMobile = useIsMobile(); ``` -- 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]
