sravani-revuri commented on code in PR #11417: URL: https://github.com/apache/ozone/pull/11417#discussion_r4245508081
########## hadoop-ozone/recon/src/main/resources/webapps/recon/ozone-recon-web/src/__tests__/containers/Containers.test.tsx: ########## @@ -0,0 +1,222 @@ +/* + * 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 { fireEvent, render, screen, waitFor } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; +import { http, HttpResponse } from 'msw'; +import { vi } from 'vitest'; + +import Containers from '@/v2/pages/containers/containers'; +import * as commonUtils from '@/utils/common'; +import { ClusterState } from '@tests/mocks/overviewMocks/overviewResponseMocks'; +import { containersServer } from '@tests/mocks/containerMocks/containersServer'; +import * as containerMocks from '@tests/mocks/containerMocks/containerResponseMocks'; +import { containerLocators, searchInputLocator } from '@tests/locators/locators'; +import { waitForContainerRows } from '@tests/utils/containers.utils'; + +vi.spyOn(commonUtils, 'showDataFetchError'); + +vi.mock('@/components/autoReloadPanel/autoReloadPanel', () => ({ + default: () => <div data-testid="auto-reload-panel" />, +})); +vi.mock('@/v2/components/select/multiSelect.tsx', () => ({ + default: ({ onChange }: { onChange: Function }) => ( + <select data-testid="multi-select" onChange={(e) => onChange(e.target.value)}> + <option value="containerID">Container ID</option> + <option value="pipelineID">Pipeline ID</option> + </select> + ), +})); + +vi.mock('@/v2/hooks/useAPIData.hook', async (importOriginal) => { + const actual = await importOriginal<typeof import('@/v2/hooks/useAPIData.hook')>(); + return { + ...actual, + useApiData: <T,>(url: string, defaultValue: T, options = {}) => { + if (url === '/api/v1/clusterState') { Review Comment: The server already handles /api/v1/clusterState and the test assertions do pass, but vitest run reports unhandled CanceledErrors on that URL without this check . Containers fetches clusterState twice on mount (initialFetch: true + clusterState.refetch() from autoReload), so the second request aborts the first and that rejection isn’t caught. I checked out how pipelines is doing it and it uses initialFetch: false instead hence it doesn't face this problem. I've currently added a comment to justify this, happy to drop / modify in a follow-up accordingly. <img width="1144" height="242" alt="Image" src="https://github.com/user-attachments/assets/9a96a56d-387e-4133-a9eb-760a74b4a772" /> -- 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]
