-
-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathtesla-updates.cy.ts
45 lines (37 loc) · 1.37 KB
/
tesla-updates.cy.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import "cypress-mailslurp";
/// <reference types="cypress-mailslurp" />
describe("Tesla Enagage Email Registration", async function () {
Cypress.on("uncaught:exception", () => {
return false;
});
before(function () {
return cy
.mailslurp()
.then((mailslurp) => mailslurp.createInbox())
.then((inbox) => {
// save inbox id and email address to this (make sure you use function and not arrow syntax)
cy.wrap(inbox.id).as("inboxId");
cy.wrap(inbox.emailAddress).as("emailAddress");
});
});
it("Enagage Form: Email is submitted from UI to server!", function () {
cy.visit("https://engage.tesla.com/");
cy.contains("Get Updates");
cy.get(".ctaContainer").within(() => {
cy.get("input").type(this.emailAddress);
});
cy.get(".cta").click();
});
it("Enagage Form: Email is delievered", function () {
cy.mailslurp()
// use inbox id and a timeout of 30 seconds
.then((mailslurp) => mailslurp.waitForLatestEmail(this.inboxId))
// extract the confirmation code from the email body
.then((email) => {
expect(email.from).to.equal("[email protected]");
expect(email.to[0]).to.equal(this.emailAddress);
expect(email.subject).to.equal("Welcome to Engage Tesla’s Newsletter!");
expect(email.body).to.contains("Welcome to Engage Tesla!");
});
});
});