Skip to content

Commit 175fe89

Browse files
dgandhi62aws-amplify-botVieltojarvi
authored
refactor: category notifications/sdk v3 migration (#14299)
* chore: update dependencies * fix: prevent infinite retry loops in deleteProject when CloudFormation stacks are stuck - Add failure predicate to treat _IN_PROGRESS states as failed after timeout - Reduce timeout to 15 minutes to fail faster on stuck operations - Prevents Jest worker processes from being killed due to hanging deletions * chore: update dependency * fix: change err.code to err.name for NotFoundException handling * fix: increase macOS binary size threshold to 1100MB * fix: resolve Jest worker SIGKILL and hanging process issues - Add sendEof() to In-App Messaging case to prevent hanging processes - Add notifications-analytics-compatibility-in-app-2.test.ts to RUN_SOLO to prevent Jest worker memory issues * fix: add failing tests to RUN_SOLO to prevent Jest worker SIGKILL errors * fix: remove 'as any' assertions from notification tests and add SIGKILL test to RUN_SOLO * feat: migrate notifications category to AWS SDK v3 * fix: retry logic in deleteProject * fix: update dependencies * chore: update dependencies * fix: add tests to run_duo in codebuild * chore: update codebuild config files * fix: correct AWS SDK versions to match other packages * fix: api extractor version change * chore: add api extractor updates * fix: dedupe yarn.lock * chore: dependency updates * chore: update dependency * chore: update e2es * fix: api and yarn * fix: extract-api and yarn lock * fix: dedupe --------- Co-authored-by: aws-amplify-bot <aws@amazon.com> Co-authored-by: Vieltojarvi <lvielto@amazon.com>
1 parent 8cb59b3 commit 175fe89

File tree

19 files changed

+1034
-575
lines changed

19 files changed

+1034
-575
lines changed

.circleci/local_publish_helpers_codebuild.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function verifyPkgCli {
141141

142142
# TODO: After V3 migrations are done, decrease 1095 back to 930 and 875 back to 750
143143
verifySinglePkg "amplify-pkg-linux-x64" "amplify-pkg-linux-x64.tgz" $((1095 * 1024 * 1024))
144-
verifySinglePkg "amplify-pkg-macos-x64" "amplify-pkg-macos-x64.tgz" $((1095 * 1024 * 1024))
144+
verifySinglePkg "amplify-pkg-macos-x64" "amplify-pkg-macos-x64.tgz" $((1105 * 1024 * 1024))
145145
verifySinglePkg "amplify-pkg-win-x64.exe" "amplify-pkg-win-x64.tgz" $((1095 * 1024 * 1024))
146146
verifySinglePkg "amplify-pkg-linux-arm64" "amplify-pkg-linux-arm64.tgz" $((875 * 1024 * 1024))
147147
}

codebuild_specs/e2e_workflow_generated.yml

Lines changed: 100 additions & 92 deletions
Large diffs are not rendered by default.

codebuild_specs/wait_for_ids.json

Lines changed: 47 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +1,64 @@
11
[
2+
"l_S3server_smoketest_smoketest_ios",
23
"l_amplify_app",
34
"l_analytics_pinpoint_flutter_analytics_kinesis_notifications_analytics_compatibility_sms_2",
4-
"l_android_analytics_pinpoint_config_opensearch_simulator_general_config_headless_init",
5-
"l_api_10_api_key_migration5_schema_iterative_rollback_1",
6-
"l_api_2a_amplify_remove_S3server",
7-
"l_api_3_layer_1_api_1",
8-
"l_api_5_api_key_migration2_api_lambda_auth_1",
9-
"l_api_6a_http_migration_schema_function_2",
10-
"l_api_6c_api_2b",
11-
"l_api_key_migration3_api_connection_migration_init_special_case",
12-
"l_api_key_migration4_schema_iterative_update_4",
5+
"l_android_notifications_pinpoint_config_android_analytics_pinpoint_config_opensearch_simulator",
6+
"l_api_10_api_key_migration5",
7+
"l_api_1_api_key_migration4",
8+
"l_api_2b_api_2a_amplify_remove",
9+
"l_api_6b_api_3_layer_1",
10+
"l_api_9a_api_6c",
11+
"l_api_9b_function_7_function_2b",
12+
"l_api_lambda_auth_1_schema_auth_14_api_key_migration1",
13+
"l_apigw_api_5_api_key_migration2",
1314
"l_auth_10_init_f_init_d",
14-
"l_auth_12_api_9a",
1515
"l_auth_1a_auth_trigger_schema_versioned",
16-
"l_auth_1b_auth_11_predictions_migration",
1716
"l_auth_2b_auth_2a_analytics_pinpoint_js",
1817
"l_auth_2c",
1918
"l_auth_2e",
19+
"l_auth_2h_auth_2g_auth_12",
2020
"l_auth_4a_auth_3b_auth_3a",
2121
"l_auth_4c_auth_3c_schema_auth_8c",
2222
"l_auth_5b_schema_auth_8a_schema_auth_7c",
2323
"l_auth_5d_tags_schema_model_a",
2424
"l_auth_5e_auth_1c_schema_predictions",
2525
"l_auth_5f_model_migration_schema_auth_5c",
26-
"l_auth_5g_auth_2h_auth_2g",
27-
"l_auth_8a_auth_4b_auth_migration",
26+
"l_auth_6_storage_1b_storage_1a",
27+
"l_auth_7b_api_6a_http_migration",
28+
"l_auth_migration_push_pull_2",
29+
"l_build_function_build_function_yarn_modern_auth_5g",
2830
"l_containers_api_1",
2931
"l_containers_api_2",
30-
"l_custom_policies_container_api_9b_function_7",
31-
"l_custom_resource_with_storage_build_function_build_function_yarn_modern",
32+
"l_containers_api_secrets_api_4_schema_auth_10",
3233
"l_custom_resources_auth_9",
3334
"l_datastore_modelgen",
35+
"l_delete_auth_1b_auth_11",
3436
"l_diagnose_mock_api_hooks_a",
35-
"l_dynamodb_simulator_user_groups_user_groups_s3_access",
3637
"l_env_1_auth_5c_auth_5a",
3738
"l_env_2_amplify_configure_layer_4",
3839
"l_env_3",
3940
"l_export_pull_a_api_7",
41+
"l_export_pull_c_custom_resource_with_storage",
42+
"l_export_pull_d_auth_8a_auth_4b",
4043
"l_feature_flags_auth_8c_auth_7a",
41-
"l_flutter_notifications_pinpoint_config_flutter_analytics_pinpoint_config_android_notifications_pinpoint_config",
4244
"l_function_10_function_permissions_env_5",
43-
"l_function_12_export_pull_c",
44-
"l_function_15_function_14_function_13",
45-
"l_function_1_storage_5",
46-
"l_function_2a_auth_6_storage_1b",
47-
"l_function_2b_function_11_api_connection_migration2",
48-
"l_function_3a_dotnet_export_pull_b_auth_7b",
49-
"l_function_3a_python_function_3a_nodejs_function_3a_go",
45+
"l_function_11_api_connection_migration2_storage_4",
46+
"l_function_13_function_12",
47+
"l_function_2d_function_15_function_14",
48+
"l_function_3a_go_function_3a_dotnet_export_pull_b",
5049
"l_function_4_function_3b_function_2c",
51-
"l_function_5_schema_function_1_schema_connection_2",
52-
"l_function_8_api_8_schema_auth_13",
5350
"l_function_migration_storage_3_schema_auth_9_c",
54-
"l_geo_add_d_geo_add_c_delete",
51+
"l_general_config_headless_init_dynamodb_simulator_user_groups",
52+
"l_geo_add_d_geo_add_c",
5553
"l_geo_add_e",
5654
"l_geo_add_f",
5755
"l_geo_import_2_geo_import_1a_function_9c",
58-
"l_geo_multi_env_searchable_datastore",
5956
"l_geo_remove_1",
6057
"l_geo_remove_2",
6158
"l_geo_remove_3",
6259
"l_geo_update_1",
6360
"l_geo_update_2",
6461
"l_global_sandbox_c_analytics_2_pull",
65-
"l_hooks_c_help_function_2d",
66-
"l_hosted_ui_admin_api_schema_iterative_update_locking",
6762
"l_hostingPROD",
6863
"l_hosting_geo_import_3",
6964
"l_iam_permissions_boundary_export_node_function",
@@ -83,47 +78,53 @@
8378
"l_import_s3_3",
8479
"l_init_c_git_clone_attach_configure_project",
8580
"l_init_e_global_sandbox_a_geo_import_1b",
86-
"l_javascript_analytics_pinpoint_config_ios_notifications_pinpoint_config_ios_analytics_pinpoint_config",
81+
"l_init_force_push_hooks_c_help",
82+
"l_init_special_case_function_3a_python_function_3a_nodejs",
83+
"l_ios_analytics_pinpoint_config_flutter_notifications_pinpoint_config_flutter_analytics_pinpoint_config",
84+
"l_javascript_notifications_pinpoint_config_javascript_analytics_pinpoint_config_ios_notifications_pinpoint_config",
8785
"l_js_frontend_config",
88-
"l_layer_2_api_lambda_auth_2_schema_iterative_update_1",
8986
"l_notifications_analytics_compatibility_in_app_1_studio_modelgen",
9087
"l_notifications_apns_init_b_container_hosting",
9188
"l_notifications_in_app_messaging",
9289
"l_notifications_lifecycle_auth_2f_auth_2d",
93-
"l_notifications_multi_env_minify_cloudformation_init_force_push",
9490
"l_notifications_sms_pull_notifications_in_app_messaging_env_1_custom_transformers",
95-
"l_parameter_store_2_parameter_store_1_notifications_sms_update",
91+
"l_notifications_sms_update_notifications_multi_env_minify_cloudformation",
9692
"l_plugin_notifications_analytics_compatibility_sms_1_hooks_b",
97-
"l_predictions_layer_3",
98-
"l_push_pull_2_pr_previews_multi_env_1",
93+
"l_pr_previews_multi_env_1_parameter_store_2_parameter_store_1",
94+
"l_predictions_migration_api_key_migration3_api_connection_migration",
9995
"l_s3_sse_geo_add_b_auth_8b",
100-
"l_schema_auth_10_schema_key_resolvers",
10196
"l_schema_auth_11_a",
97+
"l_schema_auth_11_b_predictions_layer_3",
10298
"l_schema_auth_11_c_notifications_analytics_compatibility_in_app_2",
103-
"l_schema_auth_14_api_key_migration1_api_6b",
99+
"l_schema_auth_13_layer_2_api_lambda_auth_2",
104100
"l_schema_auth_15",
105101
"l_schema_auth_1a_geo_headless_function_9a",
106-
"l_schema_auth_2a_schema_auth_1b_schema_auth_11_b",
107-
"l_schema_auth_3_schema_auth_12_schema_iterative_update_3",
108102
"l_schema_auth_4c_init_a_geo_add_a",
109103
"l_schema_auth_4d_frontend_config_drift_env_4",
110104
"l_schema_auth_6b_schema_auth_5d_global_sandbox_b",
111105
"l_schema_auth_6d_schema_auth_6c_schema_auth_2b",
106+
"l_schema_auth_7a_schema_auth_2a_schema_auth_1b",
112107
"l_schema_auth_9_a_schema_auth_8b_schema_auth_5b",
113-
"l_schema_auth_9_b_schema_auth_7b_schema_auth_7a",
114108
"l_schema_connection_1",
115-
"l_schema_iterative_rollback_2_schema_auth_5a_export_pull_d",
109+
"l_schema_connection_2_function_2a",
110+
"l_schema_function_2_schema_auth_3_schema_auth_12",
111+
"l_schema_iterative_rollback_1_schema_auth_9_b_schema_auth_7b",
112+
"l_schema_iterative_update_1_function_5_schema_function_1",
113+
"l_schema_iterative_update_2_function_9b_custom_policies_container",
114+
"l_schema_iterative_update_3_schema_iterative_rollback_2_schema_auth_5a",
115+
"l_schema_iterative_update_4_function_1",
116+
"l_schema_iterative_update_locking_function_8_api_8",
117+
"l_schema_key_resolvers_geo_multi_env",
116118
"l_schema_model_c_schema_data_access_patterns_schema_auth_6a",
117119
"l_schema_model_d_schema_model_b_schema_auth_4a",
118120
"l_schema_model_e_schema_auth_4b_notifications_sms",
119-
"l_schema_searchable_apigw",
121+
"l_searchable_datastore_schema_searchable",
120122
"l_searchable_migration",
121123
"l_smoketest_amplify_app",
122-
"l_smoketest_smoketest_ios_javascript_notifications_pinpoint_config",
123-
"l_storage_1a_schema_iterative_update_2_function_9b",
124124
"l_storage_2_function_6_custom_policies_function",
125-
"l_storage_4_containers_api_secrets_api_4",
125+
"l_storage_5",
126126
"l_uibuilder",
127+
"l_user_groups_s3_access_hosted_ui_admin_api",
127128
"l_with_babel_config_notifications_in_app_messaging_env_2_notifications_fcm",
128129
"w_admin_api_schema_iterative_update_locking",
129130
"w_amplify_configure_layer_4",

packages/amplify-category-notifications/package.json

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,20 @@
3030
"@aws-amplify/amplify-environment-parameters": "1.9.22",
3131
"@aws-amplify/amplify-prompts": "2.8.7",
3232
"@aws-amplify/amplify-provider-awscloudformation": "8.11.14",
33-
"aws-sdk": "^2.1464.0",
33+
"@aws-sdk/client-iam": "^3.624.0",
34+
"@aws-sdk/client-pinpoint": "^3.624.0",
35+
"@smithy/node-http-handler": "^4.1.0",
3436
"chalk": "^4.1.1",
3537
"fs-extra": "^8.1.0",
3638
"lodash": "^4.17.21",
3739
"ora": "^4.0.3",
3840
"promise-sequential": "^1.1.1",
3941
"proxy-agent": "^6.3.0"
4042
},
43+
"devDependencies": {
44+
"aws-sdk-client-mock": "^4.1.0",
45+
"aws-sdk-client-mock-jest": "^4.1.0"
46+
},
4147
"jest": {
4248
"testEnvironmentOptions": {
4349
"url": "http://localhost"
Lines changed: 59 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { $TSAny, $TSContext, AmplifyCategories, AmplifyFault, AmplifySupportedService, IContextPrint } from '@aws-amplify/amplify-cli-core';
22
import { prompter } from '@aws-amplify/amplify-prompts';
3+
import { mockClient } from 'aws-sdk-client-mock';
4+
import 'aws-sdk-client-mock-jest';
5+
import { PinpointClient, UpdateApnsChannelCommand, UpdateApnsSandboxChannelCommand } from '@aws-sdk/client-pinpoint';
36
import * as configureKey from '../apns-key-config';
47
import * as configureCertificate from '../apns-cert-config';
58

@@ -14,6 +17,8 @@ jest.mock('../apns-cert-config');
1417
jest.mock('@aws-amplify/amplify-prompts');
1518
const prompterMock = prompter as jest.Mocked<typeof prompter>;
1619

20+
const mockPinpointClient = mockClient(PinpointClient);
21+
1722
class NoErrorThrownError extends Error {}
1823
// wrapper to avoid conditional error checks
1924
const getError = async <TError>(call: () => unknown): Promise<TError> => {
@@ -43,8 +48,20 @@ describe('channel-APNS', () => {
4348
mockServiceOutput[channelName] = mockChannelOutput;
4449

4550
const mockPinpointResponseErr = new Error('channel-APNS.test.js error');
46-
const mockPinpointResponseData = {
47-
APNSChannelResponse: {},
51+
const mockApnsChannelResponseData = {
52+
APNSChannelResponse: {
53+
Enabled: true,
54+
ApplicationId: 'test-app-id',
55+
Platform: 'APNS' as const,
56+
},
57+
};
58+
59+
const mockApnsSandboxChannelResponseData = {
60+
APNSSandboxChannelResponse: {
61+
Enabled: true,
62+
ApplicationId: 'test-app-id',
63+
Platform: 'APNS_SANDBOX' as const,
64+
},
4865
};
4966

5067
const mockAPNSChannelResponseData = (status: boolean, action: ChannelAction, output: $TSAny): IChannelAPIResponse => ({
@@ -64,49 +81,22 @@ describe('channel-APNS', () => {
6481
const mockKeyConfig = {};
6582
const mockCertificateConfig = {};
6683

67-
const mockPinpointClient = {
68-
updateApnsChannel: jest.fn().mockReturnValue({
69-
promise: jest.fn().mockResolvedValue(mockPinpointResponseData),
70-
}),
71-
updateApnsSandboxChannel: jest.fn().mockReturnValue({
72-
promise: jest.fn().mockResolvedValue(mockPinpointResponseData),
73-
}),
74-
};
75-
76-
const mockPinpointClientReject = {
77-
updateApnsChannel: jest.fn().mockReturnValue({
78-
promise: jest.fn().mockRejectedValue(mockPinpointResponseErr),
79-
}),
80-
updateApnsSandboxChannel: jest.fn().mockReturnValue({
81-
promise: jest.fn().mockRejectedValue(mockPinpointResponseErr),
82-
}),
83-
};
84-
8584
const mockContext: $TSContext = {
8685
exeInfo: {
8786
serviceMeta: {
8887
output: mockServiceOutput,
8988
},
90-
pinpointClient: mockPinpointClient,
89+
pinpointClient: mockPinpointClient as unknown as PinpointClient,
9190
},
9291
print: {
9392
info: jest.fn(),
9493
error: jest.fn(),
9594
} as unknown as IContextPrint,
9695
} as unknown as $TSContext;
9796

98-
const mockContextReject = {
99-
exeInfo: {
100-
serviceMeta: {
101-
output: mockServiceOutput,
102-
},
103-
pinpointClient: mockPinpointClientReject,
104-
},
105-
print: {
106-
info: jest.fn(),
107-
error: jest.fn(),
108-
},
109-
};
97+
beforeEach(() => {
98+
mockPinpointClient.reset();
99+
});
110100

111101
beforeAll(() => {
112102
global.console = { ...global.console, log: jest.fn() };
@@ -118,69 +108,73 @@ describe('channel-APNS', () => {
118108
});
119109

120110
test('configure', async () => {
111+
mockPinpointClient.on(UpdateApnsChannelCommand).resolves(mockApnsChannelResponseData);
112+
mockPinpointClient.on(UpdateApnsSandboxChannelCommand).resolves(mockApnsSandboxChannelResponseData);
113+
121114
mockChannelOutput.Enabled = true;
122115
prompterMock.yesOrNo.mockResolvedValueOnce(true);
123-
await channelAPNS.configure(mockContext).then(() => {
124-
expect(mockPinpointClient.updateApnsChannel).toBeCalled();
125-
});
116+
await channelAPNS.configure(mockContext);
117+
expect(mockPinpointClient).toHaveReceivedCommand(UpdateApnsChannelCommand);
126118

127119
mockChannelOutput.Enabled = true;
128120
prompterMock.yesOrNo.mockResolvedValueOnce(false);
129-
await channelAPNS.configure(mockContext).then(() => {
130-
expect(mockPinpointClient.updateApnsChannel).toBeCalled();
131-
});
121+
prompterMock.pick.mockResolvedValueOnce('Certificate');
122+
await channelAPNS.configure(mockContext);
123+
expect(mockPinpointClient).toHaveReceivedCommand(UpdateApnsChannelCommand);
132124

133125
mockChannelOutput.Enabled = false;
134126
prompterMock.yesOrNo.mockResolvedValueOnce(true);
135127
prompterMock.pick.mockResolvedValueOnce('Certificate');
136-
await channelAPNS.configure(mockContext).then(() => {
137-
expect(mockPinpointClient.updateApnsChannel).toBeCalled();
138-
});
128+
await channelAPNS.configure(mockContext);
129+
expect(mockPinpointClient).toHaveReceivedCommand(UpdateApnsChannelCommand);
139130
});
140131

141132
test('enable', async () => {
142-
prompterMock.pick.mockResolvedValueOnce('Certificate');
133+
mockPinpointClient.on(UpdateApnsChannelCommand).resolves(mockApnsChannelResponseData);
134+
mockPinpointClient.on(UpdateApnsSandboxChannelCommand).resolves(mockApnsSandboxChannelResponseData);
143135

136+
prompterMock.pick.mockResolvedValueOnce('Certificate');
144137
const disableData = await channelAPNS.enable(mockContext, 'successMessage');
145-
expect(mockPinpointClient.updateApnsChannel).toBeCalled();
146-
expect(mockPinpointClient.updateApnsSandboxChannel).toBeCalled();
147-
expect(disableData).toEqual(mockAPNSChannelResponseData(true, ChannelAction.ENABLE, mockPinpointResponseData.APNSChannelResponse));
138+
expect(mockPinpointClient).toHaveReceivedCommand(UpdateApnsChannelCommand);
139+
expect(mockPinpointClient).toHaveReceivedCommand(UpdateApnsSandboxChannelCommand);
140+
expect(disableData).toEqual(mockAPNSChannelResponseData(true, ChannelAction.ENABLE, mockApnsChannelResponseData.APNSChannelResponse));
148141

149142
prompterMock.pick.mockResolvedValueOnce('Key');
150143
const enableData = await channelAPNS.enable(mockContext, 'successMessage');
151-
expect(mockPinpointClient.updateApnsChannel).toBeCalled();
152-
expect(mockPinpointClient.updateApnsSandboxChannel).toBeCalled();
153-
expect(enableData).toEqual(mockAPNSChannelResponseData(true, ChannelAction.ENABLE, mockPinpointResponseData.APNSChannelResponse));
144+
expect(mockPinpointClient).toHaveReceivedCommand(UpdateApnsChannelCommand);
145+
expect(mockPinpointClient).toHaveReceivedCommand(UpdateApnsSandboxChannelCommand);
146+
expect(enableData).toEqual(mockAPNSChannelResponseData(true, ChannelAction.ENABLE, mockApnsChannelResponseData.APNSChannelResponse));
154147
});
155148

156149
test('enable unsuccessful', async () => {
157-
prompterMock.pick.mockResolvedValueOnce('Certificate');
150+
mockPinpointClient.on(UpdateApnsChannelCommand).rejects(mockPinpointResponseErr);
158151

159-
const errCert: AmplifyFault = await getError(async () =>
160-
channelAPNS.enable(mockContextReject as unknown as $TSContext, 'successMessage'),
161-
);
162-
expect(mockContextReject.exeInfo.pinpointClient.updateApnsChannel).toBeCalled();
152+
prompterMock.pick.mockResolvedValueOnce('Certificate');
153+
const errCert: AmplifyFault = await getError(async () => channelAPNS.enable(mockContext, 'successMessage'));
154+
expect(mockPinpointClient).toHaveReceivedCommand(UpdateApnsChannelCommand);
163155
expect(errCert?.downstreamException?.message).toContain(mockPinpointResponseErr.message);
164156

165157
prompterMock.pick.mockResolvedValueOnce('Key');
166-
const errKey: AmplifyFault = await getError(async () =>
167-
channelAPNS.enable(mockContextReject as unknown as $TSContext, 'successMessage'),
168-
);
169-
expect(mockPinpointClient.updateApnsChannel).toBeCalled();
158+
const errKey: AmplifyFault = await getError(async () => channelAPNS.enable(mockContext, 'successMessage'));
159+
expect(mockPinpointClient).toHaveReceivedCommand(UpdateApnsChannelCommand);
170160
expect(errKey?.downstreamException?.message).toContain(mockPinpointResponseErr.message);
171161
});
172162

173163
test('disable', async () => {
174-
await channelAPNS.disable(mockContext).then((data) => {
175-
expect(mockPinpointClient.updateApnsChannel).toBeCalled();
176-
expect(mockPinpointClient.updateApnsSandboxChannel).toBeCalled();
177-
expect(data).toEqual(mockAPNSChannelResponseData(true, ChannelAction.DISABLE, mockPinpointResponseData.APNSChannelResponse));
178-
});
164+
mockPinpointClient.on(UpdateApnsChannelCommand).resolves(mockApnsChannelResponseData);
165+
mockPinpointClient.on(UpdateApnsSandboxChannelCommand).resolves(mockApnsSandboxChannelResponseData);
166+
167+
const data = await channelAPNS.disable(mockContext);
168+
expect(mockPinpointClient).toHaveReceivedCommand(UpdateApnsChannelCommand);
169+
expect(mockPinpointClient).toHaveReceivedCommand(UpdateApnsSandboxChannelCommand);
170+
expect(data).toEqual(mockAPNSChannelResponseData(true, ChannelAction.DISABLE, mockApnsChannelResponseData.APNSChannelResponse));
179171
});
180172

181173
test('disable unsuccessful', async () => {
182-
const errKey: AmplifyFault = await getError(async () => channelAPNS.disable(mockContextReject as unknown as $TSContext));
183-
expect(mockPinpointClient.updateApnsChannel).toBeCalled();
174+
mockPinpointClient.on(UpdateApnsChannelCommand).rejects(mockPinpointResponseErr);
175+
176+
const errKey: AmplifyFault = await getError(async () => channelAPNS.disable(mockContext));
177+
expect(mockPinpointClient).toHaveReceivedCommand(UpdateApnsChannelCommand);
184178
expect(errKey?.downstreamException?.message).toContain(mockPinpointResponseErr.message);
185179
});
186180
});

0 commit comments

Comments
 (0)