From 295cd782d941a115998ba100318c2ce1c42fc9c5 Mon Sep 17 00:00:00 2001 From: Patrick Ear Date: Thu, 19 Sep 2024 17:26:47 +0200 Subject: [PATCH] move timeout --- .../locations/__tests__/LocationList.test.tsx | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 src/react/locations/__tests__/LocationList.test.tsx diff --git a/src/react/locations/__tests__/LocationList.test.tsx b/src/react/locations/__tests__/LocationList.test.tsx new file mode 100644 index 000000000..4207558f6 --- /dev/null +++ b/src/react/locations/__tests__/LocationList.test.tsx @@ -0,0 +1,66 @@ +import { + screen, + waitFor, + 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'; + +jest.setTimeout(30_000); + +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(() => { + 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 defaultArtescaLocationRow = screen.getByRole('row', { + name: /us-east-1 Storage Service for ARTESCA/i, + }); + //V + await waitFor(() => { + expect( + within(defaultArtescaLocationRow).getByRole('button', { + name: /Edit Location/i, + }), + ).toBeDisabled(); + }); + }); +});