• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / gui / 951400782

pending completion
951400782

Pull #3900

gitlab-ci

web-flow
chore: bump @testing-library/jest-dom from 5.16.5 to 5.17.0

Bumps [@testing-library/jest-dom](https://github.com/testing-library/jest-dom) from 5.16.5 to 5.17.0.
- [Release notes](https://github.com/testing-library/jest-dom/releases)
- [Changelog](https://github.com/testing-library/jest-dom/blob/main/CHANGELOG.md)
- [Commits](https://github.com/testing-library/jest-dom/compare/v5.16.5...v5.17.0)

---
updated-dependencies:
- dependency-name: "@testing-library/jest-dom"
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #3900: chore: bump @testing-library/jest-dom from 5.16.5 to 5.17.0

4446 of 6414 branches covered (69.32%)

8342 of 10084 relevant lines covered (82.73%)

186.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

71.01
/src/js/components/devices/device-details/monitoring.js
1
// Copyright 2021 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14
import React, { useEffect, useState } from 'react';
15
import { useDispatch, useSelector } from 'react-redux';
16

17
import { useTheme } from '@mui/material/styles';
18

19
import { getDeviceAlerts, setAlertListState } from '../../../actions/monitorActions';
20
import { DEVICE_LIST_DEFAULTS } from '../../../constants/deviceConstants';
21
import { getOfflineThresholdSettings } from '../../../selectors';
22
import DocsLink from '../../common/docslink';
23
import Pagination from '../../common/pagination';
24
import Time from '../../common/time';
25
import MonitorDetailsDialog from '../dialogs/monitordetailsdialog';
26
import { DeviceConnectionNote } from './connection';
27
import DeviceDataCollapse from './devicedatacollapse';
28
import { DeviceOfflineHeaderNotification, NoAlertsHeaderNotification, monitoringSeverities, severityMap } from './notifications';
29

30
const { page: defaultPage, perPage: defaultPerPage } = DEVICE_LIST_DEFAULTS;
10✔
31

32
export const DeviceMonitorsMissingNote = () => (
10✔
33
  <DeviceConnectionNote>
1✔
34
    No alert monitor is currently configured for this device.
35
    <br />
36
    Please <DocsLink path="add-ons/monitor" title="see the documentation" /> for a description on how to configure different kinds of monitors.
37
  </DeviceConnectionNote>
38
);
39

40
const MonitoringAlert = ({ alert, onDetailsClick, style }) => {
10✔
41
  const { description, lines_before = [], lines_after = [], line_matching = '' } = alert.subject.details;
2✔
42
  const lines = [...lines_before, line_matching, ...lines_after].filter(i => i);
2✔
43
  return (
2✔
44
    <div className="monitoring-alert column-data" style={style}>
45
      {(severityMap[alert.level] ?? severityMap[monitoringSeverities.UNKNOWN]).icon}
2!
46
      <div className="key muted">
47
        <b>{alert.name}</b>
48
      </div>
49
      <div>{alert.level}</div>
50
      <Time value={alert.timestamp} />
51
      {(lines.length || description) && <a onClick={() => onDetailsClick(alert)}>view {lines.length ? 'log' : 'details'}</a>}
×
52
    </div>
53
  );
54
};
55

56
const paginationCutoff = defaultPerPage;
10✔
57
export const DeviceMonitoring = ({ device, onDetailsClick }) => {
10✔
58
  const theme = useTheme();
1✔
59
  const { alerts = [], latest: latestAlerts = [] } = useSelector(state => state.monitor.alerts.byDeviceId[device.id]) ?? {};
2!
60
  const alertListState = useSelector(state => state.monitor.alerts.alertList) ?? {};
2!
61
  const offlineThresholdSettings = useSelector(getOfflineThresholdSettings);
1✔
62
  const dispatch = useDispatch();
1✔
63
  const { page: pageNo = defaultPage, perPage: pageLength = defaultPerPage, total: alertCount } = alertListState;
1!
64

65
  useEffect(() => {
1✔
66
    dispatch(getDeviceAlerts(device.id, alertListState));
1✔
67
  }, [device.id, pageNo, pageLength]);
68

69
  const onChangePage = page => dispatch(setAlertListState({ page }));
1✔
70

71
  const onChangeRowsPerPage = perPage => dispatch(setAlertListState({ page: 1, perPage }));
1✔
72

73
  const { monitors = [], isOffline, updated_ts = '' } = device;
1!
74
  const hasMonitorsDefined = !!(monitors.length || alerts.length || latestAlerts.length);
1!
75

76
  return (
1✔
77
    <DeviceDataCollapse
78
      header={
79
        hasMonitorsDefined || isOffline ? (
2!
80
          <>
81
            {hasMonitorsDefined && !latestAlerts.length && <NoAlertsHeaderNotification />}
2!
82
            {latestAlerts.map(alert => (
83
              <MonitoringAlert alert={alert} key={alert.id} onDetailsClick={onDetailsClick} style={{ marginBottom: theme.spacing() }} />
1✔
84
            ))}
85
            {isOffline && <DeviceOfflineHeaderNotification offlineThresholdSettings={offlineThresholdSettings} />}
1!
86
          </>
87
        ) : (
88
          <DeviceMonitorsMissingNote />
89
        )
90
      }
91
      isAddOn
92
      title={
93
        <div className="flexbox center-aligned">
94
          <h4 className="margin-bottom-small margin-right">Monitoring</h4>
95
          {!!monitors.length && <Time className="muted" value={updated_ts} />}
1!
96
        </div>
97
      }
98
    >
99
      {alerts.length ? (
1!
100
        <>
101
          <div>
102
            <h4 className="muted">Alert history</h4>
103
            {alerts.map(alert => (
104
              <MonitoringAlert alert={alert} key={alert.id} onDetailsClick={onDetailsClick} />
1✔
105
            ))}
106
          </div>
107
          <div className="flexbox margin-top">
108
            {alertCount > paginationCutoff && (
2✔
109
              <Pagination
110
                className="margin-top-none"
111
                count={alertCount}
112
                rowsPerPage={pageLength}
113
                onChangeRowsPerPage={onChangeRowsPerPage}
114
                page={pageNo}
115
                onChangePage={onChangePage}
116
              />
117
            )}
118
          </div>
119
        </>
120
      ) : (
121
        hasMonitorsDefined && (
×
122
          <p className="muted margin-left-large" style={{ fontSize: 'larger' }}>
123
            There are currently no issues reported
124
          </p>
125
        )
126
      )}
127
    </DeviceDataCollapse>
128
  );
129
};
130

131
export const MonitoringTab = ({ device }) => {
10✔
132
  const [monitorDetails, setMonitorDetails] = useState();
1✔
133

134
  return (
1✔
135
    <>
136
      <DeviceMonitoring device={device} onDetailsClick={setMonitorDetails} />
137
      <MonitorDetailsDialog alert={monitorDetails} onClose={() => setMonitorDetails()} />
×
138
    </>
139
  );
140
};
141

142
export default MonitoringTab;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc