-
Notifications
You must be signed in to change notification settings - Fork 820
refactor: amplify-category-notifications aws sdk v3 migration #14271
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dgandhi62
merged 20 commits into
aws-amplify:dev
from
dgandhi62:category-notifications/sdk-v3-migration
Oct 21, 2025
Merged
Changes from 4 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
58e77c8
chore: update dependencies
dgandhi62 5d41a41
fix: prevent infinite retry loops in deleteProject when CloudFormatio…
dgandhi62 37eff25
chore: update dependency
dgandhi62 51cba3f
fix: change err.code to err.name for NotFoundException handling
dgandhi62 9567edd
fix: increase macOS binary size threshold to 1100MB
dgandhi62 ae486c9
fix: resolve Jest worker SIGKILL and hanging process issues
dgandhi62 7fdd750
fix: add failing tests to RUN_SOLO to prevent Jest worker SIGKILL errors
dgandhi62 e40271e
fix: remove 'as any' assertions from notification tests and add SIGKI…
dgandhi62 7499c10
feat: migrate notifications category to AWS SDK v3
dgandhi62 e28a09a
fix: retry logic in deleteProject
dgandhi62 45ea649
Merge dev branch into notifications SDK v3 migration
dgandhi62 dd17aad
fix: update dependencies
dgandhi62 98aba33
chore: update dependencies
dgandhi62 cc4b6c4
chore: merge upstream/dev with notifications category SDK v3 migration
dgandhi62 322f32f
fix: add tests to run_duo in codebuild
dgandhi62 5e7f7b4
chore: update codebuild config files
dgandhi62 b9bed4b
fix: update api extractor
dgandhi62 78a620f
chore: update API documentation files
dgandhi62 a520503
chore: merge upstream/dev
dgandhi62 f33b57c
chore: update dependencies
dgandhi62 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,7 @@ | ||
import { prompter } from '@aws-amplify/amplify-prompts'; | ||
import { mockClient } from 'aws-sdk-client-mock'; | ||
import 'aws-sdk-client-mock-jest'; | ||
import { PinpointClient, UpdateEmailChannelCommand } from '@aws-sdk/client-pinpoint'; | ||
import * as channelEmail from '../channel-email'; | ||
import { ChannelAction, ChannelConfigDeploymentType, IChannelAPIResponse } from '../channel-types'; | ||
import { $TSAny, $TSContext, AmplifyCategories, AmplifySupportedService } from '@aws-amplify/amplify-cli-core'; | ||
|
@@ -19,11 +22,13 @@ jest.mock('@aws-amplify/amplify-cli-core', () => { | |
jest.mock('@aws-amplify/amplify-prompts'); | ||
const prompterMock = prompter as jest.Mocked<typeof prompter>; | ||
|
||
const mockPinpointResponseData = (status: boolean, action: ChannelAction): IChannelAPIResponse => ({ | ||
const mockPinpointClient = mockClient(PinpointClient as any); | ||
|
||
const mockPinpointResponseData = (status: boolean, action: ChannelAction, output: any): IChannelAPIResponse => ({ | ||
action, | ||
channel: ChannelType.Email, | ||
deploymentType: ChannelConfigDeploymentType.INLINE, | ||
output: undefined, | ||
output, | ||
response: { | ||
capability: AmplifyCategories.NOTIFICATIONS, | ||
pluginName: AmplifyCategories.NOTIFICATIONS, | ||
|
@@ -33,36 +38,45 @@ const mockPinpointResponseData = (status: boolean, action: ChannelAction): IChan | |
}, | ||
}); | ||
|
||
const mockPinpointClient = { | ||
updateEmailChannel: jest.fn().mockImplementation(() => ({ | ||
promise: jest.fn(() => mockPinpointResponseData(true, ChannelAction.ENABLE)), | ||
})), | ||
}; | ||
|
||
const mockContext = (output: $TSAny, client: $TSAny): $TSContext => | ||
const mockContext = (output: $TSAny): $TSContext => | ||
({ | ||
exeInfo: { | ||
serviceMeta: { | ||
output, | ||
}, | ||
pinpointClient: client, | ||
pinpointClient: mockPinpointClient as any, | ||
}, | ||
print: { | ||
info: jest.fn(), | ||
error: jest.fn(), | ||
}, | ||
} as unknown as $TSContext); | ||
|
||
describe('channel-FCM', () => { | ||
describe('channel-Email', () => { | ||
const mockEmailChannelResponse = { Enabled: true, ApplicationId: 'test-app-id' }; | ||
|
||
beforeEach(() => { | ||
mockPinpointClient.reset(); | ||
}); | ||
|
||
test('enable should store role arn', async () => { | ||
mockPinpointClient.on(UpdateEmailChannelCommand as any).resolves({ EmailChannelResponse: mockEmailChannelResponse } as any); | ||
prompterMock.input.mockResolvedValueOnce('[email protected]'); | ||
prompterMock.input.mockResolvedValueOnce('fake:arn:identity'); | ||
prompterMock.input.mockResolvedValueOnce('fake:arn:role'); | ||
|
||
const mockContextObj = mockContext({ Enabled: true }, mockPinpointClient); | ||
const mockContextObj = mockContext({ Enabled: true }); | ||
const data = await channelEmail.enable(mockContextObj, 'successMessage'); | ||
expect(mockPinpointClient.updateEmailChannel).toBeCalled(); | ||
expect(data).toEqual(mockPinpointResponseData(true, ChannelAction.ENABLE)); | ||
expect(mockPinpointClient).toHaveReceivedCommandWith(UpdateEmailChannelCommand as any, { | ||
ApplicationId: undefined, | ||
EmailChannelRequest: { | ||
FromAddress: '[email protected]', | ||
Identity: 'fake:arn:identity', | ||
RoleArn: 'fake:arn:role', | ||
Enabled: true, | ||
}, | ||
}); | ||
expect(data).toEqual(mockPinpointResponseData(true, ChannelAction.ENABLE, mockEmailChannelResponse)); | ||
expect(mockContextObj.exeInfo.serviceMeta.output['Email'].RoleArn).toEqual('fake:arn:role'); | ||
}); | ||
}); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.