@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.
- package/dist/common/AwsModalFooter.d.ts +1 -1
- package/dist/deploymentStrategy/AdditionalFields.d.ts +1 -1
- package/dist/function/CreateLambdaFunction.d.ts +1 -1
- package/dist/function/configure/ExecutionRole.d.ts +1 -1
- package/dist/function/configure/FunctionBasicInformation.d.ts +1 -1
- package/dist/function/configure/FunctionDebugAndErrorHandling.d.ts +1 -1
- package/dist/function/configure/FunctionEnvironmentVariables.d.ts +1 -1
- package/dist/function/configure/FunctionSettings.d.ts +1 -1
- package/dist/function/configure/FunctionTags.d.ts +1 -1
- package/dist/function/configure/Network.d.ts +1 -1
- package/dist/function/details/AmazonFunctionDetails.d.ts +1 -1
- package/dist/function/details/FunctionActions.d.ts +1 -1
- package/dist/index.js +279 -1
- package/dist/index.js.map +1 -1
- package/dist/instance/details/AmazonInstanceInformation.d.ts +2 -2
- package/dist/instance/details/CostFactor.d.ts +2 -2
- package/dist/instance/details/InstanceDns.d.ts +2 -2
- package/dist/instance/details/InstanceInformation.d.ts +2 -2
- package/dist/instance/details/InstanceSecurityGroups.d.ts +2 -2
- package/dist/instance/details/InstanceStatus.d.ts +2 -2
- package/dist/instance/details/InstanceTags.d.ts +2 -2
- package/dist/loadBalancer/configure/AmazonLoadBalancerChoiceModal.d.ts +1 -1
- package/dist/loadBalancer/configure/application/ALBListeners.d.ts +1 -1
- package/dist/loadBalancer/configure/application/ConfigureOidcConfigModal.d.ts +1 -1
- package/dist/loadBalancer/configure/application/ConfigureRedirectConfigModal.d.ts +1 -1
- package/dist/loadBalancer/configure/application/CreateApplicationLoadBalancer.d.ts +1 -1
- package/dist/loadBalancer/configure/application/TargetGroups.d.ts +1 -1
- package/dist/loadBalancer/configure/classic/AdvancedSettings.d.ts +1 -1
- package/dist/loadBalancer/configure/classic/HealthCheck.d.ts +1 -1
- package/dist/loadBalancer/configure/classic/Listeners.d.ts +1 -1
- package/dist/loadBalancer/configure/common/AmazonCertificateSelectField.d.ts +1 -1
- package/dist/loadBalancer/configure/common/LoadBalancerLocation.d.ts +1 -1
- package/dist/loadBalancer/configure/common/SecurityGroups.d.ts +1 -1
- package/dist/loadBalancer/configure/network/CertificateSelectors.d.ts +2 -2
- package/dist/loadBalancer/configure/network/NLBListeners.d.ts +1 -1
- package/dist/loadBalancer/configure/network/TargetGroups.d.ts +1 -1
- package/dist/loadBalancer/details/LoadBalancerActions.d.ts +1 -1
- package/dist/pipeline/stages/AmazonStageConfig.d.ts +2 -2
- package/dist/pipeline/stages/bake/AwsBakeStageConfig.d.ts +2 -2
- package/dist/pipeline/stages/cloneServerGroup/AwsCloneServerGroupStageConfig.d.ts +2 -2
- package/dist/pipeline/stages/deleteLambda/DeleteLambdaFunctionStageForm.d.ts +2 -2
- package/dist/pipeline/stages/deleteLambda/LambdaDeleteStage.d.ts +2 -2
- package/dist/pipeline/stages/deleteLambda/constants/deleteVersion.picker.d.ts +1 -1
- package/dist/pipeline/stages/deployCloudFormation/CloudFormationChangeSetInfo.d.ts +2 -2
- package/dist/pipeline/stages/deployCloudFormation/DeployCloudFormationStackStageConfig.d.ts +2 -2
- package/dist/pipeline/stages/deployCloudFormation/deployCloudFormationExecutionDetails.d.ts +1 -1
- package/dist/pipeline/stages/deployCloudFormation/evaluateCloudFormationChangeSetExecutionApproval.d.ts +2 -2
- package/dist/pipeline/stages/deployCloudFormation/evaluateCloudFormationChangeSetExecutionDetails.d.ts +1 -1
- package/dist/pipeline/stages/deployCloudFormation/evaluateCloudFormationChangeSetExecutionLabel.d.ts +1 -1
- package/dist/pipeline/stages/deployCloudFormation/evaluateCloudFormationChangeSetExecutionMarkerIcon.d.ts +1 -1
- package/dist/pipeline/stages/deployLambda/components/AwsLambdaFunctionStageForm.d.ts +2 -2
- package/dist/pipeline/stages/deployLambda/components/BasicSettingsForm.d.ts +2 -2
- package/dist/pipeline/stages/deployLambda/components/EnvironmentForm.d.ts +2 -2
- package/dist/pipeline/stages/deployLambda/components/ExecutionRoleForm.d.ts +2 -2
- package/dist/pipeline/stages/deployLambda/components/LambdaAtEdgeForm.d.ts +2 -2
- package/dist/pipeline/stages/deployLambda/components/NetworkForm.d.ts +2 -2
- package/dist/pipeline/stages/deployLambda/components/TriggerEventsForm.d.ts +2 -2
- package/dist/pipeline/stages/deployLambda/config/LambdaDeploymentStageConfig.d.ts +2 -2
- package/dist/pipeline/stages/deployLambda/config/LambdaDeploymentStageExecutionDetails.d.ts +2 -2
- package/dist/pipeline/stages/disableAsg/AwsDisableAsgStageConfig.d.ts +2 -2
- package/dist/pipeline/stages/disableCluster/AwsDisableClusterStageConfig.d.ts +2 -2
- package/dist/pipeline/stages/enableAsg/AwsEnableAsgStageConfig.d.ts +2 -2
- package/dist/pipeline/stages/findImageFromTags/AwsFindImageFromTagsStageConfig.d.ts +2 -2
- package/dist/pipeline/stages/invokeLambda/InvokeLambdaFunctionStageForm.d.ts +2 -2
- package/dist/pipeline/stages/invokeLambda/LambdaInvokeStage.d.ts +2 -2
- package/dist/pipeline/stages/invokeLambda/components/InvokeLambdaOperation.d.ts +2 -2
- package/dist/pipeline/stages/modifyScalingProcess/ModifyScalingProcessStageConfig.d.ts +2 -2
- package/dist/pipeline/stages/modifyWarmPool/ModifyWarmPoolStageConfig.d.ts +2 -2
- package/dist/pipeline/stages/resizeAsg/AwsResizeAsgStageConfig.d.ts +2 -2
- package/dist/pipeline/stages/rollbackCluster/AwsRollbackClusterStageConfig.d.ts +2 -2
- package/dist/pipeline/stages/routeLambda/LambdaRouteStage.d.ts +2 -2
- package/dist/pipeline/stages/routeLambda/RouteLambdaFunctionStageForm.d.ts +2 -2
- package/dist/pipeline/stages/routeLambda/TriggerEventsForm.d.ts +2 -2
- package/dist/pipeline/stages/routeLambda/components/BlueGreenDeployment/BlueGreenDeploymentForm.d.ts +2 -2
- package/dist/pipeline/stages/routeLambda/components/BlueGreenDeployment/HealthCheckStrategy.d.ts +2 -2
- package/dist/pipeline/stages/routeLambda/components/BlueGreenDeployment/InvocationHealthCheck.d.ts +2 -2
- package/dist/pipeline/stages/routeLambda/components/DeploymentStrategyForm.d.ts +2 -2
- package/dist/pipeline/stages/routeLambda/components/RenderStrategy.d.ts +2 -2
- package/dist/pipeline/stages/routeLambda/components/SimpleDeploymentForm.d.ts +2 -2
- package/dist/pipeline/stages/routeLambda/components/VersionPicker.d.ts +1 -1
- package/dist/pipeline/stages/routeLambda/components/WeightedDeploymentForm.d.ts +2 -2
- package/dist/pipeline/stages/routeLambda/constants/strategy.picker.d.ts +1 -1
- package/dist/pipeline/stages/scaleDownCluster/AwsScaleDownClusterStageConfig.d.ts +2 -2
- package/dist/pipeline/stages/shrinkCluster/AwsShrinkClusterStageConfig.d.ts +2 -2
- package/dist/pipeline/stages/tagImage/awsTagImageStage.d.ts +2 -2
- package/dist/pipeline/stages/updateCodeLambda/LambdaUpdateCodeStageConfig.d.ts +2 -2
- package/dist/pipeline/stages/updateCodeLambda/LambdaUpdateCodeStageExecutionDetails.d.ts +2 -2
- package/dist/pipeline/stages/updateCodeLambda/components/UpdateCodeStageForm.d.ts +2 -2
- package/dist/securityGroup/details/IPRangeRules.d.ts +1 -1
- package/dist/serverGroup/configure/AmazonImageSelectInput.d.ts +1 -1
- package/dist/serverGroup/configure/wizard/AmazonCloneServerGroupModal.d.ts +1 -1
- package/dist/serverGroup/configure/wizard/ServerGroupTemplateSelection.d.ts +1 -1
- package/dist/serverGroup/configure/wizard/capacity/CapacitySelector.d.ts +1 -1
- package/dist/serverGroup/configure/wizard/capacity/MinMaxDesired.d.ts +1 -1
- package/dist/serverGroup/configure/wizard/instanceType/CpuCreditsToggle.d.ts +2 -2
- package/dist/serverGroup/configure/wizard/instanceType/InstanceTypeSelector.d.ts +2 -2
- package/dist/serverGroup/configure/wizard/instanceType/InstanceTypeWarning.d.ts +2 -2
- package/dist/serverGroup/configure/wizard/instanceType/advancedMode/AdvancedModeSelector.d.ts +2 -2
- package/dist/serverGroup/configure/wizard/instanceType/advancedMode/AmazonInstanceTypeInfoRenderer.d.ts +2 -2
- package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceProfileSelector.d.ts +2 -2
- package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeRow.d.ts +2 -2
- package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeSelect.d.ts +2 -2
- package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTable.d.ts +2 -2
- package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableBody.d.ts +2 -2
- package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstanceTypeTableParts.d.ts +4 -4
- package/dist/serverGroup/configure/wizard/instanceType/advancedMode/InstancesDistribution.d.ts +2 -2
- package/dist/serverGroup/configure/wizard/instanceType/simpleMode/SimpleModeSelector.d.ts +2 -2
- package/dist/serverGroup/configure/wizard/pages/ServerGroupBasicSettings.d.ts +1 -1
- package/dist/serverGroup/configure/wizard/pages/ServerGroupCapacity.d.ts +1 -1
- package/dist/serverGroup/configure/wizard/pages/ServerGroupInstanceType.d.ts +1 -1
- package/dist/serverGroup/configure/wizard/pages/ServerGroupLoadBalancers.d.ts +1 -1
- package/dist/serverGroup/configure/wizard/pages/ServerGroupSecurityGroups.d.ts +1 -1
- package/dist/serverGroup/configure/wizard/pages/ServerGroupZones.d.ts +1 -1
- package/dist/serverGroup/configure/wizard/pages/advancedSettings/ServerGroupAdvancedSettings.d.ts +1 -1
- package/dist/serverGroup/configure/wizard/pages/advancedSettings/ServerGroupAdvancedSettingsCommon.d.ts +1 -1
- package/dist/serverGroup/configure/wizard/pages/advancedSettings/ServerGroupAdvancedSettingsInner.d.ts +1 -1
- package/dist/serverGroup/configure/wizard/securityGroups/SecurityGroupSelector.d.ts +1 -1
- package/dist/serverGroup/configure/wizard/securityGroups/ServerGroupSecurityGroupsRemoved.d.ts +1 -1
- package/dist/serverGroup/details/advancedSettings/EditAsgAdvancedSettingsModal.d.ts +2 -1
- package/dist/serverGroup/details/resize/AmazonResizeServerGroupModal.d.ts +1 -1
- package/dist/serverGroup/details/scalingPolicy/CreateScalingPolicyButton.d.ts +1 -1
- package/dist/serverGroup/details/scalingPolicy/ScalingPolicySummary.d.ts +2 -2
- package/dist/serverGroup/details/scalingPolicy/StepPolicySummary.d.ts +2 -2
- package/dist/serverGroup/details/scalingPolicy/chart/DateLineChart.d.ts +2 -2
- package/dist/serverGroup/details/scalingPolicy/chart/MetricAlarmChart.d.ts +3 -3
- package/dist/serverGroup/details/scalingPolicy/popover/AlarmSummary.d.ts +2 -2
- package/dist/serverGroup/details/scalingPolicy/popover/StepPolicyPopoverContent.d.ts +2 -2
- package/dist/serverGroup/details/scalingPolicy/targetTracking/TargetMetricFields.d.ts +2 -2
- package/dist/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingAdditionalSettings.d.ts +2 -3
- package/dist/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingChart.d.ts +2 -2
- package/dist/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingSummary.d.ts +2 -2
- package/dist/serverGroup/details/scalingPolicy/targetTracking/UpsertTargetTrackingModal.d.ts +2 -2
- package/dist/serverGroup/details/scalingPolicy/upsert/PolicyTypeSelectionModal.d.ts +2 -2
- package/dist/serverGroup/details/scalingPolicy/upsert/ScalingPolicyAdditionalSettings.d.ts +2 -2
- package/dist/serverGroup/details/scalingPolicy/upsert/UpsertScalingPolicyModal.d.ts +2 -2
- package/dist/serverGroup/details/scalingPolicy/upsert/alarm/AlarmConfigurer.d.ts +2 -2
- package/dist/serverGroup/details/scalingPolicy/upsert/alarm/DimensionsEditor.d.ts +2 -2
- package/dist/serverGroup/details/scalingPolicy/upsert/alarm/MetricSelector.d.ts +2 -2
- package/dist/serverGroup/details/scalingPolicy/upsert/simple/SimplePolicyAction.d.ts +2 -2
- package/dist/serverGroup/details/scalingPolicy/upsert/step/StepPolicyAction.d.ts +2 -2
- package/dist/serverGroup/details/scalingProcesses/ModifyScalingProcessesModal.d.ts +1 -1
- package/dist/serverGroup/details/scheduledAction/ScheduledAction.d.ts +1 -1
- package/dist/serverGroup/details/scheduledActions/EditScheduledActionsModal.d.ts +1 -1
- package/dist/serverGroup/details/sections/InstancesDistributionDetailsSection.d.ts +2 -2
- package/dist/serverGroup/details/sections/LaunchTemplateDetailsSection.d.ts +2 -2
- package/dist/serverGroup/details/sections/MultipleInstanceTypesSubSection.d.ts +2 -2
- package/dist/serverGroup/details/securityGroups/EditSecurityGroupsModal.d.ts +1 -1
- package/dist/serverGroup/details/warmPool/ModifyWarmPoolModal.d.ts +1 -1
- package/dist/subnet/SubnetSelectField.d.ts +1 -1
- package/dist/subnet/SubnetSelectInput.d.ts +1 -1
- package/dist/vpc/VpcTag.d.ts +2 -2
- package/package.json +5 -7
- package/src/aws.module.spec.ts +20 -21
- package/src/function/details/AmazonFunctionDetails.tsx +1 -1
- package/src/function/details/FunctionActions.spec.tsx +56 -36
- package/src/instance/awsInstanceType.service.spec.js +24 -22
- package/src/instance/details/AmazonInstanceDetails.spec.tsx +7 -7
- package/src/instance/details/InstanceInformation.spec.tsx +44 -24
- package/src/loadBalancer/AmazonLoadBalancersTag.spec.tsx +1 -1
- package/src/loadBalancer/TargetGroupDetails.spec.tsx +5 -5
- package/src/loadBalancer/configure/application/TargetGroups.tsx +1 -1
- package/src/loadBalancer/configure/common/SecurityGroups.spec.tsx +4 -4
- package/src/loadBalancer/configure/network/TargetGroups.tsx +1 -1
- package/src/loadBalancer/details/amazonLoadBalancerDetails.spec.tsx +31 -53
- package/src/pipeline/stages/AmazonStageConfig.spec.tsx +37 -46
- package/src/pipeline/stages/deployCloudFormation/DeployCloudFormationStackStageConfig.tsx +1 -0
- package/src/pipeline/stages/deployCloudFormation/deployCloudFormationStackStage.spec.tsx +316 -279
- package/src/pipeline/stages/findImageFromTags/AwsFindImageFromTagsStageConfig.spec.tsx +70 -90
- package/src/pipeline/stages/modifyScalingProcess/modifyScalingProcessStage.spec.tsx +198 -130
- package/src/pipeline/stages/modifyWarmPool/modifyWarmPoolStage.spec.tsx +49 -40
- package/src/pipeline/stages/resizeAsg/AwsResizeAsgStageConfig.spec.tsx +341 -427
- package/src/pipeline/stages/resizeAsg/AwsResizeAsgStageConfig.tsx +7 -0
- package/src/pipeline/stages/tagImage/awsTagImageStage.spec.tsx +62 -107
- package/src/routerConsumers.spec.tsx +23 -23
- package/src/securityGroup/configure/AmazonSecurityGroupModal.spec.tsx +38 -47
- package/src/securityGroup/details/AmazonSecurityGroupDetails.spec.tsx +7 -6
- package/src/serverGroup/configure/AmazonImageSelectInput.spec.tsx +47 -65
- package/src/serverGroup/configure/AmazonImageSelectInput.tsx +1 -1
- package/src/serverGroup/configure/serverGroupCommandBuilder.aws.service.spec.js +18 -19
- package/src/serverGroup/configure/serverGroupCommandBuilder.spec.js +41 -26
- package/src/serverGroup/configure/wizard/instanceType/simpleMode/SimpleModeSelector.spec.tsx +52 -75
- package/src/serverGroup/configure/wizard/pages/ServerGroupBasicSettings.spec.tsx +1 -1
- package/src/serverGroup/configure/wizard/pages/advancedSettings/ServerGroupAdvancedSettingsCommon.spec.tsx +36 -33
- package/src/serverGroup/configure/wizard/pages/advancedSettings/ServerGroupAdvancedSettingsCommon.tsx +7 -1
- package/src/serverGroup/configure/wizard/securityGroups/SecurityGroupSelector.spec.tsx +2 -2
- package/src/serverGroup/details/AmazonServerGroupActions.spec.tsx +79 -67
- package/src/serverGroup/details/advancedSettings/EditAsgAdvancedSettingsModal.spec.tsx +78 -66
- package/src/serverGroup/details/advancedSettings/EditAsgAdvancedSettingsModal.tsx +23 -6
- package/src/serverGroup/details/rollback/AmazonRollbackServerGroupModal.spec.tsx +86 -94
- package/src/serverGroup/details/rollback/AmazonRollbackServerGroupModal.tsx +3 -0
- package/src/serverGroup/details/scalingPolicy/targetTracking/TargetTrackingAdditionalSettings.tsx +1 -39
- package/src/serverGroup/details/scalingPolicy/targetTracking/UpsertTargetTrackingModal.tsx +0 -1
- package/src/serverGroup/details/scalingProcesses/ModifyScalingProcessesModal.spec.tsx +5 -5
- package/src/serverGroup/details/scheduledActions/EditScheduledActionsModal.spec.tsx +8 -8
- package/src/serverGroup/details/sections/AmazonServerGroupMaintenanceActions.spec.tsx +71 -60
- package/src/serverGroup/details/sections/InstancesDistributionDetailsSection.spec.tsx +21 -39
- package/src/serverGroup/details/sections/LaunchTemplateDetailsSection.spec.tsx +56 -97
- package/src/serverGroup/details/securityGroups/EditSecurityGroupsModal.spec.tsx +48 -77
- package/src/serverGroup/details/warmPool/ModifyWarmPoolModal.spec.tsx +5 -5
- package/src/vpc/VpcReader.spec.ts +1 -1
- package/src/vpc/VpcTag.spec.tsx +11 -15
- /package/dist/{amazon.logo352d4e042476837f.svg → amazon.logoBzC5E-3F.svg} +0 -0
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { mount } from 'enzyme';
|
|
1
|
+
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
3
2
|
import React from 'react';
|
|
4
|
-
import { act } from 'react-dom/test-utils';
|
|
5
3
|
|
|
6
|
-
import type { Application
|
|
7
|
-
import { TetheredSelect } from '@spinnaker/core';
|
|
4
|
+
import type { Application } from '@spinnaker/core';
|
|
8
5
|
|
|
9
6
|
import { AmazonImageSelectInput } from './AmazonImageSelectInput';
|
|
7
|
+
import { setupUser } from '../../../../core/src/utils/testUtils/userEvent';
|
|
10
8
|
import type { IAmazonImage } from '../../image';
|
|
11
9
|
import { AwsImageReader } from '../../image';
|
|
12
10
|
|
|
@@ -24,29 +22,14 @@ describe('AmazonImageSelectInput', () => {
|
|
|
24
22
|
const image2 = makeImage('app-package-2.0', 'ami-222');
|
|
25
23
|
|
|
26
24
|
beforeEach(() => {
|
|
27
|
-
spyOn(AwsImageReader.prototype, 'findImages').
|
|
28
|
-
|
|
25
|
+
vi.spyOn(AwsImageReader.prototype, 'findImages').mockImplementation(({ q }: { q: string }) =>
|
|
26
|
+
Promise.resolve(q === 'app-package-2' ? [image2] : [image1, image2]),
|
|
27
|
+
);
|
|
28
|
+
vi.spyOn(AwsImageReader.prototype, 'getImage').mockReturnValue(Promise.resolve(null));
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
await Promise.resolve();
|
|
34
|
-
await Promise.resolve();
|
|
35
|
-
});
|
|
36
|
-
component.update();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// The package-images dropdown's menu is only rendered by the underlying react-select
|
|
40
|
-
// instance once it's open, which normally happens via a real focus/mousedown DOM event.
|
|
41
|
-
// Driving the TetheredSelect instance directly is more reliable than simulating focus in a
|
|
42
|
-
// detached test DOM, and it's how a user's click on the control ultimately manifests anyway.
|
|
43
|
-
function openMenu(component: ReactWrapper): void {
|
|
44
|
-
(component.find(TetheredSelect).instance() as TetheredSelectType).setState({ isOpen: true });
|
|
45
|
-
component.update();
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function mountInput(onChange: (image: IAmazonImage) => void, value: IAmazonImage = null) {
|
|
49
|
-
return mount(
|
|
31
|
+
function renderInput(onChange: (image: IAmazonImage) => void, value: IAmazonImage = null) {
|
|
32
|
+
return render(
|
|
50
33
|
<AmazonImageSelectInput
|
|
51
34
|
onChange={onChange}
|
|
52
35
|
value={value}
|
|
@@ -57,69 +40,68 @@ describe('AmazonImageSelectInput', () => {
|
|
|
57
40
|
);
|
|
58
41
|
}
|
|
59
42
|
|
|
43
|
+
async function waitForPackageImages(): Promise<void> {
|
|
44
|
+
expect(await screen.findByText('Pick an image')).toBeInTheDocument();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function openMenu(container: HTMLElement): void {
|
|
48
|
+
fireEvent.mouseDown(container.querySelector('.Select-control'));
|
|
49
|
+
}
|
|
50
|
+
|
|
60
51
|
it('renders a single options menu wrapper, not a nested duplicate', async () => {
|
|
61
|
-
const
|
|
62
|
-
await
|
|
63
|
-
openMenu(
|
|
52
|
+
const { container } = renderInput(vi.fn());
|
|
53
|
+
await waitForPackageImages();
|
|
54
|
+
openMenu(container);
|
|
64
55
|
|
|
65
56
|
// Regression test: buildImageMenu used to re-wrap its options in a second
|
|
66
57
|
// ".Select-menu-outer > .Select-menu" pair on top of react-select's own wrapper. The inner
|
|
67
58
|
// duplicate kept its default `position: absolute` styling instead of the `position: static`
|
|
68
59
|
// override TetheredSelect applies to the outermost wrapper, which broke the sizing/hit-testing
|
|
69
60
|
// of the real, Tether-positioned menu: the list was visible but clicks landed on nothing.
|
|
70
|
-
expect(
|
|
61
|
+
expect(await screen.findAllByRole('option')).toHaveLength(2);
|
|
62
|
+
expect(document.querySelectorAll('.Select-menu-outer')).toHaveLength(1);
|
|
71
63
|
});
|
|
72
64
|
|
|
73
65
|
it('selects the clicked image from the package images dropdown', async () => {
|
|
74
|
-
const onChange =
|
|
75
|
-
const
|
|
76
|
-
await
|
|
77
|
-
openMenu(
|
|
66
|
+
const onChange = vi.fn();
|
|
67
|
+
const { container } = renderInput(onChange);
|
|
68
|
+
await waitForPackageImages();
|
|
69
|
+
openMenu(container);
|
|
78
70
|
|
|
79
|
-
const options =
|
|
80
|
-
expect(options
|
|
81
|
-
|
|
71
|
+
const options = await screen.findAllByRole('option');
|
|
72
|
+
expect(options).toHaveLength(2);
|
|
73
|
+
fireEvent.mouseDown(screen.getByRole('option', { name: new RegExp(image1.imageName) }));
|
|
82
74
|
|
|
83
|
-
expect(onChange).toHaveBeenCalledWith(
|
|
75
|
+
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ imageName: image1.imageName }));
|
|
84
76
|
});
|
|
85
77
|
|
|
86
78
|
it('provides a way back from "Search All Images" to the package images dropdown', async () => {
|
|
87
|
-
const
|
|
88
|
-
|
|
79
|
+
const user = setupUser();
|
|
80
|
+
renderInput(vi.fn());
|
|
81
|
+
await waitForPackageImages();
|
|
89
82
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
component.find('button.link').simulate('click');
|
|
93
|
-
component.update();
|
|
94
|
-
expect(component.text()).toContain('Search for an image');
|
|
83
|
+
await user.click(screen.getByRole('button', { name: 'Search All Images' }));
|
|
84
|
+
expect(screen.getByText('Search for an image...')).toBeInTheDocument();
|
|
95
85
|
|
|
96
86
|
// Regression test: there used to be no control to switch back out of search-all-images mode.
|
|
97
|
-
|
|
98
|
-
expect(backButton.text()).toContain('Back to Package Images');
|
|
99
|
-
backButton.simulate('click');
|
|
100
|
-
component.update();
|
|
87
|
+
await user.click(screen.getByRole('button', { name: 'Back to Package Images' }));
|
|
101
88
|
|
|
102
|
-
expect(
|
|
89
|
+
expect(screen.getByText('Pick an image')).toBeInTheDocument();
|
|
103
90
|
});
|
|
104
91
|
|
|
105
92
|
it('selects the clicked image while searching all images', async () => {
|
|
106
|
-
const
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
component.find('button.link').simulate('click');
|
|
111
|
-
component.update();
|
|
93
|
+
const user = setupUser();
|
|
94
|
+
const onChange = vi.fn();
|
|
95
|
+
const { container } = renderInput(onChange);
|
|
96
|
+
await waitForPackageImages();
|
|
112
97
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
(component.instance() as AmazonImageSelectInput).setState({ searchString: 'app', searchResults: [image2] });
|
|
116
|
-
component.update();
|
|
117
|
-
openMenu(component);
|
|
98
|
+
await user.click(screen.getByRole('button', { name: 'Search All Images' }));
|
|
99
|
+
await user.type(screen.getByRole('combobox'), 'app-package-2');
|
|
118
100
|
|
|
119
|
-
|
|
120
|
-
expect(
|
|
121
|
-
|
|
101
|
+
await waitFor(() => expect(screen.getAllByRole('option')).toHaveLength(1), { timeout: 2000 });
|
|
102
|
+
expect(container.querySelector('.Select')).toHaveClass('is-open');
|
|
103
|
+
fireEvent.mouseDown(screen.getByRole('option', { name: new RegExp(image2.imageName) }));
|
|
122
104
|
|
|
123
|
-
expect(onChange).toHaveBeenCalledWith(
|
|
105
|
+
expect(onChange).toHaveBeenCalledWith(expect.objectContaining({ imageName: image2.imageName }));
|
|
124
106
|
});
|
|
125
107
|
});
|
|
@@ -48,7 +48,7 @@ export class AmazonImageSelectInput extends React.Component<IAmazonImageSelector
|
|
|
48
48
|
private awsImageReader = new AwsImageReader();
|
|
49
49
|
private props$ = new Subject<IAmazonImageSelectorProps>();
|
|
50
50
|
private searchInput$ = new Subject<string>();
|
|
51
|
-
private destroy$ = new Subject();
|
|
51
|
+
private destroy$ = new Subject<void>();
|
|
52
52
|
private sortImagesBy$ = new BehaviorSubject<sortImagesByOptions>('ts');
|
|
53
53
|
|
|
54
54
|
public static makeFakeImage(imageName: string, imageId: string, region: string): IAmazonImage {
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
2
|
import { AccountService, SubnetReader } from '@spinnaker/core';
|
|
4
3
|
|
|
5
4
|
import { AWSProviderSettings } from '../../aws.settings';
|
|
@@ -11,22 +10,22 @@ import {
|
|
|
11
10
|
} from '@spinnaker/mocks';
|
|
12
11
|
import { createAwsServerGroupCommandBuilder } from './serverGroupCommandBuilder.service';
|
|
13
12
|
|
|
13
|
+
const testContext = {};
|
|
14
|
+
|
|
14
15
|
describe('Service: awsServerGroup', function () {
|
|
15
16
|
let instanceTypeService;
|
|
16
17
|
beforeEach(function () {
|
|
17
18
|
instanceTypeService = {
|
|
18
|
-
getCategoryForMultipleInstanceTypes:
|
|
19
|
-
.createSpy('getCategoryForMultipleInstanceTypes')
|
|
20
|
-
.and.returnValue(Promise.resolve('custom')),
|
|
19
|
+
getCategoryForMultipleInstanceTypes: vi.fn().mockReturnValue(Promise.resolve('custom')),
|
|
21
20
|
};
|
|
22
|
-
|
|
21
|
+
testContext.service = createAwsServerGroupCommandBuilder(instanceTypeService);
|
|
23
22
|
});
|
|
24
23
|
|
|
25
24
|
afterEach(AWSProviderSettings.resetToOriginal);
|
|
26
25
|
|
|
27
26
|
describe('buildServerGroupCommandFromPipeline', function () {
|
|
28
27
|
beforeEach(function () {
|
|
29
|
-
|
|
28
|
+
testContext.cluster = {
|
|
30
29
|
loadBalancers: ['elb-1'],
|
|
31
30
|
account: 'prod',
|
|
32
31
|
availabilityZones: {
|
|
@@ -44,9 +43,9 @@ describe('Service: awsServerGroup', function () {
|
|
|
44
43
|
region: 'us-east-1',
|
|
45
44
|
};
|
|
46
45
|
|
|
47
|
-
spyOn(AccountService, 'getAvailabilityZonesForAccountAndRegion').
|
|
46
|
+
vi.spyOn(AccountService, 'getAvailabilityZonesForAccountAndRegion').mockReturnValue(Promise.resolve(['d', 'g']));
|
|
48
47
|
|
|
49
|
-
spyOn(AccountService, 'getCredentialsKeyedByAccount').
|
|
48
|
+
vi.spyOn(AccountService, 'getCredentialsKeyedByAccount').mockReturnValue(
|
|
50
49
|
Promise.resolve({
|
|
51
50
|
test: ['us-east-1', 'us-west-1'],
|
|
52
51
|
prod: ['us-west-1', 'eu-west-1'],
|
|
@@ -55,19 +54,19 @@ describe('Service: awsServerGroup', function () {
|
|
|
55
54
|
});
|
|
56
55
|
|
|
57
56
|
it('applies account, region from cluster', async function () {
|
|
58
|
-
const command = await
|
|
57
|
+
const command = await testContext.service.buildServerGroupCommandFromPipeline({}, testContext.cluster);
|
|
59
58
|
|
|
60
59
|
expect(command.credentials).toBe('prod');
|
|
61
60
|
expect(command.region).toBe('us-west-1');
|
|
62
61
|
});
|
|
63
62
|
|
|
64
63
|
it('sets usePreferredZones', async function () {
|
|
65
|
-
let command = await
|
|
64
|
+
let command = await testContext.service.buildServerGroupCommandFromPipeline({}, testContext.cluster);
|
|
66
65
|
expect(command.viewState.usePreferredZones).toBe(true);
|
|
67
66
|
|
|
68
67
|
// remove an availability zone, should be false
|
|
69
|
-
|
|
70
|
-
command = await
|
|
68
|
+
testContext.cluster.availabilityZones['us-west-1'].pop();
|
|
69
|
+
command = await testContext.service.buildServerGroupCommandFromPipeline({}, testContext.cluster);
|
|
71
70
|
expect(command.viewState.usePreferredZones).toBe(false);
|
|
72
71
|
});
|
|
73
72
|
|
|
@@ -121,7 +120,7 @@ describe('Service: awsServerGroup', function () {
|
|
|
121
120
|
|
|
122
121
|
clusters.forEach((test) => {
|
|
123
122
|
it(`cluster with ${test.desc}`, async function () {
|
|
124
|
-
const actualCommand = await
|
|
123
|
+
const actualCommand = await testContext.service.buildServerGroupCommandFromPipeline({}, test.cluster);
|
|
125
124
|
|
|
126
125
|
expect(instanceTypeService.getCategoryForMultipleInstanceTypes).toHaveBeenCalledWith(
|
|
127
126
|
'aws',
|
|
@@ -137,8 +136,8 @@ describe('Service: awsServerGroup', function () {
|
|
|
137
136
|
|
|
138
137
|
describe('buildServerGroupCommandFromExisting', function () {
|
|
139
138
|
beforeEach(function () {
|
|
140
|
-
spyOn(AccountService, 'getPreferredZonesByAccount').
|
|
141
|
-
spyOn(SubnetReader, 'listSubnets').
|
|
139
|
+
vi.spyOn(AccountService, 'getPreferredZonesByAccount').mockReturnValue(Promise.resolve([]));
|
|
140
|
+
vi.spyOn(SubnetReader, 'listSubnets').mockReturnValue(Promise.resolve([]));
|
|
142
141
|
});
|
|
143
142
|
|
|
144
143
|
it('retains non-core suspended processes', async function () {
|
|
@@ -155,7 +154,7 @@ describe('Service: awsServerGroup', function () {
|
|
|
155
154
|
},
|
|
156
155
|
launchTemplate: mockLaunchTemplate,
|
|
157
156
|
};
|
|
158
|
-
const command = await
|
|
157
|
+
const command = await testContext.service.buildServerGroupCommandFromExisting({}, serverGroup);
|
|
159
158
|
expect(command.suspendedProcesses).toEqual(['AZRebalance']);
|
|
160
159
|
});
|
|
161
160
|
|
|
@@ -168,7 +167,7 @@ describe('Service: awsServerGroup', function () {
|
|
|
168
167
|
},
|
|
169
168
|
launchTemplate: mockLaunchTemplate,
|
|
170
169
|
};
|
|
171
|
-
const command = await
|
|
170
|
+
const command = await testContext.service.buildServerGroupCommandFromExisting({}, serverGroup, 'editPipeline');
|
|
172
171
|
|
|
173
172
|
expect(command.viewState.useSimpleCapacity).toBe(false);
|
|
174
173
|
expect(command.useSourceCapacity).toBe(true);
|
|
@@ -361,7 +360,7 @@ describe('Service: awsServerGroup', function () {
|
|
|
361
360
|
|
|
362
361
|
[...serverGroupsWithoutMip, ...serverGroupsWithMip].forEach((test) => {
|
|
363
362
|
it(`extracts instanceProfile, instanceType and useSimpleInstanceTypeSelector from server group with ${test.desc} correctly`, async function () {
|
|
364
|
-
const actualCommand = await
|
|
363
|
+
const actualCommand = await testContext.service.buildServerGroupCommandFromExisting({}, test.sg, 'clone');
|
|
365
364
|
|
|
366
365
|
expect(instanceTypeService.getCategoryForMultipleInstanceTypes).toHaveBeenCalledWith(
|
|
367
366
|
'aws',
|
|
@@ -377,7 +376,7 @@ describe('Service: awsServerGroup', function () {
|
|
|
377
376
|
|
|
378
377
|
serverGroupsWithMip.forEach((test) => {
|
|
379
378
|
it(`extracts launchTemplateOverridesForInstanceType and sets explicit priority correctly for server group with ${test.desc}`, async function () {
|
|
380
|
-
const actualCommand = await
|
|
379
|
+
const actualCommand = await testContext.service.buildServerGroupCommandFromExisting({}, test.sg, 'clone');
|
|
381
380
|
|
|
382
381
|
expect(
|
|
383
382
|
_.isEqual(
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
-
|
|
3
2
|
import { AccountService, SubnetReader } from '@spinnaker/core';
|
|
4
3
|
|
|
5
4
|
import { AWSProviderSettings } from '../../aws.settings';
|
|
@@ -11,22 +10,26 @@ import {
|
|
|
11
10
|
mockLaunchTemplate,
|
|
12
11
|
} from '@spinnaker/mocks';
|
|
13
12
|
|
|
13
|
+
const testContext = {};
|
|
14
|
+
|
|
14
15
|
describe('awsServerGroupCommandBuilder', function () {
|
|
15
16
|
const AccountServiceFixture = require('./AccountServiceFixtures');
|
|
16
17
|
|
|
17
18
|
beforeEach(function () {
|
|
18
|
-
|
|
19
|
-
getCategoryForMultipleInstanceTypes:
|
|
19
|
+
testContext.instanceTypeService = {
|
|
20
|
+
getCategoryForMultipleInstanceTypes: vi.fn(),
|
|
20
21
|
};
|
|
21
|
-
|
|
22
|
-
spyOn(AccountService, 'getPreferredZonesByAccount').
|
|
22
|
+
testContext.awsServerGroupCommandBuilder = createAwsServerGroupCommandBuilder(testContext.instanceTypeService);
|
|
23
|
+
vi.spyOn(AccountService, 'getPreferredZonesByAccount').mockReturnValue(
|
|
23
24
|
Promise.resolve(AccountServiceFixture.preferredZonesByAccount),
|
|
24
25
|
);
|
|
25
|
-
spyOn(AccountService, 'getCredentialsKeyedByAccount').
|
|
26
|
+
vi.spyOn(AccountService, 'getCredentialsKeyedByAccount').mockReturnValue(
|
|
26
27
|
Promise.resolve(AccountServiceFixture.credentialsKeyedByAccount),
|
|
27
28
|
);
|
|
28
|
-
spyOn(SubnetReader, 'listSubnets').
|
|
29
|
-
spyOn(AccountService, 'getAvailabilityZonesForAccountAndRegion').
|
|
29
|
+
vi.spyOn(SubnetReader, 'listSubnets').mockReturnValue(Promise.resolve([]));
|
|
30
|
+
vi.spyOn(AccountService, 'getAvailabilityZonesForAccountAndRegion').mockReturnValue(
|
|
31
|
+
Promise.resolve(['a', 'b', 'c']),
|
|
32
|
+
);
|
|
30
33
|
});
|
|
31
34
|
|
|
32
35
|
afterEach(AWSProviderSettings.resetToOriginal);
|
|
@@ -34,7 +37,7 @@ describe('awsServerGroupCommandBuilder', function () {
|
|
|
34
37
|
describe('buildNewServerGroupCommand', function () {
|
|
35
38
|
it('initializes to default values, setting usePreferredZone flag to true', async function () {
|
|
36
39
|
AWSProviderSettings.defaults.iamRole = '{{application}}IAMRole';
|
|
37
|
-
const command = await
|
|
40
|
+
const command = await testContext.awsServerGroupCommandBuilder.buildNewServerGroupCommand(
|
|
38
41
|
{ name: 'appo', defaultCredentials: {}, defaultRegions: {} },
|
|
39
42
|
'aws',
|
|
40
43
|
);
|
|
@@ -46,7 +49,7 @@ describe('awsServerGroupCommandBuilder', function () {
|
|
|
46
49
|
|
|
47
50
|
it('sets unlimitedCpuCredits to undefined if not modified by user', async function () {
|
|
48
51
|
AWSProviderSettings.defaults.iamRole = '{{application}}IAMRole';
|
|
49
|
-
const command = await
|
|
52
|
+
const command = await testContext.awsServerGroupCommandBuilder.buildNewServerGroupCommand(
|
|
50
53
|
{ name: 'test-app', defaultCredentials: {}, defaultRegions: {} },
|
|
51
54
|
'aws',
|
|
52
55
|
);
|
|
@@ -57,7 +60,7 @@ describe('awsServerGroupCommandBuilder', function () {
|
|
|
57
60
|
|
|
58
61
|
describe('buildServerGroupCommandFromExisting', function () {
|
|
59
62
|
it('sets usePreferredZones flag based on initial value', async function () {
|
|
60
|
-
|
|
63
|
+
testContext.instanceTypeService.getCategoryForMultipleInstanceTypes.mockReturnValue(Promise.resolve('custom'));
|
|
61
64
|
const baseServerGroup = {
|
|
62
65
|
account: 'prod',
|
|
63
66
|
region: 'us-west-1',
|
|
@@ -67,7 +70,7 @@ describe('awsServerGroupCommandBuilder', function () {
|
|
|
67
70
|
},
|
|
68
71
|
launchTemplate: mockLaunchTemplate,
|
|
69
72
|
};
|
|
70
|
-
let command = await
|
|
73
|
+
let command = await testContext.awsServerGroupCommandBuilder.buildServerGroupCommandFromExisting(
|
|
71
74
|
{ name: 'appo' },
|
|
72
75
|
baseServerGroup,
|
|
73
76
|
);
|
|
@@ -77,7 +80,7 @@ describe('awsServerGroupCommandBuilder', function () {
|
|
|
77
80
|
|
|
78
81
|
baseServerGroup.asg.availabilityZones = ['g'];
|
|
79
82
|
|
|
80
|
-
command = await
|
|
83
|
+
command = await testContext.awsServerGroupCommandBuilder.buildServerGroupCommandFromExisting(
|
|
81
84
|
{ name: 'appo' },
|
|
82
85
|
baseServerGroup,
|
|
83
86
|
);
|
|
@@ -87,7 +90,9 @@ describe('awsServerGroupCommandBuilder', function () {
|
|
|
87
90
|
});
|
|
88
91
|
|
|
89
92
|
it('sets profile and instance type if available', async function () {
|
|
90
|
-
|
|
93
|
+
testContext.instanceTypeService.getCategoryForMultipleInstanceTypes.mockReturnValue(
|
|
94
|
+
Promise.resolve('selectedProfile'),
|
|
95
|
+
);
|
|
91
96
|
|
|
92
97
|
const baseServerGroup = {
|
|
93
98
|
account: 'prod',
|
|
@@ -102,7 +107,7 @@ describe('awsServerGroupCommandBuilder', function () {
|
|
|
102
107
|
securityGroups: [],
|
|
103
108
|
},
|
|
104
109
|
};
|
|
105
|
-
const command = await
|
|
110
|
+
const command = await testContext.awsServerGroupCommandBuilder.buildServerGroupCommandFromExisting(
|
|
106
111
|
{ name: 'appo' },
|
|
107
112
|
baseServerGroup,
|
|
108
113
|
);
|
|
@@ -112,7 +117,9 @@ describe('awsServerGroupCommandBuilder', function () {
|
|
|
112
117
|
});
|
|
113
118
|
|
|
114
119
|
it('copies suspended processes unless the mode is "editPipeline"', async function () {
|
|
115
|
-
|
|
120
|
+
testContext.instanceTypeService.getCategoryForMultipleInstanceTypes.mockReturnValue(
|
|
121
|
+
Promise.resolve('selectedProfile'),
|
|
122
|
+
);
|
|
116
123
|
|
|
117
124
|
const baseServerGroup = {
|
|
118
125
|
account: 'prod',
|
|
@@ -128,14 +135,14 @@ describe('awsServerGroupCommandBuilder', function () {
|
|
|
128
135
|
securityGroups: [],
|
|
129
136
|
},
|
|
130
137
|
};
|
|
131
|
-
let command = await
|
|
138
|
+
let command = await testContext.awsServerGroupCommandBuilder.buildServerGroupCommandFromExisting(
|
|
132
139
|
{ name: 'appo' },
|
|
133
140
|
baseServerGroup,
|
|
134
141
|
);
|
|
135
142
|
|
|
136
143
|
expect(command.suspendedProcesses).toEqual(['x', 'a']);
|
|
137
144
|
|
|
138
|
-
command = await
|
|
145
|
+
command = await testContext.awsServerGroupCommandBuilder.buildServerGroupCommandFromExisting(
|
|
139
146
|
{ name: 'appo' },
|
|
140
147
|
baseServerGroup,
|
|
141
148
|
'editPipeline',
|
|
@@ -145,7 +152,9 @@ describe('awsServerGroupCommandBuilder', function () {
|
|
|
145
152
|
});
|
|
146
153
|
|
|
147
154
|
it('copies tags not in the reserved list:', async function () {
|
|
148
|
-
|
|
155
|
+
testContext.instanceTypeService.getCategoryForMultipleInstanceTypes.mockReturnValue(
|
|
156
|
+
Promise.resolve('selectedProfile'),
|
|
157
|
+
);
|
|
149
158
|
|
|
150
159
|
const baseServerGroup = {
|
|
151
160
|
account: 'prod',
|
|
@@ -174,7 +183,7 @@ describe('awsServerGroupCommandBuilder', function () {
|
|
|
174
183
|
securityGroups: [],
|
|
175
184
|
},
|
|
176
185
|
};
|
|
177
|
-
const command = await
|
|
186
|
+
const command = await testContext.awsServerGroupCommandBuilder.buildServerGroupCommandFromExisting(
|
|
178
187
|
{ name: 'appo' },
|
|
179
188
|
baseServerGroup,
|
|
180
189
|
);
|
|
@@ -183,7 +192,9 @@ describe('awsServerGroupCommandBuilder', function () {
|
|
|
183
192
|
});
|
|
184
193
|
|
|
185
194
|
it('sets unlimitedCpuCredits to false when building from source server group with standard credits', async function () {
|
|
186
|
-
|
|
195
|
+
testContext.instanceTypeService.getCategoryForMultipleInstanceTypes.mockReturnValue(
|
|
196
|
+
Promise.resolve('selectedProfile'),
|
|
197
|
+
);
|
|
187
198
|
|
|
188
199
|
const baseServerGroup = createMockAmazonServerGroupWithLt(
|
|
189
200
|
createCustomMockLaunchTemplate('testLtCpuCredits', {
|
|
@@ -193,7 +204,7 @@ describe('awsServerGroupCommandBuilder', function () {
|
|
|
193
204
|
}),
|
|
194
205
|
);
|
|
195
206
|
|
|
196
|
-
const command = await
|
|
207
|
+
const command = await testContext.awsServerGroupCommandBuilder.buildServerGroupCommandFromExisting(
|
|
197
208
|
{ name: 'test' },
|
|
198
209
|
baseServerGroup,
|
|
199
210
|
);
|
|
@@ -202,7 +213,9 @@ describe('awsServerGroupCommandBuilder', function () {
|
|
|
202
213
|
});
|
|
203
214
|
|
|
204
215
|
it('sets unlimitedCpuCredits to true when building from source server group with unlimited credits', async function () {
|
|
205
|
-
|
|
216
|
+
testContext.instanceTypeService.getCategoryForMultipleInstanceTypes.mockReturnValue(
|
|
217
|
+
Promise.resolve('selectedProfile'),
|
|
218
|
+
);
|
|
206
219
|
|
|
207
220
|
const baseServerGroup = createMockAmazonServerGroupWithLt(
|
|
208
221
|
createCustomMockLaunchTemplate('testLtCpuCredits', {
|
|
@@ -212,7 +225,7 @@ describe('awsServerGroupCommandBuilder', function () {
|
|
|
212
225
|
}),
|
|
213
226
|
);
|
|
214
227
|
|
|
215
|
-
const command = await
|
|
228
|
+
const command = await testContext.awsServerGroupCommandBuilder.buildServerGroupCommandFromExisting(
|
|
216
229
|
{ name: 'test' },
|
|
217
230
|
baseServerGroup,
|
|
218
231
|
);
|
|
@@ -221,11 +234,13 @@ describe('awsServerGroupCommandBuilder', function () {
|
|
|
221
234
|
});
|
|
222
235
|
|
|
223
236
|
it('sets unlimitedCpuCredits to undefined when building from source server group with cpu credits unset', async function () {
|
|
224
|
-
|
|
237
|
+
testContext.instanceTypeService.getCategoryForMultipleInstanceTypes.mockReturnValue(
|
|
238
|
+
Promise.resolve('selectedProfile'),
|
|
239
|
+
);
|
|
225
240
|
|
|
226
241
|
const baseServerGroup = createMockAmazonServerGroupWithLt();
|
|
227
242
|
|
|
228
|
-
const command = await
|
|
243
|
+
const command = await testContext.awsServerGroupCommandBuilder.buildServerGroupCommandFromExisting(
|
|
229
244
|
{ name: 'test' },
|
|
230
245
|
baseServerGroup,
|
|
231
246
|
);
|
package/src/serverGroup/configure/wizard/instanceType/simpleMode/SimpleModeSelector.spec.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
|
+
import userEvent from '@testing-library/user-event';
|
|
2
3
|
import React from 'react';
|
|
3
4
|
|
|
4
5
|
import { DeckRuntimeContext } from '@spinnaker/core';
|
|
@@ -6,62 +7,46 @@ import { DeckRuntimeContext } from '@spinnaker/core';
|
|
|
6
7
|
import { SimpleModeSelector } from './SimpleModeSelector';
|
|
7
8
|
|
|
8
9
|
describe('SimpleModeSelector', () => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
function renderSelector(command = buildCommand()) {
|
|
11
|
+
return {
|
|
12
|
+
command,
|
|
13
|
+
...render(
|
|
14
|
+
<DeckRuntimeContext.Provider value={{ services: { instanceTypeService: instanceTypeService() } } as any}>
|
|
15
|
+
<SimpleModeSelector
|
|
16
|
+
command={command as any}
|
|
17
|
+
setUnlimitedCpuCredits={vi.fn()}
|
|
18
|
+
setFieldValue={vi.fn()}
|
|
19
|
+
clearWarnings={vi.fn()}
|
|
20
|
+
/>
|
|
21
|
+
</DeckRuntimeContext.Provider>,
|
|
22
|
+
),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
18
25
|
|
|
19
26
|
it('shows instance type rows when an instance profile tile is clicked', async () => {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const component = mount(
|
|
23
|
-
<SimpleModeSelector
|
|
24
|
-
command={command as any}
|
|
25
|
-
setUnlimitedCpuCredits={jasmine.createSpy('setUnlimitedCpuCredits')}
|
|
26
|
-
setFieldValue={jasmine.createSpy('setFieldValue')}
|
|
27
|
-
clearWarnings={jasmine.createSpy('clearWarnings')}
|
|
28
|
-
/>,
|
|
29
|
-
);
|
|
30
|
-
await settle(component);
|
|
27
|
+
renderSelector();
|
|
28
|
+
expect(screen.queryByText('m5.large')).not.toBeInTheDocument();
|
|
31
29
|
|
|
32
|
-
|
|
30
|
+
await userEvent.click(await screen.findByRole('button', { name: /General Purpose/i }));
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
await settle(component);
|
|
36
|
-
|
|
37
|
-
expect(component.find('.instance-type-row').text()).toContain('m5.large');
|
|
32
|
+
expect(await screen.findByText('m5.large')).toBeInTheDocument();
|
|
38
33
|
});
|
|
39
34
|
|
|
40
35
|
it('updates derived command fields from the selected instance type', async () => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<SimpleModeSelector
|
|
45
|
-
command={command as any}
|
|
46
|
-
setUnlimitedCpuCredits={jasmine.createSpy('setUnlimitedCpuCredits')}
|
|
47
|
-
setFieldValue={jasmine.createSpy('setFieldValue')}
|
|
48
|
-
clearWarnings={jasmine.createSpy('clearWarnings')}
|
|
49
|
-
/>,
|
|
50
|
-
);
|
|
51
|
-
await settle(component);
|
|
36
|
+
const { command } = renderSelector();
|
|
37
|
+
await userEvent.click(await screen.findByRole('button', { name: /General Purpose/i }));
|
|
38
|
+
await userEvent.click(await screen.findByText('m5.large'));
|
|
52
39
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
expect(command.instanceTypeChanged).toHaveBeenCalledWith(jasmine.objectContaining({ instanceType: 'm5.large' }));
|
|
40
|
+
await waitFor(() =>
|
|
41
|
+
expect(command.instanceTypeChanged).toHaveBeenCalledWith(expect.objectContaining({ instanceType: 'm5.large' })),
|
|
42
|
+
);
|
|
58
43
|
});
|
|
59
44
|
});
|
|
60
45
|
|
|
61
46
|
function buildCommand() {
|
|
62
47
|
return {
|
|
63
48
|
backingData: { filtered: { instanceTypes: ['m5.large'] } },
|
|
64
|
-
instanceTypeChanged:
|
|
49
|
+
instanceTypeChanged: vi.fn(),
|
|
65
50
|
selectedProvider: 'aws',
|
|
66
51
|
viewState: { dirty: {} },
|
|
67
52
|
};
|
|
@@ -69,37 +54,29 @@ function buildCommand() {
|
|
|
69
54
|
|
|
70
55
|
function instanceTypeService() {
|
|
71
56
|
return {
|
|
72
|
-
getCategories:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
),
|
|
97
|
-
getInstanceTypeDetails: jasmine.createSpy('getInstanceTypeDetails').and.returnValue(Promise.resolve({})),
|
|
57
|
+
getCategories: vi.fn().mockResolvedValue([
|
|
58
|
+
{
|
|
59
|
+
type: 'general',
|
|
60
|
+
label: 'General Purpose',
|
|
61
|
+
icon: 'cloud',
|
|
62
|
+
description: 'General purpose',
|
|
63
|
+
families: [
|
|
64
|
+
{
|
|
65
|
+
type: 'm5',
|
|
66
|
+
description: 'Balanced compute',
|
|
67
|
+
instanceTypes: [
|
|
68
|
+
{
|
|
69
|
+
name: 'm5.large',
|
|
70
|
+
label: 'm5.large',
|
|
71
|
+
cpu: 2,
|
|
72
|
+
memory: 8,
|
|
73
|
+
storage: { count: 1, size: 0, type: 'EBS' },
|
|
74
|
+
},
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
]),
|
|
80
|
+
getInstanceTypeDetails: vi.fn().mockResolvedValue({}),
|
|
98
81
|
};
|
|
99
82
|
}
|
|
100
|
-
|
|
101
|
-
async function settle(component: any) {
|
|
102
|
-
await Promise.resolve();
|
|
103
|
-
await Promise.resolve();
|
|
104
|
-
component.update();
|
|
105
|
-
}
|