Skip to content
Snippets Groups Projects
Unverified Commit 118ac17c authored by Jessica DeWitt's avatar Jessica DeWitt Committed by GitHub
Browse files

Repro/Email alert toggle (#12835)

* cypress repro for #12349

* skip so test passes until issue is resolved

* added note and skip
parent 37c745d3
No related branches found
No related tags found
No related merge requests found
......@@ -81,6 +81,23 @@ export function openProductsTable() {
cy.visit("/question/new?database=1&table=1");
}
export function setupLocalHostEmail() {
// Email info
cy.findByPlaceholderText("smtp.yourservice.com").type("localhost");
cy.findByPlaceholderText("587").type("1025");
cy.findByText("None").click();
// Leaves password and username blank
cy.findByPlaceholderText("metabase@yourcompany.com").type("test@local.host");
// *** Unnecessary click (Issue #12692)
cy.findByPlaceholderText("smtp.yourservice.com").click();
cy.findByText("Save changes").click();
cy.findByText("Changes saved!");
cy.findByText("Send test email").click();
}
// Find a text field by label text, type it in, then blur the field.
// Commonly used in our Admin section as we auto-save settings.
export function typeAndBlurUsingLabel(label, value) {
......
......@@ -5,6 +5,7 @@ import {
signOut,
signInAsNormalUser,
signIn,
setupLocalHostEmail,
} from "__support__/cypress";
const new_user = {
......@@ -67,22 +68,7 @@ describe("smoketest > admin_setup", () => {
cy.findByText("Email address you want to use as the sender of Metabase.");
cy.findByText("Sample Database").should("not.exist");
// Email info
cy.findByPlaceholderText("smtp.yourservice.com").type("localhost");
cy.findByPlaceholderText("587").type("1025");
cy.findByText("None").click();
// Leaves password and username blank
cy.findByPlaceholderText("metabase@yourcompany.com").type(
"test@local.host",
);
// *** Unnecessary click (Issue #12692)
cy.findByPlaceholderText("smtp.yourservice.com").click();
cy.findByText("Save changes").click();
cy.findByText("Changes saved!");
cy.findByText("Send test email").click();
setupLocalHostEmail();
// *** Will fail if test works correctly:
cy.wait(2000)
......
# Metabase Scenarios
## Running
- If you are running tests that include `alert > email_alert`, run `python -m smtpd -n -c DebuggingServer localhost:1025`in terminal first for setting up email through your localhost
import {
restore,
signInAsAdmin,
setupLocalHostEmail,
} from "../../../__support__/cypress";
function setUpHourlyAlert(question_num) {
cy.visit(`/question/${question_num}`);
cy.get(".Icon-bell").click();
cy.findByText("Set up an alert").click();
cy.findByText("Daily").click();
cy.findByText("Hourly").click();
}
describe("scenarios > alert > email_alert", () => {
beforeEach(restore);
beforeEach(signInAsAdmin);
it("should have no alerts set up initially", () => {
cy.server();
cy.visit("/");
cy.request("/api/alert").then(response => {
expect(response.body).to.have.length(0);
});
});
describe.skip("alert set up", () => {
// NOTE: To run tests, first run `python -m smtpd -n -c DebuggingServer localhost:1025` in your terminal
beforeEach(() => {
cy.server();
cy.visit("/admin/settings/email");
cy.findByText("SMTP Host");
setupLocalHostEmail();
});
it("should work with email alerts toggled on", () => {
// Set up alert
setUpHourlyAlert(1);
cy.findByText("Done")
.click()
.then(() => {
cy.findByText("Sample Dataset");
});
// Check alert api is sending email
cy.request("/api/alert").then(response => {
expect(response.body[0].channels).to.have.length(1);
expect(response.body[0].channels[0].recipients).to.have.length(1);
});
});
it("should have email alerts toggled off (Issue #12349)", () => {
// Turn off email alerts during alert setup
setUpHourlyAlert(2);
cy.findByText("Email")
.parent()
.find("a")
.click();
cy.findByText("Done")
.click()
.then(() => {
cy.findAllByText("Orders");
});
// Check alert api is NOT sending email
cy.request("/api/alert").then(response => {
expect(response.body[0].channels).to.have.length(1);
expect(response.body[0].channels[0].recipients).to.equal("null");
});
});
});
});
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment