Skip to content

Commit

Permalink
temp
Browse files Browse the repository at this point in the history
  • Loading branch information
ChengYanJin committed Jul 1, 2024
1 parent 77dd4d4 commit 06eb269
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/js/mock/managementClientMSWHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,17 +144,22 @@ export const LOCATIONS = {
name: 'ring-nick',
objectId: '99a06f79-c62c-11ec-b993-7e8a0ab79998',
},
'us-east-1': {
isBuiltin: true,
locationType: 'location-file-v1',
name: 'us-east-1',
objectId: '95dbedf5-9888-11ec-8565-1ac2af7d1e53',
},
[azureblobstorage]: {
locationType: 'location-azure-v1',
name: azureblobstorage,
details: {},
},
'us-east-1': {
details: {
bootstrapList: [
'artesca-storage-service-hdservice-proxy.xcore.svc:18888',
],
repoId: null,
},
locationType: 'location-scality-hdclient-v2',
name: 'us-east-1',
objectId: '22f31240-4bd3-11ee-98b3-1e5b6f897bc7',
},
};

export const ENDPOINTS = [
Expand Down
2 changes: 1 addition & 1 deletion src/react/locations/LocationsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ const ActionButtons = ({
variant="danger"
onClick={() => setShowModal(true)}
type="button"
aria-label="Delete Location"
tooltip={{
overlay: <TooltipOverlay />,
overlayStyle: { textAlign: 'left' },
Expand Down Expand Up @@ -220,7 +221,6 @@ export function LocationsList() {
const loadingBuckets = useSelector(
(state: AppState) => state.networkActivity.counter > 0,
);

const SEARCH_QUERY_PARAM = 'search';
const columns = useMemo(() => {
const dataUsedColumn = getDataUsedColumn(
Expand Down
62 changes: 62 additions & 0 deletions src/react/locations/__tests__/LocationList.test.tsx
Original file line number Diff line number Diff line change
@@ -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(<LocationsList />);
//E
await waitForElementToBeRemoved(() => [
...screen.queryAllByText(/Loading/i),
]);
const hdLocationRow = screen.getByRole('row', {
name: /us-east-1 Storage Service for ARTESCA/i,
});
//V
expect(
within(hdLocationRow).getByRole('button', {
name: /Delete Location/i,
}),
).toBeDisabled();
});
});

0 comments on commit 06eb269

Please sign in to comment.