Skip to content
Snippets Groups Projects
Commit 4d53d618 authored by Atte Keinänen's avatar Atte Keinänen
Browse files

Fix tests regarding dashboard creation by adding a dashboard counter

parent e724ae97
Branches
Tags
No related merge requests found
......@@ -3,7 +3,10 @@ import {
describeE2E
} from "../support/utils";
import {createDashboardInEmptyState} from "./dashboards.utils"
import {
createDashboardInEmptyState, getLatestDashboardUrl, getPreviousDashboardUrl,
incrementDashboardCount
} from "./dashboards.utils"
import {removeCurrentDash} from "../dashboard/dashboard.utils"
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
......@@ -23,7 +26,7 @@ describeE2E("dashboards/dashboards", () => {
// Return to the dashboard list and re-enter the card through the list item
await driver.get(`${server.host}/dashboard`);
await d.select(".Grid-cell > a").wait().click();
await d.waitUrl(`${server.host}/dashboard/1`)
await d.waitUrl(getLatestDashboardUrl());
// Create another one
await d.get(`${server.host}/dashboard`);
......@@ -31,7 +34,8 @@ describeE2E("dashboards/dashboards", () => {
await d.select("#CreateDashboardModal input[name='name']").wait().sendKeys("Some Excessively Long Dashboard Title Just For Fun");
await d.select("#CreateDashboardModal input[name='description']").wait().sendKeys("");
await d.select("#CreateDashboardModal .Button--primary").wait().click();
await d.waitUrl(`${server.host}/dashboard/2`)
incrementDashboardCount();
await d.waitUrl(getLatestDashboardUrl());
// Test filtering
await d.get(`${server.host}/dashboard`);
......@@ -41,7 +45,7 @@ describeE2E("dashboards/dashboards", () => {
// Should search from both title and description
await d.select("input[type='text']").wait().clear().sendKeys("usual response times");
await d.select(".Grid-cell > a").wait().click();
await d.waitUrl(`${server.host}/dashboard/1`);
await d.waitUrl(getPreviousDashboardUrl(1));
// Remove the created dashboards to prevent clashes with other tests
await removeCurrentDash();
......
export var dashboardCount = 0
export const incrementDashboardCount = () => {
dashboardCount += 1;
}
export const getLatestDashboardUrl = () => {
console.log(`/dashboard/${dashboardCount}`)
return `/dashboard/${dashboardCount}`
}
export const getPreviousDashboardUrl = (nFromLatest) => {
return `/dashboard/${dashboardCount - nFromLatest}`
}
export const createDashboardInEmptyState = async () => {
await d.get("/dashboard");
......@@ -7,6 +19,7 @@ export const createDashboardInEmptyState = async () => {
await d.select("#CreateDashboardModal input[name='description']").wait().sendKeys("For seeing the usual response times, feedback topics, our response rate, how often customers are directed to our knowledge base instead of providing a customized response");
await d.select("#CreateDashboardModal .Button--primary").wait().click();
// Make sure that the redirect was successful
await d.waitUrl("/dashboard/1");
incrementDashboardCount();
await d.waitUrl(getLatestDashboardUrl());
}
......@@ -4,7 +4,10 @@ import {
} from "../support/utils";
import {removeCurrentDash} from "../dashboard/dashboard.utils";
import {createDashboardInEmptyState} from "../dashboards/dashboards.utils";
import {
createDashboardInEmptyState, getLatestDashboardUrl,
incrementDashboardCount
} from "../dashboards/dashboards.utils";
jasmine.DEFAULT_TIMEOUT_INTERVAL = 60000;
......@@ -48,6 +51,8 @@ describeE2E("query_builder", () => {
await d.select("#QuestionSavedModal .Button.Button--primary").wait().click();
await d.select("#CreateDashboardModal input[name='name']").wait().sendKeys("Main Dashboard");
await d.select("#CreateDashboardModal .Button.Button--primary").wait().click().waitRemoved(); // wait for the modal to be removed
incrementDashboardCount();
await d.waitUrl(getLatestDashboardUrl() + "?add=1");
// save dashboard
await d.select(".EditHeader .Button.Button--primary").wait().click();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment