• 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

58.49
/src/js/utils/onboardingmanager.js
1
// Copyright 2019 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 from 'react';
15

16
import CreateArtifactDialog from '../components/common/dialogs/createartifactdialog';
17
import BaseOnboardingTip from '../components/helptips/baseonboardingtip';
18
import DeploymentCompleteTip from '../components/helptips/deploymentcompletetip';
19
import OnboardingCompleteTip from '../components/helptips/onboardingcompletetip';
20
import {
21
  ApplicationUpdateReminderTip,
22
  ArtifactIncludedDeployOnboarding,
23
  ArtifactIncludedOnboarding,
24
  ArtifactModifiedOnboarding,
25
  DashboardOnboardingPendings,
26
  DashboardOnboardingState,
27
  DeploymentsInprogress,
28
  DeploymentsPast,
29
  DeploymentsPastCompletedFailure,
30
  DevicePendingTip,
31
  DevicesAcceptedOnboarding,
32
  DevicesPendingAcceptingOnboarding,
33
  GetStartedTip,
34
  SchedulingAllDevicesSelection,
35
  SchedulingArtifactSelection,
36
  SchedulingGroupSelection,
37
  SchedulingReleaseToDevices,
38
  UploadNewArtifactDialogClick,
39
  UploadNewArtifactDialogDestination,
40
  UploadNewArtifactDialogDeviceType,
41
  UploadNewArtifactDialogReleaseName,
42
  UploadNewArtifactDialogUpload,
43
  UploadNewArtifactTip,
44
  UploadPreparedArtifactTip,
45
  WelcomeSnackTip
46
} from '../components/helptips/onboardingtips';
47
import { yes } from '../constants/appConstants';
48
import { DEPLOYMENT_STATES } from '../constants/deploymentConstants';
49
import { onboardingSteps as stepNames } from '../constants/onboardingConstants';
50

