• 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

73.2
/src/js/components/app.js
1
// Copyright 2015 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 { useIdleTimer, workerTimers } from 'react-idle-timer';
16
import { useDispatch, useSelector } from 'react-redux';
17
import { useLocation, useNavigate } from 'react-router-dom';
18

19
import { CssBaseline } from '@mui/material';
20
import { ThemeProvider, createTheme } from '@mui/material/styles';
21
import withStyles from '@mui/styles/withStyles';
22
import { makeStyles } from 'tss-react/mui';
23

24
import Cookies from 'universal-cookie';
25

26
import { parseEnvironmentInfo, setSnackbar } from '../actions/appActions';
27
import { logoutUser, setAccountActivationCode, setShowConnectingDialog } from '../actions/userActions';
28
import { expirySet, getToken, updateMaxAge } from '../auth';
29
import SharedSnackbar from '../components/common/sharedsnackbar';
30
import { PrivateRoutes, PublicRoutes } from '../config/routes';
31
import { onboardingSteps } from '../constants/onboardingConstants';
32
import ErrorBoundary from '../errorboundary';
33
import { isDarkMode, toggle } from '../helpers';
34
import { getOnboardingState, getUserSettings } from '../selectors';
35
import { dark as darkTheme, light as lightTheme } from '../themes/Mender';
36
import Tracking from '../tracking';
37
import { getOnboardingComponentFor } from '../utils/onboardingmanager';
38
import ConfirmDismissHelptips from './common/dialogs/confirmdismisshelptips';
39
import DeviceConnectionDialog from './common/dialogs/deviceconnectiondialog';
40
import Footer from './footer';
41
import Header from './header/header';
42
import LeftNav from './leftnav';
43
import SearchResult from './search-result';
44
import Uploads from './uploads';
45

46
const activationPath = '/activate';
2✔
47
export const timeout = 900000; // 15 minutes idle time
2✔
48
const cookies = new Cookies();
2✔
49

50
const reducePalette =
51
  prefix =>
2✔
52
  (accu, [key, value]) => {
713✔
53
    if (value instanceof Object) {
3,038✔
54
      return {
682✔
55
        ...accu,
56
        ...Object.entries(value).reduce(reducePalette(`${prefix}-${key}`), {})
57
      };
58
    } else {
59
      accu[`${prefix}-${key}`] = value;
2,356✔
60
    }
61
    return accu;
2,356✔
62
  };
63

64
const cssVariables = ({ palette }) => {
2✔
65
  const muiVariables = Object.entries(palette).reduce(reducePalette('--mui'), {});
31✔
66
  return {
31✔
67
    '@global': {
68
      ':root': {
69
        ...muiVariables,
70
        '--mui-overlay': palette.grey[400]
71
      }
72
    }
73
  };
74
};
75

76
const WrappedBaseline = withStyles(cssVariables)(CssBaseline);
2✔
77

78
const useStyles = makeStyles()(() => ({
6✔
79
  public: {
80
    display: 'grid',
81
    gridTemplateRows: 'max-content 1fr max-content',
82
    height: '100vh',
83
    '.content': {
84
      alignSelf: 'center',
85
      justifySelf: 'center'
86
    }
87
  }
88
}));
89

