Skip to content

Commit 7a06ef1

Browse files
authored
Fix promoSync handling of landingPage (#3331)
1 parent e955f94 commit 7a06ef1

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

handlers/promotions-lambdas/src/handlers/promoSync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ const transformPromo = (oldPromo: OldPromo): Promo[] => {
6363
promo.description = oldPromo.description;
6464
}
6565

66-
if (oldPromo.landingPage) {
66+
if (oldPromo.landingPage?.title) {
6767
promo.landingPage = {
6868
title: oldPromo.landingPage.title,
6969
description: oldPromo.landingPage.description,

handlers/promotions-lambdas/test/promoSync.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,32 @@ describe('promoSync handler', () => {
215215

216216
expect(mockedWriteToDynamoDb).not.toHaveBeenCalled();
217217
});
218+
219+
it('should not include landingPage when title is undefined', async () => {
220+
const imageWithoutLandingPageTitle: Record<string, AttributeValue> = {
221+
...validNewImage,
222+
landingPage: {
223+
M: {
224+
type: { S: 'supporterPlus' },
225+
},
226+
},
227+
};
228+
229+
const record: DynamoDBRecord = {
230+
eventName: 'INSERT',
231+
dynamodb: {
232+
NewImage: imageWithoutLandingPageTitle,
233+
SequenceNumber: '123',
234+
},
235+
} as DynamoDBRecord;
236+
237+
await handler(createEvent([record]));
238+
239+
expect(mockedWriteToDynamoDb).toHaveBeenCalledTimes(2);
240+
241+
const calls = mockedWriteToDynamoDb.mock.calls as Array<[object, string]>;
242+
calls.forEach(([item]) => {
243+
expect(item).not.toHaveProperty('landingPage');
244+
});
245+
});
218246
});

0 commit comments

Comments
 (0)