chihsuan commented on code in PR #11417: URL: https://github.com/apache/ozone/pull/11417#discussion_r4246697407
########## 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: Thanks for digging into this! @sravani-revuri The double fetch also happens on the page itself, so I've opened HDDS-16877 as a follow-up, and #11484 fixes it. Since this PR will merge first, we can drop the special case in #11484. -- 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]
