diff --git a/.eslintrc.js b/.eslintrc.js index e56c8fecd64..8ae3243dbf2 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -72,6 +72,13 @@ module.exports = { "@typescript-eslint/explicit-module-boundary-types": ["warn"], }, }, + { + files: ["cypress/**/*.ts"], + // Set to turn off jest linting error on cypress library + rules: { + "jest/valid-expect": "off", + }, + }, ], settings: { "import/resolver": { diff --git a/cypress/integration/app/settingsflow.spec.ts b/cypress/integration/app/settingsflow.spec.ts index 7db503b7b6e..28dffbaad34 100644 --- a/cypress/integration/app/settingsflow.spec.ts +++ b/cypress/integration/app/settingsflow.spec.ts @@ -136,5 +136,17 @@ describe("Settings flow", () => { cy.get("#advanced-options").click(); cy.findByLabelText(/host expiry window/i).should("have.value", "5"); + + cy.getEmails().then((response) => { + expect(response.body.items[0].To[0]).to.have.property("Domain"); + expect(response.body.items[0].To[0].Mailbox).to.equal("test"); + expect(response.body.items[0].To[0].Domain).to.equal("fleetdm.com"); + expect(response.body.items[0].From.Mailbox).to.equal("rachel"); + expect(response.body.items[0].From.Domain).to.equal("fleetdm.com"); + expect(response.body.items[0].Content.Headers.Subject[0]).to.equal( + "Hello from Fleet" + ); + console.log(response.body.items[0]); + }); }); }); diff --git a/cypress/support/commands.ts b/cypress/support/commands.ts index 800638d6199..7c59b26de8c 100644 --- a/cypress/support/commands.ts +++ b/cypress/support/commands.ts @@ -117,3 +117,12 @@ Cypress.Commands.add("loginSSO", () => { }); }); }); + +Cypress.Commands.add("getEmails", () => { + return cy + .request("http://localhost:8025/api/v2/messages") + .then((response) => { + expect(response.status).to.eq(200); + return response; + }); +}); diff --git a/cypress/support/index.d.ts b/cypress/support/index.d.ts index 2a6321d1c3e..385e88117f1 100644 --- a/cypress/support/index.d.ts +++ b/cypress/support/index.d.ts @@ -32,5 +32,10 @@ declare namespace Cypress { * Custom command to login a user1@example.com via SSO. */ loginSSO(): Chainable; + + /** + * Custom command to get the emails handled by the Mailhog server. + */ + getEmails(): Chainable; } }