Skip to content

Commit

Permalink
Fixed tests errors
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexisD02 committed Sep 16, 2024
1 parent 431cb74 commit b52f5b9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe('Connectors List Page', () => {
it('renders header without create button for readonly cluster', async () => {
await renderComponent({ ...initialValue, isReadOnly: true });
expect(
screen.getByRole('heading', { name: 'Connectors' })
screen.getByRole('heading', { name: /local \/ Connectors/ })
).toBeInTheDocument();
expect(
screen.queryByRole('link', { name: 'Create Connector' })
Expand All @@ -59,7 +59,7 @@ describe('Connectors List Page', () => {
it('renders header with create button for read/write cluster', async () => {
await renderComponent();
expect(
screen.getByRole('heading', { name: 'Connectors' })
screen.getByRole('heading', { name: /local \/ Connectors/ })
).toBeInTheDocument();
expect(
screen.getByRole('link', { name: 'Create Connector' })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import React from 'react';
import { screen } from '@testing-library/react';
import { Cluster, ClusterFeaturesEnum } from 'generated-sources';
import ClusterMenu from 'components/Nav/ClusterMenu/ClusterMenu';
import userEvent from '@testing-library/user-event';
import { clusterConnectorsPath } from 'lib/paths';
import { render } from 'lib/testHelpers';
import { onlineClusterPayload } from 'lib/fixtures/clusters';
Expand Down Expand Up @@ -31,8 +30,6 @@ describe('ClusterMenu', () => {
render(setupComponent(onlineClusterPayload));
expect(getCluster()).toBeInTheDocument();

expect(getMenuItems().length).toEqual(1);
await userEvent.click(getMenuItem());
expect(getMenuItems().length).toEqual(4);

expect(getBrokers()).toBeInTheDocument();
Expand All @@ -50,8 +47,6 @@ describe('ClusterMenu', () => {
],
})
);
expect(getMenuItems().length).toEqual(1);
await userEvent.click(getMenuItem());
expect(getMenuItems().length).toEqual(7);

expect(getBrokers()).toBeInTheDocument();
Expand Down Expand Up @@ -80,8 +75,6 @@ describe('ClusterMenu', () => {
}),
{ initialEntries: [clusterConnectorsPath(onlineClusterPayload.name)] }
);
expect(getMenuItems().length).toEqual(1);
await userEvent.click(getMenuItem());
expect(getMenuItems().length).toEqual(5);

const kafkaConnect = getKafkaConnect();
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Nav/__tests__/Nav.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ describe('Nav', () => {

it('renders ClusterMenu', () => {
renderComponent([onlineClusterPayload, offlineClusterPayload]);
expect(screen.getAllByRole('menu').length).toEqual(3);
expect(getMenuItemsCount()).toEqual(3);
expect(screen.getAllByRole('menu').length).toEqual(5);
expect(getMenuItemsCount()).toEqual(9);
expect(getDashboard()).toBeInTheDocument();
expect(screen.getByText(onlineClusterPayload.name)).toBeInTheDocument();
expect(screen.getByText(offlineClusterPayload.name)).toBeInTheDocument();
Expand Down
12 changes: 6 additions & 6 deletions frontend/src/components/Topics/New/__test__/New.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,24 @@ describe('New', () => {
}));
});
it('checks header for create new', async () => {
await act(() => {
await act(async () => {
renderComponent(clusterTopicNewPath(clusterName));
});
expect(screen.getByRole('heading', { name: 'Create' })).toBeInTheDocument();
expect(screen.getByRole('heading', { name: /local \/ Topics \/ Create/ })).toBeInTheDocument();

Check warning on line 48 in frontend/src/components/Topics/New/__test__/New.spec.tsx

View workflow job for this annotation

GitHub Actions / build / build-and-test

Replace `screen.getByRole('heading',·{·name:·/local·\/·Topics·\/·Create/·})` with `⏎······screen.getByRole('heading',·{·name:·/local·\/·Topics·\/·Create/·})⏎····`
});

it('checks header for copy', async () => {
await act(() => {
await act(async () => {
renderComponent(`${clusterTopicCopyPath(clusterName)}?name=test`);
});
expect(screen.getByRole('heading', { name: 'Copy' })).toBeInTheDocument();
expect(screen.getByRole('heading', { name: /local \/ Topics \/ Copy/ })).toBeInTheDocument();

Check warning on line 55 in frontend/src/components/Topics/New/__test__/New.spec.tsx

View workflow job for this annotation

GitHub Actions / build / build-and-test

Replace `screen.getByRole('heading',·{·name:·/local·\/·Topics·\/·Copy/·})` with `⏎······screen.getByRole('heading',·{·name:·/local·\/·Topics·\/·Copy/·})⏎····`
});
it('validates form', async () => {
renderComponent(clusterTopicNewPath(clusterName));
await userEvent.type(screen.getByPlaceholderText('Topic Name'), topicName);
await userEvent.clear(screen.getByPlaceholderText('Topic Name'));
await userEvent.tab();
await expect(
expect(

Check warning on line 62 in frontend/src/components/Topics/New/__test__/New.spec.tsx

View workflow job for this annotation

GitHub Actions / build / build-and-test

Replace `⏎······screen.getByText('Topic·Name·is·required')⏎····` with `screen.getByText('Topic·Name·is·required')`
screen.getByText('Topic Name is required')
).toBeInTheDocument();
await userEvent.type(
Expand All @@ -68,7 +68,7 @@ describe('New', () => {
);
await userEvent.clear(screen.getByLabelText('Number of Partitions *'));
await userEvent.tab();
await expect(
expect(
screen.getByText('Number of Partitions is required and must be a number')
).toBeInTheDocument();

Expand Down

0 comments on commit b52f5b9

Please sign in to comment.