90
export const AppRoot = () => {
2✔
91
  const [showSearchResult, setShowSearchResult] = useState(false);
55✔
92
  const navigate = useNavigate();
54✔
93
  const { pathname = '', hash } = useLocation();
54!
94

95
  const dispatch = useDispatch();
54✔
96
  const currentUser = useSelector(state => state.users.currentUser);
1,151✔
97
  const onboardingState = useSelector(getOnboardingState);
54✔
98
  const showDismissHelptipsDialog = useSelector(state => !state.onboarding.complete && state.onboarding.showTipsDialog);
1,151✔
99
  const showDeviceConnectionDialog = useSelector(state => state.users.showConnectDeviceDialog);
1,151✔
100
  const snackbar = useSelector(state => state.app.snackbar);
1,151✔
101
  const trackingCode = useSelector(state => state.app.trackerCode);
1,151✔
102
  const { mode } = useSelector(getUserSettings);
54✔
103

104
  useEffect(() => {
54✔
105
    dispatch(parseEnvironmentInfo());
5✔
106
    if (!trackingCode) {
5✔
107
      return;
3✔
108
    }
109
    if (!cookies.get('_ga')) {
2!
110
      Tracking.cookieconsent().then(({ trackingConsentGiven }) => {
×
111
        if (trackingConsentGiven) {
×
112
          Tracking.initialize(trackingCode);
×
113
          Tracking.pageview();
×
114
        }
115
      });
116
    } else {
117
      Tracking.initialize(trackingCode);
2✔
118
    }
119
    trackLocationChange(pathname);
2✔
120
  }, [trackingCode]);
121

122
  useEffect(() => {
54✔
123
    trackLocationChange(pathname);
4✔
124
    // the following is added to ensure backwards capability for hash containing routes & links (e.g. /ui/#/devices => /ui/devices)
125
    if (hash) {
4!
126
      navigate(hash.substring(1));
×
127
    }
128
  }, [hash, pathname]);
129

130
  const trackLocationChange = pathname => {
54✔
131
    let page = pathname;
6✔
132
    // if we're on page whose path might contain sensitive device/ group/ deployment names etc. we sanitize the sent information before submission
133
    if (page.includes('=') && (page.startsWith('/devices') || page.startsWith('/deployments'))) {
6!
134
      const splitter = page.lastIndexOf('/');
×
135
      const filters = page.slice(splitter + 1);
×
136
      const keyOnlyFilters = filters.split('&').reduce((accu, item) => `${accu}:${item.split('=')[0]}&`, ''); // assume the keys to filter by are not as revealing as the values things are filtered by
×
137
      page = `${page.substring(0, splitter)}?${keyOnlyFilters.substring(0, keyOnlyFilters.length - 1)}`; // cut off the last & of the reduced filters string
×
138
    } else if (page.startsWith(activationPath)) {
6!
139
      dispatch(setAccountActivationCode(page.substring(activationPath.length + 1)));
×
140
      navigate('/settings/my-profile', { replace: true });
×
141
    }
142
    Tracking.pageview(page);
6✔
143
  };
144

145
  const onIdle = () => {
54✔
146
    if (expirySet() && currentUser) {
2✔
147
      // logout user and warn
148
      return dispatch(logoutUser('Your session has expired. You have been automatically logged out due to inactivity.')).catch(updateMaxAge);
1✔
149
    }
150
  };
151

152
  useIdleTimer({ crossTab: true, onAction: updateMaxAge, onActive: updateMaxAge, onIdle, syncTimers: 400, timeout, timers: workerTimers });
54✔
153

154
  const onToggleSearchResult = () => setShowSearchResult(toggle);
54✔
155

156
  const onboardingComponent = getOnboardingComponentFor(onboardingSteps.ARTIFACT_CREATION_DIALOG, onboardingState);
54✔
157
  const theme = createTheme(isDarkMode(mode) ? darkTheme : lightTheme);
54!
158

159
  const { classes } = useStyles();
54✔
160

161
  return (
54✔
162
    <ThemeProvider theme={theme}>
163
      <WrappedBaseline enableColorScheme />
164
      <>
165
        {getToken() ? (
54✔
166
          <div id="app">
167
            <Header mode={mode} />
168
            <LeftNav />
169
            <div className="rightFluid container">
170
              <ErrorBoundary>
171
                <SearchResult onToggleSearchResult={onToggleSearchResult} open={showSearchResult} />
172
                <PrivateRoutes />
173
              </ErrorBoundary>
174
            </div>
175
            {onboardingComponent ? onboardingComponent : null}
52!
176
            {showDismissHelptipsDialog && <ConfirmDismissHelptips />}
52!
177
            {showDeviceConnectionDialog && <DeviceConnectionDialog onCancel={() => dispatch(setShowConnectingDialog(false))} />}
×
178
          </div>
179
        ) : (
180
          <div className={classes.public}>
181
            <PublicRoutes />
182
            <Footer />
183
          </div>
184
        )}
185
        <SharedSnackbar snackbar={snackbar} setSnackbar={message => dispatch(setSnackbar(message))} />
×
186
        <Uploads />
187
      </>
188
    </ThemeProvider>
189
  );
190
};
191

192
export default AppRoot;
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