From 74c8a8ac5e83144fab7291b9ad57c14742fe8bbf Mon Sep 17 00:00:00 2001 From: Grégoire Aubert Date: Mon, 11 Sep 2017 17:01:34 +0200 Subject: SONAR-9802 Add nodes to system info in cluster mode --- .../src/main/js/apps/system/components/App.tsx | 125 +++++++++++++ .../apps/system/components/ChangeLogLevelForm.tsx | 114 ++++++++++++ .../js/apps/system/components/ClusterSysInfos.tsx | 82 +++++++++ .../main/js/apps/system/components/PageActions.tsx | 163 +++++++++++++++++ .../main/js/apps/system/components/PageHeader.tsx | 50 ++++++ .../apps/system/components/StandAloneSysInfos.tsx | 30 ++++ .../__tests__/ChangeLogLevelForm-test.tsx | 38 ++++ .../components/__tests__/ClusterSysInfos-test.tsx | 47 +++++ .../components/__tests__/PageActions-test.tsx | 55 ++++++ .../components/__tests__/PageHeader-test.tsx | 34 ++++ .../__snapshots__/ChangeLogLevelForm-test.tsx.snap | 194 +++++++++++++++++++++ .../__snapshots__/ClusterSysInfos-test.tsx.snap | 59 +++++++ .../__snapshots__/PageActions-test.tsx.snap | 126 +++++++++++++ .../__snapshots__/PageHeader-test.tsx.snap | 38 ++++ .../system/components/info-items/HealthCard.tsx | 84 +++++++++ .../components/info-items/HealthCauseItem.tsx | 41 +++++ .../system/components/info-items/HealthItem.tsx | 42 +++++ .../apps/system/components/info-items/Section.tsx | 52 ++++++ .../system/components/info-items/SysInfoItem.tsx | 71 ++++++++ .../info-items/__tests__/HealthCard-test.tsx | 64 +++++++ .../info-items/__tests__/HealthCauseItem-test.tsx | 32 ++++ .../info-items/__tests__/HealthItem-test.tsx | 47 +++++ .../info-items/__tests__/Section-test.tsx | 32 ++++ .../info-items/__tests__/SysInfoItem-test.tsx | 60 +++++++ .../__snapshots__/HealthCard-test.tsx.snap | 132 ++++++++++++++ .../__snapshots__/HealthCauseItem-test.tsx.snap | 17 ++ .../__snapshots__/HealthItem-test.tsx.snap | 68 ++++++++ .../__tests__/__snapshots__/Section-test.tsx.snap | 125 +++++++++++++ .../__snapshots__/SysInfoItem-test.tsx.snap | 180 +++++++++++++++++++ 29 files changed, 2202 insertions(+) create mode 100644 server/sonar-web/src/main/js/apps/system/components/App.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/ChangeLogLevelForm.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/PageActions.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/PageHeader.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/StandAloneSysInfos.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/__tests__/ChangeLogLevelForm-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/__tests__/ClusterSysInfos-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/__tests__/PageActions-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/__tests__/PageHeader-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/ChangeLogLevelForm-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/ClusterSysInfos-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageActions-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageHeader-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/system/components/info-items/HealthCard.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/info-items/Section.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/HealthCard-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/HealthCauseItem-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/HealthItem-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/Section-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/SysInfoItem-test.tsx create mode 100644 server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/HealthCard-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/HealthCauseItem-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/HealthItem-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/Section-test.tsx.snap create mode 100644 server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/SysInfoItem-test.tsx.snap (limited to 'server/sonar-web/src/main/js/apps/system/components') diff --git a/server/sonar-web/src/main/js/apps/system/components/App.tsx b/server/sonar-web/src/main/js/apps/system/components/App.tsx new file mode 100644 index 00000000000..440b117929a --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/App.tsx @@ -0,0 +1,125 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import * as PropTypes from 'prop-types'; +import Helmet from 'react-helmet'; +import ClusterSysInfos from './ClusterSysInfos'; +import PageHeader from './PageHeader'; +import StandAloneSysInfos from './StandAloneSysInfos'; +import { translate } from '../../../helpers/l10n'; +import { getSystemInfo, SysInfo } from '../../../api/system'; +import { isCluster, parseQuery, Query, serializeQuery } from '../utils'; +import { RawQuery } from '../../../helpers/query'; +import '../styles.css'; + +interface Props { + location: { pathname: string; query: RawQuery }; +} + +interface State { + loading: boolean; + sysInfoData?: SysInfo; +} + +export default class App extends React.PureComponent { + mounted: boolean; + state: State = { loading: true }; + + static contextTypes = { + router: PropTypes.object + }; + + componentDidMount() { + this.mounted = true; + this.fetchSysInfo(); + } + + componentWillUnmount() { + this.mounted = false; + } + + fetchSysInfo = () => { + this.setState({ loading: true }); + getSystemInfo().then( + (sysInfoData: SysInfo) => { + if (this.mounted) { + this.setState({ loading: false, sysInfoData }); + } + }, + () => { + if (this.mounted) { + this.setState({ loading: false }); + } + } + ); + }; + + toggleSysInfoCards = (toggledCard: string) => { + const query = parseQuery(this.props.location.query); + let expandedCards; + if (query.expandedCards.includes(toggledCard)) { + expandedCards = query.expandedCards.filter(card => card !== toggledCard); + } else { + expandedCards = query.expandedCards.concat(toggledCard); + } + this.updateQuery({ expandedCards }); + }; + + updateQuery = (newQuery: Query) => { + const query = serializeQuery({ ...parseQuery(this.props.location.query), ...newQuery }); + this.context.router.push({ pathname: this.props.location.pathname, query }); + }; + + renderSysInfo() { + const { sysInfoData } = this.state; + if (!sysInfoData) { + return null; + } + + const query = parseQuery(this.props.location.query); + if (isCluster(sysInfoData)) { + return ( + + ); + } + return ; + } + + render() { + const { loading, sysInfoData } = this.state; + // TODO Correctly get logLevel, we are not sure yet how we want to do it for cluster mode + return ( +
+ + + {this.renderSysInfo()} +
+ ); + } +} diff --git a/server/sonar-web/src/main/js/apps/system/components/ChangeLogLevelForm.tsx b/server/sonar-web/src/main/js/apps/system/components/ChangeLogLevelForm.tsx new file mode 100644 index 00000000000..3065a0be66d --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/ChangeLogLevelForm.tsx @@ -0,0 +1,114 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import Modal from 'react-modal'; +import { setLogLevel } from '../../../api/system'; +import { translate } from '../../../helpers/l10n'; + +interface Props { + infoMsg: string; + logLevel: string; + onChange: (level: string) => void; + onClose: () => void; +} + +interface State { + newLevel: string; + updating: boolean; +} + +const LOG_LEVELS = ['INFO', 'DEBUG', 'TRACE']; + +export default class ChangeLogLevelForm extends React.PureComponent { + constructor(props: Props) { + super(props); + this.state = { newLevel: props.logLevel, updating: false }; + } + + handleCancelClick = (event: React.SyntheticEvent) => { + event.preventDefault(); + this.props.onClose(); + }; + + handleFormSubmit = (event: React.SyntheticEvent) => { + event.preventDefault(); + const { newLevel } = this.state; + if (!this.state.updating && newLevel !== this.props.logLevel) { + this.setState({ updating: true }); + setLogLevel(newLevel).then( + () => this.props.onChange(newLevel), + () => this.setState({ updating: false }) + ); + } + }; + + handleLevelChange = (event: React.ChangeEvent) => + this.setState({ newLevel: event.currentTarget.value }); + + render() { + const { updating, newLevel } = this.state; + const header = translate('system.set_log_level'); + const disableSubmit = updating || newLevel === this.props.logLevel; + return ( + +
+
+

{header}

+
+
+ {LOG_LEVELS.map(level => ( +

+ + {level} +

+ ))} +
{this.props.infoMsg}
+ {newLevel !== 'INFO' && ( +
+ {translate('system.log_level.warning')} +
+ )} +
+
+ {updating && } + + + {translate('cancel')} + +
+ +
+ ); + } +} diff --git a/server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx b/server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx new file mode 100644 index 00000000000..7f68dc6771a --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/ClusterSysInfos.tsx @@ -0,0 +1,82 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { sortBy } from 'lodash'; +import HealthCard from './info-items/HealthCard'; +import { translate } from '../../../helpers/l10n'; +import { + getAppNodes, + getHealth, + getHealthCauses, + getMainCardSection, + getNodeName, + getSearchNodes, + ignoreInfoFields +} from '../utils'; +import { SysInfo } from '../../../api/system'; + +interface Props { + expandedCards: string[]; + sysInfoData: SysInfo; + toggleCard: (toggledCard: string) => void; +} + +export default function ClusterSysInfos({ expandedCards, sysInfoData, toggleCard }: Props) { + const mainCardName = 'System'; + return ( +
    + +
  • + {translate('system.application_nodes_title')} +
  • + {sortBy(getAppNodes(sysInfoData), 'name').map(node => ( + + ))} +
  • {translate('system.search_nodes_title')}
  • + {sortBy(getSearchNodes(sysInfoData), 'name').map(node => ( + + ))} +
+ ); +} diff --git a/server/sonar-web/src/main/js/apps/system/components/PageActions.tsx b/server/sonar-web/src/main/js/apps/system/components/PageActions.tsx new file mode 100644 index 00000000000..1b2ef92d34a --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/PageActions.tsx @@ -0,0 +1,163 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import ChangeLogLevelForm from './ChangeLogLevelForm'; +import RestartForm from '../../../components/common/RestartForm'; +import { getBaseUrl } from '../../../helpers/urls'; +import { translate } from '../../../helpers/l10n'; + +interface Props { + canDownloadLogs: boolean; + canRestart: boolean; + cluster: boolean; + logLevel: string; +} + +interface State { + logLevel: string; + openLogsLevelForm: boolean; + openRestartForm: boolean; +} + +export default class PageActions extends React.PureComponent { + constructor(props: Props) { + super(props); + this.state = { + openLogsLevelForm: false, + openRestartForm: false, + logLevel: props.logLevel + }; + } + + componentWillReceiveProps(nextProps: Props) { + if (nextProps.logLevel !== this.state.logLevel) { + this.setState({ logLevel: nextProps.logLevel }); + } + } + + handleLogsLevelOpen = (event: React.SyntheticEvent) => { + event.preventDefault(); + this.setState({ openLogsLevelForm: true }); + }; + + handleLogsLevelChange = (logLevel: string) => { + this.setState({ logLevel }); + this.handleLogsLevelClose(); + }; + + handleLogsLevelClose = () => this.setState({ openLogsLevelForm: false }); + + handleServerRestartOpen = () => this.setState({ openRestartForm: true }); + handleServerRestartClose = () => this.setState({ openRestartForm: false }); + + render() { + const infoUrl = getBaseUrl() + '/api/system/info'; + const logsUrl = getBaseUrl() + '/api/system/logs'; + return ( +
+ + {translate('system.logs_level')} + {':'} + {this.state.logLevel} + + + {this.props.canDownloadLogs && ( + + )} + + {translate('system.download_system_info')} + + {this.props.canRestart && ( + + )} + {this.props.canRestart && + this.state.openRestartForm && } + {this.state.openLogsLevelForm && ( + + )} +
+ ); + } +} diff --git a/server/sonar-web/src/main/js/apps/system/components/PageHeader.tsx b/server/sonar-web/src/main/js/apps/system/components/PageHeader.tsx new file mode 100644 index 00000000000..c9d84569e30 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/PageHeader.tsx @@ -0,0 +1,50 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import PageActions from './PageActions'; +import { translate } from '../../../helpers/l10n'; + +interface Props { + isCluster: boolean; + loading: boolean; + logLevel: string; + showActions: boolean; +} + +export default function PageHeader({ isCluster, loading, logLevel, showActions }: Props) { + return ( +
+

{translate('system_info.page')}

+ {showActions && ( + + )} + {loading && ( +
+ +
+ )} +
+ ); +} diff --git a/server/sonar-web/src/main/js/apps/system/components/StandAloneSysInfos.tsx b/server/sonar-web/src/main/js/apps/system/components/StandAloneSysInfos.tsx new file mode 100644 index 00000000000..2a142c58a0e --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/StandAloneSysInfos.tsx @@ -0,0 +1,30 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; + +interface Props { + sysInfoData: object; +} + +export default class StandAloneSysInfos extends React.PureComponent { + render() { + return
StandAloneSysInfos
; + } +} diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/ChangeLogLevelForm-test.tsx b/server/sonar-web/src/main/js/apps/system/components/__tests__/ChangeLogLevelForm-test.tsx new file mode 100644 index 00000000000..08c177e418b --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/ChangeLogLevelForm-test.tsx @@ -0,0 +1,38 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import ChangeLogLevelForm from '../ChangeLogLevelForm'; + +it('should render correctly', () => { + expect( + shallow( + {}} onClose={() => {}} /> + ) + ).toMatchSnapshot(); +}); + +it('should display some warning messages for non INFO levels', () => { + expect( + shallow( + {}} onClose={() => {}} /> + ) + ).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/ClusterSysInfos-test.tsx b/server/sonar-web/src/main/js/apps/system/components/__tests__/ClusterSysInfos-test.tsx new file mode 100644 index 00000000000..5b703a1a214 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/ClusterSysInfos-test.tsx @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import ClusterSysInfos from '../ClusterSysInfos'; +import { HealthType, SysInfo } from '../../../../api/system'; + +const sysInfoData: SysInfo = { + Cluster: true, + Health: HealthType.RED, + Name: 'Foo', + 'Health Causes': [{ message: 'Database down' }], + 'Application Nodes': [{ Name: 'Bar', Health: HealthType.GREEN, 'Health Causes': [] }], + 'Search Nodes': [{ Name: 'Baz', Health: HealthType.YELLOW, 'Health Causes': [] }] +}; + +it('should render correctly', () => { + expect(getWrapper()).toMatchSnapshot(); +}); + +function getWrapper(props = {}) { + return shallow( + {}} + {...props} + /> + ); +} diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/PageActions-test.tsx b/server/sonar-web/src/main/js/apps/system/components/__tests__/PageActions-test.tsx new file mode 100644 index 00000000000..098e897ec92 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/PageActions-test.tsx @@ -0,0 +1,55 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import PageActions from '../PageActions'; +import { click } from '../../../../helpers/testUtils'; + +it('should render correctly', () => { + expect( + shallow( + + ) + ).toMatchSnapshot(); +}); + +it('should render without restart and log download', () => { + expect( + shallow( + + ) + ).toMatchSnapshot(); +}); + +it('should open restart modal', () => { + const wrapper = shallow( + + ); + click(wrapper.find('#restart-server-button')); + expect(wrapper.find('RestartForm')).toHaveLength(1); +}); + +it('should open change log level modal', () => { + const wrapper = shallow( + + ); + click(wrapper.find('#edit-logs-level-button')); + expect(wrapper.find('ChangeLogLevelForm')).toHaveLength(1); +}); diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/PageHeader-test.tsx b/server/sonar-web/src/main/js/apps/system/components/__tests__/PageHeader-test.tsx new file mode 100644 index 00000000000..f5255c7228e --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/PageHeader-test.tsx @@ -0,0 +1,34 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import PageHeader from '../PageHeader'; + +it('should render correctly', () => { + expect( + shallow() + ).toMatchSnapshot(); +}); + +it('should show a loading spinner and no actions', () => { + expect( + shallow() + ).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/ChangeLogLevelForm-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/ChangeLogLevelForm-test.tsx.snap new file mode 100644 index 00000000000..04cfc11d49b --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/ChangeLogLevelForm-test.tsx.snap @@ -0,0 +1,194 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should display some warning messages for non INFO levels 1`] = ` + +
+
+

+ system.set_log_level +

+
+
+

+ + INFO +

+

+ + DEBUG +

+

+ + TRACE +

+
+ Foo +
+
+ system.log_level.warning +
+
+
+ + + cancel + +
+
+
+`; + +exports[`should render correctly 1`] = ` + +
+
+

+ system.set_log_level +

+
+
+

+ + INFO +

+

+ + DEBUG +

+

+ + TRACE +

+
+ Foo +
+
+
+ + + cancel + +
+
+
+`; diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/ClusterSysInfos-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/ClusterSysInfos-test.tsx.snap new file mode 100644 index 00000000000..20ed8d541f6 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/ClusterSysInfos-test.tsx.snap @@ -0,0 +1,59 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` +
    + +
  • + system.application_nodes_title +
  • + +
  • + system.search_nodes_title +
  • + +
+`; diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageActions-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageActions-test.tsx.snap new file mode 100644 index 00000000000..9d84700539f --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageActions-test.tsx.snap @@ -0,0 +1,126 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` + +`; + +exports[`should render without restart and log download 1`] = ` +
+ + system.logs_level + : + + INFO + + + + + system.download_system_info + +
+`; diff --git a/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageHeader-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageHeader-test.tsx.snap new file mode 100644 index 00000000000..2945b6df932 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/__tests__/__snapshots__/PageHeader-test.tsx.snap @@ -0,0 +1,38 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` +
+

+ system_info.page +

+ +
+`; + +exports[`should show a loading spinner and no actions 1`] = ` +
+

+ system_info.page +

+
+ +
+
+`; diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCard.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCard.tsx new file mode 100644 index 00000000000..b45205dccba --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCard.tsx @@ -0,0 +1,84 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import * as classNames from 'classnames'; +import { map } from 'lodash'; +import HealthItem from './HealthItem'; +import OpenCloseIcon from '../../../../components/icons-components/OpenCloseIcon'; +import Section from './Section'; +import { HealthType, HealthCause, SysValueObject } from '../../../../api/system'; +import { groupSections } from '../../utils'; + +interface Props { + biggerHealth?: boolean; + health: HealthType; + healthCauses: HealthCause[]; + onClick: (toggledCard: string) => void; + open: boolean; + name: string; + sysInfoData: SysValueObject; +} + +interface State { + hoveringDetail: boolean; +} + +export default class HealthCard extends React.PureComponent { + state: State = { hoveringDetail: false }; + + handleClick = () => this.props.onClick(this.props.name); + onDetailEnter = () => this.setState({ hoveringDetail: true }); + onDetailLeave = () => this.setState({ hoveringDetail: false }); + + render() { + const { open, sysInfoData } = this.props; + const { mainSection, sections } = groupSections(sysInfoData); + const showFields = open && mainSection && Object.keys(mainSection).length > 0; + const showSections = open && sections; + return ( +
  • +
    + + + {this.props.name} + + +
    + {open && ( +
    + {showFields &&
    } + {showSections && + map(sections, (section, name) =>
    )} +
    + )} +
  • + ); + } +} diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx new file mode 100644 index 00000000000..49b22b717bb --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthCauseItem.tsx @@ -0,0 +1,41 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import * as classNames from 'classnames'; +import { HealthCause, HealthType } from '../../../../api/system'; + +interface Props { + className?: string; + health: HealthType; + healthCause: HealthCause; +} + +export default function HealthCauseItem({ className, health, healthCause }: Props) { + return ( + + {healthCause.message} + + ); +} diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx new file mode 100644 index 00000000000..a0793a81831 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/HealthItem.tsx @@ -0,0 +1,42 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import * as classNames from 'classnames'; +import HealthCauseItem from './HealthCauseItem'; +import { HealthType, HealthCause } from '../../../../api/system'; + +interface Props { + className?: string; + health: HealthType; + healthCauses?: HealthCause[]; +} + +export default function HealthItem({ className, health, healthCauses }: Props) { + const hasHealthCauses = healthCauses && healthCauses.length > 0 && health !== HealthType.GREEN; + return ( +
    + {hasHealthCauses && + healthCauses!.map((cause, idx) => ( + + ))} + +
    + ); +} diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/Section.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/Section.tsx new file mode 100644 index 00000000000..3da339cbdf2 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/Section.tsx @@ -0,0 +1,52 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { map } from 'lodash'; +import SysInfoItem from './SysInfoItem'; +import { SysValueObject } from '../../../../api/system'; + +interface Props { + name?: string; + items: SysValueObject; +} + +export default function Section({ name, items }: Props) { + return ( +
    + {name &&

    {name}

    } + + + {map(items, (value, name) => { + return ( + + + + + ); + })} + +
    +
    {name}
    +
    + +
    +
    + ); +} diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx new file mode 100644 index 00000000000..12876d75940 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/SysInfoItem.tsx @@ -0,0 +1,71 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { map } from 'lodash'; +import HealthItem from './HealthItem'; +import { HealthType, SysValue, SysValueObject } from '../../../../api/system'; +import { HEALTH_FIELD } from '../../utils'; + +interface Props { + name: string; + value: SysValue; +} + +export default function SysInfoItem({ name, value }: Props): JSX.Element { + if (name === HEALTH_FIELD) { + return ; + } + if (value instanceof Array) { + return {JSON.stringify(value)}; + } + switch (typeof value) { + case 'boolean': + return ; + case 'object': + return ; + default: + return {value}; + } +} + +function BooleanItem({ value }: { value: boolean }) { + if (value) { + return ; + } else { + return ; + } +} + +function ObjectItem({ value }: { value: SysValueObject }) { + return ( + + + {map(value, (value, name) => ( + + + + + ))} + +
    {name} + +
    + ); +} diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/HealthCard-test.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/HealthCard-test.tsx new file mode 100644 index 00000000000..c080f444dec --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/HealthCard-test.tsx @@ -0,0 +1,64 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import HealthCard from '../HealthCard'; +import { click } from '../../../../../helpers/testUtils'; +import { HealthType } from '../../../../../api/system'; + +it('should render correctly', () => { + expect(getShallowWrapper()).toMatchSnapshot(); +}); + +it('should display the sysinfo detail', () => { + expect(getShallowWrapper({ biggerHealth: true, open: true })).toMatchSnapshot(); +}); + +it('should show the sysinfo detail when the card is clicked', () => { + const onClick = jest.fn(); + click(getShallowWrapper({ onClick }).find('.boxed-group-header')); + expect(onClick).toBeCalled(); + expect(onClick).toBeCalledWith('Foobar'); +}); + +it('should show a main section and multiple sub sections', () => { + const sysInfoData = { + Name: 'foo', + bar: 'Bar', + Database: { db: 'test' }, + Elasticseach: { Elastic: 'search' } + }; + expect(getShallowWrapper({ open: true, sysInfoData })).toMatchSnapshot(); +}); + +function getShallowWrapper(props = {}) { + return shallow( + {}} + open={false} + sysInfoData={{}} + {...props} + /> + ); +} diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/HealthCauseItem-test.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/HealthCauseItem-test.tsx new file mode 100644 index 00000000000..24504f09a91 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/HealthCauseItem-test.tsx @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import HealthCauseItem from '../HealthCauseItem'; +import { HealthType } from '../../../../../api/system'; + +it('should render correctly', () => { + expect( + shallow() + ).toMatchSnapshot(); + expect( + shallow() + ).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/HealthItem-test.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/HealthItem-test.tsx new file mode 100644 index 00000000000..f77622b9e92 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/HealthItem-test.tsx @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import HealthItem from '../HealthItem'; +import { HealthType } from '../../../../../api/system'; + +it('should render correctly', () => { + expect( + shallow() + ).toMatchSnapshot(); +}); + +it('should not render health causes', () => { + expect( + shallow() + ).toMatchSnapshot(); + expect(shallow()).toMatchSnapshot(); +}); + +it('should render multiple health causes', () => { + expect( + shallow( + + ) + ).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/Section-test.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/Section-test.tsx new file mode 100644 index 00000000000..2778dc855b8 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/Section-test.tsx @@ -0,0 +1,32 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { shallow } from 'enzyme'; +import Section from '../Section'; + +it('should render correctly', () => { + expect( + shallow(
    ) + ).toMatchSnapshot(); +}); + +it('should not render a title', () => { + expect(shallow(
    )).toMatchSnapshot(); +}); diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/SysInfoItem-test.tsx b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/SysInfoItem-test.tsx new file mode 100644 index 00000000000..2761a2ddbf9 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/SysInfoItem-test.tsx @@ -0,0 +1,60 @@ +/* + * SonarQube + * Copyright (C) 2009-2017 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 * as React from 'react'; +import { shallow, mount } from 'enzyme'; +import SysInfoItem from '../SysInfoItem'; + +it('should render string', () => { + const wrapper = shallow(); + expect(wrapper.find('code').text()).toBe('/some/path/as/an/example'); +}); + +it('should render object', () => { + const wrapper = shallow(); + expect(wrapper.find('ObjectItem').prop('value')).toEqual({ bar: 'baz' }); +}); + +it('should render boolean', () => { + const wrapper = shallow(); + expect(wrapper.find('BooleanItem').prop('value')).toBe(true); +}); + +it('should render health item', () => { + const wrapper = shallow(); + expect(wrapper.find('HealthItem').prop('health')).toBe('GREEN'); +}); + +it('should render object correctly', () => { + expect( + mount( + + ).find('ObjectItem') + ).toMatchSnapshot(); +}); + +it('should render `true`', () => { + const wrapper = mount(); + expect(wrapper.find('.icon-check')).toHaveLength(1); +}); + +it('should render `false`', () => { + const wrapper = mount(); + expect(wrapper.find('.icon-delete')).toHaveLength(1); +}); diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/HealthCard-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/HealthCard-test.tsx.snap new file mode 100644 index 00000000000..724001990fa --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/HealthCard-test.tsx.snap @@ -0,0 +1,132 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should display the sysinfo detail 1`] = ` +
  • +
    + + + Foobar + + +
    +
    +
  • +`; + +exports[`should render correctly 1`] = ` +
  • +
    + + + Foobar + + +
    +
  • +`; + +exports[`should show a main section and multiple sub sections 1`] = ` +
  • +
    + + + Foobar + + +
    +
    +
    +
    +
    +
    +
  • +`; diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/HealthCauseItem-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/HealthCauseItem-test.tsx.snap new file mode 100644 index 00000000000..3202387cf1c --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/HealthCauseItem-test.tsx.snap @@ -0,0 +1,17 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render correctly 1`] = ` + + foo + +`; + +exports[`should render correctly 2`] = ` + + foo + +`; diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/HealthItem-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/HealthItem-test.tsx.snap new file mode 100644 index 00000000000..d9fa53a2956 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/HealthItem-test.tsx.snap @@ -0,0 +1,68 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should not render health causes 1`] = ` +
    + +
    +`; + +exports[`should not render health causes 2`] = ` +
    + +
    +`; + +exports[`should render correctly 1`] = ` +
    + + +
    +`; + +exports[`should render multiple health causes 1`] = ` +
    + + + +
    +`; diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/Section-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/Section-test.tsx.snap new file mode 100644 index 00000000000..20fce92a9b7 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/Section-test.tsx.snap @@ -0,0 +1,125 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should not render a title 1`] = ` +
    + + + + + + + +
    +
    + foo +
    +
    + +
    +
    +`; + +exports[`should render correctly 1`] = ` +
    +

    + foo +

    + + + + + + + + + + + + + + + +
    +
    + foo +
    +
    + +
    +
    + bar +
    +
    + +
    +
    + baz +
    +
    + +
    +
    +`; diff --git a/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/SysInfoItem-test.tsx.snap b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/SysInfoItem-test.tsx.snap new file mode 100644 index 00000000000..a1ff67c3506 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/system/components/info-items/__tests__/__snapshots__/SysInfoItem-test.tsx.snap @@ -0,0 +1,180 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`should render object correctly 1`] = ` +Array [ + + + + + + + + + + + + + + + + +
    + foo + + + + Far + + +
    + bar + + + + + + + + + + + + + + +
    + a + + + + 1 + + +
    + b + + + + b + + +
    +
    +
    +
    + baz + + + + + + +
    +
    , + + + + + + + + + + + + +
    + a + + + + 1 + + +
    + b + + + + b + + +
    +
    , +] +`; -- cgit v1.2.3