From 07b49a758a16926d455c69ccfa6f5aa7fb2a10db Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Thu, 23 Mar 2023 16:10:33 +0100 Subject: [PATCH] SONAR-18776 Project settings and info link --- .../src/components/NavBarTabs.tsx | 20 +- .../src/components/icons/ChevronDownIcon.tsx | 2 +- .../src/components/icons/index.ts | 2 +- .../design-system/src/helpers/constants.ts | 1 + .../components/nav/component/ComponentNav.tsx | 94 +- .../js/app/components/nav/component/Menu.tsx | 274 ++-- .../component/__tests__/ComponentNav-test.tsx | 6 +- .../nav/component/__tests__/Menu-test.tsx | 20 +- .../projectInformation/InfoDrawer.css | 6 +- .../__tests__/DrawerLink-test.tsx | 40 - .../__tests__/InfoDrawer-test.tsx | 44 - .../__tests__/InfoDrawerPage-test.tsx | 44 - .../__tests__/ProjectInformation-test.tsx | 81 - .../ProjectInformationRenderer-test.tsx | 102 -- .../__snapshots__/DrawerLink-test.tsx.snap | 13 - .../__snapshots__/InfoDrawer-test.tsx.snap | 47 - .../InfoDrawerPage-test.tsx.snap | 32 - .../ProjectInformation-test.tsx.snap | 294 ---- .../ProjectInformationRenderer-test.tsx.snap | 1399 ----------------- .../components/nav/settings/SettingsNav.tsx | 6 +- .../__snapshots__/SettingsNav-test.tsx.snap | 18 +- 21 files changed, 216 insertions(+), 2329 deletions(-) delete mode 100644 server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/DrawerLink-test.tsx delete mode 100644 server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/InfoDrawer-test.tsx delete mode 100644 server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/InfoDrawerPage-test.tsx delete mode 100644 server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/ProjectInformation-test.tsx delete mode 100644 server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/ProjectInformationRenderer-test.tsx delete mode 100644 server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/DrawerLink-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/InfoDrawer-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/InfoDrawerPage-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/ProjectInformation-test.tsx.snap delete mode 100644 server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/ProjectInformationRenderer-test.tsx.snap diff --git a/server/sonar-web/design-system/src/components/NavBarTabs.tsx b/server/sonar-web/design-system/src/components/NavBarTabs.tsx index 669f2d3642c..87e8ce3f126 100644 --- a/server/sonar-web/design-system/src/components/NavBarTabs.tsx +++ b/server/sonar-web/design-system/src/components/NavBarTabs.tsx @@ -20,10 +20,11 @@ import styled from '@emotion/styled'; import classNames from 'classnames'; +import React from 'react'; import tw, { theme } from 'twin.macro'; import { themeBorder, themeColor, themeContrast } from '../helpers/theme'; import { isDefined } from '../helpers/types'; -import ChevronDownIcon from './icons/ChevronDownIcon'; +import { ChevronDownIcon } from './icons/ChevronDownIcon'; import NavLink, { NavLinkProps } from './NavLink'; import Tooltip from './Tooltip'; @@ -34,7 +35,7 @@ interface Props extends React.HTMLAttributes { export function NavBarTabs({ children, className, ...other }: Props) { return ( - } - tagName="li" + id="component-navigation-admin" + size="auto" + overlay={adminLinks} > - {({ onToggleClick, open }) => ( - ( + - {hasMessage('layout.settings', component.qualifier) - ? translate('layout.settings', component.qualifier) - : translate('layout.settings')} - - + text={ + hasMessage('layout.settings', component.qualifier) + ? translate('layout.settings', component.qualifier) + : translate('layout.settings') + } + withChevron={true} + to={{}} + {...a11yAttrs} + /> )} ); @@ -350,17 +352,15 @@ export class Menu extends React.PureComponent { return ( (isProject || isApplication) && ( -
  • - + { - this.projectInfoLink = node; - }} + preventDefault={true} + ref={(node: HTMLAnchorElement | null) => (this.projectInfoLink = node)} + to={{}} > - {label} - +
  • ) ); @@ -371,13 +371,12 @@ export class Menu extends React.PureComponent { return null; } return ( -
  • - - {translate('project_settings.page')} - -
  • + + {translate('project_settings.page')} + ); }; @@ -391,13 +390,12 @@ export class Menu extends React.PureComponent { } return ( -
  • - - {translate('project_branch_pull_request.page')} - -
  • + + {translate('project_branch_pull_request.page')} + ); }; @@ -406,13 +404,12 @@ export class Menu extends React.PureComponent { return null; } return ( -
  • - - {translate('project_baseline.page')} - -
  • + + {translate('project_baseline.page')} + ); }; @@ -421,16 +418,15 @@ export class Menu extends React.PureComponent { return null; } return ( -
  • - - {translate('project_dump.page')} - -
  • + + {translate('project_dump.page')} + ); }; @@ -439,16 +435,15 @@ export class Menu extends React.PureComponent { return null; } return ( -
  • - - {translate('project_quality_profiles.page')} - -
  • + + {translate('project_quality_profiles.page')} + ); }; @@ -457,13 +452,12 @@ export class Menu extends React.PureComponent { return null; } return ( -
  • - - {translate('project_quality_gate.page')} - -
  • + + {translate('project_quality_gate.page')} + ); }; @@ -472,11 +466,12 @@ export class Menu extends React.PureComponent { return null; } return ( -
  • - - {translate('project_links.page')} - -
  • + + {translate('project_links.page')} + ); }; @@ -485,11 +480,12 @@ export class Menu extends React.PureComponent { return null; } return ( -
  • - - {translate('permissions.page')} - -
  • + + {translate('permissions.page')} + ); }; @@ -498,16 +494,15 @@ export class Menu extends React.PureComponent { return null; } return ( -
  • - - {translate('background_tasks.page')} - -
  • + + {translate('background_tasks.page')} + ); }; @@ -516,11 +511,12 @@ export class Menu extends React.PureComponent { return null; } return ( -
  • - - {translate('update_key.page')} - -
  • + + {translate('update_key.page')} + ); }; @@ -529,13 +525,12 @@ export class Menu extends React.PureComponent { return null; } return ( -
  • - - {translate('webhooks.page')} - -
  • + + {translate('webhooks.page')} + ); }; @@ -557,13 +552,12 @@ export class Menu extends React.PureComponent { } return ( -
  • - - {translate('deletion.page')} - -
  • + + {translate('deletion.page')} + ); }; @@ -571,9 +565,9 @@ export class Menu extends React.PureComponent { const pathname = isAdmin ? `/project/admin/extension/${key}` : `/project/extension/${key}`; const query = { ...baseQuery, qualifier: this.props.component.qualifier }; return ( -
  • - {name} -
  • + + {name} + ); }; @@ -586,7 +580,7 @@ export class Menu extends React.PureComponent { renderExtensions = () => { const query = this.getQuery(); - const extensions = this.props.component.extensions || []; + const extensions = this.props.component.extensions ?? []; const withoutSecurityExtension = extensions.filter( (extension) => !extension.key.startsWith('securityreport/') && !extension.key.startsWith('governance/') @@ -599,24 +593,20 @@ export class Menu extends React.PureComponent { return ( - {withoutSecurityExtension.map((e) => this.renderExtension(e, false, query))} - - } - tagName="li" + id="component-navigation-more" + size="auto" + overlay={withoutSecurityExtension.map((e) => this.renderExtension(e, false, query))} > - {({ onToggleClick, open }) => ( - ( + - {translate('more')} - - + preventDefault={true} + text={translate('more')} + withChevron={true} + to={{}} + {...a11yAttrs} + /> )} ); @@ -624,8 +614,8 @@ export class Menu extends React.PureComponent { render() { return ( -
    - +
    + {this.renderDashboardLink()} {this.renderBreakdownLink()} {this.renderIssuesLink()} @@ -636,10 +626,10 @@ export class Menu extends React.PureComponent { {this.renderActivityLink()} {this.renderExtensions()} - + {this.renderAdministration()} {this.renderProjectInformationButton()} - +
    ); } diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNav-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNav-test.tsx index 81b2ea7fc3b..18c7a3353f2 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNav-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNav-test.tsx @@ -66,11 +66,11 @@ it('renders correctly when the project binding is incorrect', () => { it('correctly returns focus to the Project Information link when the drawer is closed', () => { renderComponentNav(); - screen.getByRole('button', { name: 'project.info.title' }).click(); - expect(screen.getByRole('button', { name: 'project.info.title' })).not.toHaveFocus(); + screen.getByRole('link', { name: 'project.info.title' }).click(); + expect(screen.getByRole('link', { name: 'project.info.title' })).not.toHaveFocus(); screen.getByRole('button', { name: 'close' }).click(); - expect(screen.getByRole('button', { name: 'project.info.title' })).toHaveFocus(); + expect(screen.getByRole('link', { name: 'project.info.title' })).toHaveFocus(); }); function renderComponentNav(props: Partial = {}) { diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/Menu-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/Menu-test.tsx index ad00e62a704..599299e7e7b 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/Menu-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/Menu-test.tsx @@ -18,6 +18,7 @@ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import { screen } from '@testing-library/react'; +import userEvent from '@testing-library/user-event'; import * as React from 'react'; import { mockBranch, @@ -35,7 +36,8 @@ const BASE_COMPONENT = mockComponent({ name: 'foo', }); -it('should render correctly', () => { +it('should render correctly', async () => { + const user = userEvent.setup(); const component = { ...BASE_COMPONENT, configuration: { @@ -60,9 +62,9 @@ it('should render correctly', () => { // Check the dropdown. const button = screen.getByRole('button', { name: 'more' }); expect(button).toBeInTheDocument(); - button.click(); - expect(screen.getByRole('link', { name: 'ComponentFoo' })).toBeInTheDocument(); - expect(screen.getByRole('link', { name: 'ComponentBar' })).toBeInTheDocument(); + await user.click(button); + expect(screen.getByRole('menuitem', { name: 'ComponentFoo' })).toBeInTheDocument(); + expect(screen.getByRole('menuitem', { name: 'ComponentBar' })).toBeInTheDocument(); }); it('should render correctly when on a Portofolio', () => { @@ -101,13 +103,7 @@ it('should render correctly when on a branch', () => { expect(screen.getByRole('link', { name: 'overview.page' })).toBeInTheDocument(); expect(screen.getByRole('link', { name: 'issues.page' })).toBeInTheDocument(); expect(screen.getByRole('link', { name: 'layout.measures' })).toBeInTheDocument(); - expect(screen.getByRole('button', { name: 'project.info.title' })).toBeInTheDocument(); - - // If on a branch, regardless is the user is an admin or not, we do not show - // the settings link. - expect( - screen.queryByRole('link', { name: `layout.settings.${ComponentQualifier.Project}` }) - ).not.toBeInTheDocument(); + expect(screen.getByRole('link', { name: 'project.info.title' })).toBeInTheDocument(); }); it('should render correctly when on a pull request', () => { @@ -140,7 +136,7 @@ it('should disable links if no analysis has been done', () => { expect(screen.getByRole('link', { name: 'overview.page' })).toBeInTheDocument(); expect(screen.queryByRole('link', { name: 'issues.page' })).toHaveClass('disabled-link'); expect(screen.queryByRole('link', { name: 'layout.measures' })).toHaveClass('disabled-link'); - expect(screen.getByRole('button', { name: 'project.info.title' })).toBeInTheDocument(); + expect(screen.getByRole('link', { name: 'project.info.title' })).toBeInTheDocument(); }); it('should disable links if application has inaccessible projects', () => { diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/InfoDrawer.css b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/InfoDrawer.css index 224d5625b3f..1070a3d4c24 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/InfoDrawer.css +++ b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/InfoDrawer.css @@ -21,16 +21,12 @@ --drawer-width: 380px; } -/* TODO: should we move this? Or handle it differently? */ -.navbar-inner-with-notif .info-drawer { - border-top: 1px solid var(--barBorderColor); -} - .info-drawer-pane { background-color: white; right: calc(-1 * var(--drawer-width)); width: var(--drawer-width); transition: right 0.3s ease-in-out; + border-top: 1px solid var(--barBorderColor); border-left: 1px solid var(--barBorderColor); box-sizing: border-box; } diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/DrawerLink-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/DrawerLink-test.tsx deleted file mode 100644 index bbb8536ea82..00000000000 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/DrawerLink-test.tsx +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { DrawerLink, DrawerLinkProps } from '../DrawerLink'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); -}); - -it('should call onPageChange when clicked', () => { - const onPageChange = jest.fn(); - const to = 'target'; - const wrapper = shallowRender({ onPageChange, to }); - - wrapper.simulate('click'); - - expect(onPageChange).toHaveBeenCalledWith(to); -}); - -function shallowRender(props: Partial> = {}) { - return shallow(); -} diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/InfoDrawer-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/InfoDrawer-test.tsx deleted file mode 100644 index c19b0e055d0..00000000000 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/InfoDrawer-test.tsx +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { ClearButton } from '../../../../../../components/controls/buttons'; -import InfoDrawer, { InfoDrawerProps } from '../InfoDrawer'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ displayed: true })).toMatchSnapshot('displayed'); -}); - -it('should call onClose when button is clicked', () => { - const onClose = jest.fn(); - const wrapper = shallowRender({ onClose, displayed: true }); - wrapper.find(ClearButton).simulate('click'); - - expect(onClose).toHaveBeenCalled(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - content - - ); -} diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/InfoDrawerPage-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/InfoDrawerPage-test.tsx deleted file mode 100644 index 7b6e6dca218..00000000000 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/InfoDrawerPage-test.tsx +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import InfoDrawerPage, { InfoDrawerPageProps } from '../InfoDrawerPage'; - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot(); - expect(shallowRender({ displayed: true })).toMatchSnapshot(); -}); - -it('should call onPageChange when clicked', () => { - const onPageChange = jest.fn(); - const wrapper = shallowRender({ onPageChange, displayed: true }); - - wrapper.find('.back-button').simulate('click'); - - expect(onPageChange).toHaveBeenCalledTimes(1); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - -
    content
    -
    - ); -} diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/ProjectInformation-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/ProjectInformation-test.tsx deleted file mode 100644 index c6150027ce4..00000000000 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/ProjectInformation-test.tsx +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { mockComponent } from '../../../../../../helpers/mocks/component'; -import { mockCurrentUser, mockLoggedInUser, mockMetric } from '../../../../../../helpers/testMocks'; -import { waitAndUpdate } from '../../../../../../helpers/testUtils'; -import { ComponentQualifier, Visibility } from '../../../../../../types/component'; -import ProjectBadges from '../badges/ProjectBadges'; -import { ProjectInformation } from '../ProjectInformation'; -import { ProjectInformationPages } from '../ProjectInformationPages'; - -jest.mock('../../../../../../api/measures', () => { - const { mockMeasure } = jest.requireActual('../../../../../../helpers/testMocks'); - return { - getMeasures: jest.fn().mockResolvedValue([mockMeasure()]), - }; -}); - -it('should render correctly', async () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ currentUser: mockLoggedInUser() })).toMatchSnapshot('logged in user'); - expect( - shallowRender({ component: mockComponent({ visibility: Visibility.Private }) }) - ).toMatchSnapshot('private'); - const wrapper = shallowRender(); - await waitAndUpdate(wrapper); - expect(wrapper).toMatchSnapshot('measures loaded'); -}); - -it('should handle page change', async () => { - const wrapper = shallowRender(); - - wrapper.instance().setPage(ProjectInformationPages.badges); - - await waitAndUpdate(wrapper); - - expect(wrapper.state().page).toBe(ProjectInformationPages.badges); -}); - -it('should display badge', () => { - const wrapper = shallowRender({ - component: mockComponent({ qualifier: ComponentQualifier.Project }), - }); - - expect(wrapper.find(ProjectBadges).type).toBeDefined(); - - wrapper.setProps({ component: mockComponent({ qualifier: ComponentQualifier.Application }) }); - expect(wrapper.find(ProjectBadges).type).toBeDefined(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/ProjectInformationRenderer-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/ProjectInformationRenderer-test.tsx deleted file mode 100644 index 796f3e6274d..00000000000 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/ProjectInformationRenderer-test.tsx +++ /dev/null @@ -1,102 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2023 SonarSource SA - * mailto:info AT sonarsource DOT com - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -import { shallow } from 'enzyme'; -import * as React from 'react'; -import { mockComponent } from '../../../../../../helpers/mocks/component'; -import { ComponentQualifier, Visibility } from '../../../../../../types/component'; -import { - ProjectInformationRenderer, - ProjectInformationRendererProps, -} from '../ProjectInformationRenderer'; - -jest.mock('react', () => { - return { - ...jest.requireActual('react'), - useEffect: jest.fn().mockImplementation((f) => f()), - useRef: jest.fn().mockReturnValue(document.createElement('h2')), - }; -}); - -it('should render correctly', () => { - expect(shallowRender()).toMatchSnapshot('default'); - expect(shallowRender({ canConfigureNotifications: false })).toMatchSnapshot('with notifications'); - expect(shallowRender({ canUseBadges: false })).toMatchSnapshot('no badges'); - expect(shallowRender({ canConfigureNotifications: false, canUseBadges: false })).toMatchSnapshot( - 'no badges, no notifications' - ); -}); - -it('should render a private project correctly', () => { - expect( - shallowRender({ component: mockComponent({ visibility: Visibility.Private }) }) - ).toMatchSnapshot(); -}); - -it('should render an app correctly', () => { - const component = mockComponent({ qualifier: 'APP' }); - expect(shallowRender({ component })).toMatchSnapshot('default'); -}); - -it('should render with description', () => { - const component = mockComponent({ description: 'Lorem ipsum' }); - expect(shallowRender({ component })).toMatchSnapshot(); -}); - -it('should handle missing quality profiles and quality gates', () => { - expect( - shallowRender({ - component: mockComponent({ qualityGate: undefined, qualityProfiles: undefined }), - }) - ).toMatchSnapshot(); -}); - -it('should render app correctly when regulatoryReport feature is not enabled', () => { - expect( - shallowRender({ - hasFeature: jest.fn().mockReturnValue(false), - }) - ).toMatchSnapshot(); -}); - -it('should set focus on the heading when rendered', () => { - const fakeElement = document.createElement('h2'); - const focus = jest.fn(); - (React.useRef as jest.Mock).mockReturnValueOnce({ current: { ...fakeElement, focus } }); - - shallowRender(); - expect(focus).toHaveBeenCalled(); -}); - -function shallowRender(props: Partial = {}) { - return shallow( - - ); -} diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/DrawerLink-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/DrawerLink-test.tsx.snap deleted file mode 100644 index 56f55967256..00000000000 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/DrawerLink-test.tsx.snap +++ /dev/null @@ -1,13 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` - - switch page - - -`; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/InfoDrawer-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/InfoDrawer-test.tsx.snap deleted file mode 100644 index 3628f4e3f5e..00000000000 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/InfoDrawer-test.tsx.snap +++ /dev/null @@ -1,47 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: default 1`] = ` -
    -`; - -exports[`should render correctly: displayed 1`] = ` -
    -
    - -
    - - -
    - - content - -
    -
    -
    -
    -`; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/InfoDrawerPage-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/InfoDrawerPage-test.tsx.snap deleted file mode 100644 index 4525678f4b9..00000000000 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/InfoDrawerPage-test.tsx.snap +++ /dev/null @@ -1,32 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly 1`] = ` -
    -`; - -exports[`should render correctly 2`] = ` -
    - - - back - -
    -
    - content -
    -
    -
    -`; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/ProjectInformation-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/ProjectInformation-test.tsx.snap deleted file mode 100644 index 42048bd4cb8..00000000000 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/ProjectInformation-test.tsx.snap +++ /dev/null @@ -1,294 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should render correctly: default 1`] = ` - - - - - - -`; - -exports[`should render correctly: logged in user 1`] = ` - - - - - - - - - -`; - -exports[`should render correctly: measures loaded 1`] = ` - - - - - - -`; - -exports[`should render correctly: private 1`] = ` - - - - - - -`; diff --git a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/ProjectInformationRenderer-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/ProjectInformationRenderer-test.tsx.snap deleted file mode 100644 index 789251f82cd..00000000000 --- a/server/sonar-web/src/main/js/app/components/nav/component/projectInformation/__tests__/__snapshots__/ProjectInformationRenderer-test.tsx.snap +++ /dev/null @@ -1,1399 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`should handle missing quality profiles and quality gates 1`] = ` - -
    -

    - project.info.title -

    -
    -
    -
    -
    -

    - project.info.description -

    -
    - -
    -
    - -
    - -
    - -
    -
      -
    • - -
    • -
    • - -
    • -
    • - - - -
    • -
    -
    -
    -`; - -exports[`should render a private project correctly 1`] = ` - -
    -

    - project.info.title -

    -
    -
    -
    -
    -

    - project.info.description -

    - -
    - -
    -
    - -
    -
    - - -
    - -
    - -
    -
      -
    • - -
    • -
    • - -
    • -
    • - - - -
    • -
    -
    -
    -`; - -exports[`should render an app correctly: default 1`] = ` - -
    -

    - application.info.title -

    -
    -
    -
    -
    -

    - project.info.description -

    -
    - -
    -
    - -
    -
    - -
    -
      -
    • - -
    • -
    • - -
    • -
    -
    -
    -`; - -exports[`should render app correctly when regulatoryReport feature is not enabled 1`] = ` - -
    -

    - project.info.title -

    -
    -
    -
    -
    -

    - project.info.description -

    - -
    - -
    -
    - -
    -
    - - -
    - -
    - -
    -
      -
    • - -
    • -
    • - -
    • -
    -
    -
    -`; - -exports[`should render correctly: default 1`] = ` - -
    -

    - project.info.title -

    -
    -
    -
    -
    -

    - project.info.description -

    - -
    - -
    -
    - -
    -
    - - -
    - -
    - -
    -
      -
    • - -
    • -
    • - -
    • -
    • - - - -
    • -
    -
    -
    -`; - -exports[`should render correctly: no badges 1`] = ` - -
    -

    - project.info.title -

    -
    -
    -
    -
    -

    - project.info.description -

    - -
    - -
    -
    - -
    -
    - - -
    - -
    - -
    -
      -
    • - -
    • -
    • - - - -
    • -
    -
    -
    -`; - -exports[`should render correctly: no badges, no notifications 1`] = ` - -
    -

    - project.info.title -

    -
    -
    -
    -
    -

    - project.info.description -

    - -
    - -
    -
    - -
    -
    - - -
    - -
    - -
    -
      -
    • - - - -
    • -
    -
    -
    -`; - -exports[`should render correctly: with notifications 1`] = ` - -
    -

    - project.info.title -

    -
    -
    -
    -
    -

    - project.info.description -

    - -
    - -
    -
    - -
    -
    - - -
    - -
    - -
    -
      -
    • - -
    • -
    • - - - -
    • -
    -
    -
    -`; - -exports[`should render with description 1`] = ` - -
    -

    - project.info.title -

    -
    -
    -
    -
    -

    - project.info.description -

    -
    -

    - Lorem ipsum -

    - -
    -
    - -
    -
    - - -
    - -
    - -
    -
      -
    • - -
    • -
    • - -
    • -
    • - - - -
    • -
    -
    -
    -`; diff --git a/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx b/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx index 369780bbe5e..4222ac6fc3b 100644 --- a/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/settings/SettingsNav.tsx @@ -100,7 +100,7 @@ export class SettingsNav extends React.PureComponent { return ( +
    • {translate('settings.page')} @@ -152,7 +152,7 @@ export class SettingsNav extends React.PureComponent { return ( +
      • {translate('management')} @@ -188,7 +188,7 @@ export class SettingsNav extends React.PureComponent { return ( +
        • {translate('users.page')} diff --git a/server/sonar-web/src/main/js/app/components/nav/settings/__tests__/__snapshots__/SettingsNav-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/settings/__tests__/__snapshots__/SettingsNav-test.tsx.snap index 01c0bb4afc5..9f662b53101 100644 --- a/server/sonar-web/src/main/js/app/components/nav/settings/__tests__/__snapshots__/SettingsNav-test.tsx.snap +++ b/server/sonar-web/src/main/js/app/components/nav/settings/__tests__/__snapshots__/SettingsNav-test.tsx.snap @@ -41,7 +41,7 @@ exports[`should render correctly when governance is active 1`] = `