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 const branchSelect = screen.getByRole('textbox');
45 expect(branchSelect).toBeInTheDocument();
47 await user.click(branchSelect);
48 await user.keyboard('[ArrowDown][Enter]');
50 const downloadButton = screen.getByText('download_verb');
51 expect(downloadButton).toBeInTheDocument();
53 expect(screen.queryByText('regulatory_page.download_start.sentence')).not.toBeInTheDocument();
54 await user.click(downloadButton);
55 expect(screen.getByText('regulatory_page.download_start.sentence')).toBeInTheDocument();
58 function renderRegulatoryReportApp() {
59 renderComponent(<RegulatoryReport component={{ key: '', name: '' }} onClose={() => {}} />);