From e9af4a82e3204b80f7e02bdb2c94b7687f86920a Mon Sep 17 00:00:00 2001 From: YanJin Date: Mon, 1 Jul 2024 15:31:35 +0200 Subject: [PATCH] temp --- src/js/mock/managementClientMSWHandlers.ts | 11 ++++ src/react/locations/LocationsList.tsx | 3 +- .../locations/__tests__/LocationList.test.tsx | 62 +++++++++++++++++++ 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 src/react/locations/__tests__/LocationList.test.tsx diff --git a/src/js/mock/managementClientMSWHandlers.ts b/src/js/mock/managementClientMSWHandlers.ts index f02b6a7b7..8210d1c8d 100644 --- a/src/js/mock/managementClientMSWHandlers.ts +++ b/src/js/mock/managementClientMSWHandlers.ts @@ -155,6 +155,17 @@ export const LOCATIONS = { name: azureblobstorage, details: {}, }, + 'us-east-2': { + details: { + bootstrapList: [ + 'artesca-storage-service-hdservice-proxy.xcore.svc:18888', + ], + repoId: null, + }, + locationType: 'location-scality-hdclient-v2', + name: 'us-east-2', + objectId: '22f31240-4bd3-11ee-98b3-1e5b6f897bc7', + }, }; export const ENDPOINTS = [ diff --git a/src/react/locations/LocationsList.tsx b/src/react/locations/LocationsList.tsx index f758c5031..96fc08342 100644 --- a/src/react/locations/LocationsList.tsx +++ b/src/react/locations/LocationsList.tsx @@ -178,6 +178,7 @@ const ActionButtons = ({ variant="danger" onClick={() => setShowModal(true)} type="button" + aria-label="Delete Location" tooltip={{ overlay: , overlayStyle: { textAlign: 'left' }, @@ -220,7 +221,7 @@ export function LocationsList() { const loadingBuckets = useSelector( (state: AppState) => state.networkActivity.counter > 0, ); - + console.log({ data }); const SEARCH_QUERY_PARAM = 'search'; const columns = useMemo(() => { const dataUsedColumn = getDataUsedColumn( diff --git a/src/react/locations/__tests__/LocationList.test.tsx b/src/react/locations/__tests__/LocationList.test.tsx new file mode 100644 index 000000000..9ac0e6736 --- /dev/null +++ b/src/react/locations/__tests__/LocationList.test.tsx @@ -0,0 +1,62 @@ +import { + screen, + waitForElementToBeRemoved, + within, +} from '@testing-library/react'; +import { setupServer } from 'msw/node'; +import { rest } from 'msw'; +import { + getConfigOverlay, + getStorageConsumptionMetricsHandlers, +} from '../../../js/mock/managementClientMSWHandlers'; +import { + TEST_API_BASE_URL, + mockOffsetSize, + renderWithRouterMatch, + zenkoUITestConfig, +} from '../../utils/testUtil'; +import { INSTANCE_ID } from '../../actions/__tests__/utils/testUtil'; +import { LocationsList } from '../LocationsList'; + +const server = setupServer( + getConfigOverlay(TEST_API_BASE_URL, INSTANCE_ID), + ...getStorageConsumptionMetricsHandlers( + zenkoUITestConfig.managementEndpoint, + INSTANCE_ID, + ), + rest.get( + `${TEST_API_BASE_URL}/api/v1/instance/${INSTANCE_ID}/status`, + (req, res, ctx) => res(ctx.json({})), + ), +); + +describe('LocationList', () => { + beforeAll(() => { + jest.setTimeout(20_000); + mockOffsetSize(500, 100); + server.listen({ onUnhandledRequest: 'error' }); + }); + afterEach(() => { + server.resetHandlers(); + }); + afterAll(() => { + server.close(); + }); + it('should disable the delete button for default location', async () => { + //S + renderWithRouterMatch(); + //E + await waitForElementToBeRemoved(() => [ + ...screen.queryAllByText(/Loading/i), + ]); + const hdLocationRow = screen.getByRole('row', { + name: /us-east-2 Storage Service for ARTESCA/i, + }); + //V + expect( + within(hdLocationRow).getByRole('button', { + name: /Delete Location/i, + }), + ).toBeDisabled(); + }); +});