Skip to content

Commit

Permalink
Settings email form fixes (metabase#12283)
Browse files Browse the repository at this point in the history
* Fix email settings form. Resolves metabase#12274, Resolves metabase#12275

* Add email settings cypress tests
  • Loading branch information
tlrobinson authored Apr 8, 2020
1 parent e67f169 commit 275fd83
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ const SAVE_SETTINGS_BUTTONS_STATES = {
@connect(
null,
{ updateSettings },
null,
{ withRef: true }, // HACK: needed so consuming components can call methods on the component :-/
)
export default class SettingsBatchForm extends Component {
constructor(props, context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class SettingsEmailForm extends Component {
const { sendingEmail } = this.state;
return (
<SettingsBatchForm
ref={form => (this._form = form)}
ref={form => (this._form = form && form.getWrappedInstance())}
{...this.props}
updateSettings={this.props.updateEmailSettings}
disable={sendingEmail !== "default"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,37 @@ describe("scenarios > admin > settings", () => {
openOrdersTable();
cy.contains(/^February 11, 2019, 9:40 PM$/);
});

describe(" > email settings", () => {
it("should be able to save email settings", () => {
cy.visit("/admin/settings/email");
cy.findByPlaceholderText("smtp.yourservice.com")
.type("localhost")
.blur();
cy.findByPlaceholderText("587")
.type("1234")
.blur();
cy.findByPlaceholderText("[email protected]")
.type("[email protected]")
.blur();
cy.findByText("Save changes").click();

cy.findByText("Changes saved!");
});
it("should show an error if test email fails", () => {
cy.visit("/admin/settings/email");
cy.findByText("Send test email").click();
cy.findByText("Sorry, something went wrong. Please try again.");
});
it("should be able to clear email settings", () => {
cy.visit("/admin/settings/email");
cy.findByText("Clear").click();
cy.findByPlaceholderText("smtp.yourservice.com").should("have.value", "");
cy.findByPlaceholderText("587").should("have.value", "");
cy.findByPlaceholderText("[email protected]").should(
"have.value",
"",
);
});
});
});

0 comments on commit 275fd83

Please sign in to comment.