51
export const onboardingSteps = {
187✔
52
  [stepNames.ONBOARDING_START]: {
53
    condition: { min: stepNames.ONBOARDING_START, max: stepNames.DEVICES_PENDING_ONBOARDING },
54
    specialComponent: <WelcomeSnackTip progress={1} />
55
  },
56
  [stepNames.DASHBOARD_ONBOARDING_START]: {
57
    condition: { min: stepNames.ONBOARDING_START },
58
    component: GetStartedTip,
59
    progress: 1
60
  },
61
  [stepNames.DEVICES_PENDING_ONBOARDING_START]: {
62
    condition: { min: stepNames.DASHBOARD_ONBOARDING_START, max: stepNames.DEVICES_PENDING_ONBOARDING },
63
    fallbackStep: stepNames.DASHBOARD_ONBOARDING_START,
64
    specialComponent: <DevicePendingTip />
65
  },
66
  [stepNames.DEVICES_PENDING_ONBOARDING]: {
67
    condition: { min: stepNames.DASHBOARD_ONBOARDING_START },
68
    component: DashboardOnboardingState,
69
    fallbackStep: stepNames.DASHBOARD_ONBOARDING_START,
70
    progress: 1
71
  },
72
  [stepNames.DEVICES_PENDING_ACCEPTING_ONBOARDING]: {
73
    condition: { min: stepNames.DEVICES_PENDING_ONBOARDING, max: stepNames.DEVICES_ACCEPTED_ONBOARDING },
74
    component: DevicesPendingAcceptingOnboarding,
75
    progress: 1
76
  },
77
  [stepNames.DASHBOARD_ONBOARDING_PENDINGS]: {
78
    condition: { min: stepNames.DEVICES_PENDING_ONBOARDING },
79
    component: DashboardOnboardingPendings,
80
    progress: 1
81
  },
82
  [stepNames.DEVICES_ACCEPTED_ONBOARDING]: {
83
    condition: { max: stepNames.DEVICES_ACCEPTED_ONBOARDING_NOTIFICATION },
84
    component: DevicesAcceptedOnboarding,
85
    progress: 1
86
  },
87
  [stepNames.DEVICES_ACCEPTED_ONBOARDING_NOTIFICATION]: {
88
    condition: { min: stepNames.DASHBOARD_ONBOARDING_PENDINGS, max: stepNames.APPLICATION_UPDATE_REMINDER_TIP },
89
    specialComponent: <WelcomeSnackTip progress={2} />
90
  },
91
  [stepNames.APPLICATION_UPDATE_REMINDER_TIP]: {
92
    condition: { max: stepNames.ARTIFACT_INCLUDED_DEPLOY_ONBOARDING, extra: () => window.location.pathname.includes('/devices') },
×
93
    component: ApplicationUpdateReminderTip,
94
    progress: 2
95
  },
96
  [stepNames.UPLOAD_PREPARED_ARTIFACT_TIP]: {
97
    condition: { min: stepNames.DEVICES_ACCEPTED_ONBOARDING },
98
    component: UploadPreparedArtifactTip,
99
    fallbackStep: stepNames.APPLICATION_UPDATE_REMINDER_TIP,
100
    progress: 2
101
  },
102
  [stepNames.ARTIFACT_INCLUDED_ONBOARDING]: {
103
    condition: {
104
      min: stepNames.DEVICES_ACCEPTED_ONBOARDING,
105
      max: stepNames.DEPLOYMENTS_INPROGRESS,
106
      extra: () => !window.location.pathname.substring(window.location.pathname.indexOf('/releases') + '/releases'.length).length
×
107
    },
108
    component: ArtifactIncludedOnboarding,
109
    fallbackStep: stepNames.APPLICATION_UPDATE_REMINDER_TIP,
110
    progress: 1
111
  },
112
  [stepNames.ARTIFACT_INCLUDED_DEPLOY_ONBOARDING]: {
113
    condition: { max: stepNames.DEPLOYMENTS_INPROGRESS },
114
    component: ArtifactIncludedDeployOnboarding,
115
    fallbackStep: stepNames.ARTIFACT_INCLUDED_ONBOARDING,
116
    progress: 1
117
  },
118
  [stepNames.SCHEDULING_ALL_DEVICES_SELECTION]: {
119
    condition: { min: stepNames.ARTIFACT_INCLUDED_ONBOARDING, max: stepNames.DEPLOYMENTS_INPROGRESS },
120
    component: SchedulingAllDevicesSelection,
121
    fallbackStep: stepNames.ARTIFACT_INCLUDED_ONBOARDING,
122
    progress: 2
123
  },
124
  [stepNames.SCHEDULING_GROUP_SELECTION]: {
125
    condition: { min: stepNames.ARTIFACT_INCLUDED_ONBOARDING, max: stepNames.DEPLOYMENTS_INPROGRESS },
126
    component: SchedulingGroupSelection,
127
    fallbackStep: stepNames.ARTIFACT_INCLUDED_ONBOARDING,
128
    progress: 2
129
  },
130
  [stepNames.SCHEDULING_ARTIFACT_SELECTION]: {
131
    condition: { min: stepNames.SCHEDULING_ALL_DEVICES_SELECTION, max: stepNames.DEPLOYMENTS_INPROGRESS },
132
    component: SchedulingArtifactSelection,
133
    fallbackStep: stepNames.ARTIFACT_INCLUDED_ONBOARDING,
134
    progress: 2
135
  },
136
  [stepNames.SCHEDULING_RELEASE_TO_DEVICES]: {
137
    condition: { min: stepNames.SCHEDULING_ARTIFACT_SELECTION, max: stepNames.DEPLOYMENTS_INPROGRESS },
138
    component: SchedulingReleaseToDevices,
139
    fallbackStep: stepNames.ARTIFACT_INCLUDED_ONBOARDING
140
  },
141
  [stepNames.DEPLOYMENTS_INPROGRESS]: {
142
    condition: {},
143
    component: DeploymentsInprogress,
144
    progress: 2
145
  },
146
  [stepNames.DEPLOYMENTS_PAST]: {
147
    condition: { min: stepNames.DEPLOYMENTS_INPROGRESS, extra: () => !window.location.pathname.includes(DEPLOYMENT_STATES.finished) },
×
148
    component: DeploymentsPast,
149
    progress: 3
150
  },
151
  [stepNames.DEPLOYMENTS_PAST_COMPLETED_NOTIFICATION]: {
152
    condition: { min: stepNames.DEPLOYMENTS_PAST },
153
    specialComponent: <WelcomeSnackTip progress={3} />
154
  },
155
  [stepNames.DEPLOYMENTS_PAST_COMPLETED]: {
156
    condition: { min: stepNames.DEPLOYMENTS_PAST_COMPLETED_NOTIFICATION, max: stepNames.DEPLOYMENTS_PAST_COMPLETED_FAILURE },
157
    specialComponent: <DeploymentCompleteTip targetUrl="destination-unreachable" />
158
  },
159
  [stepNames.DEPLOYMENTS_PAST_COMPLETED_FAILURE]: {
160
    condition: { max: stepNames.ARTIFACT_CREATION_DIALOG },
161
    component: DeploymentsPastCompletedFailure
162
  },
163
  [stepNames.ARTIFACT_CREATION_DIALOG]: {
164
    condition: { max: stepNames.UPLOAD_NEW_ARTIFACT_TIP },
165
    specialComponent: <CreateArtifactDialog />
166
  },
167
  [stepNames.UPLOAD_NEW_ARTIFACT_TIP]: {
168
    condition: {},
169
    component: UploadNewArtifactTip,
170
    progress: 2
171
  },
172
  [stepNames.UPLOAD_NEW_ARTIFACT_DIALOG_UPLOAD]: {
173
    condition: { min: stepNames.UPLOAD_NEW_ARTIFACT_TIP },
174
    component: UploadNewArtifactDialogUpload,
175
    fallbackStep: stepNames.UPLOAD_NEW_ARTIFACT_TIP,
176
    progress: 2
177
  },
178
  [stepNames.UPLOAD_NEW_ARTIFACT_DIALOG_DESTINATION]: {
179
    condition: { min: stepNames.UPLOAD_NEW_ARTIFACT_TIP, max: stepNames.UPLOAD_NEW_ARTIFACT_DIALOG_RELEASE_NAME },
180
    component: UploadNewArtifactDialogDestination,
181
    fallbackStep: stepNames.UPLOAD_NEW_ARTIFACT_TIP,
182
    progress: 2
183
  },
184
  [stepNames.UPLOAD_NEW_ARTIFACT_DIALOG_RELEASE_NAME]: {
185
    condition: { min: stepNames.UPLOAD_NEW_ARTIFACT_DIALOG_DESTINATION },
186
    component: UploadNewArtifactDialogReleaseName,
187
    fallbackStep: stepNames.UPLOAD_NEW_ARTIFACT_TIP,
188
    progress: 2
189
  },
190
  [stepNames.UPLOAD_NEW_ARTIFACT_DIALOG_DEVICE_TYPE]: {
191
    condition: { min: stepNames.UPLOAD_NEW_ARTIFACT_DIALOG_RELEASE_NAME },
192
    component: UploadNewArtifactDialogDeviceType,
193
    fallbackStep: stepNames.UPLOAD_NEW_ARTIFACT_TIP,
194
    progress: 2
195
  },
196
  [stepNames.UPLOAD_NEW_ARTIFACT_DIALOG_CLICK]: {
197
    condition: {},
198
    component: UploadNewArtifactDialogClick,
199
    fallbackStep: stepNames.UPLOAD_NEW_ARTIFACT_TIP,
200
    progress: 2
201
  },
202
  [stepNames.ARTIFACT_MODIFIED_ONBOARDING]: {
203
    condition: {},
204
    component: ArtifactModifiedOnboarding,
205
    progress: 1
206
  },
207
  [stepNames.ONBOARDING_FINISHED]: {
208
    condition: {},
209
    specialComponent: <OnboardingCompleteTip targetUrl="destination-unreachable" />
210
  },
211
  [stepNames.ONBOARDING_FINISHED_NOTIFICATION]: {
212
    condition: { min: stepNames.ONBOARDING_FINISHED },
213
    specialComponent: <WelcomeSnackTip progress={4} />
214
  },
215
  [stepNames.ONBOARDING_CANCELED]: {
216
    condition: { extra: yes },
217
    specialComponent: <div />,
218
    progress: 3
219
  }
220
};
221

