-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from City-of-Helsinki/feature/KYV-326-email-te…
…mplate Feature/kyv 326 email template
- Loading branch information
Showing
10 changed files
with
671 additions
and
91 deletions.
There are no files selected for viewing
This file contains 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
430 changes: 358 additions & 72 deletions
430
packages/message-backend/src/email/create/__snapshots__/HandleBar.spec.ts.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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 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 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 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 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
100 changes: 100 additions & 0 deletions
100
packages/message-backend/src/email/send/service.spec.ts
This file contains 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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
import { parseOrderItemMetaVisibilityAndOrdinal } from './service' | ||
import type { OrderItemMeta } from '../create/types' | ||
|
||
describe('Test service.ts functions', () => { | ||
it('Should parse order metas to correct order and show only certain fields', async () => { | ||
const order = { | ||
meta: [ | ||
{ | ||
orderItemMetaId: 'ec627fb7-d557-4b7b-9c1c-61434322c109', | ||
orderItemId: 'orderItemId1', | ||
orderId: '76a9121f-3bb7-33b2-8ca8-bc6a23db24c1', | ||
key: 'meta key ordinal 0 show all', | ||
value: 'meta value ordinal 0 show all', | ||
label: 'meta label ordinal 0 show all', | ||
visibleInCheckout: 'true', | ||
ordinal: '0', | ||
}, | ||
{ | ||
orderItemMetaId: 'ec627fb7-d557-4b7b-9c1c-61434322c109', | ||
orderItemId: 'orderItemId1', | ||
orderId: '76a9121f-3bb7-33b2-8ca8-bc6a23db24c1', | ||
key: 'meta key no ordinal', | ||
value: 'when label is empty shows only value row', | ||
visibleInCheckout: 'true', | ||
}, | ||
{ | ||
orderItemMetaId: 'ec627fb7-d557-4b7b-9c1c-61434322c109', | ||
orderItemId: 'orderItemId2', | ||
orderId: '76a9121f-3bb7-33b2-8ca8-bc6a23db24c1', | ||
key: 'meta key ordinal 1', | ||
value: 'meta value ordinal 1', | ||
label: 'meta label ordinal 1', | ||
visibleInCheckout: 'true', | ||
ordinal: '1', | ||
}, | ||
{ | ||
orderItemMetaId: 'ec627fb7-d557-4b7b-9c1c-61434322c109', | ||
orderItemId: 'orderItemId3', | ||
orderId: 'no-ordinal-3bb7-33b2-8ca8-bc6a23db24c1', | ||
key: 'meta key no ordinal', | ||
value: 'meta value no ordinal', | ||
label: 'meta label no ordinal', | ||
}, | ||
{ | ||
orderItemMetaId: 'ec627fb7-d557-4b7b-9c1c-61434322c109', | ||
orderItemId: 'orderItemId3', | ||
orderId: 'no-ordinal-3bb7-33b2-8ca8-bc6a23db24c1', | ||
key: 'meta key should not show', | ||
value: 'meta value should not show', | ||
label: 'meta label should not show', | ||
visibleInCheckout: 'false', | ||
}, | ||
] as OrderItemMeta[], | ||
} | ||
|
||
order.meta = parseOrderItemMetaVisibilityAndOrdinal(order.meta || []) | ||
|
||
expect(order.meta[0]).toEqual({ | ||
orderItemMetaId: 'ec627fb7-d557-4b7b-9c1c-61434322c109', | ||
orderItemId: 'orderItemId1', | ||
orderId: '76a9121f-3bb7-33b2-8ca8-bc6a23db24c1', | ||
key: 'meta key ordinal 0 show all', | ||
value: 'meta value ordinal 0 show all', | ||
label: 'meta label ordinal 0 show all', | ||
visibleInCheckout: 'true', | ||
ordinal: '0', | ||
}) | ||
|
||
expect(order.meta[1]).toEqual({ | ||
orderItemMetaId: 'ec627fb7-d557-4b7b-9c1c-61434322c109', | ||
orderItemId: 'orderItemId2', | ||
orderId: '76a9121f-3bb7-33b2-8ca8-bc6a23db24c1', | ||
key: 'meta key ordinal 1', | ||
value: 'meta value ordinal 1', | ||
label: 'meta label ordinal 1', | ||
visibleInCheckout: 'true', | ||
ordinal: '1', | ||
}) | ||
|
||
expect(order.meta[2]).toEqual({ | ||
orderItemMetaId: 'ec627fb7-d557-4b7b-9c1c-61434322c109', | ||
orderItemId: 'orderItemId1', | ||
orderId: '76a9121f-3bb7-33b2-8ca8-bc6a23db24c1', | ||
key: '', // This should be empty when label is not given. | ||
value: 'when label is empty shows only value row', | ||
visibleInCheckout: 'true', | ||
}) | ||
|
||
expect(order.meta[3]).toEqual({ | ||
orderItemMetaId: 'ec627fb7-d557-4b7b-9c1c-61434322c109', | ||
orderItemId: 'orderItemId3', | ||
orderId: 'no-ordinal-3bb7-33b2-8ca8-bc6a23db24c1', | ||
key: 'meta key no ordinal', | ||
value: 'meta value no ordinal', | ||
label: 'meta label no ordinal', | ||
}) | ||
// Last meta should be ignored because visibleInCheckout: 'false' | ||
expect(order.meta[4]).toBeUndefined() | ||
}) | ||
}) |
Oops, something went wrong.