@spinnaker/amazon 2026.3.2 → 2026.4.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.
Files changed (202) hide show
  1. package/dist/common/AwsModalFooter.d.ts +1 -1
  2. package/dist/deploymentStrategy/AdditionalFields.d.ts +1 -1
  3. package/dist/function/CreateLambdaFunction.d.ts +1 -1
  4. package/dist/function/configure/ExecutionRole.d.ts +1 -1
  5. package/dist/function/configure/FunctionBasicInformation.d.ts +1 -1
  6. package/dist/function/configure/FunctionDebugAndErrorHandling.d.ts +1 -1
  7. package/dist/function/configure/FunctionEnvironmentVariables.d.ts +1 -1
  8. package/dist/function/configure/FunctionSettings.d.ts +1 -1
  9. package/dist/function/configure/FunctionTags.d.ts +1 -1
  10. package/dist/function/configure/Network.d.ts +1 -1
  11. package/dist/function/details/AmazonFunctionDetails.d.ts +1 -1
  12. package/dist/function/details/FunctionActions.d.ts +1 -1
  13. package/dist/index.js +279 -1
  14. package/dist/index.js.map +1 -1
  15. package/dist/instance/details/AmazonInstanceInformation.d.ts +2 -2
  16. package/dist/instance/details/CostFactor.d.ts +2 -2
  17. package/dist/instance/details/InstanceDns.d.ts +2 -2
  18. package/dist/instance/details/InstanceInformation.d.ts +2 -2
  19. package/dist/instance/details/InstanceSecurityGroups.d.ts +2 -2
  20. package/dist/instance/details/InstanceStatus.d.ts +2 -2
  21. package/dist/instance/details/InstanceTags.d.ts +2 -2
  22. package/dist/loadBalancer/configure/AmazonLoadBalancerChoiceModal.d.ts +1 -1
  23. package/dist/loadBalancer/configure/application/ALBListeners.d.ts +1 -1
  24. package/dist/loadBalancer/configure/application/ConfigureOidcConfigModal.d.ts +1 -1
  25. package/dist/loadBalancer/configure/application/ConfigureRedirectConfigModal.d.ts +1 -1
  26. package/dist/loadBalancer/configure/application/CreateApplicationLoadBalancer.d.ts +1 -1
  27. package/dist/loadBalancer/configure/application/TargetGroups.d.ts +1 -1
  28. package/dist/loadBalancer/configure/classic/AdvancedSettings.d.ts +1 -1
  29. package/dist/loadBalancer/configure/classic/HealthCheck.d.ts +1 -1
  30. package/dist/loadBalancer/configure/classic/Listeners.d.ts +1 -1
  31. package/dist/loadBalancer/configure/common/AmazonCertificateSelectField.d.ts +1 -1
  32. package/dist/loadBalancer/configure/common/LoadBalancerLocation.d.ts +1 -1
  33. package/dist/loadBalancer/configure/common/SecurityGroups.d.ts +1 -1
  34. package/dist/loadBalancer/configure/network/CertificateSelectors.d.ts +2 -2
  35. package/dist/loadBalancer/configure/network/NLBListeners.d.ts +1 -1
  36. package/dist/loadBalancer/configure/network/TargetGroups.d.ts +1 -1
  37. package/dist/loadBalancer/details/LoadBalancerActions.d.ts +1 -1
  38. package/dist/pipeline/stages/AmazonStageConfig.d.ts +2 -2
  39. package/dist/pipeline/stages/bake/AwsBakeStageConfig.d.ts +2 -2
  40. package/dist/pipeline/stages/cloneServerGroup/AwsCloneServerGroupStageConfig.d.ts +2 -2
  41. package/dist/pipeline/stages/deleteLambda/DeleteLambdaFunctionStageForm.d.ts +2 -2
  42. package/dist/pipeline/stages/deleteLambda/LambdaDeleteStage.d.ts +2 -2
  43. package/dist/pipeline/stages/deleteLambda/constants/deleteVersion.picker.d.ts +1 -1
  44. package/dist/pipeline/stages/deployCloudFormation/CloudFormationChangeSetInfo.d.ts +2 -2
  45. package/dist/pipeline/stages/deployCloudFormation/DeployCloudFormationStackStageConfig.d.ts +2 -2
  46. package/dist/pipeline/stages/deployCloudFormation/deployCloudFormationExecutionDetails.d.ts +1 -1
  47. package/dist/pipeline/stages/deployCloudFormation/evaluateCloudFormationChangeSetExecutionApproval.d.ts +2 -2
  48. package/dist/pipeline/stages/deployCloudFormation/evaluateCloudFormationChangeSetExecutionDetails.d.ts +1 -1
  49. package/dist/pipeline/stages/deployCloudFormation/evaluateCloudFormationChangeSetExecutionLabel.d.ts +1 -1
  50. package/dist/pipeline/stages/deployCloudFormation/evaluateCloudFormationChangeSetExecutionMarkerIcon.d.ts +1 -1
  51. package/dist/pipeline/stages/deployLambda/components/AwsLambdaFunctionStageForm.d.ts +2 -2
  52. package/dist/pipeline/stages/deployLambda/components/BasicSettingsForm.d.ts +2 -2
  53. package/dist/pipeline/stages/deployLambda/components/EnvironmentForm.d.ts +2 -2
  54. package/dist/pipeline/stages/deployLambda/components/ExecutionRoleForm.d.ts +2 -2
  55. package/dist/pipeline/stages/deployLambda/components/LambdaAtEdgeForm.d.ts +2 -2
  56. package/dist/pipeline/stages/deployLambda/components/NetworkForm.d.ts +2 -2
  57. package/dist/pipeline/stages/deployLambda/components/TriggerEventsForm.d.ts +2 -2
  58. package/dist/pipeline/stages/deployLambda/config/LambdaDeploymentStageConfig.d.ts +2 -2
  59. package/dist/pipeline/stages/deployLambda/config/LambdaDeploymentStageExecutionDetails.d.ts +2 -2
  60. package/dist/pipeline/stages/disableAsg/AwsDisableAsgStageConfig.d.ts +2 -2
  61. package/dist/pipeline/stages/disableCluster/AwsDisableClusterStageConfig.d.ts +2 -2
  62. package/dist/pipeline/stages/enableAsg/AwsEnableAsgStageConfig.d.ts +2 -2
  63. package/dist/pipeline/stages/findImageFromTags/AwsFindImageFromTagsStageConfig.d.ts +2 -2
  64. package/dist/pipeline/stages/invokeLambda/InvokeLambdaFunctionStageForm.d.ts +2 -2
  65. package/dist/pipeline/stages/invokeLambda/LambdaInvokeStage.d.ts +2 -2
  66. package/dist/pipeline/stages/invokeLambda/components/InvokeLambdaOperation.d.ts +2 -2
  67. package/dist/pipeline/stages/modifyScalingProcess/ModifyScalingProcessStageConfig.d.ts +2 -2
  68. package/dist/pipeline/stages/modifyWarmPool/ModifyWarmPoolStageConfig.d.ts +2 -2
  69. package/dist/pipeline/stages/resizeAsg/AwsResizeAsgStageConfig.d.ts +2 -2
  70. package/dist/pipeline/stages/rollbackCluster/AwsRollbackClusterStageConfig.d.ts +2 -2
  71. package/dist/pipeline/stages/routeLambda/LambdaRouteStage.d.ts +2 -2
  72. package/dist/pipeline/stages/routeLambda/RouteLambdaFunctionStageForm.d.ts +2 -2
  73. package/dist/pipeline/stages/routeLambda/TriggerEventsForm.d.ts +2 -2
  74. package/dist/pipeline/stages/routeLambda/components/BlueGreenDeployment/BlueGreenDeploymentForm.d.ts +2 -2
  75. package/dist/pipeline/stages/routeLambda/components/BlueGreenDeployment/HealthCheckStrategy.d.ts +2 -2
  76. package/dist/pipeline/stages/routeLambda/components/BlueGreenDeployment/InvocationHealthCheck.d.ts +2 -2
  77. package/dist/pipeline/stages/routeLambda/components/DeploymentStrategyForm.d.ts +2 -2
  78. package/dist/pipeline/stages/routeLambda/components/RenderStrategy.d.ts +2 -2
  79. package/dist/pipeline/stages/routeLambda/components/SimpleDeploymentForm.d.ts +2 -2
  80. package/dist/pipeline/stages/routeLambda/components/VersionPicker.d.ts +1 -1
  81. package/dist/pipeline/stages/routeLambda/components/WeightedDeploymentForm.d.ts +2 -2
  82. package/dist/pipeline/stages/routeLambda/constants/strategy.picker.d.ts +1 -1
  83. package/dist/pipeline/stages/scaleDownCluster/AwsScaleDownClusterStageConfig.d.ts +2 -2
  84. package/dist/pipeline/stages/shrinkCluster/AwsShrinkClusterStageConfig.d.ts +2 -2
  85. package/dist/pipeline/stages/tagImage/awsTagImageStage.d.ts +2 -2
  86. package/dist/pipeline/stages/updateCodeLambda/LambdaUpdateCodeStageConfig.d.ts +2 -2
  87. package/dist/pipeline/stages/updateCodeLambda/LambdaUpdateCodeStageExecutionDetails.d.ts +2 -2
  88. package/dist/pipeline/stages/updateCodeLambda/components/UpdateCodeStageForm.d.ts +2 -2
  89. package/dist/securityGroup/details/IPRangeRules.d.ts +1 -1
  90. package/dist/serverGroup/configure/AmazonImageSelectInput.d.ts +1 -1
  91. package/dist/serverGroup/configure/wizard/AmazonCloneServerGroupModal.d.ts +1 -1
  92. package/dist/serverGroup/configure/wizard/ServerGroupTemplateSelection.d.ts +1 -1
  93. package/dist/serverGroup/configure/wizard/capacity/CapacitySelector.d.ts +1 -1
  94. package/dist/serverGroup/configure/wizard/capacity/MinMaxDesired.d.ts +1 -1
  95. package/dist/serverGroup/configure/wizard/instanceType/CpuCreditsToggle.d.ts +2 -2
  96. package/dist/serverGroup/configure/wizard/instanceType/InstanceTypeSelector.d.ts +2 -2
  97. package/dist/serverGroup/configure/wizard/instanceType/InstanceTypeWarning.d.ts +2 -2
  98. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/AdvancedModeSelector.d.ts +2 -2
  99. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/AmazonInstanceTypeInfoRenderer.d.ts +2 -2
  100. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceProfileSelector.d.ts +2 -2
  101. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeRow.d.ts +2 -2
  102. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeSelect.d.ts +2 -2
  103. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTable.d.ts +2 -2
  104. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableBody.d.ts +2 -2
  105. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableParts.d.ts +4 -4
  106. package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstancesDistribution.d.ts +2 -2
  107. package/dist/serverGroup/configure/wizard/instanceType/simpleMode/SimpleModeSelector.d.ts +2 -2
  108. package/dist/serverGroup/configure/wizard/pages/ServerGroupBasicSettings.d.ts +1 -1
  109. package/dist/serverGroup/configure/wizard/pages/ServerGroupCapacity.d.ts +1 -1
  110. package/dist/serverGroup/configure/wizard/pages/ServerGroupInstanceType.d.ts +1 -1
  111. package/dist/serverGroup/configure/wizard/pages/ServerGroupLoadBalancers.d.ts +1 -1
  112. package/dist/serverGroup/configure/wizard/pages/ServerGroupSecurityGroups.d.ts +1 -1
  113. package/dist/serverGroup/configure/wizard/pages/ServerGroupZones.d.ts +1 -1
  114. package/dist/serverGroup/configure/wizard/pages/advancedSettings/ServerGroupAdvancedSettings.d.ts +1 -1
  115. package/dist/serverGroup/configure/wizard/pages/advancedSettings/ServerGroupAdvancedSettingsCommon.d.ts +1 -1
  116. package/dist/serverGroup/configure/wizard/pages/advancedSettings/ServerGroupAdvancedSettingsInner.d.ts +1 -1
  117. package/dist/serverGroup/configure/wizard/securityGroups/SecurityGroupSelector.d.ts +1 -1
  118. package/dist/serverGroup/configure/wizard/securityGroups/ServerGroupSecurityGroupsRemoved.d.ts +1 -1
  119. package/dist/serverGroup/details/advancedSettings/EditAsgAdvancedSettingsModal.d.ts +2 -1
  120. package/dist/serverGroup/details/resize/AmazonResizeServerGroupModal.d.ts +1 -1
  121. package/dist/serverGroup/details/scalingPolicy/CreateScalingPolicyButton.d.ts +1 -1
  122. package/dist/serverGroup/details/scalingPolicy/ScalingPolicySummary.d.ts +2 -2
  123. package/dist/serverGroup/details/scalingPolicy/StepPolicySummary.d.ts +2 -2
  124. package/dist/serverGroup/details/scalingPolicy/chart/DateLineChart.d.ts +2 -2
  125. package/dist/serverGroup/details/scalingPolicy/chart/MetricAlarmChart.d.ts +3 -3
  126. package/dist/serverGroup/details/scalingPolicy/popover/AlarmSummary.d.ts +2 -2
  127. package/dist/serverGroup/details/scalingPolicy/popover/StepPolicyPopoverContent.d.ts +2 -2
  128. package/dist/serverGroup/details/scalingPolicy/targetTracking/TargetMetricFields.d.ts +2 -2
  129. package/dist/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingAdditionalSettings.d.ts +2 -3
  130. package/dist/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingChart.d.ts +2 -2
  131. package/dist/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingSummary.d.ts +2 -2
  132. package/dist/serverGroup/details/scalingPolicy/targetTracking/UpsertTargetTrackingModal.d.ts +2 -2
  133. package/dist/serverGroup/details/scalingPolicy/upsert/PolicyTypeSelectionModal.d.ts +2 -2
  134. package/dist/serverGroup/details/scalingPolicy/upsert/ScalingPolicyAdditionalSettings.d.ts +2 -2
  135. package/dist/serverGroup/details/scalingPolicy/upsert/UpsertScalingPolicyModal.d.ts +2 -2
  136. package/dist/serverGroup/details/scalingPolicy/upsert/alarm/AlarmConfigurer.d.ts +2 -2
  137. package/dist/serverGroup/details/scalingPolicy/upsert/alarm/DimensionsEditor.d.ts +2 -2
  138. package/dist/serverGroup/details/scalingPolicy/upsert/alarm/MetricSelector.d.ts +2 -2
  139. package/dist/serverGroup/details/scalingPolicy/upsert/simple/SimplePolicyAction.d.ts +2 -2
  140. package/dist/serverGroup/details/scalingPolicy/upsert/step/StepPolicyAction.d.ts +2 -2
  141. package/dist/serverGroup/details/scalingProcesses/ModifyScalingProcessesModal.d.ts +1 -1
  142. package/dist/serverGroup/details/scheduledAction/ScheduledAction.d.ts +1 -1
  143. package/dist/serverGroup/details/scheduledActions/EditScheduledActionsModal.d.ts +1 -1
  144. package/dist/serverGroup/details/sections/InstancesDistributionDetailsSection.d.ts +2 -2
  145. package/dist/serverGroup/details/sections/LaunchTemplateDetailsSection.d.ts +2 -2
  146. package/dist/serverGroup/details/sections/MultipleInstanceTypesSubSection.d.ts +2 -2
  147. package/dist/serverGroup/details/securityGroups/EditSecurityGroupsModal.d.ts +1 -1
  148. package/dist/serverGroup/details/warmPool/ModifyWarmPoolModal.d.ts +1 -1
  149. package/dist/subnet/SubnetSelectField.d.ts +1 -1
  150. package/dist/subnet/SubnetSelectInput.d.ts +1 -1
  151. package/dist/vpc/VpcTag.d.ts +2 -2
  152. package/package.json +5 -7
  153. package/src/aws.module.spec.ts +20 -21
  154. package/src/function/details/AmazonFunctionDetails.tsx +1 -1
  155. package/src/function/details/FunctionActions.spec.tsx +56 -36
  156. package/src/instance/awsInstanceType.service.spec.js +24 -22
  157. package/src/instance/details/AmazonInstanceDetails.spec.tsx +7 -7
  158. package/src/instance/details/InstanceInformation.spec.tsx +44 -24
  159. package/src/loadBalancer/AmazonLoadBalancersTag.spec.tsx +1 -1
  160. package/src/loadBalancer/TargetGroupDetails.spec.tsx +5 -5
  161. package/src/loadBalancer/configure/application/TargetGroups.tsx +1 -1
  162. package/src/loadBalancer/configure/common/SecurityGroups.spec.tsx +4 -4
  163. package/src/loadBalancer/configure/network/TargetGroups.tsx +1 -1
  164. package/src/loadBalancer/details/amazonLoadBalancerDetails.spec.tsx +31 -53
  165. package/src/pipeline/stages/AmazonStageConfig.spec.tsx +37 -46
  166. package/src/pipeline/stages/deployCloudFormation/DeployCloudFormationStackStageConfig.tsx +1 -0
  167. package/src/pipeline/stages/deployCloudFormation/deployCloudFormationStackStage.spec.tsx +316 -279
  168. package/src/pipeline/stages/findImageFromTags/AwsFindImageFromTagsStageConfig.spec.tsx +70 -90
  169. package/src/pipeline/stages/modifyScalingProcess/modifyScalingProcessStage.spec.tsx +198 -130
  170. package/src/pipeline/stages/modifyWarmPool/modifyWarmPoolStage.spec.tsx +49 -40
  171. package/src/pipeline/stages/resizeAsg/AwsResizeAsgStageConfig.spec.tsx +341 -427
  172. package/src/pipeline/stages/resizeAsg/AwsResizeAsgStageConfig.tsx +7 -0
  173. package/src/pipeline/stages/tagImage/awsTagImageStage.spec.tsx +62 -107
  174. package/src/routerConsumers.spec.tsx +23 -23
  175. package/src/securityGroup/configure/AmazonSecurityGroupModal.spec.tsx +38 -47
  176. package/src/securityGroup/details/AmazonSecurityGroupDetails.spec.tsx +7 -6
  177. package/src/serverGroup/configure/AmazonImageSelectInput.spec.tsx +47 -65
  178. package/src/serverGroup/configure/AmazonImageSelectInput.tsx +1 -1
  179. package/src/serverGroup/configure/serverGroupCommandBuilder.aws.service.spec.js +18 -19
  180. package/src/serverGroup/configure/serverGroupCommandBuilder.spec.js +41 -26
  181. package/src/serverGroup/configure/wizard/instanceType/simpleMode/SimpleModeSelector.spec.tsx +52 -75
  182. package/src/serverGroup/configure/wizard/pages/ServerGroupBasicSettings.spec.tsx +1 -1
  183. package/src/serverGroup/configure/wizard/pages/advancedSettings/ServerGroupAdvancedSettingsCommon.spec.tsx +36 -33
  184. package/src/serverGroup/configure/wizard/pages/advancedSettings/ServerGroupAdvancedSettingsCommon.tsx +7 -1
  185. package/src/serverGroup/configure/wizard/securityGroups/SecurityGroupSelector.spec.tsx +2 -2
  186. package/src/serverGroup/details/AmazonServerGroupActions.spec.tsx +79 -67
  187. package/src/serverGroup/details/advancedSettings/EditAsgAdvancedSettingsModal.spec.tsx +78 -66
  188. package/src/serverGroup/details/advancedSettings/EditAsgAdvancedSettingsModal.tsx +23 -6
  189. package/src/serverGroup/details/rollback/AmazonRollbackServerGroupModal.spec.tsx +86 -94
  190. package/src/serverGroup/details/rollback/AmazonRollbackServerGroupModal.tsx +3 -0
  191. package/src/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingAdditionalSettings.tsx +1 -39
  192. package/src/serverGroup/details/scalingPolicy/targetTracking/UpsertTargetTrackingModal.tsx +0 -1
  193. package/src/serverGroup/details/scalingProcesses/ModifyScalingProcessesModal.spec.tsx +5 -5
  194. package/src/serverGroup/details/scheduledActions/EditScheduledActionsModal.spec.tsx +8 -8
  195. package/src/serverGroup/details/sections/AmazonServerGroupMaintenanceActions.spec.tsx +71 -60
  196. package/src/serverGroup/details/sections/InstancesDistributionDetailsSection.spec.tsx +21 -39
  197. package/src/serverGroup/details/sections/LaunchTemplateDetailsSection.spec.tsx +56 -97
  198. package/src/serverGroup/details/securityGroups/EditSecurityGroupsModal.spec.tsx +48 -77
  199. package/src/serverGroup/details/warmPool/ModifyWarmPoolModal.spec.tsx +5 -5
  200. package/src/vpc/VpcReader.spec.ts +1 -1
  201. package/src/vpc/VpcTag.spec.tsx +11 -15
  202. /package/dist/{amazon.logo352d4e042476837f.svg → amazon.logoBzC5E-3F.svg} +0 -0
@@ -1,22 +1,28 @@
1
- import { mount } from 'enzyme';
1
+ import { act, fireEvent, render, screen, waitFor, within } from '@testing-library/react';
2
2
  import React from 'react';
3
3
 
4
- import { AccountRegionClusterSelector, AccountService, PlatformHealthOverride, TargetSelect } from '@spinnaker/core';
4
+ import { AccountService } from '@spinnaker/core';
5
+ import { getFormGroupByLabel } from '../../../../../core/src/utils/testUtils/rtl';
5
6
 
6
7
  import { AmazonStageConfig } from '../AmazonStageConfig';
7
-
8
8
  import { awsResizeAsgStage } from './awsResizeAsgStage';
9
9
 
10
10
  describe('AWS Resize Server Group stage', () => {
11
11
  beforeEach(() => {
12
- spyOn(AccountService, 'getUniqueAttributeForAllAccounts').and.returnValue(Promise.resolve([]));
13
- spyOn(AccountService, 'listAccounts').and.returnValue(Promise.resolve([]));
12
+ vi.spyOn(AccountService, 'getUniqueAttributeForAllAccounts').mockResolvedValue([]);
13
+ vi.spyOn(AccountService, 'listAccounts').mockResolvedValue([]);
14
14
  });
15
15
 
16
- function renderStage(stageOverrides: Record<string, any> = {}, applicationOverrides: Record<string, any> = {}) {
17
- const stage = {
16
+ function renderStage(
17
+ stageOverrides: Record<string, any> = {},
18
+ applicationOverrides: Record<string, any> = {},
19
+ pipelineOverrides: Record<string, any> = {},
20
+ ) {
21
+ const initialStage = {
18
22
  action: 'scale_up',
19
23
  capacity: {},
24
+ cloudProvider: 'aws',
25
+ regions: [],
20
26
  resizeType: 'pct',
21
27
  scalePct: 150,
22
28
  target: 'current_asg',
@@ -30,61 +36,67 @@ describe('AWS Resize Server Group stage', () => {
30
36
  getDataSource: () => ({ data: [] }),
31
37
  ...applicationOverrides,
32
38
  };
33
- const updateStage = jasmine.createSpy('updateStage');
34
- const updateStageField = jasmine.createSpy('updateStageField');
39
+ const updateStage = vi.fn();
40
+ const updateStageField = vi.fn();
35
41
  const Component = awsResizeAsgStage.component as React.ComponentType<any>;
36
- const wrapper = mount(
37
- <Component
38
- application={application}
39
- pipeline={{}}
40
- stage={stage}
41
- stageFieldUpdated={jasmine.createSpy('stageFieldUpdated')}
42
- updateStage={updateStage}
43
- updateStageField={updateStageField}
44
- />,
45
- );
46
-
47
- return { stage, updateStage, updateStageField, wrapper };
42
+ let replaceStage: React.Dispatch<React.SetStateAction<any>>;
43
+
44
+ function StageHarness() {
45
+ const [stage, setStage] = React.useState(initialStage);
46
+ replaceStage = setStage;
47
+ const update = (changes: any) => {
48
+ updateStage(changes);
49
+ setStage((current: any) => ({ ...current, ...changes }));
50
+ };
51
+ const updateField = (changes: any) => {
52
+ updateStageField(changes);
53
+ setStage((current: any) => ({ ...current, ...changes }));
54
+ };
55
+ return (
56
+ <Component
57
+ application={application}
58
+ pipeline={{ strategy: true, ...pipelineOverrides }}
59
+ stage={stage}
60
+ stageFieldUpdated={vi.fn()}
61
+ updateStage={update}
62
+ updateStageField={updateField}
63
+ />
64
+ );
65
+ }
66
+
67
+ return {
68
+ initialStage,
69
+ replaceStage: (stage: any) => act(() => replaceStage(stage)),
70
+ updateStage,
71
+ updateStageField,
72
+ ...render(<StageHarness />),
73
+ };
48
74
  }
49
75
 
50
- it('registers a dedicated stage editor', () => {
51
- expect(awsResizeAsgStage.component).not.toBe(AmazonStageConfig);
52
- });
76
+ const validator = () => awsResizeAsgStage.validators.find(({ type }) => type === 'custom');
53
77
 
54
- it('registers a prevent-save numeric validator', () => {
55
- expect(awsResizeAsgStage.validators).toContain(jasmine.objectContaining({ type: 'custom', preventSave: true }));
78
+ it('registers a dedicated stage editor and prevent-save numeric validator', () => {
79
+ expect(awsResizeAsgStage.component).not.toBe(AmazonStageConfig);
80
+ expect(validator()).toEqual(expect.objectContaining({ type: 'custom', preventSave: true }));
56
81
  });
57
82
 
58
- it('prevents saving persisted invalid percentages while allowing valid values and expressions', () => {
59
- const validator = awsResizeAsgStage.validators.find(({ type }) => type === 'custom');
60
- const validStage = {
61
- action: 'scale_up',
62
- resizeType: 'pct',
63
- scalePct: 25,
64
- targetHealthyDeployPercentage: 75,
65
- };
66
-
67
- expect(validator.validate({}, { ...validStage, scalePct: 12.5 })).toBe(
68
- 'Resize percentage must be a nonnegative integer or pipeline expression.',
69
- );
70
- expect(validator.validate({}, { ...validStage, scalePct: -1 })).toBe(
83
+ it('validates percentage and health values while allowing integers and expressions', () => {
84
+ const valid = { action: 'scale_up', resizeType: 'pct', scalePct: 25, targetHealthyDeployPercentage: 75 };
85
+ expect(validator().validate({}, { ...valid, scalePct: 12.5 })).toBe(
71
86
  'Resize percentage must be a nonnegative integer or pipeline expression.',
72
87
  );
73
- expect(validator.validate({}, { ...validStage, scalePct: null })).toBe(
88
+ expect(validator().validate({}, { ...valid, scalePct: -1 })).toBe(
74
89
  'Resize percentage must be a nonnegative integer or pipeline expression.',
75
90
  );
76
- expect(validator.validate({}, { ...validStage, targetHealthyDeployPercentage: 75.5 })).toBe(
91
+ expect(validator().validate({}, { ...valid, targetHealthyDeployPercentage: 101 })).toBe(
77
92
  'Target healthy percentage must be an integer from 0 through 100 or pipeline expression.',
78
93
  );
79
- expect(validator.validate({}, { ...validStage, targetHealthyDeployPercentage: 101 })).toBe(
80
- 'Target healthy percentage must be an integer from 0 through 100 or pipeline expression.',
81
- );
82
- expect(validator.validate({}, { ...validStage, scalePct: 125, targetHealthyDeployPercentage: 100 })).toBe('');
94
+ expect(validator().validate({}, { ...valid, scalePct: 125, targetHealthyDeployPercentage: 100 })).toBe('');
83
95
  expect(
84
- validator.validate(
96
+ validator().validate(
85
97
  {},
86
98
  {
87
- ...validStage,
99
+ ...valid,
88
100
  scalePct: '${ parameters.percentage }',
89
101
  targetHealthyDeployPercentage: '${ parameters.healthPercentage }',
90
102
  },
@@ -92,168 +104,165 @@ describe('AWS Resize Server Group stage', () => {
92
104
  ).toBe('');
93
105
  });
94
106
 
95
- it('only applies percentage validation to fields used by the selected resize mode', () => {
96
- const validator = awsResizeAsgStage.validators.find(({ type }) => type === 'custom');
97
-
107
+ it('validates only fields used by incremental and exact modes', () => {
108
+ const countMessage = 'Resize count must be a nonnegative integer or pipeline expression.';
109
+ expect(validator().validate({}, { action: 'scale_down', resizeType: 'incr', scaleNum: 2.5 })).toBe(countMessage);
110
+ expect(validator().validate({}, { action: 'scale_down', resizeType: 'incr', scaleNum: 0 })).toBe('');
98
111
  expect(
99
- validator.validate(
112
+ validator().validate(
100
113
  {},
101
- {
102
- action: 'scale_up',
103
- resizeType: 'capacity',
104
- scalePct: 12.5,
105
- targetHealthyDeployPercentage: 75,
106
- },
114
+ { action: 'scale_exact', resizeType: 'exact', capacity: { min: 1.5, max: -1, desired: Number.NaN } },
107
115
  ),
108
- ).toBe('');
116
+ ).toBe('Minimum capacity must be a nonnegative integer or pipeline expression.');
109
117
  expect(
110
- validator.validate(
118
+ validator().validate(
119
+ {},
120
+ { action: 'scale_exact', resizeType: 'exact', capacity: { min: 1, max: -1, desired: Number.NaN } },
121
+ ),
122
+ ).toBe('Maximum capacity must be a nonnegative integer or pipeline expression.');
123
+ expect(
124
+ validator().validate(
125
+ {},
126
+ { action: 'scale_exact', resizeType: 'exact', capacity: { min: 1, max: 2, desired: Number.NaN } },
127
+ ),
128
+ ).toBe('Desired capacity must be a nonnegative integer or pipeline expression.');
129
+ expect(
130
+ validator().validate(
111
131
  {},
112
132
  {
113
- action: 'scale_down',
133
+ action: 'scale_up',
114
134
  resizeType: 'pct',
115
135
  scalePct: 25,
116
- targetHealthyDeployPercentage: 101,
136
+ scaleNum: -1,
137
+ capacity: { min: -1, max: -1, desired: -1 },
138
+ targetHealthyDeployPercentage: 75,
117
139
  },
118
140
  ),
119
141
  ).toBe('');
120
142
  });
121
143
 
122
- it('prevents saving invalid incremental counts while allowing integers and expressions', () => {
123
- const validator = awsResizeAsgStage.validators.find(({ type }) => type === 'custom');
124
- const validStage = { action: 'scale_down', resizeType: 'incr', scaleNum: 2 };
125
- const message = 'Resize count must be a nonnegative integer or pipeline expression.';
144
+ it('rejects a null percentage in percentage mode', () => {
145
+ expect(
146
+ validator().validate(
147
+ {},
148
+ { action: 'scale_up', resizeType: 'pct', scalePct: null, targetHealthyDeployPercentage: 100 },
149
+ ),
150
+ ).toBe('Resize percentage must be a nonnegative integer or pipeline expression.');
151
+ });
126
152
 
127
- expect(validator.validate({}, { ...validStage, scaleNum: 2.5 })).toBe(message);
128
- expect(validator.validate({}, { ...validStage, scaleNum: -1 })).toBe(message);
129
- expect(validator.validate({}, { ...validStage, scaleNum: Number.NaN })).toBe(message);
130
- expect(validator.validate({}, { ...validStage, scaleNum: 0 })).toBe('');
131
- expect(validator.validate({}, { ...validStage, scaleNum: '${ parameters.count }' })).toBe('');
153
+ it('rejects a fractional target health percentage', () => {
154
+ expect(
155
+ validator().validate(
156
+ {},
157
+ { action: 'scale_up', resizeType: 'pct', scalePct: 25, targetHealthyDeployPercentage: 99.5 },
158
+ ),
159
+ ).toBe('Target healthy percentage must be an integer from 0 through 100 or pipeline expression.');
132
160
  });
133
161
 
134
- it('prevents saving invalid exact capacities in min, max, desired order', () => {
135
- const validator = awsResizeAsgStage.validators.find(({ type }) => type === 'custom');
136
- const validStage = {
137
- action: 'scale_exact',
138
- resizeType: 'exact',
139
- capacity: { min: 1, max: 2, desired: 3 },
140
- };
162
+ it('rejects negative and non-finite incremental counts while accepting an expression', () => {
163
+ const message = 'Resize count must be a nonnegative integer or pipeline expression.';
141
164
 
142
- expect(validator.validate({}, { ...validStage, capacity: { min: 1.5, max: -1, desired: Number.NaN } })).toBe(
143
- 'Minimum capacity must be a nonnegative integer or pipeline expression.',
144
- );
145
- expect(validator.validate({}, { ...validStage, capacity: { min: 1, max: -1, desired: Number.NaN } })).toBe(
146
- 'Maximum capacity must be a nonnegative integer or pipeline expression.',
147
- );
148
- expect(validator.validate({}, { ...validStage, capacity: { min: 1, max: 2, desired: Number.NaN } })).toBe(
149
- 'Desired capacity must be a nonnegative integer or pipeline expression.',
150
- );
165
+ expect(validator().validate({}, { action: 'scale_down', resizeType: 'incr', scaleNum: -1 })).toBe(message);
166
+ expect(validator().validate({}, { action: 'scale_down', resizeType: 'incr', scaleNum: Number.NaN })).toBe(message);
167
+ expect(validator().validate({}, { action: 'scale_down', resizeType: 'incr', scaleNum: '${ count }' })).toBe('');
168
+ });
169
+
170
+ it('accepts expressions for every exact capacity', () => {
151
171
  expect(
152
- validator.validate(
172
+ validator().validate(
153
173
  {},
154
174
  {
155
- ...validStage,
156
- capacity: {
157
- min: '${ parameters.min }',
158
- max: '${ parameters.max }',
159
- desired: '${ parameters.desired }',
160
- },
175
+ action: 'scale_exact',
176
+ resizeType: 'exact',
177
+ capacity: { min: '${ min }', max: '${ max }', desired: '${ desired }' },
161
178
  },
162
179
  ),
163
180
  ).toBe('');
164
181
  });
165
182
 
166
- it('ignores stale incremental and capacity values outside their active modes', () => {
167
- const validator = awsResizeAsgStage.validators.find(({ type }) => type === 'custom');
168
-
183
+ it('validates only eligible fields across incremental, exact, and scale-down percentage modes', () => {
169
184
  expect(
170
- validator.validate(
185
+ validator().validate(
171
186
  {},
172
187
  {
173
188
  action: 'scale_up',
174
- resizeType: 'pct',
175
- scalePct: 25,
176
- scaleNum: -1,
189
+ resizeType: 'incr',
190
+ scaleNum: 1,
191
+ scalePct: null,
177
192
  capacity: { min: -1, max: -1, desired: -1 },
178
- targetHealthyDeployPercentage: 75,
193
+ targetHealthyDeployPercentage: 100,
179
194
  },
180
195
  ),
181
196
  ).toBe('');
182
197
  expect(
183
- validator.validate(
198
+ validator().validate(
184
199
  {},
185
200
  {
186
- action: 'scale_down',
187
- resizeType: 'incr',
188
- scaleNum: 2,
189
- capacity: { min: -1, max: -1, desired: -1 },
201
+ action: 'scale_exact',
202
+ resizeType: 'exact',
203
+ scaleNum: -1,
204
+ scalePct: null,
205
+ capacity: { min: 1, max: 2, desired: 2 },
206
+ targetHealthyDeployPercentage: 99.5,
190
207
  },
191
208
  ),
192
209
  ).toBe('');
193
210
  expect(
194
- validator.validate(
211
+ validator().validate(
195
212
  {},
196
213
  {
197
- action: 'scale_exact',
198
- resizeType: 'exact',
199
- scaleNum: -1,
200
- capacity: { min: 1, max: 2, desired: 3 },
214
+ action: 'scale_down',
215
+ resizeType: 'pct',
216
+ scaleNum: Number.NaN,
217
+ scalePct: 25,
218
+ capacity: { min: -1, max: -1, desired: -1 },
219
+ targetHealthyDeployPercentage: 99.5,
201
220
  },
202
221
  ),
203
222
  ).toBe('');
204
223
  });
205
224
 
206
- it('renders AWS target, action, percentage, health threshold, and platform health controls', () => {
207
- const { wrapper } = renderStage();
208
-
209
- expect(wrapper.find(AccountRegionClusterSelector).exists()).toBe(true);
210
- expect(wrapper.find(TargetSelect).exists()).toBe(true);
211
- expect(wrapper.find('select[name="action"] option').map((option) => option.prop('value'))).toEqual([
212
- 'scale_up',
213
- 'scale_down',
214
- 'scale_to_cluster',
215
- 'scale_exact',
216
- ]);
217
- expect(wrapper.find('select[name="resizeType"]').exists()).toBe(true);
218
- expect(wrapper.find('input[name="scalePct"]').prop('value')).toBe(150);
219
- expect(wrapper.find('input[name="targetHealthyDeployPercentage"]').prop('value')).toBe(100);
220
- expect(wrapper.find(PlatformHealthOverride).prop('platformHealthType')).toBe('Amazon');
225
+ it('renders target, action, percentage, health threshold, and task completion controls', () => {
226
+ renderStage();
227
+
228
+ expect(within(getFormGroupByLabel('Target')).getByRole('combobox')).toHaveAttribute(
229
+ 'placeholder',
230
+ '(Deprecated) Current Server Group',
231
+ );
232
+ const action = within(getFormGroupByLabel('Action')).getByRole('combobox');
233
+ expect(
234
+ within(action)
235
+ .getAllByRole('option')
236
+ .map((option) => (option as HTMLOptionElement).value),
237
+ ).toEqual(['scale_up', 'scale_down', 'scale_to_cluster', 'scale_exact']);
238
+ expect(screen.getByRole('textbox', { name: 'Resize percentage' })).toHaveValue('150');
239
+ expect(screen.getByRole('textbox', { name: 'Target healthy percentage' })).toHaveValue('100');
240
+ expect(getFormGroupByLabel('Task Completion')).toHaveTextContent('Amazon');
221
241
  });
222
242
 
223
243
  it('renders exact min, max, and desired capacity without percentage controls', () => {
224
- const { wrapper } = renderStage({
244
+ renderStage({
225
245
  action: 'scale_exact',
226
246
  capacity: { desired: 4, max: '${ parameters.max }', min: 2 },
227
247
  resizeType: 'exact',
228
248
  });
229
249
 
230
- expect(wrapper.find('select[name="resizeType"]').exists()).toBe(false);
231
- const capacityInputs = wrapper.find('input[data-capacity-field]');
232
- expect(capacityInputs.map((input) => input.prop('name'))).toEqual([
233
- 'capacity.min',
234
- 'capacity.max',
235
- 'capacity.desired',
236
- ]);
237
- expect(capacityInputs.map((input) => input.prop('value'))).toEqual([2, '${ parameters.max }', 4]);
238
- expect(wrapper.find('input[name="targetHealthyDeployPercentage"]').exists()).toBe(false);
250
+ expect(screen.getByRole('textbox', { name: 'Minimum capacity' })).toHaveValue('2');
251
+ expect(screen.getByRole('textbox', { name: 'Maximum capacity' })).toHaveValue('${ parameters.max }');
252
+ expect(screen.getByRole('textbox', { name: 'Desired capacity' })).toHaveValue('4');
253
+ expect(screen.queryByRole('textbox', { name: 'Resize percentage' })).not.toBeInTheDocument();
254
+ expect(screen.queryByRole('textbox', { name: 'Target healthy percentage' })).not.toBeInTheDocument();
239
255
  });
240
256
 
241
257
  it('renders an incremental count for scale down without a health threshold', () => {
242
- const { wrapper } = renderStage({
243
- action: 'scale_down',
244
- resizeType: 'incr',
245
- scaleNum: '${ parameters.count }',
246
- });
258
+ renderStage({ action: 'scale_down', resizeType: 'incr', scaleNum: '${ parameters.count }' });
247
259
 
248
- expect(wrapper.find('input[name="scaleNum"]').map((input) => input.prop('value'))).toEqual([
249
- '${ parameters.count }',
250
- ]);
251
- expect(wrapper.find('input[name="scalePct"]').exists()).toBe(false);
252
- expect(wrapper.find('input[name="targetHealthyDeployPercentage"]').exists()).toBe(false);
260
+ expect(screen.getByRole('textbox', { name: 'Resize count' })).toHaveValue('${ parameters.count }');
261
+ expect(screen.queryByRole('textbox', { name: 'Target healthy percentage' })).not.toBeInTheDocument();
253
262
  });
254
263
 
255
264
  it('applies AWS defaults to a new stage', () => {
256
- const { updateStageField } = renderStage(
265
+ const rendered = renderStage(
257
266
  {
258
267
  action: undefined,
259
268
  capacity: undefined,
@@ -273,7 +282,7 @@ describe('AWS Resize Server Group stage', () => {
273
282
  },
274
283
  );
275
284
 
276
- expect(updateStageField).toHaveBeenCalledWith({
285
+ expect(rendered.updateStageField).toHaveBeenCalledWith({
277
286
  action: 'scale_up',
278
287
  capacity: {},
279
288
  cloudProvider: 'aws',
@@ -286,313 +295,206 @@ describe('AWS Resize Server Group stage', () => {
286
295
  });
287
296
  });
288
297
 
289
- ['scale_up', 'scale_down', 'scale_to_cluster'].forEach((action) => {
290
- it(`defaults legacy exact mode to percentage when changing to ${action}`, () => {
291
- const exact = renderStage({
298
+ describe('mode transitions', () => {
299
+ it.each(['scale_up', 'scale_down', 'scale_to_cluster'])(
300
+ 'defaults legacy exact mode to percentage when changing to %s',
301
+ (action) => {
302
+ const rendered = renderStage({
303
+ action: 'scale_exact',
304
+ capacity: { desired: 4, max: 4, min: 4 },
305
+ resizeType: 'exact',
306
+ scaleNum: 3,
307
+ scalePct: undefined,
308
+ });
309
+ const original = { ...rendered.initialStage, capacity: { ...rendered.initialStage.capacity } };
310
+ rendered.updateStage.mockClear();
311
+ rendered.updateStageField.mockClear();
312
+
313
+ fireEvent.change(within(getFormGroupByLabel('Action')).getByRole('combobox'), { target: { value: action } });
314
+
315
+ expect(rendered.initialStage).toEqual(original);
316
+ expect(rendered.updateStage.mock.lastCall?.[0]).toStrictEqual({
317
+ action,
318
+ capacity: {},
319
+ resizeType: 'pct',
320
+ scaleNum: undefined,
321
+ scalePct: 0,
322
+ });
323
+ expect(rendered.updateStageField).not.toHaveBeenCalled();
324
+ },
325
+ );
326
+
327
+ it('clears stale fields when changing between exact, incremental, and percentage modes', () => {
328
+ const exact = renderStage({ scaleNum: 3 });
329
+ const originalExact = { ...exact.initialStage, capacity: { ...exact.initialStage.capacity } };
330
+ exact.updateStage.mockClear();
331
+ exact.updateStageField.mockClear();
332
+
333
+ fireEvent.change(within(getFormGroupByLabel('Action')).getByRole('combobox'), {
334
+ target: { value: 'scale_exact' },
335
+ });
336
+
337
+ expect(exact.initialStage).toEqual(originalExact);
338
+ expect(exact.updateStage.mock.lastCall?.[0]).toStrictEqual({
292
339
  action: 'scale_exact',
293
- capacity: { desired: 4, max: 4, min: 4 },
294
340
  resizeType: 'exact',
295
- scaleNum: 3,
341
+ scaleNum: undefined,
296
342
  scalePct: undefined,
297
343
  });
298
- const originalStage = { ...exact.stage, capacity: { ...exact.stage.capacity } };
299
- exact.updateStage.calls.reset();
300
- exact.updateStageField.calls.reset();
344
+ expect(exact.updateStageField).not.toHaveBeenCalled();
301
345
 
302
- exact.wrapper.find('select[name="action"]').simulate('change', { target: { value: action } });
346
+ exact.updateStage.mockClear();
347
+ fireEvent.change(within(getFormGroupByLabel('Action')).getByRole('combobox'), {
348
+ target: { value: 'scale_up' },
349
+ });
350
+ fireEvent.change(within(getFormGroupByLabel('Type')).getByRole('combobox'), {
351
+ target: { value: 'incr' },
352
+ });
353
+ expect(exact.updateStage.mock.lastCall?.[0]).toStrictEqual({
354
+ action: 'scale_up',
355
+ capacity: {},
356
+ resizeType: 'incr',
357
+ scaleNum: 0,
358
+ scalePct: undefined,
359
+ });
303
360
 
304
- expect(exact.stage).toEqual(originalStage);
305
- expect(exact.updateStage).toHaveBeenCalledWith({
306
- action,
361
+ fireEvent.change(within(getFormGroupByLabel('Type')).getByRole('combobox'), {
362
+ target: { value: 'pct' },
363
+ });
364
+ expect(exact.updateStage.mock.lastCall?.[0]).toStrictEqual({
365
+ action: 'scale_up',
307
366
  capacity: {},
308
367
  resizeType: 'pct',
309
368
  scaleNum: undefined,
310
369
  scalePct: 0,
311
370
  });
312
- expect(exact.updateStageField).not.toHaveBeenCalled();
313
- });
314
- });
315
-
316
- it('reports stale resize field removals without mutating the stage prop', () => {
317
- const exact = renderStage({ scaleNum: 3 });
318
- const originalExactStage = { ...exact.stage, capacity: { ...exact.stage.capacity } };
319
- exact.updateStage.calls.reset();
320
- exact.updateStageField.calls.reset();
321
-
322
- exact.wrapper.find('select[name="action"]').simulate('change', { target: { value: 'scale_exact' } });
323
-
324
- expect(exact.stage).toEqual(originalExactStage);
325
- expect(exact.updateStage).toHaveBeenCalledWith({
326
- action: 'scale_exact',
327
- resizeType: 'exact',
328
- scaleNum: undefined,
329
- scalePct: undefined,
330
- });
331
- expect(exact.updateStageField).not.toHaveBeenCalled();
332
-
333
- const incremental = renderStage({ capacity: { desired: 4 }, scalePct: 25 });
334
- const originalIncrementalStage = { ...incremental.stage, capacity: { ...incremental.stage.capacity } };
335
- incremental.updateStage.calls.reset();
336
- incremental.updateStageField.calls.reset();
337
-
338
- incremental.wrapper.find('select[name="resizeType"]').simulate('change', { target: { value: 'incr' } });
339
-
340
- expect(incremental.stage).toEqual(originalIncrementalStage);
341
- expect(incremental.updateStage).toHaveBeenCalledWith({
342
- action: 'scale_up',
343
- capacity: {},
344
- resizeType: 'incr',
345
- scaleNum: 0,
346
- scalePct: undefined,
347
- });
348
- expect(incremental.updateStageField).not.toHaveBeenCalled();
349
-
350
- const percentage = renderStage({ resizeType: 'incr', scaleNum: 3, scalePct: undefined });
351
- const originalPercentageStage = { ...percentage.stage, capacity: { ...percentage.stage.capacity } };
352
- percentage.updateStage.calls.reset();
353
- percentage.updateStageField.calls.reset();
354
-
355
- percentage.wrapper.find('select[name="resizeType"]').simulate('change', { target: { value: 'pct' } });
356
-
357
- expect(percentage.stage).toEqual(originalPercentageStage);
358
- expect(percentage.updateStage).toHaveBeenCalledWith({
359
- action: 'scale_up',
360
- capacity: {},
361
- resizeType: 'pct',
362
- scaleNum: undefined,
363
- scalePct: 0,
364
- });
365
- expect(percentage.updateStageField).not.toHaveBeenCalled();
366
- });
367
-
368
- it('validates numeric modes while preserving pipeline expressions', () => {
369
- const percentage = renderStage({ scalePct: 125 });
370
- percentage.updateStageField.calls.reset();
371
- const percentageInput = percentage.wrapper.find('input[name="scalePct"]');
372
-
373
- expect(percentageInput.prop('aria-invalid')).toBe(false);
374
- percentageInput.simulate('change', { target: { value: '${ parameters.percentage }' } });
375
- expect(percentage.updateStageField).toHaveBeenCalledWith({ scalePct: '${ parameters.percentage }' });
376
-
377
- const healthPercentage = renderStage({ targetHealthyDeployPercentage: 100 });
378
- healthPercentage.updateStageField.calls.reset();
379
- const healthPercentageInput = healthPercentage.wrapper.find('input[name="targetHealthyDeployPercentage"]');
380
-
381
- expect(healthPercentageInput.prop('aria-invalid')).toBe(false);
382
- healthPercentageInput.simulate('change', { target: { value: '${ parameters.healthPercentage }' } });
383
- expect(healthPercentage.updateStageField).toHaveBeenCalledWith({
384
- targetHealthyDeployPercentage: '${ parameters.healthPercentage }',
385
371
  });
386
-
387
- expect(renderStage({ scalePct: -1 }).wrapper.find('input[name="scalePct"]').prop('aria-invalid')).toBe(true);
388
- expect(renderStage({ scalePct: 12.5 }).wrapper.find('input[name="scalePct"]').prop('aria-invalid')).toBe(true);
389
- expect(
390
- renderStage({ targetHealthyDeployPercentage: -1 })
391
- .wrapper.find('input[name="targetHealthyDeployPercentage"]')
392
- .prop('aria-invalid'),
393
- ).toBe(true);
394
- expect(
395
- renderStage({ targetHealthyDeployPercentage: 12.5 })
396
- .wrapper.find('input[name="targetHealthyDeployPercentage"]')
397
- .prop('aria-invalid'),
398
- ).toBe(true);
399
- expect(
400
- renderStage({ targetHealthyDeployPercentage: 101 })
401
- .wrapper.find('input[name="targetHealthyDeployPercentage"]')
402
- .prop('aria-invalid'),
403
- ).toBe(true);
404
- expect(
405
- renderStage({ action: 'scale_down', resizeType: 'incr', scaleNum: 2.5 })
406
- .wrapper.find('input[name="scaleNum"]')
407
- .prop('aria-invalid'),
408
- ).toBe(true);
409
- expect(
410
- renderStage({ action: 'scale_exact', capacity: { desired: 3, max: '${ parameters.max }', min: -1 } })
411
- .wrapper.find('input[data-capacity-field="min"]')
412
- .prop('aria-invalid'),
413
- ).toBe(true);
414
- expect(
415
- renderStage({ action: 'scale_exact', capacity: { desired: 3, max: '${ parameters.max }', min: 1 } })
416
- .wrapper.find('input[data-capacity-field="max"]')
417
- .prop('aria-invalid'),
418
- ).toBe(false);
419
372
  });
420
373
 
421
- it('keeps invalid resize percentage edits local and only reports valid values', () => {
422
- const percentage = renderStage({ scalePct: 25 });
423
- percentage.updateStageField.calls.reset();
424
-
425
- ['12.5', '-1', 'Infinity'].forEach((value) => {
426
- percentage.wrapper.find('input[name="scalePct"]').simulate('change', { target: { value } });
427
-
428
- const input = percentage.wrapper.find('input[name="scalePct"]');
429
- expect(input.prop('value')).toBe(value);
430
- expect(input.prop('aria-invalid')).toBe(true);
431
- expect(percentage.stage.scalePct).toBe(25);
432
- expect(percentage.updateStageField).not.toHaveBeenCalled();
433
- });
434
-
435
- percentage.wrapper.find('input[name="scalePct"]').simulate('change', { target: { value: '125' } });
436
- expect(percentage.updateStageField).toHaveBeenCalledWith({ scalePct: 125 });
437
-
438
- percentage.updateStageField.calls.reset();
439
- percentage.wrapper
440
- .find('input[name="scalePct"]')
441
- .simulate('change', { target: { value: '${ parameters.percentage }' } });
442
- expect(percentage.updateStageField).toHaveBeenCalledWith({ scalePct: '${ parameters.percentage }' });
374
+ it('keeps invalid percentage edits local and reports valid values and expressions', () => {
375
+ const rendered = renderStage({ scalePct: 25 });
376
+ rendered.updateStageField.mockClear();
377
+ const percentage = screen.getByRole('textbox', { name: 'Resize percentage' });
378
+
379
+ for (const value of ['12.5', '-1', 'Infinity']) {
380
+ fireEvent.change(percentage, { target: { value } });
381
+ expect(percentage).toHaveValue(value);
382
+ expect(percentage).toHaveAttribute('aria-invalid', 'true');
383
+ expect(rendered.initialStage.scalePct).toBe(25);
384
+ expect(rendered.updateStageField).not.toHaveBeenCalled();
385
+ }
386
+
387
+ fireEvent.change(percentage, { target: { value: '125' } });
388
+ expect(rendered.updateStageField).toHaveBeenCalledWith({ scalePct: 125 });
389
+ rendered.updateStageField.mockClear();
390
+ fireEvent.change(percentage, { target: { value: '${ parameters.percentage }' } });
391
+ expect(rendered.updateStageField).toHaveBeenCalledWith({ scalePct: '${ parameters.percentage }' });
443
392
  });
444
393
 
445
- it('keeps invalid health percentage edits local and only reports valid values', () => {
394
+ it('keeps invalid health and incremental edits local and reports valid values', () => {
446
395
  const health = renderStage({ targetHealthyDeployPercentage: 75 });
447
- health.updateStageField.calls.reset();
396
+ health.updateStageField.mockClear();
397
+ const healthPercentage = screen.getByRole('textbox', { name: 'Target healthy percentage' });
448
398
 
449
- ['75.5', '-1', '101', 'Infinity'].forEach((value) => {
450
- health.wrapper.find('input[name="targetHealthyDeployPercentage"]').simulate('change', { target: { value } });
451
-
452
- const input = health.wrapper.find('input[name="targetHealthyDeployPercentage"]');
453
- expect(input.prop('value')).toBe(value);
454
- expect(input.prop('aria-invalid')).toBe(true);
455
- expect(health.stage.targetHealthyDeployPercentage).toBe(75);
399
+ for (const value of ['75.5', '-1', '101', 'Infinity']) {
400
+ fireEvent.change(healthPercentage, { target: { value } });
401
+ expect(healthPercentage).toHaveValue(value);
402
+ expect(healthPercentage).toHaveAttribute('aria-invalid', 'true');
456
403
  expect(health.updateStageField).not.toHaveBeenCalled();
457
- });
458
-
459
- health.wrapper.find('input[name="targetHealthyDeployPercentage"]').simulate('change', { target: { value: '100' } });
404
+ }
405
+ fireEvent.change(healthPercentage, { target: { value: '100' } });
460
406
  expect(health.updateStageField).toHaveBeenCalledWith({ targetHealthyDeployPercentage: 100 });
407
+ health.unmount();
461
408
 
462
- health.updateStageField.calls.reset();
463
- health.wrapper
464
- .find('input[name="targetHealthyDeployPercentage"]')
465
- .simulate('change', { target: { value: '${ parameters.healthPercentage }' } });
466
- expect(health.updateStageField).toHaveBeenCalledWith({
467
- targetHealthyDeployPercentage: '${ parameters.healthPercentage }',
468
- });
469
- });
470
-
471
- it('keeps invalid incremental edits local and only reports valid values', () => {
472
409
  const incremental = renderStage({ action: 'scale_down', resizeType: 'incr', scaleNum: 2 });
473
- incremental.updateStageField.calls.reset();
474
-
475
- ['2.5', '-1', 'NaN'].forEach((value) => {
476
- incremental.wrapper.find('input[name="scaleNum"]').simulate('change', { target: { value } });
477
-
478
- const input = incremental.wrapper.find('input[name="scaleNum"]');
479
- expect(input.prop('value')).toBe(value);
480
- expect(input.prop('aria-invalid')).toBe(true);
481
- expect(incremental.stage.scaleNum).toBe(2);
410
+ incremental.updateStageField.mockClear();
411
+ const count = screen.getByRole('textbox', { name: 'Resize count' });
412
+ for (const value of ['2.5', '-1', 'NaN']) {
413
+ fireEvent.change(count, { target: { value } });
414
+ expect(count).toHaveValue(value);
415
+ expect(count).toHaveAttribute('aria-invalid', 'true');
482
416
  expect(incremental.updateStageField).not.toHaveBeenCalled();
483
- });
484
-
485
- incremental.wrapper.find('input[name="scaleNum"]').simulate('change', { target: { value: '3' } });
417
+ }
418
+ fireEvent.change(count, { target: { value: '3' } });
486
419
  expect(incremental.updateStageField).toHaveBeenCalledWith({ scaleNum: 3 });
487
-
488
- incremental.updateStageField.calls.reset();
489
- incremental.wrapper
490
- .find('input[name="scaleNum"]')
491
- .simulate('change', { target: { value: '${ parameters.count }' } });
492
- expect(incremental.updateStageField).toHaveBeenCalledWith({ scaleNum: '${ parameters.count }' });
493
-
494
- incremental.wrapper.setProps({ stage: { ...incremental.stage, scaleNum: 4 } });
495
- incremental.wrapper.update();
496
- expect(incremental.wrapper.find('input[name="scaleNum"]').prop('value')).toBe(4);
497
420
  });
498
421
 
499
- it('keeps invalid exact capacity edits local and reports valid values in capacity order', () => {
500
- const capacity = { min: 1, max: 2, desired: 3 };
501
-
502
- [
503
- { field: 'min', value: '1.5' },
504
- { field: 'max', value: '-1' },
505
- { field: 'desired', value: 'NaN' },
506
- ].forEach(({ field, value }) => {
507
- const exact = renderStage({ action: 'scale_exact', capacity, resizeType: 'exact' });
508
- exact.updateStageField.calls.reset();
509
-
510
- exact.wrapper.find(`input[data-capacity-field="${field}"]`).simulate('change', { target: { value } });
511
-
512
- const input = exact.wrapper.find(`input[data-capacity-field="${field}"]`);
513
- expect(input.prop('value')).toBe(value);
514
- expect(input.prop('aria-invalid')).toBe(true);
515
- expect(exact.stage.capacity).toEqual(capacity);
516
- expect(exact.updateStageField).not.toHaveBeenCalled();
422
+ it('keeps invalid exact capacity edits local', () => {
423
+ const rendered = renderStage({
424
+ action: 'scale_exact',
425
+ capacity: { min: 1, max: 2, desired: 3 },
426
+ resizeType: 'exact',
517
427
  });
428
+ rendered.updateStageField.mockClear();
429
+
430
+ for (const [name, value] of [
431
+ ['Minimum capacity', '1.5'],
432
+ ['Maximum capacity', '-1'],
433
+ ['Desired capacity', 'NaN'],
434
+ ]) {
435
+ const input = screen.getByRole('textbox', { name });
436
+ fireEvent.change(input, { target: { value } });
437
+ expect(input).toHaveValue(value);
438
+ expect(input).toHaveAttribute('aria-invalid', 'true');
439
+ }
440
+ expect(rendered.initialStage.capacity).toEqual({ min: 1, max: 2, desired: 3 });
441
+ expect(rendered.updateStageField).not.toHaveBeenCalled();
442
+ });
518
443
 
519
- const exact = renderStage({ action: 'scale_exact', capacity, resizeType: 'exact' });
520
- exact.updateStageField.calls.reset();
521
-
522
- exact.wrapper.find('input[data-capacity-field="min"]').simulate('change', { target: { value: '4' } });
523
- expect(exact.updateStageField).toHaveBeenCalledWith({ capacity: { min: 4, max: 2, desired: 3 } });
524
-
525
- exact.updateStageField.calls.reset();
526
- exact.wrapper
527
- .find('input[data-capacity-field="max"]')
528
- .simulate('change', { target: { value: '${ parameters.max }' } });
529
- expect(exact.updateStageField).toHaveBeenCalledWith({
530
- capacity: { min: 1, max: '${ parameters.max }', desired: 3 },
444
+ it('reports valid exact capacities in min, max, desired order', () => {
445
+ const rendered = renderStage({
446
+ action: 'scale_exact',
447
+ capacity: { min: 1, max: 2, desired: 3 },
448
+ resizeType: 'exact',
449
+ });
450
+ rendered.updateStageField.mockClear();
451
+ const input = (name: string) => screen.getByRole('textbox', { name });
452
+
453
+ fireEvent.change(input('Minimum capacity'), { target: { value: '4' } });
454
+ expect(rendered.updateStageField).toHaveBeenLastCalledWith({ capacity: { min: 4, max: 2, desired: 3 } });
455
+ fireEvent.change(input('Maximum capacity'), { target: { value: '${ parameters.max }' } });
456
+ expect(rendered.updateStageField).toHaveBeenLastCalledWith({
457
+ capacity: { min: 4, max: '${ parameters.max }', desired: 3 },
458
+ });
459
+ fireEvent.change(input('Desired capacity'), { target: { value: '5' } });
460
+ expect(rendered.updateStageField).toHaveBeenLastCalledWith({
461
+ capacity: { min: 4, max: '${ parameters.max }', desired: 5 },
531
462
  });
532
-
533
- exact.updateStageField.calls.reset();
534
- exact.wrapper.find('input[data-capacity-field="desired"]').simulate('change', { target: { value: '5' } });
535
- expect(exact.updateStageField).toHaveBeenCalledWith({ capacity: { min: 1, max: 2, desired: 5 } });
536
-
537
- exact.wrapper.setProps({ stage: { ...exact.stage, capacity: { min: 4, max: 5, desired: 6 } } });
538
- exact.wrapper.update();
539
- const inputs = exact.wrapper.find('input[data-capacity-field]');
540
- expect(inputs.map((input) => input.prop('data-capacity-field'))).toEqual(['min', 'max', 'desired']);
541
- expect(inputs.map((input) => input.prop('value'))).toEqual([4, 5, 6]);
542
463
  });
543
464
 
544
- it('synchronizes controlled percentage inputs when stage props change', () => {
545
- const rendered = renderStage({ scalePct: 25, targetHealthyDeployPercentage: 75 });
546
-
547
- rendered.wrapper.find('input[name="scalePct"]').simulate('change', { target: { value: '12.5' } });
548
- rendered.wrapper
549
- .find('input[name="targetHealthyDeployPercentage"]')
550
- .simulate('change', { target: { value: '101' } });
551
-
552
- rendered.wrapper.setProps({
553
- stage: { ...rendered.stage, scalePct: 50, targetHealthyDeployPercentage: 80 },
465
+ it('synchronizes controlled drafts when persisted stage values change', () => {
466
+ const rendered = renderStage({ refId: 'stage-a', scalePct: 25, targetHealthyDeployPercentage: 75 });
467
+ fireEvent.change(screen.getByRole('textbox', { name: 'Resize percentage' }), { target: { value: '12.5' } });
468
+ fireEvent.change(screen.getByRole('textbox', { name: 'Target healthy percentage' }), {
469
+ target: { value: '101' },
554
470
  });
555
- rendered.wrapper.update();
556
471
 
557
- expect(rendered.wrapper.find('input[name="scalePct"]').prop('value')).toBe(50);
558
- expect(rendered.wrapper.find('input[name="targetHealthyDeployPercentage"]').prop('value')).toBe(80);
559
- });
472
+ rendered.replaceStage({ ...rendered.initialStage, scalePct: 50, targetHealthyDeployPercentage: 80 });
560
473
 
561
- it('resets every controlled draft when the stage refId changes with equal persisted values', () => {
562
- const validator = awsResizeAsgStage.validators.find(({ type }) => type === 'custom');
474
+ expect(screen.getByRole('textbox', { name: 'Resize percentage' })).toHaveValue('50');
475
+ expect(screen.getByRole('textbox', { name: 'Target healthy percentage' })).toHaveValue('80');
476
+ });
563
477
 
564
- const percentage = renderStage({
565
- refId: 'stage-a',
566
- scalePct: 25,
567
- targetHealthyDeployPercentage: 75,
478
+ it('resets every controlled draft when refId changes with equal persisted values', () => {
479
+ const percentage = renderStage({ refId: 'stage-a', scalePct: 25, targetHealthyDeployPercentage: 75 });
480
+ fireEvent.change(screen.getByRole('textbox', { name: 'Resize percentage' }), { target: { value: '12.5' } });
481
+ fireEvent.change(screen.getByRole('textbox', { name: 'Target healthy percentage' }), {
482
+ target: { value: '101' },
568
483
  });
569
- percentage.updateStageField.calls.reset();
570
- percentage.wrapper.find('input[name="scalePct"]').simulate('change', { target: { value: '12.5' } });
571
- percentage.wrapper
572
- .find('input[name="targetHealthyDeployPercentage"]')
573
- .simulate('change', { target: { value: '101' } });
574
- const nextPercentageStage = { ...percentage.stage, refId: 'stage-b' };
575
- percentage.wrapper.setProps({ stage: nextPercentageStage });
576
- percentage.wrapper.update();
577
-
578
- expect(percentage.wrapper.find('input[name="scalePct"]').prop('value')).toBe(25);
579
- expect(percentage.wrapper.find('input[name="scalePct"]').prop('aria-invalid')).toBe(false);
580
- expect(percentage.wrapper.find('input[name="targetHealthyDeployPercentage"]').prop('value')).toBe(75);
581
- expect(percentage.wrapper.find('input[name="targetHealthyDeployPercentage"]').prop('aria-invalid')).toBe(false);
484
+ percentage.updateStageField.mockClear();
485
+ percentage.replaceStage({ ...percentage.initialStage, refId: 'stage-b' });
486
+ expect(screen.getByRole('textbox', { name: 'Resize percentage' })).toHaveValue('25');
487
+ expect(screen.getByRole('textbox', { name: 'Target healthy percentage' })).toHaveValue('75');
582
488
  expect(percentage.updateStageField).not.toHaveBeenCalled();
583
- expect(validator.validate({}, nextPercentageStage)).toBe('');
489
+ percentage.unmount();
584
490
 
585
491
  const incremental = renderStage({ action: 'scale_down', refId: 'stage-a', resizeType: 'incr', scaleNum: 2 });
586
- incremental.updateStageField.calls.reset();
587
- incremental.wrapper.find('input[name="scaleNum"]').simulate('change', { target: { value: '2.5' } });
588
- const nextIncrementalStage = { ...incremental.stage, refId: 'stage-b' };
589
- incremental.wrapper.setProps({ stage: nextIncrementalStage });
590
- incremental.wrapper.update();
591
-
592
- expect(incremental.wrapper.find('input[name="scaleNum"]').prop('value')).toBe(2);
593
- expect(incremental.wrapper.find('input[name="scaleNum"]').prop('aria-invalid')).toBe(false);
492
+ fireEvent.change(screen.getByRole('textbox', { name: 'Resize count' }), { target: { value: '2.5' } });
493
+ incremental.updateStageField.mockClear();
494
+ incremental.replaceStage({ ...incremental.initialStage, refId: 'stage-b' });
495
+ expect(screen.getByRole('textbox', { name: 'Resize count' })).toHaveValue('2');
594
496
  expect(incremental.updateStageField).not.toHaveBeenCalled();
595
- expect(validator.validate({}, nextIncrementalStage)).toBe('');
497
+ incremental.unmount();
596
498
 
597
499
  const exact = renderStage({
598
500
  action: 'scale_exact',
@@ -600,18 +502,30 @@ describe('AWS Resize Server Group stage', () => {
600
502
  refId: 'stage-a',
601
503
  resizeType: 'exact',
602
504
  });
603
- exact.updateStageField.calls.reset();
604
- ['min', 'max', 'desired'].forEach((field) => {
605
- exact.wrapper.find(`input[data-capacity-field="${field}"]`).simulate('change', { target: { value: 'NaN' } });
606
- });
607
- const nextExactStage = { ...exact.stage, refId: 'stage-b' };
608
- exact.wrapper.setProps({ stage: nextExactStage });
609
- exact.wrapper.update();
610
-
611
- const capacityInputs = exact.wrapper.find('input[data-capacity-field]');
612
- expect(capacityInputs.map((input) => input.prop('value'))).toEqual([1, 2, 3]);
613
- expect(capacityInputs.map((input) => input.prop('aria-invalid'))).toEqual([false, false, false]);
505
+ for (const name of ['Minimum capacity', 'Maximum capacity', 'Desired capacity']) {
506
+ fireEvent.change(screen.getByRole('textbox', { name }), { target: { value: 'NaN' } });
507
+ }
508
+ exact.updateStageField.mockClear();
509
+ exact.replaceStage({ ...exact.initialStage, refId: 'stage-b' });
510
+ expect(screen.getByRole('textbox', { name: 'Minimum capacity' })).toHaveValue('1');
511
+ expect(screen.getByRole('textbox', { name: 'Maximum capacity' })).toHaveValue('2');
512
+ expect(screen.getByRole('textbox', { name: 'Desired capacity' })).toHaveValue('3');
614
513
  expect(exact.updateStageField).not.toHaveBeenCalled();
615
- expect(validator.validate({}, nextExactStage)).toBe('');
514
+ });
515
+
516
+ it('renders the account, region, and cluster selector outside strategy pipelines', async () => {
517
+ vi.spyOn(AccountService, 'listAccounts').mockResolvedValue([{ name: 'test-account' }] as any);
518
+ vi.spyOn(AccountService, 'getUniqueAttributeForAllAccounts').mockResolvedValue(['eu-west-1'] as any);
519
+ renderStage(
520
+ { cloudProviderType: 'aws', credentials: 'test-account', regions: ['eu-west-1'] },
521
+ {},
522
+ { strategy: false },
523
+ );
524
+
525
+ await waitFor(() =>
526
+ expect(within(getFormGroupByLabel('Account')).getByRole('combobox')).toHaveValue('test-account'),
527
+ );
528
+ expect(within(getFormGroupByLabel('Regions')).getByRole('checkbox', { name: 'eu-west-1' })).toBeChecked();
529
+ expect(within(getFormGroupByLabel('Cluster')).getByRole('combobox')).toHaveDisplayValue('Select a cluster...');
616
530
  });
617
531
  });