Skip to content
Snippets Groups Projects
Unverified Commit dfd30e5a authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

Register mocked Slack configuration (global e2e helper) (#18618)

* Refactor and register global Slack configuration e2e helper

* Use slack helper in tests
parent 2c9f4d60
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@ export * from "./helpers/e2e-data-model-helpers";
export * from "./helpers/e2e-misc-helpers";
export * from "./helpers/e2e-deprecated-helpers";
export * from "./helpers/e2e-email-helpers";
export * from "./helpers/e2e-slack-helpers";
export * from "./helpers/e2e-custom-column-helpers";
Cypress.on("uncaught:exception", (err, runnable) => false);
// Since there is no testing API token for Slack, it's easier to mock its configuration
const mockedSlack = {
type: "slack",
name: "Slack",
allows_recipients: true,
schedules: ["hourly", "daily", "weekly", "monthly"],
fields: [
{
name: "channel",
type: "select",
displayName: "Post to",
options: ["#work", "#play"],
required: true,
},
],
configured: true,
};
export function mockSlackConfigured() {
// First, let's get the actual config (email might have already been configured and we want to preserve that)
cy.request("GET", "/api/pulse/form_input").then(({ body }) => {
const originalEmailConfig = body.channels.email;
const mockedConfig = Object.assign({}, body, {
channels: {
email: originalEmailConfig,
slack: mockedSlack,
},
});
// Stubbing the response in advance
// (Cypress will intercept it when we navigate to "Dashboard subscriptions" or a question alert)
cy.intercept("GET", "/api/pulse/form_input", mockedConfig);
});
}
......@@ -5,6 +5,7 @@ import {
popover,
mockSessionProperty,
sidebar,
mockSlackConfigured,
} from "__support__/e2e/cypress";
import { USERS } from "__support__/e2e/cypress_data";
const { admin } = USERS;
......@@ -435,36 +436,3 @@ function addParametersToDashboard() {
// wait for dashboard to save
cy.contains("You're editing this dashboard.").should("not.exist");
}
function mockSlackConfigured() {
// Stubbing the response in advance (Cypress will intercept it when we navigate to "Dashboard subscriptions")
cy.server();
cy.route("GET", "/api/pulse/form_input", {
channels: {
email: {
type: "email",
name: "Email",
allows_recipients: false,
recipients: ["user", "email"],
schedules: ["hourly", "daily", "weekly", "monthly"],
configured: false,
},
slack: {
type: "slack",
name: "Slack",
allows_recipients: true,
schedules: ["hourly", "daily", "weekly", "monthly"],
fields: [
{
name: "channel",
type: "select",
displayName: "Post to",
options: ["#work", "#play"],
required: true,
},
],
configured: true,
},
},
});
}
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