Files
redash/client/cypress/integration/alert/edit_alert_spec.js
Omer Lachish de052ff02b Cypress touch-ups (#5109)
* allow non-sequential IDs for DataSources in Cypress tests

* refactor redash-api to a set of Cypress commands

* support mounting Redash endpoints in Cypress routes

* fix some parameter specs by waiting for schema to load

* extract baseUrl from cypress.json

* Restyled by prettier (#5110)

Co-authored-by: Restyled.io <commits@restyled.io>

Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com>
Co-authored-by: Restyled.io <commits@restyled.io>
2020-08-19 21:00:06 +03:00

44 lines
1.4 KiB
JavaScript

describe("Edit Alert", () => {
beforeEach(() => {
cy.login();
});
it("renders the page and takes a screenshot", () => {
cy.createQuery({ query: "select 1 as col_name" })
.then(({ id: queryId }) => cy.createAlert(queryId, { column: "col_name" }))
.then(({ id: alertId }) => {
cy.visit(`/alerts/${alertId}/edit`);
cy.getByTestId("Criteria").should("exist");
cy.percySnapshot("Edit Alert screen");
});
});
it("edits the notification template and takes a screenshot", () => {
cy.createQuery()
.then(({ id: queryId }) => cy.createAlert(queryId, { custom_subject: "FOO", custom_body: "BAR" }))
.then(({ id: alertId }) => {
cy.visit(`/alerts/${alertId}/edit`);
cy.getByTestId("AlertCustomTemplate").should("exist");
cy.percySnapshot("Alert Custom Template screen");
});
});
it("previews rendered template correctly", () => {
const options = {
value: "123",
op: "==",
custom_subject: "{{ ALERT_CONDITION }}",
custom_body: "{{ ALERT_THRESHOLD }}",
};
cy.createQuery()
.then(({ id: queryId }) => cy.createAlert(queryId, options))
.then(({ id: alertId }) => {
cy.visit(`/alerts/${alertId}/edit`);
cy.get(".alert-template-preview").click();
cy.getByTestId("CustomSubject").should("have.value", options.op);
cy.getByTestId("CustomBody").should("have.value", options.value);
});
});
});