3 * Copyright (C) 2009-2023 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 import { screen } from '@testing-library/react';
21 import userEvent from '@testing-library/user-event';
22 import * as React from 'react';
23 import BranchesServiceMock from '../../../../../../../api/mocks/BranchesServiceMock';
24 import { renderComponent } from '../../../../../../../helpers/testReactTestingUtils';
25 import RegulatoryReport from '../RegulatoryReport';
27 jest.mock('../../../../../../../api/branches');
29 let handler: BranchesServiceMock;
32 handler = new BranchesServiceMock();
35 afterEach(() => handler.resetBranches());
37 it('should open the regulatory report page', async () => {
38 const user = userEvent.setup();
39 renderRegulatoryReportApp();
40 expect(await screen.findByText('regulatory_report.page')).toBeInTheDocument();
41 expect(screen.getByText('regulatory_report.description1')).toBeInTheDocument();
42 expect(screen.getByText('regulatory_report.description2')).toBeInTheDocument();
44 screen.getByText('regulatory_page.available_branches_info.only_keep_when_inactive')
45 ).toBeInTheDocument();
46 expect(screen.getByText('regulatory_page.available_branches_info.more_info')).toBeInTheDocument();
48 const branchSelect = screen.getByRole('combobox', { name: 'regulatory_page.select_branch' });
49 expect(branchSelect).toBeInTheDocument();
51 await user.click(branchSelect);
52 await user.keyboard('[ArrowDown][Enter]');
54 const downloadButton = screen.getByText('download_verb');
55 expect(downloadButton).toBeInTheDocument();
57 expect(screen.queryByText('regulatory_page.download_start.sentence')).not.toBeInTheDocument();
58 await user.click(downloadButton);
59 expect(screen.getByText('regulatory_page.download_start.sentence')).toBeInTheDocument();
62 function renderRegulatoryReportApp() {
63 renderComponent(<RegulatoryReport component={{ key: '', name: '' }} onClose={() => {}} />);