@northern.tech/store 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.cjs +9 -0
- package/.prettierignore +1 -0
- package/CHANGELOG.md +12 -0
- package/actions.ts +32 -0
- package/api/general-api.test.ts +51 -0
- package/api/general-api.ts +60 -0
- package/api/types/AWSCredentials.ts +16 -0
- package/api/types/Actor.ts +35 -0
- package/api/types/Addon.ts +17 -0
- package/api/types/AddonTenantadm.ts +17 -0
- package/api/types/Alert.ts +34 -0
- package/api/types/AlertDetails.ts +23 -0
- package/api/types/AlertSubject.ts +23 -0
- package/api/types/ApiBurst.ts +21 -0
- package/api/types/ApiBurstTenantadm.ts +21 -0
- package/api/types/ApiLimits.ts +16 -0
- package/api/types/ApiLimitsTenantadm.ts +16 -0
- package/api/types/ApiQuota.ts +17 -0
- package/api/types/ApiQuotaTenantadm.ts +17 -0
- package/api/types/Artifact.ts +48 -0
- package/api/types/ArtifactDeployments.ts +48 -0
- package/api/types/ArtifactInfo.ts +11 -0
- package/api/types/ArtifactInfoDeployments.ts +11 -0
- package/api/types/ArtifactLink.ts +11 -0
- package/api/types/ArtifactTypeInfo.ts +13 -0
- package/api/types/ArtifactTypeInfoDeployments.ts +13 -0
- package/api/types/ArtifactUpdate.ts +10 -0
- package/api/types/ArtifactUploadLink.ts +15 -0
- package/api/types/Attribute.ts +36 -0
- package/api/types/AttributeInventory.ts +32 -0
- package/api/types/AuditLog.ts +26 -0
- package/api/types/AuthSet.ts +33 -0
- package/api/types/AuthSetDeviceauth.ts +37 -0
- package/api/types/AutoAuthRequest.ts +23 -0
- package/api/types/AzureSharedAccessSecret.ts +11 -0
- package/api/types/BillingInfo.ts +13 -0
- package/api/types/BinaryDeltaConfiguration.ts +15 -0
- package/api/types/BinaryDeltaConfigurationDeployments.ts +15 -0
- package/api/types/BinaryDeltaLimits.ts +15 -0
- package/api/types/BinaryDeltaLimitsDeployments.ts +15 -0
- package/api/types/BoundingBox.ts +11 -0
- package/api/types/CancelRequest.ts +10 -0
- package/api/types/CardData.ts +49 -0
- package/api/types/CardSetupData.ts +17 -0
- package/api/types/CheckoutData.ts +13 -0
- package/api/types/Configuration.ts +11 -0
- package/api/types/Count.ts +13 -0
- package/api/types/Credentials.ts +23 -0
- package/api/types/DBusSubsystem.ts +27 -0
- package/api/types/DeltaConfiguration.ts +14 -0
- package/api/types/DeltaConfigurationDeployments.ts +14 -0
- package/api/types/Deployment.ts +95 -0
- package/api/types/DeploymentAggregation.ts +18 -0
- package/api/types/DeploymentAggregationItem.ts +18 -0
- package/api/types/DeploymentAggregationTerm.ts +23 -0
- package/api/types/DeploymentAggregationTerms.ts +18 -0
- package/api/types/DeploymentAttributeProjection.ts +11 -0
- package/api/types/DeploymentAuditlogs.ts +11 -0
- package/api/types/DeploymentDeployments.ts +99 -0
- package/api/types/DeploymentFilterTerm.ts +37 -0
- package/api/types/DeploymentIdentifier.ts +10 -0
- package/api/types/DeploymentPhase.ts +23 -0
- package/api/types/DeploymentReporting.ts +46 -0
- package/api/types/DeploymentSearchTerms.ts +39 -0
- package/api/types/DeploymentSortTerm.ts +25 -0
- package/api/types/DeploymentStatistics.ts +15 -0
- package/api/types/DeploymentStatusStatistics.ts +54 -0
- package/api/types/Device.ts +29 -0
- package/api/types/DeviceAggregation.ts +18 -0
- package/api/types/DeviceAggregationItem.ts +18 -0
- package/api/types/DeviceAggregationTerm.ts +27 -0
- package/api/types/DeviceAggregationTerms.ts +22 -0
- package/api/types/DeviceAttribute.ts +23 -0
- package/api/types/DeviceAttributeProjection.ts +15 -0
- package/api/types/DeviceAuditlogs.ts +17 -0
- package/api/types/DeviceAuthEvent.ts +23 -0
- package/api/types/DeviceConfiguration.ts +16 -0
- package/api/types/DeviceDeployment.ts +11 -0
- package/api/types/DeviceDeployments.ts +31 -0
- package/api/types/DeviceDeviceauth.ts +42 -0
- package/api/types/DeviceFilterAttribute.ts +22 -0
- package/api/types/DeviceFilterTerm.ts +41 -0
- package/api/types/DeviceInventory.ts +19 -0
- package/api/types/DeviceInventoryInventory.ts +19 -0
- package/api/types/DeviceReporting.ts +22 -0
- package/api/types/DeviceSearchTerms.ts +39 -0
- package/api/types/DeviceSortTerm.ts +29 -0
- package/api/types/DeviceState.ts +32 -0
- package/api/types/DeviceStateDeviceconnect.ts +33 -0
- package/api/types/DeviceStateIot_manager.ts +14 -0
- package/api/types/DeviceStatus.ts +19 -0
- package/api/types/DeviceWithImage.ts +80 -0
- package/api/types/DirectUploadMetadata.ts +18 -0
- package/api/types/EmailVerificationCompletion.ts +13 -0
- package/api/types/EmailVerificationRequest.ts +13 -0
- package/api/types/Error.ts +17 -0
- package/api/types/ErrorAuditlogs.ts +13 -0
- package/api/types/ErrorDeployments.ts +17 -0
- package/api/types/ErrorDeviceauth.ts +13 -0
- package/api/types/ErrorDeviceconfig.ts +17 -0
- package/api/types/ErrorDeviceconnect.ts +17 -0
- package/api/types/ErrorDevicemonitor.ts +17 -0
- package/api/types/ErrorExt.ts +18 -0
- package/api/types/ErrorInventory.ts +17 -0
- package/api/types/ErrorIot_manager.ts +17 -0
- package/api/types/ErrorNotFound.ts +17 -0
- package/api/types/ErrorReporting.ts +18 -0
- package/api/types/ErrorTenantadm.ts +13 -0
- package/api/types/ErrorUseradm.ts +17 -0
- package/api/types/Event.ts +48 -0
- package/api/types/ExternalIdentity.ts +17 -0
- package/api/types/Features.ts +17 -0
- package/api/types/FileUpload.ts +23 -0
- package/api/types/Filter.ts +19 -0
- package/api/types/FilterAttribute.ts +21 -0
- package/api/types/FilterDefinition.ts +18 -0
- package/api/types/FilterDeployments.ts +19 -0
- package/api/types/FilterInventory.ts +20 -0
- package/api/types/FilterPredicate.ts +78 -0
- package/api/types/FilterPredicateDeployments.ts +48 -0
- package/api/types/FilterPredicateInventory.ts +76 -0
- package/api/types/GeoBoundingBox.ts +10 -0
- package/api/types/GeoBoundingBoxFilter.ts +6 -0
- package/api/types/GeoDistance.ts +17 -0
- package/api/types/GeoDistanceFilter.ts +10 -0
- package/api/types/GeoPoint.ts +15 -0
- package/api/types/Group.ts +10 -0
- package/api/types/HTTP.ts +19 -0
- package/api/types/IdentityData.ts +25 -0
- package/api/types/InputParameter.ts +8 -0
- package/api/types/Integration.ts +24 -0
- package/api/types/JobStatus.ts +13 -0
- package/api/types/Limit.ts +21 -0
- package/api/types/LimitDeployments.ts +21 -0
- package/api/types/LimitDeviceauth.ts +10 -0
- package/api/types/LimitUseradm.ts +11 -0
- package/api/types/Limits.ts +11 -0
- package/api/types/LineDescriptor.ts +11 -0
- package/api/types/LogSubsystem.ts +23 -0
- package/api/types/LoginOptions.ts +18 -0
- package/api/types/ManagementAPIConfiguration.ts +5 -0
- package/api/types/MenderTypes.ts +183 -0
- package/api/types/MonitorConfiguration.ts +22 -0
- package/api/types/NewConfigurationDeployment.ts +15 -0
- package/api/types/NewConfigurationDeploymentResponse.ts +10 -0
- package/api/types/NewDeployment.ts +42 -0
- package/api/types/NewDeploymentForGroup.ts +33 -0
- package/api/types/NewDeploymentPhase.ts +37 -0
- package/api/types/NewDeploymentPhaseDeployments.ts +20 -0
- package/api/types/NewDeploymentV2.ts +31 -0
- package/api/types/NewTenant.ts +41 -0
- package/api/types/Object.ts +35 -0
- package/api/types/OwnUserUpdate.ts +21 -0
- package/api/types/PasswordResetCompletion.ts +17 -0
- package/api/types/PasswordResetRequest.ts +13 -0
- package/api/types/Permission.ts +21 -0
- package/api/types/PermissionObject.ts +14 -0
- package/api/types/PermissionSet.ts +22 -0
- package/api/types/PermissionSetWithScope.ts +15 -0
- package/api/types/PersonalAccessToken.ts +29 -0
- package/api/types/PersonalAccessTokenRequest.ts +18 -0
- package/api/types/Plan.ts +19 -0
- package/api/types/PlanBindingDetails.ts +13 -0
- package/api/types/PlanChangeRequest.ts +14 -0
- package/api/types/PlanLimits.ts +12 -0
- package/api/types/PreAuthSet.ts +16 -0
- package/api/types/Release.ts +32 -0
- package/api/types/ReleaseDeployments.ts +32 -0
- package/api/types/ReleaseUpdate.ts +13 -0
- package/api/types/Releases.ts +9 -0
- package/api/types/ReleasesDeleteError.ts +21 -0
- package/api/types/ReleasesDeployments.ts +9 -0
- package/api/types/Role.ts +19 -0
- package/api/types/RolePermission.ts +25 -0
- package/api/types/RolePermissionObject.ts +17 -0
- package/api/types/RoleUseradm.ts +19 -0
- package/api/types/SAMLMetadata.ts +21 -0
- package/api/types/Scope.ts +19 -0
- package/api/types/SelectAttribute.ts +17 -0
- package/api/types/ServiceSubsystem.ts +19 -0
- package/api/types/Settings.ts +23 -0
- package/api/types/SortCriteria.ts +30 -0
- package/api/types/SsoObject.ts +21 -0
- package/api/types/Status.ts +17 -0
- package/api/types/StatusDeviceauth.ts +18 -0
- package/api/types/StatusTenantadm.ts +19 -0
- package/api/types/StorageLimit.ts +17 -0
- package/api/types/SubscriptionData.ts +8 -0
- package/api/types/SupportRequest.ts +17 -0
- package/api/types/Tag.ts +27 -0
- package/api/types/Tags.ts +10 -0
- package/api/types/TaskResult.ts +13 -0
- package/api/types/TaskResultCLI.ts +10 -0
- package/api/types/TaskResultHTTPRequest.ts +8 -0
- package/api/types/TaskResultHTTPResponse.ts +10 -0
- package/api/types/Tenant.ts +38 -0
- package/api/types/TenantApiLimits.ts +12 -0
- package/api/types/TenantApiLimitsTenantadm.ts +12 -0
- package/api/types/TenantIdName.ts +14 -0
- package/api/types/TenantIdsData.ts +10 -0
- package/api/types/TenantInfo.ts +14 -0
- package/api/types/TenantShortInfo.ts +21 -0
- package/api/types/TenantTenantadm.ts +38 -0
- package/api/types/TenantsIdName.ts +6 -0
- package/api/types/Update.ts +17 -0
- package/api/types/UpdateDeployments.ts +18 -0
- package/api/types/UpdateFile.ts +13 -0
- package/api/types/UpdateFileDeployments.ts +13 -0
- package/api/types/UpdateTypes.ts +8 -0
- package/api/types/UpgradeCompleteRequest.ts +23 -0
- package/api/types/User.ts +13 -0
- package/api/types/UserAuditlogs.ts +13 -0
- package/api/types/UserNew.ts +26 -0
- package/api/types/UserUpdate.ts +25 -0
- package/api/types/UserUseradm.ts +45 -0
- package/api/types/UserWithTenantInfo.ts +8 -0
- package/api/types/XDeltaArgs.ts +9 -0
- package/api/types/XDeltaArgsDeployments.ts +9 -0
- package/api/types/XDeltaArgsLimits.ts +10 -0
- package/api/types/XDeltaArgsLimitsDeployments.ts +10 -0
- package/api/users-api.ts +34 -0
- package/appSlice/constants.ts +166 -0
- package/appSlice/index.ts +159 -0
- package/appSlice/reducer.test.ts +97 -0
- package/appSlice/selectors.ts +33 -0
- package/appSlice/thunks.test.ts +118 -0
- package/appSlice/thunks.ts +148 -0
- package/auth.test.ts +36 -0
- package/auth.ts +82 -0
- package/commonConstants.tsx +252 -0
- package/commonSelectors.ts +255 -0
- package/constants.ts +22 -0
- package/deploymentsSlice/constants.ts +175 -0
- package/deploymentsSlice/index.ts +145 -0
- package/deploymentsSlice/reducer.test.ts +108 -0
- package/deploymentsSlice/selectors.ts +58 -0
- package/deploymentsSlice/thunks.test.ts +425 -0
- package/deploymentsSlice/thunks.ts +382 -0
- package/devicesSlice/constants.ts +56 -0
- package/devicesSlice/index.ts +207 -0
- package/devicesSlice/reducer.test.ts +194 -0
- package/devicesSlice/selectors.ts +127 -0
- package/devicesSlice/thunks.test.tsx +1245 -0
- package/devicesSlice/thunks.tsx +1098 -0
- package/monitorSlice/constants.ts +17 -0
- package/monitorSlice/index.ts +65 -0
- package/monitorSlice/reducer.test.ts +79 -0
- package/monitorSlice/selectors.ts +15 -0
- package/monitorSlice/thunks.test.ts +112 -0
- package/monitorSlice/thunks.ts +101 -0
- package/onboardingSlice/constants.ts +53 -0
- package/onboardingSlice/index.ts +60 -0
- package/onboardingSlice/reducer.test.ts +45 -0
- package/onboardingSlice/selectors.ts +15 -0
- package/onboardingSlice/thunks.test.ts +235 -0
- package/onboardingSlice/thunks.ts +142 -0
- package/organizationSlice/constants.ts +82 -0
- package/organizationSlice/index.ts +111 -0
- package/organizationSlice/reducer.test.ts +78 -0
- package/organizationSlice/selectors.ts +45 -0
- package/organizationSlice/thunks.test.ts +619 -0
- package/organizationSlice/thunks.ts +383 -0
- package/package.json +38 -0
- package/releasesSlice/constants.ts +18 -0
- package/releasesSlice/index.ts +116 -0
- package/releasesSlice/reducer.test.ts +78 -0
- package/releasesSlice/selectors.ts +33 -0
- package/releasesSlice/thunks.test.ts +389 -0
- package/releasesSlice/thunks.ts +379 -0
- package/selectors.ts +22 -0
- package/store.ts +89 -0
- package/storehooks.test.tsx +386 -0
- package/storehooks.ts +250 -0
- package/thunks.ts +21 -0
- package/tsconfig.json +11 -0
- package/tsup.config.ts +11 -0
- package/usersSlice/constants.ts +374 -0
- package/usersSlice/index.ts +151 -0
- package/usersSlice/reducer.test.ts +141 -0
- package/usersSlice/selectors.ts +60 -0
- package/usersSlice/thunks.test.ts +660 -0
- package/usersSlice/thunks.ts +773 -0
- package/utils.test.ts +187 -0
- package/utils.ts +249 -0
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Copyright 2024 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
|
+
// @ts-nocheck
|
|
15
|
+
|
|
16
|
+
/*eslint import/namespace: ['error', { allowComputed: true }]*/
|
|
17
|
+
import reducer, { actions, initialState } from '.';
|
|
18
|
+
import { defaultState } from '../../../../tests/mockData';
|
|
19
|
+
import { DEPLOYMENT_STATES } from './constants';
|
|
20
|
+
|
|
21
|
+
describe('deployment reducer', () => {
|
|
22
|
+
it('should return the initial state', async () => {
|
|
23
|
+
expect(reducer(undefined, {})).toEqual(initialState);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should handle RECEIVE_DEPLOYMENT', async () => {
|
|
27
|
+
expect(reducer(undefined, { type: actions.receivedDeployment, payload: defaultState.deployments.byId.d1 }).byId.d1).toEqual(
|
|
28
|
+
defaultState.deployments.byId.d1
|
|
29
|
+
);
|
|
30
|
+
expect(reducer(initialState, { type: actions.receivedDeployment, payload: defaultState.deployments.byId.d1 }).byId.d1).toEqual(
|
|
31
|
+
defaultState.deployments.byId.d1
|
|
32
|
+
);
|
|
33
|
+
});
|
|
34
|
+
it('should handle RECEIVE_DEPLOYMENTS', async () => {
|
|
35
|
+
const { statistics } = defaultState.deployments.byId.d1;
|
|
36
|
+
expect(reducer(undefined, { type: actions.receivedDeployments, payload: { plain: 'passing' } }).byId.plain).toBeTruthy();
|
|
37
|
+
expect(
|
|
38
|
+
reducer(initialState, { type: actions.receivedDeployments, payload: { [defaultState.deployments.byId.d1.id]: { statistics } } }).byId.d1.statistics
|
|
39
|
+
).toBeTruthy();
|
|
40
|
+
});
|
|
41
|
+
it('should handle RECEIVE_DEPLOYMENT_DEVICE_LOG', async () => {
|
|
42
|
+
expect(
|
|
43
|
+
reducer(undefined, {
|
|
44
|
+
type: actions.receivedDeploymentDeviceLog,
|
|
45
|
+
payload: { id: defaultState.deployments.byId.d1.id, deviceId: defaultState.deployments.byId.d1.devices.a1.id, log: 'foo' }
|
|
46
|
+
}).byId.d1.devices.a1.log
|
|
47
|
+
).toEqual('foo');
|
|
48
|
+
expect(
|
|
49
|
+
reducer(initialState, {
|
|
50
|
+
type: actions.receivedDeploymentDeviceLog,
|
|
51
|
+
payload: { id: defaultState.deployments.byId.d1.id, deviceId: defaultState.deployments.byId.d1.devices.a1.id, log: 'bar' }
|
|
52
|
+
}).byId.d1.devices.a1.log
|
|
53
|
+
).toEqual('bar');
|
|
54
|
+
});
|
|
55
|
+
it('should handle RECEIVE_DEPLOYMENT_DEVICES', async () => {
|
|
56
|
+
const { devices, id } = defaultState.deployments.byId.d1;
|
|
57
|
+
expect(
|
|
58
|
+
reducer(undefined, {
|
|
59
|
+
type: actions.receivedDeploymentDevices,
|
|
60
|
+
payload: { id, devices, selectedDeviceIds: [devices.a1.id], totalDeviceCount: 500 }
|
|
61
|
+
}).byId.d1.totalDeviceCount
|
|
62
|
+
).toEqual(500);
|
|
63
|
+
expect(
|
|
64
|
+
reducer(defaultState.deployments, {
|
|
65
|
+
type: actions.receivedDeploymentDevices,
|
|
66
|
+
payload: { id, devices, selectedDeviceIds: [devices.a1.id], totalDeviceCount: 500 }
|
|
67
|
+
}).byId.d1.statistics
|
|
68
|
+
).toEqual(defaultState.deployments.byId.d1.statistics);
|
|
69
|
+
});
|
|
70
|
+
it('should handle RECEIVE_<deploymentstatus>_DEPLOYMENTS', async () => {
|
|
71
|
+
Object.values(DEPLOYMENT_STATES).forEach(status => {
|
|
72
|
+
expect(reducer(undefined, { type: actions.receivedDeploymentsForStatus, payload: { deploymentIds: ['a1'], total: 1, status } }).byStatus[status]).toEqual(
|
|
73
|
+
{ deploymentIds: ['a1'], total: 1 }
|
|
74
|
+
);
|
|
75
|
+
expect(
|
|
76
|
+
reducer(initialState, { type: actions.receivedDeploymentsForStatus, payload: { deploymentIds: ['a1'], total: 1, status } }).byStatus[status]
|
|
77
|
+
).toEqual({ deploymentIds: ['a1'], total: 1 });
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
it('should handle SELECT_<deploymentstatus>_DEPLOYMENTS', async () => {
|
|
81
|
+
Object.values(DEPLOYMENT_STATES).forEach(status => {
|
|
82
|
+
expect(
|
|
83
|
+
reducer(undefined, { type: actions.selectDeploymentsForStatus, payload: { deploymentIds: ['a1'], status } }).selectionState[status].selection
|
|
84
|
+
).toEqual(['a1']);
|
|
85
|
+
expect(
|
|
86
|
+
reducer(initialState, { type: actions.selectDeploymentsForStatus, payload: { deploymentIds: ['a1'], status } }).selectionState[status].selection
|
|
87
|
+
).toEqual(['a1']);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
it('should handle SET_DEPLOYMENTS_STATE', async () => {
|
|
91
|
+
const newState = { something: 'new' };
|
|
92
|
+
expect(reducer(undefined, { type: actions.setDeploymentsState, payload: newState }).selectionState).toEqual(newState);
|
|
93
|
+
expect(reducer(initialState, { type: actions.setDeploymentsState, payload: newState }).selectionState).toEqual(newState);
|
|
94
|
+
});
|
|
95
|
+
it('should handle REMOVE_DEPLOYMENT', async () => {
|
|
96
|
+
let state = reducer(undefined, { type: actions.receivedDeployment, payload: defaultState.deployments.byId.d1 });
|
|
97
|
+
expect(reducer(state, { type: actions.removedDeployment, payload: defaultState.deployments.byId.d1.id }).byId).toEqual({});
|
|
98
|
+
expect(reducer(initialState, { type: actions.removedDeployment, payload: 'a1' }).byId).toEqual({});
|
|
99
|
+
});
|
|
100
|
+
it('should handle CREATE_DEPLOYMENT', async () => {
|
|
101
|
+
expect(reducer(undefined, { type: actions.createdDeployment, payload: { name: 'test', id: 'test' } }).byId.test.devices).toEqual({});
|
|
102
|
+
expect(reducer(initialState, { type: actions.createdDeployment, payload: { name: 'test', id: 'a1' } }).byStatus.pending.deploymentIds).toContain('a1');
|
|
103
|
+
});
|
|
104
|
+
it('should handle SET_DEPLOYMENTS_CONFIG', async () => {
|
|
105
|
+
expect(reducer(undefined, { type: actions.setDeploymentsConfig, payload: { name: 'test' } }).config).toEqual({ name: 'test' });
|
|
106
|
+
expect(reducer(initialState, { type: actions.setDeploymentsConfig, payload: { name: 'test' } }).config).toEqual({ name: 'test' });
|
|
107
|
+
});
|
|
108
|
+
});
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// Copyright 2023 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
|
+
// @ts-nocheck
|
|
15
|
+
import { createSelector } from '@reduxjs/toolkit';
|
|
16
|
+
|
|
17
|
+
import { DEPLOYMENT_STATES } from './constants';
|
|
18
|
+
|
|
19
|
+
export const getDeploymentsById = state => state.deployments.byId;
|
|
20
|
+
export const getDeploymentsByStatus = state => state.deployments.byStatus;
|
|
21
|
+
export const getSelectedDeploymentDeviceIds = state => state.deployments.selectedDeviceIds;
|
|
22
|
+
export const getDeploymentsSelectionState = state => state.deployments.selectionState;
|
|
23
|
+
|
|
24
|
+
export const getMappedDeploymentSelection = createSelector(
|
|
25
|
+
[getDeploymentsSelectionState, (_, deploymentsState) => deploymentsState, getDeploymentsById],
|
|
26
|
+
(selectionState, deploymentsState, deploymentsById) => {
|
|
27
|
+
const { selection = [] } = selectionState[deploymentsState] ?? {};
|
|
28
|
+
return selection.reduce((accu, id) => {
|
|
29
|
+
if (deploymentsById[id]) {
|
|
30
|
+
accu.push(deploymentsById[id]);
|
|
31
|
+
}
|
|
32
|
+
return accu;
|
|
33
|
+
}, []);
|
|
34
|
+
}
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
const relevantDeploymentStates = [DEPLOYMENT_STATES.pending, DEPLOYMENT_STATES.inprogress, DEPLOYMENT_STATES.finished];
|
|
38
|
+
export const DEPLOYMENT_CUTOFF = 3;
|
|
39
|
+
export const getRecentDeployments = createSelector([getDeploymentsById, getDeploymentsByStatus], (deploymentsById, deploymentsByStatus) =>
|
|
40
|
+
Object.entries(deploymentsByStatus).reduce(
|
|
41
|
+
(accu, [state, byStatus]) => {
|
|
42
|
+
if (!relevantDeploymentStates.includes(state) || !byStatus.deploymentIds.length) {
|
|
43
|
+
return accu;
|
|
44
|
+
}
|
|
45
|
+
accu[state] = byStatus.deploymentIds
|
|
46
|
+
.reduce((accu, id) => {
|
|
47
|
+
if (deploymentsById[id]) {
|
|
48
|
+
accu.push(deploymentsById[id]);
|
|
49
|
+
}
|
|
50
|
+
return accu;
|
|
51
|
+
}, [])
|
|
52
|
+
.slice(0, DEPLOYMENT_CUTOFF);
|
|
53
|
+
accu.total += byStatus.total;
|
|
54
|
+
return accu;
|
|
55
|
+
},
|
|
56
|
+
{ total: 0 }
|
|
57
|
+
)
|
|
58
|
+
);
|
|
@@ -0,0 +1,425 @@
|
|
|
1
|
+
// Copyright 2020 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
|
+
// @ts-nocheck
|
|
15
|
+
import { getGlobalSettings, saveGlobalSettings, setOfflineThreshold } from '@northern.tech/store/thunks';
|
|
16
|
+
import configureMockStore from 'redux-mock-store';
|
|
17
|
+
import { thunk } from 'redux-thunk';
|
|
18
|
+
|
|
19
|
+
import { actions } from '.';
|
|
20
|
+
import { defaultState } from '../../../../tests/mockData';
|
|
21
|
+
import { actions as appActions } from '../appSlice';
|
|
22
|
+
import { actions as deviceActions } from '../devicesSlice';
|
|
23
|
+
import { actions as userActions } from '../usersSlice';
|
|
24
|
+
import * as DeploymentConstants from './constants';
|
|
25
|
+
import {
|
|
26
|
+
abortDeployment,
|
|
27
|
+
createDeployment,
|
|
28
|
+
getDeploymentDevices,
|
|
29
|
+
getDeploymentsByStatus,
|
|
30
|
+
getDeploymentsConfig,
|
|
31
|
+
getDeviceDeployments,
|
|
32
|
+
getDeviceLog,
|
|
33
|
+
getSingleDeployment,
|
|
34
|
+
resetDeviceDeployments,
|
|
35
|
+
saveDeltaDeploymentsConfig,
|
|
36
|
+
setDeploymentsState,
|
|
37
|
+
updateDeploymentControlMap
|
|
38
|
+
} from './thunks';
|
|
39
|
+
|
|
40
|
+
const middlewares = [thunk];
|
|
41
|
+
const mockStore = configureMockStore(middlewares);
|
|
42
|
+
|
|
43
|
+
const createdDeployment = {
|
|
44
|
+
...defaultState.deployments.byId.d1,
|
|
45
|
+
id: 'created-123'
|
|
46
|
+
};
|
|
47
|
+
const deploymentsConfig = {
|
|
48
|
+
binaryDelta: {
|
|
49
|
+
compressionLevel: 6,
|
|
50
|
+
disableChecksum: false,
|
|
51
|
+
disableDecompression: false,
|
|
52
|
+
duplicatesWindow: 0,
|
|
53
|
+
inputWindow: 0,
|
|
54
|
+
instructionBuffer: 0,
|
|
55
|
+
sourceWindow: 0,
|
|
56
|
+
timeout: 0
|
|
57
|
+
},
|
|
58
|
+
binaryDeltaLimits: {
|
|
59
|
+
duplicatesWindow: DeploymentConstants.limitDefault,
|
|
60
|
+
inputWindow: DeploymentConstants.limitDefault,
|
|
61
|
+
instructionBuffer: DeploymentConstants.limitDefault,
|
|
62
|
+
sourceWindow: DeploymentConstants.limitDefault,
|
|
63
|
+
timeout: { default: 60, max: 3600, min: 60 }
|
|
64
|
+
},
|
|
65
|
+
hasDelta: true
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const defaultResponseActions = {
|
|
69
|
+
creation: {
|
|
70
|
+
type: actions.createdDeployment.type,
|
|
71
|
+
isImportant: true,
|
|
72
|
+
payload: { id: createdDeployment.id, devices: [{ id: Object.keys(defaultState.devices.byId)[0], status: 'pending' }], statistics: { status: {} } }
|
|
73
|
+
},
|
|
74
|
+
devices: {
|
|
75
|
+
type: actions.receivedDeploymentDevices.type,
|
|
76
|
+
payload: {
|
|
77
|
+
id: defaultState.deployments.byId.d1.id,
|
|
78
|
+
devices: defaultState.deployments.byId.d1.devices,
|
|
79
|
+
selectedDeviceIds: [defaultState.deployments.byId.d1.devices.a1.id],
|
|
80
|
+
totalDeviceCount: 1
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
log: {
|
|
84
|
+
type: actions.receivedDeploymentDeviceLog.type,
|
|
85
|
+
payload: {
|
|
86
|
+
id: defaultState.deployments.byId.d1.id,
|
|
87
|
+
deviceId: defaultState.deployments.byId.d1.devices.a1.id,
|
|
88
|
+
log: 'test'
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
snackbar: { type: appActions.setSnackbar.type, payload: 'Deployment created successfully' },
|
|
92
|
+
receive: { type: actions.receivedDeployment.type, payload: createdDeployment },
|
|
93
|
+
receiveMultiple: { type: actions.receivedDeployments.type, payload: {} },
|
|
94
|
+
receiveInprogress: { type: actions.receivedDeploymentsForStatus.type, payload: { deploymentIds: [], status: 'inprogress', total: 0 } },
|
|
95
|
+
remove: { type: actions.removedDeployment.type, payload: defaultState.deployments.byId.d1.id },
|
|
96
|
+
selectMultiple: {
|
|
97
|
+
type: actions.selectDeploymentsForStatus.type,
|
|
98
|
+
payload: { deploymentIds: Object.keys(defaultState.deployments.byId), status: 'inprogress' }
|
|
99
|
+
},
|
|
100
|
+
setOfflineThreshold: { type: appActions.setOfflineThreshold.type, payload: '2019-01-12T13:00:00.900Z' }
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
104
|
+
const { id_attribute, ...retrievedSettings } = defaultState.users.globalSettings;
|
|
105
|
+
|
|
106
|
+
const assertionFunction =
|
|
107
|
+
storeActions =>
|
|
108
|
+
({ type, isImportant, payload }, index) => {
|
|
109
|
+
expect(storeActions[index].type).toEqual(type);
|
|
110
|
+
if (isImportant) {
|
|
111
|
+
expect(storeActions[index].payload).toEqual(payload);
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/* eslint-disable sonarjs/no-identical-functions */
|
|
116
|
+
describe('deployment actions', () => {
|
|
117
|
+
it('should allow aborting deployments', async () => {
|
|
118
|
+
const store = mockStore({ ...defaultState });
|
|
119
|
+
const expectedActions = [
|
|
120
|
+
{ type: abortDeployment.pending.type },
|
|
121
|
+
defaultResponseActions.receiveMultiple,
|
|
122
|
+
defaultResponseActions.receiveInprogress,
|
|
123
|
+
defaultResponseActions.remove,
|
|
124
|
+
{ ...defaultResponseActions.snackbar, payload: 'The deployment was successfully aborted' },
|
|
125
|
+
{ type: abortDeployment.fulfilled.type }
|
|
126
|
+
];
|
|
127
|
+
return store
|
|
128
|
+
.dispatch(abortDeployment(defaultState.deployments.byId.d1.id))
|
|
129
|
+
.unwrap()
|
|
130
|
+
.then(() => {
|
|
131
|
+
const storeActions = store.getActions();
|
|
132
|
+
expect(storeActions.length).toEqual(expectedActions.length);
|
|
133
|
+
expectedActions.map((action, index) => expect(storeActions[index]).toMatchObject(action));
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
it(`should reject aborting deployments that don't exist`, () => {
|
|
137
|
+
const store = mockStore({ ...defaultState });
|
|
138
|
+
const abortedDeployment = store.dispatch(abortDeployment(`${defaultState.deployments.byId.d1.id}-invalid`)).unwrap();
|
|
139
|
+
expect(typeof abortedDeployment === Promise);
|
|
140
|
+
expect(abortedDeployment).rejects.toBeTruthy();
|
|
141
|
+
});
|
|
142
|
+
it('should allow creating deployments without filter or group', async () => {
|
|
143
|
+
const store = mockStore({
|
|
144
|
+
...defaultState,
|
|
145
|
+
deployments: {
|
|
146
|
+
...defaultState.deployments,
|
|
147
|
+
byStatus: {
|
|
148
|
+
...defaultState.deployments.byStatus,
|
|
149
|
+
finished: { ...defaultState.deployments.byStatus.finished, total: 0 },
|
|
150
|
+
inprogress: { ...defaultState.deployments.byStatus.inprogress, total: 0 },
|
|
151
|
+
pending: { ...defaultState.deployments.byStatus.pending, total: 0 },
|
|
152
|
+
scheduled: { ...defaultState.deployments.byStatus.scheduled, total: 0 }
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
const expectedActions = [
|
|
157
|
+
{ type: createDeployment.pending.type },
|
|
158
|
+
defaultResponseActions.creation,
|
|
159
|
+
{ type: getSingleDeployment.pending.type },
|
|
160
|
+
defaultResponseActions.snackbar,
|
|
161
|
+
{ type: saveGlobalSettings.pending.type },
|
|
162
|
+
{ type: getGlobalSettings.pending.type },
|
|
163
|
+
defaultResponseActions.receive,
|
|
164
|
+
{ type: getSingleDeployment.fulfilled.type },
|
|
165
|
+
{ type: userActions.setGlobalSettings.type },
|
|
166
|
+
{ type: setOfflineThreshold.pending.type },
|
|
167
|
+
defaultResponseActions.setOfflineThreshold,
|
|
168
|
+
{ type: setOfflineThreshold.fulfilled.type },
|
|
169
|
+
{ type: getGlobalSettings.fulfilled.type },
|
|
170
|
+
{ type: userActions.setGlobalSettings.type },
|
|
171
|
+
{ type: saveGlobalSettings.fulfilled.type },
|
|
172
|
+
{ type: createDeployment.fulfilled.type }
|
|
173
|
+
];
|
|
174
|
+
return store.dispatch(createDeployment({ newDeployment: { devices: [Object.keys(defaultState.devices.byId)[0]] } })).then(() => {
|
|
175
|
+
const storeActions = store.getActions();
|
|
176
|
+
expect(storeActions.length).toEqual(expectedActions.length);
|
|
177
|
+
expectedActions.map(assertionFunction(storeActions));
|
|
178
|
+
});
|
|
179
|
+
});
|
|
180
|
+
it('should allow creating deployments with a filter', async () => {
|
|
181
|
+
const store = mockStore({ ...defaultState });
|
|
182
|
+
const filter_id = '1234';
|
|
183
|
+
const expectedActions = [
|
|
184
|
+
{ type: createDeployment.pending.type },
|
|
185
|
+
{ ...defaultResponseActions.creation, payload: { ...defaultResponseActions.creation.payload, devices: [], filter_id, statistics: { status: {} } } },
|
|
186
|
+
{ type: getSingleDeployment.pending.type },
|
|
187
|
+
defaultResponseActions.snackbar,
|
|
188
|
+
{ type: saveGlobalSettings.pending.type },
|
|
189
|
+
{ type: getGlobalSettings.pending.type },
|
|
190
|
+
defaultResponseActions.receive,
|
|
191
|
+
{ type: getSingleDeployment.fulfilled.type },
|
|
192
|
+
{ type: userActions.setGlobalSettings.type },
|
|
193
|
+
{ type: setOfflineThreshold.pending.type },
|
|
194
|
+
defaultResponseActions.setOfflineThreshold,
|
|
195
|
+
{ type: setOfflineThreshold.fulfilled.type },
|
|
196
|
+
{ type: getGlobalSettings.fulfilled.type },
|
|
197
|
+
{ type: userActions.setGlobalSettings.type },
|
|
198
|
+
{ type: saveGlobalSettings.fulfilled.type },
|
|
199
|
+
{ type: createDeployment.fulfilled.type }
|
|
200
|
+
];
|
|
201
|
+
return store.dispatch(createDeployment({ newDeployment: { filter_id } })).then(() => {
|
|
202
|
+
const storeActions = store.getActions();
|
|
203
|
+
expect(storeActions.length).toEqual(expectedActions.length);
|
|
204
|
+
expectedActions.map(assertionFunction(storeActions));
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
it('should allow creating deployments with a group', async () => {
|
|
208
|
+
const store = mockStore({ ...defaultState });
|
|
209
|
+
const group = Object.keys(defaultState.devices.groups.byId)[0];
|
|
210
|
+
const expectedActions = [
|
|
211
|
+
{ type: createDeployment.pending.type },
|
|
212
|
+
{ ...defaultResponseActions.creation, payload: { ...defaultResponseActions.creation.payload, devices: [], group, statistics: { status: {} } } },
|
|
213
|
+
{ type: getSingleDeployment.pending.type },
|
|
214
|
+
defaultResponseActions.snackbar,
|
|
215
|
+
{ type: saveGlobalSettings.pending.type },
|
|
216
|
+
{ type: getGlobalSettings.pending.type },
|
|
217
|
+
defaultResponseActions.receive,
|
|
218
|
+
{ type: getSingleDeployment.fulfilled.type },
|
|
219
|
+
{ type: userActions.setGlobalSettings.type },
|
|
220
|
+
{ type: setOfflineThreshold.pending.type },
|
|
221
|
+
defaultResponseActions.setOfflineThreshold,
|
|
222
|
+
{ type: setOfflineThreshold.fulfilled.type },
|
|
223
|
+
{ type: getGlobalSettings.fulfilled.type },
|
|
224
|
+
{ type: userActions.setGlobalSettings.type },
|
|
225
|
+
{ type: saveGlobalSettings.fulfilled.type },
|
|
226
|
+
{ type: createDeployment.fulfilled.type }
|
|
227
|
+
];
|
|
228
|
+
return store.dispatch(createDeployment({ newDeployment: { group } })).then(() => {
|
|
229
|
+
const storeActions = store.getActions();
|
|
230
|
+
expect(storeActions.length).toEqual(expectedActions.length);
|
|
231
|
+
expectedActions.map(assertionFunction(storeActions));
|
|
232
|
+
});
|
|
233
|
+
});
|
|
234
|
+
it('should allow deployments retrieval', async () => {
|
|
235
|
+
const store = mockStore({ ...defaultState });
|
|
236
|
+
const expectedActions = [
|
|
237
|
+
{ type: getDeploymentsByStatus.pending.type },
|
|
238
|
+
{ ...defaultResponseActions.receiveMultiple, payload: defaultState.deployments.byId },
|
|
239
|
+
{
|
|
240
|
+
...defaultResponseActions.receiveInprogress,
|
|
241
|
+
payload: {
|
|
242
|
+
deploymentIds: Object.keys(defaultState.deployments.byId),
|
|
243
|
+
total: defaultState.deployments.byStatus.inprogress.total
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
defaultResponseActions.selectMultiple,
|
|
247
|
+
{ type: getDeploymentsByStatus.fulfilled.type }
|
|
248
|
+
];
|
|
249
|
+
return store
|
|
250
|
+
.dispatch(getDeploymentsByStatus({ status: 'inprogress', group: Object.keys(defaultState.devices.groups.byId)[0], type: 'configuration' }))
|
|
251
|
+
.then(() => {
|
|
252
|
+
const storeActions = store.getActions();
|
|
253
|
+
expect(storeActions.length).toEqual(expectedActions.length);
|
|
254
|
+
expectedActions.map((action, index) => expect(storeActions[index]).toMatchObject(action));
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
it('should allow deployment device log retrieval', async () => {
|
|
258
|
+
const store = mockStore({ ...defaultState });
|
|
259
|
+
const expectedActions = [{ type: getDeviceLog.pending.type }, defaultResponseActions.log, { type: getDeviceLog.fulfilled.type }];
|
|
260
|
+
return store
|
|
261
|
+
.dispatch(getDeviceLog({ deploymentId: Object.keys(defaultState.deployments.byId)[0], deviceId: defaultState.deployments.byId.d1.devices.a1.id }))
|
|
262
|
+
.then(() => {
|
|
263
|
+
const storeActions = store.getActions();
|
|
264
|
+
expect(storeActions.length).toEqual(expectedActions.length);
|
|
265
|
+
expectedActions.map((action, index) => expect(storeActions[index]).toMatchObject(action));
|
|
266
|
+
});
|
|
267
|
+
});
|
|
268
|
+
it('should allow deployment device list retrieval', async () => {
|
|
269
|
+
const store = mockStore({ ...defaultState });
|
|
270
|
+
const expectedActions = [{ type: getDeploymentDevices.pending.type }, defaultResponseActions.devices, { type: getDeploymentDevices.fulfilled.type }];
|
|
271
|
+
return store.dispatch(getDeploymentDevices({ id: Object.keys(defaultState.deployments.byId)[0] })).then(() => {
|
|
272
|
+
const storeActions = store.getActions();
|
|
273
|
+
expect(storeActions.length).toEqual(expectedActions.length);
|
|
274
|
+
expectedActions.map((action, index) => expect(storeActions[index]).toMatchObject(action));
|
|
275
|
+
});
|
|
276
|
+
});
|
|
277
|
+
it('should allow device deployment history retrieval', async () => {
|
|
278
|
+
const store = mockStore({ ...defaultState });
|
|
279
|
+
const expectedActions = [
|
|
280
|
+
{ type: getDeviceDeployments.pending.type },
|
|
281
|
+
{
|
|
282
|
+
type: deviceActions.receivedDevice.type,
|
|
283
|
+
payload: {
|
|
284
|
+
id: defaultState.devices.byId.a1.id,
|
|
285
|
+
deploymentsCount: 34,
|
|
286
|
+
deviceDeployments: [
|
|
287
|
+
{
|
|
288
|
+
id: defaultState.deployments.byId.d1.id,
|
|
289
|
+
release: defaultState.deployments.byId.d1.artifact_name,
|
|
290
|
+
created: '2019-01-01T12:35:00.000Z',
|
|
291
|
+
finished: '2019-01-01T12:40:00.000Z',
|
|
292
|
+
status: 'noartifact',
|
|
293
|
+
route: DeploymentConstants.DEPLOYMENT_ROUTES.active.key
|
|
294
|
+
}
|
|
295
|
+
]
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
{ type: getDeviceDeployments.fulfilled.type }
|
|
299
|
+
];
|
|
300
|
+
await store.dispatch(getDeviceDeployments({ deviceId: defaultState.devices.byId.a1.id }));
|
|
301
|
+
const storeActions = store.getActions();
|
|
302
|
+
expect(storeActions.length).toEqual(expectedActions.length);
|
|
303
|
+
expectedActions.map((action, index) => expect(storeActions[index]).toMatchObject(action));
|
|
304
|
+
});
|
|
305
|
+
it('should allow device deployment history deletion', async () => {
|
|
306
|
+
const store = mockStore({ ...defaultState });
|
|
307
|
+
const expectedActions = [
|
|
308
|
+
{ type: resetDeviceDeployments.pending.type },
|
|
309
|
+
{ type: getDeviceDeployments.pending.type },
|
|
310
|
+
{
|
|
311
|
+
type: deviceActions.receivedDevice.type,
|
|
312
|
+
payload: {
|
|
313
|
+
id: defaultState.devices.byId.a1.id,
|
|
314
|
+
deploymentsCount: 34,
|
|
315
|
+
deviceDeployments: [
|
|
316
|
+
{
|
|
317
|
+
id: defaultState.deployments.byId.d1.id,
|
|
318
|
+
release: defaultState.deployments.byId.d1.artifact_name,
|
|
319
|
+
created: '2019-01-01T12:35:00.000Z',
|
|
320
|
+
finished: '2019-01-01T12:40:00.000Z',
|
|
321
|
+
status: 'noartifact',
|
|
322
|
+
route: DeploymentConstants.DEPLOYMENT_ROUTES.active.key
|
|
323
|
+
}
|
|
324
|
+
]
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
{ type: getDeviceDeployments.fulfilled.type },
|
|
328
|
+
{ type: resetDeviceDeployments.fulfilled.type }
|
|
329
|
+
];
|
|
330
|
+
await store.dispatch(resetDeviceDeployments(defaultState.devices.byId.a1.id));
|
|
331
|
+
const storeActions = store.getActions();
|
|
332
|
+
expect(storeActions.length).toEqual(expectedActions.length);
|
|
333
|
+
expectedActions.map((action, index) => expect(storeActions[index]).toMatchObject(action));
|
|
334
|
+
});
|
|
335
|
+
it('should allow updating a deployment to continue the execution', async () => {
|
|
336
|
+
const store = mockStore({ ...defaultState });
|
|
337
|
+
const expectedActions = [
|
|
338
|
+
{ type: updateDeploymentControlMap.pending.type },
|
|
339
|
+
{ type: getSingleDeployment.pending.type },
|
|
340
|
+
defaultResponseActions.receive,
|
|
341
|
+
{ type: getSingleDeployment.fulfilled.type },
|
|
342
|
+
{ type: updateDeploymentControlMap.fulfilled.type }
|
|
343
|
+
];
|
|
344
|
+
return store.dispatch(updateDeploymentControlMap({ deploymentId: createdDeployment.id, updateControlMap: { something: 'continue' } })).then(() => {
|
|
345
|
+
const storeActions = store.getActions();
|
|
346
|
+
expect(storeActions.length).toEqual(expectedActions.length);
|
|
347
|
+
expectedActions.map((action, index) => expect(storeActions[index]).toMatchObject(action));
|
|
348
|
+
});
|
|
349
|
+
});
|
|
350
|
+
it('should allow deployment state tracking', async () => {
|
|
351
|
+
const store = mockStore({ ...defaultState });
|
|
352
|
+
await store.dispatch(
|
|
353
|
+
setDeploymentsState({
|
|
354
|
+
general: { showCreationDialog: true },
|
|
355
|
+
[DeploymentConstants.DEPLOYMENT_STATES.finished]: { something: 'new' },
|
|
356
|
+
selectedId: createdDeployment.id
|
|
357
|
+
})
|
|
358
|
+
);
|
|
359
|
+
const expectedActions = [
|
|
360
|
+
{ type: setDeploymentsState.pending.type },
|
|
361
|
+
{
|
|
362
|
+
type: actions.setDeploymentsState.type,
|
|
363
|
+
payload: {
|
|
364
|
+
...defaultState.deployments.selectionState,
|
|
365
|
+
finished: {
|
|
366
|
+
...defaultState.deployments.selectionState.finished,
|
|
367
|
+
something: 'new'
|
|
368
|
+
},
|
|
369
|
+
general: {
|
|
370
|
+
...defaultState.deployments.selectionState.general,
|
|
371
|
+
showCreationDialog: true
|
|
372
|
+
},
|
|
373
|
+
selectedId: createdDeployment.id
|
|
374
|
+
}
|
|
375
|
+
},
|
|
376
|
+
{ type: getSingleDeployment.pending.type },
|
|
377
|
+
defaultResponseActions.receive,
|
|
378
|
+
{ type: getSingleDeployment.fulfilled.type },
|
|
379
|
+
{ type: setDeploymentsState.fulfilled.type }
|
|
380
|
+
];
|
|
381
|
+
const storeActions = store.getActions();
|
|
382
|
+
expect(storeActions.length).toEqual(expectedActions.length);
|
|
383
|
+
expectedActions.map((action, index) => expect(storeActions[index]).toMatchObject(action));
|
|
384
|
+
});
|
|
385
|
+
|
|
386
|
+
it('should allow retrieving config for deployments', async () => {
|
|
387
|
+
const store = mockStore({ ...defaultState });
|
|
388
|
+
const expectedActions = [
|
|
389
|
+
{ type: getDeploymentsConfig.pending.type },
|
|
390
|
+
{ type: actions.setDeploymentsConfig.type, payload: deploymentsConfig },
|
|
391
|
+
{ type: getDeploymentsConfig.fulfilled.type }
|
|
392
|
+
];
|
|
393
|
+
return store.dispatch(getDeploymentsConfig()).then(() => {
|
|
394
|
+
const storeActions = store.getActions();
|
|
395
|
+
expect(storeActions.length).toEqual(expectedActions.length);
|
|
396
|
+
expectedActions.map((action, index) => expect(storeActions[index]).toMatchObject(action));
|
|
397
|
+
});
|
|
398
|
+
});
|
|
399
|
+
it('should allow storing delta deployments settings', async () => {
|
|
400
|
+
const store = mockStore({ ...defaultState });
|
|
401
|
+
const changedConfig = {
|
|
402
|
+
timeout: 100,
|
|
403
|
+
duplicatesWindow: 734,
|
|
404
|
+
compressionLevel: 5,
|
|
405
|
+
disableChecksum: true,
|
|
406
|
+
disableDecompression: false,
|
|
407
|
+
inputWindow: 1253,
|
|
408
|
+
instructionBuffer: 123,
|
|
409
|
+
sourceWindow: 13
|
|
410
|
+
};
|
|
411
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
412
|
+
const { hasDelta, ...expectedConfig } = deploymentsConfig;
|
|
413
|
+
const expectedActions = [
|
|
414
|
+
{ type: saveDeltaDeploymentsConfig.pending.type },
|
|
415
|
+
{ type: actions.setDeploymentsConfig.type, payload: { ...expectedConfig, binaryDelta: { ...expectedConfig.binaryDelta, ...changedConfig } } },
|
|
416
|
+
{ ...defaultResponseActions.setSnackbar, payload: 'Settings saved successfully' },
|
|
417
|
+
{ type: saveDeltaDeploymentsConfig.fulfilled.type }
|
|
418
|
+
];
|
|
419
|
+
return store.dispatch(saveDeltaDeploymentsConfig(changedConfig)).then(() => {
|
|
420
|
+
const storeActions = store.getActions();
|
|
421
|
+
expect(storeActions.length).toEqual(expectedActions.length);
|
|
422
|
+
expectedActions.map((action, index) => expect(storeActions[index]).toMatchObject(action));
|
|
423
|
+
});
|
|
424
|
+
});
|
|
425
|
+
});
|