222
const getOnboardingStepCompleted = (id, progress, complete, showHelptips, showTips) => {
187✔
223
  const keys = Object.keys(onboardingSteps);
2,422✔
224
  const {
225
    min = id,
565✔
226
    max = id,
1,056✔
227
    extra
228
  } = Object.entries(onboardingSteps).reduce((accu, [key, value]) => {
2,422✔
229
    if (key === id) {
77,504✔
230
      return value.condition;
2,422✔
231
    }
232
    return accu;
75,082✔
233
  }, {});
234
  const progressIndex = keys.findIndex(step => step === progress);
64,892✔
235
  return (
2,422✔
236
    !complete &&
6,987!
237
    showHelptips &&
238
    showTips &&
239
    progressIndex >= keys.findIndex(step => step === min) &&
×
240
    progressIndex <= keys.findIndex(step => step === max) &&
×
241
    (extra ? extra() : true)
×
242
  );
243
};
244

245
export const getOnboardingComponentFor = (id, componentProps, params = {}, previousComponent = null) => {
187✔
246
  const step = onboardingSteps[id];
2,422✔
247
  const isValid = getOnboardingStepCompleted(id, componentProps.progress, componentProps.complete, componentProps.showHelptips, componentProps.showTips);
2,422✔
248
  if (!isValid) {
2,422!
249
    return previousComponent;
2,422✔
250
  }
251
  if (step.specialComponent) {
×
252
    return React.cloneElement(step.specialComponent, params);
×
253
  }
254
  const component = step.component(componentProps);
×
255
  return <BaseOnboardingTip id={id} component={component} progress={step.progress || params.progress || null} {...params} />;
×
256
};
257

258
export const applyOnboardingFallbacks = progress => {
187✔
259
  const step = onboardingSteps[progress];
8✔
260
  if (step && step.fallbackStep) {
8!
261
    return step.fallbackStep;
×
262
  }
263
  return progress;
8✔
264
};
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