Skip to content

Commit

Permalink
EES-5558 - responding to PR comments. Removing navigation check from …
Browse files Browse the repository at this point in the history
…tests as it is not necessary to test.
  • Loading branch information
duncan-at-hiveit committed Dec 2, 2024
1 parent 3fcdf91 commit 029fc49
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import WarningMessage from '@common/components/WarningMessage';
import useToggle from '@common/hooks/useToggle';
import { useQuery } from '@tanstack/react-query';
import React, { ReactNode } from 'react';
import { generatePath, useHistory } from 'react-router-dom';
import { generatePath } from 'react-router-dom';
import releaseDataPageTabIds from '@admin/pages/release/data/utils/releaseDataPageTabIds';

interface Props {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import _apiDataSetCandidateService, {
} from '@admin/services/apiDataSetCandidateService';
import _apiDataSetService from '@admin/services/apiDataSetService';
import baseRender from '@common-test/render';
import { screen, waitFor } from '@testing-library/react';
import { screen, waitFor, within } from '@testing-library/react';
import { createMemoryHistory, History } from 'history';
import noop from 'lodash/noop';
import { ReactElement } from 'react';
Expand All @@ -29,8 +29,6 @@ describe('ApiDataSetCreateModal', () => {
];

test('renders warning message in modal when no candidates', async () => {
const history = createMemoryHistory();

apiDataSetCandidateService.listCandidates.mockResolvedValue([]);

const { user } = render(
Expand All @@ -39,7 +37,6 @@ describe('ApiDataSetCreateModal', () => {
releaseId="release-id"
onSubmit={noop}
/>,
{ history },
);

expect(await screen.findByText('Create API data set')).toBeInTheDocument();
Expand All @@ -50,26 +47,22 @@ describe('ApiDataSetCreateModal', () => {

expect(screen.getByRole('button', { name: 'Close' })).toBeInTheDocument();

const modal = within(screen.getByRole('dialog'));

expect(
screen.getByText(
modal.getByText(
/No API data sets can be created as there are no candidate data files available/,
),
).toBeInTheDocument();

expect(
await screen.findByRole('link', { name: 'Data and files' }),
).toBeInTheDocument();
expect(modal.getByRole('link', { name: 'Data and files' })).toHaveAttribute(
'href',
'/publication/publication-id/release/release-id/data#data-uploads',
);

await user.click(screen.getByRole('link', { name: 'Data and files' }));

expect(
screen.queryByRole('link', { name: 'Data and files' }),
).not.toBeInTheDocument();

expect(history.location.pathname).toEqual(
'/publication/publication-id/release/release-id/data',
);
expect(history.location.hash).toEqual('#data-uploads');
expect(screen.queryByRole('dialog')).not.toBeInTheDocument();
});

test('renders form in modal when there are candidates', async () => {
Expand Down

0 comments on commit 029fc49

Please sign in to comment.