@@ -37,6 +37,11 @@ const importedExampleTemplate = createImportedEmailTemplate(
3737 exampleTemplateContent
3838)
3939
40+ const importedBundleSafeTemplate = createImportedEmailTemplate (
41+ 'src/actions/utils/email/__fixtures__/missing-from-runtime-bundle.mjml' ,
42+ exampleTemplateContent
43+ )
44+
4045describe ( 'compileEmailTemplate' , ( ) => {
4146 it ( 'compiles the moved contact message template from its imported source' , async ( ) => {
4247 const result = await compileEmailTemplate ( contactMessageTemplate , {
@@ -111,6 +116,18 @@ describe('compileEmailTemplate', () => {
111116 expect ( result . text ) . toContain ( 'Urgent message body' )
112117 } )
113118
119+ it ( 'compiles imported template content when the source file is absent at runtime' , async ( ) => {
120+ const result = await compileEmailTemplate ( importedBundleSafeTemplate , {
121+ htmlMessage : '<strong>Urgent</strong> message body' ,
122+ items : [ 'Coffee Beans' ] ,
123+ name : 'Alex' ,
124+ } )
125+
126+ expect ( result . html ) . toContain ( 'Hello, Alex!' )
127+ expect ( result . html ) . toContain ( 'Coffee Beans' )
128+ expect ( result . text ) . toContain ( 'Urgent message body' )
129+ } )
130+
114131 it ( 'throws ActionsFunctionError when MJML compilation reports errors' , async ( ) => {
115132 await expect ( compileEmailTemplate ( invalidTemplate ) ) . rejects . toMatchObject ( {
116133 appCode : 'EMAIL_TEMPLATE_COMPILE_FAILED' ,
0 commit comments