From aac92d6e2dec6914d10f65de918639988a830f57 Mon Sep 17 00:00:00 2001 From: jackmahoney Date: Sat, 30 Mar 2024 23:19:16 +1300 Subject: [PATCH] open0emailopreviews --- .../cypress/e2e/spec.cy.js | 21 ++++++++++++++++++- .../package-lock.json | 8 +++---- .../package.json | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/javascript-cypress-newsletter-signup/cypress/e2e/spec.cy.js b/javascript-cypress-newsletter-signup/cypress/e2e/spec.cy.js index 410b375d..a9c1da60 100644 --- a/javascript-cypress-newsletter-signup/cypress/e2e/spec.cy.js +++ b/javascript-cypress-newsletter-signup/cypress/e2e/spec.cy.js @@ -1,3 +1,5 @@ +Cypress.config('defaultCommandTimeout', 10000); + describe('can sign up for newsletter', () => { it('can enter email and receive confirmation', () => { //cypress_newsletter_client_2 @@ -25,7 +27,7 @@ describe('can sign up for newsletter', () => { // //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') // cy.screenshot('cypress-newsletter-page-01.png') //cypress_newsletter_fill_5 @@ -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') + }) + // + //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') + }) }) // }) diff --git a/javascript-cypress-newsletter-signup/package-lock.json b/javascript-cypress-newsletter-signup/package-lock.json index 3e272851..a42b11f1 100644 --- a/javascript-cypress-newsletter-signup/package-lock.json +++ b/javascript-cypress-newsletter-signup/package-lock.json @@ -10,7 +10,7 @@ "license": "ISC", "devDependencies": { "cypress": "^13.7.1", - "mailslurp-client": "^15.18.2" + "mailslurp-client": "^15.19.0" } }, "node_modules/@colors/colors": { @@ -1343,9 +1343,9 @@ } }, "node_modules/mailslurp-client": { - "version": "15.18.2", - "resolved": "https://registry.npmjs.org/mailslurp-client/-/mailslurp-client-15.18.2.tgz", - "integrity": "sha512-n5Geh1ACwkBfBdteTO+4CfdyiercqDCa4eY5kRWRjk4dI0yxToz9mGQCOn/jWyrID5xW1ePaWZ9ZTozwULLJEA==", + "version": "15.19.0", + "resolved": "https://registry.npmjs.org/mailslurp-client/-/mailslurp-client-15.19.0.tgz", + "integrity": "sha512-cnaxqLK1hLbIEvOeOtF+BzpFOrZcYuonxkHTKfJmtk2yduQKClZWarooB4t+kMjQURvd5v4+UC1x7S3Km26qbg==", "dev": true, "dependencies": { "cross-fetch": "^3.1.5", diff --git a/javascript-cypress-newsletter-signup/package.json b/javascript-cypress-newsletter-signup/package.json index d080243e..6536f2fd 100644 --- a/javascript-cypress-newsletter-signup/package.json +++ b/javascript-cypress-newsletter-signup/package.json @@ -11,6 +11,6 @@ "license": "ISC", "devDependencies": { "cypress": "^13.7.1", - "mailslurp-client": "^15.18.2" + "mailslurp-client": "^15.19.0" } }