-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add send test email button in email page
- Loading branch information
1 parent
ccc4c90
commit 77d0672
Showing
14 changed files
with
1,588 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -126,6 +126,7 @@ Under the hood a default configuration will be loaded but a file `marilena.confi | |
| mjmlParsingOptions | | options passed to mjml render. See: [mjml options](https://www.npmjs.com/package/mjml) | | ||
| htmlVersion | | function of type `(emailName: string, locale: string) => string`. If set, this function allow to customize the output html filename. The function must return file name `es: ${emailName}-${locale}.html` | index.html | | ||
| textVersion | | function of type `(emailName: string, locale: string) => string`. If set, this function allow to generate text version of email stripping all html. The function must return file name `es: ${emailName}-${locale}-text-version.txt` | | ||
| sendTestOptions | | option in case you want to send the email to some account for testing. Setting this should add `send email` button during development: Read below for some use cases | | ||
|
||
## About templateOptions | ||
|
||
|
@@ -161,6 +162,28 @@ templateOptions: { | |
|
||
--- | ||
|
||
## About templateOptions | ||
|
||
This option provides a fast way to test email sending an email to real account. For now this is possible using `aws-ses` provider. In this case you shoul have a valid Amazon SES account. Setting this options will add a small form in the email page development. Example: | ||
|
||
```js | ||
sendTestOptions: { | ||
provider: "aws-ses", // only aws-ses is supported | ||
to: "[email protected]", // this is only a default. During development you can set different address | ||
from: "noreply@custom_domain.com", // only valid and registered alias are working with your associated Aws Ses accout | ||
// this field must return an object of type aws.SES. Below is only a basic working example | ||
ses: () => | ||
new aws.SES({ | ||
apiVersion: "2010-12-01", // should be the same | ||
region: "us-east-1", | ||
credentials: { | ||
accessKeyId: "...", | ||
secretAccessKey: "...", | ||
}, | ||
}), | ||
}, | ||
``` | ||
|
||
## Use css | ||
|
||
If you want to add a css file import in `mj-include` tag. Path start from root directory of the project (like package json): | ||
|
@@ -186,12 +209,13 @@ If you want to add a css file import in `mj-include` tag. Path start from root d | |
- [x] load varibles from yaml/json format | ||
- [x] load common variables | ||
- [x] pass option to MJML render | ||
- [x] easy way to send a real email (AWS Ses) | ||
|
||
## 🏗️ Roadmap (PRs are welcome 😀) | ||
|
||
- [ ] liquid, ejs, nunjucks, mustache, dot | ||
- [ ] config in typescript | ||
- [ ] easy way to send a real email (AWS Ses/Nodemailer) | ||
- [ ] extends send test email to custom provider | ||
- [ ] fast-refresh on config change | ||
- [ ] snaphost test for each email out of the box | ||
- [ ] refactor to esm instead common js |
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 |
---|---|---|
|
@@ -122,6 +122,42 @@ describe("Email refresh - Playground", () => { | |
}); | ||
}); | ||
|
||
describe("Email Actions - Playground", () => { | ||
it("email page with should sendOptions should send a test email and render result without error", () => { | ||
cy.visit(`http://localhost:8080/${welcomeHrefUrl_it("en")}`); | ||
|
||
cy.intercept("POST", /api\/postSendEmail/, { | ||
fixture: "postSendEmail_aws_ses_ok", | ||
statusCode: 200, | ||
}).as("postSendEmail"); | ||
|
||
cy.get("#send-form__input").should( | ||
"have.value", | ||
"[email protected]", | ||
); | ||
cy.contains("SEND EMAIL TO").click(); | ||
cy.wait("@postSendEmail"); | ||
cy.get("#modal-send-email__result").should("be.visible"); | ||
}); | ||
|
||
it("email page with should sendOptions should send a test email and render result with error", () => { | ||
cy.visit(`http://localhost:8080/${welcomeHrefUrl_it("en")}`); | ||
|
||
cy.intercept("POST", /api\/postSendEmail/, { | ||
fixture: "postSendEmail_aws_ses_ko", | ||
statusCode: 400, | ||
}).as("postSendEmail"); | ||
|
||
cy.get("#send-form__input").should( | ||
"have.value", | ||
"[email protected]", | ||
); | ||
cy.contains("SEND EMAIL TO").click(); | ||
cy.wait("@postSendEmail"); | ||
cy.get("#modal-send-email__result").should("be.visible"); | ||
}); | ||
}); | ||
|
||
// describe.only("delete", () => { | ||
// before(() => { | ||
// cy.wrap("asmdsdj").as("todo"); | ||
|
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,5 @@ | ||
{ | ||
"statusCode": 400, | ||
"error": "Bad Request", | ||
"message": "Email address is not verified. The following identities failed the check in region US-EAST-1: noreply@custom_domain.com" | ||
} |
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,15 @@ | ||
{ | ||
"envelope": { | ||
"from": "noreply@custom_domain.com", | ||
"to": [ | ||
"[email protected]" | ||
] | ||
}, | ||
"messageId": "<[email protected]>", | ||
"response": "123456", | ||
"raw": { | ||
"type": "Buffer", | ||
"data": [ | ||
] | ||
} | ||
} |
Oops, something went wrong.