Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Lines routing test #1367

Merged
merged 2 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@folio/stripes-acq-components": "^6.0.0",
"@folio/stripes-cli": "^3.2.0",
"@folio/stripes-erm-components": "^9.2.0",
"@folio/stripes-erm-testing": "^2.2.1",
"@folio/stripes-erm-testing": "^3.0.0",
"@formatjs/cli": "^6.1.3",
"classnames": ">=2.2.6",
"core-js": "^3.6.1",
Expand Down
97 changes: 82 additions & 15 deletions src/components/AgreementSections/Lines/Lines.test.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,39 @@

import { waitFor } from '@folio/jest-config-stripes/testing-library/react';
import { Accordion, Button, MultiColumnList, renderWithIntl } from '@folio/stripes-erm-testing';
import { MemoryRouter } from 'react-router-dom';
import { Accordion, Button, renderWithIntl } from '@folio/stripes-erm-testing';
import { MemoryRouter, Switch, Route } from 'react-router-dom';
import translationsProperties from '../../../../test/helpers';
import Lines from './Lines';
import { agreement, handlers } from './testResources';

jest.mock('../CoveredEResourcesList', () => () => (
<div>CoveredEResourcesList</div>
));

jest.mock('../LinesList', () => () => (
<div>LinesList</div>
));

describe('Lines', () => {
let renderComponent;
beforeEach(() => {
renderWithIntl(
renderComponent = renderWithIntl(
/* EXAMPLE testing "to" redirects using memory router */
<MemoryRouter>
<Lines
agreement={agreement}
handlers={handlers}
/>
<Switch>
<Route path="/erm/agreements/:agreementId/line/create">
Create agreement line
</Route>
<Route path="/erm/agreementLines">
View agreement lines
</Route>
<Route path="/">
<Lines
agreement={agreement}
handlers={handlers}
/>
</Route>
</Switch>
</MemoryRouter>,
translationsProperties
);
Expand All @@ -23,10 +43,27 @@ describe('Lines', () => {
await Accordion('Agreement lines').exists();
});

describe('Actions menu', () => {
test('renders LinesList component', async () => {
const { getByText } = renderComponent;
await waitFor(() => {
expect(getByText('LinesList')).toBeInTheDocument();
});
});

test('renders CoveredEResourcesList component', async () => {
const { getByText } = renderComponent;
await waitFor(() => {
expect(getByText('CoveredEResourcesList')).toBeInTheDocument();
});
});

test('actions menu exists', async () => {
await Button('Actions').exists();
});

describe('opening actions menu', () => {
beforeEach(async () => {
await waitFor(async () => {
await Button('Actions').exists();
await Button('Actions').click();
});
});
Expand All @@ -42,13 +79,43 @@ describe('Lines', () => {
await Button('View in agreement lines search').exists();
});
});
});

test('renders Lines list MCL', async () => {
await MultiColumnList('agreement-lines').exists();
});
test('renders ColumnManagerMenu component', async () => {
const { getByText } = renderComponent;
await waitFor(() => {
expect(getByText('ColumnManagerMenu')).toBeInTheDocument();
});
});


describe('clicking new agreement line button', () => {
beforeEach(async () => {
await waitFor(async () => {
await Button('New agreement line').click();
});
});

test('redirected to agreement line screen', async () => {
const { getByText } = renderComponent;
await waitFor(async () => {
expect(getByText('Create agreement line')).toBeInTheDocument();
});
});
});

describe('clicking view in agreement lines search button', () => {
beforeEach(async () => {
await waitFor(async () => {
await Button('View in agreement lines search').click();
});
});

test('renders covered e-resources MCL', async () => {
await MultiColumnList('eresources-covered').exists();
test('redirected to agreement line screen', async () => {
const { getByText } = renderComponent;
await waitFor(async () => {
expect(getByText('View agreement lines')).toBeInTheDocument();
});
});
});
});
});