Skip to content

Commit

Permalink
open0emailopreviews
Browse files Browse the repository at this point in the history
  • Loading branch information
jackmahoney committed Mar 30, 2024
1 parent cdbee32 commit aac92d6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 6 deletions.
21 changes: 20 additions & 1 deletion javascript-cypress-newsletter-signup/cypress/e2e/spec.cy.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
Cypress.config('defaultCommandTimeout', 10000);

describe('can sign up for newsletter', () => {
it('can enter email and receive confirmation', () => {
//<gen>cypress_newsletter_client_2
Expand Down Expand Up @@ -25,7 +27,7 @@ describe('can sign up for newsletter', () => {
//</gen>
//<gen>cypress_newsletter_visit_4
// visit the newsletter page and fill in the form
cy.visit('https://playground-newsletter.mailslurp.com')
cy.visit('https://newsletter.mailslurp.biz')
//</gen>
cy.screenshot('cypress-newsletter-page-01.png')
//<gen>cypress_newsletter_fill_5
Expand All @@ -45,6 +47,23 @@ describe('can sign up for newsletter', () => {
}).then(email => {
expect(email.subject).to.eq('Welcome to my newsletter')
expect(email.body).to.contain('Jack')
cy.wrap(email.id).as('emailId')
})
//</gen>
//<gen>cypress_newsletter_view_7
// open the email to view it in cypress
cy.then(function () {
cy.log('Get url for viewing email')
return this.mailslurp.emailController.getEmailPreviewURLs({
emailId: this.emailId
})
}).then(emailPreviewUrls => {
cy.log(`Open email in browser: ${emailPreviewUrls.html}`)
return cy.origin(emailPreviewUrls.origin, { args: { url: emailPreviewUrls.plainHtmlBodyUrl } }, ({ url }) => {
cy.visit(url)
cy.get('body').contains('Jack')
cy.screenshot('cypress-open-email')
})
})
//</gen>
})
Expand Down
8 changes: 4 additions & 4 deletions javascript-cypress-newsletter-signup/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion javascript-cypress-newsletter-signup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"license": "ISC",
"devDependencies": {
"cypress": "^13.7.1",
"mailslurp-client": "^15.18.2"
"mailslurp-client": "^15.19.0"
}
}

0 comments on commit aac92d6

Please sign in to comment.