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

[E2E] Fix models tests (#23698)

* Fix model flakes

* Add additional guards

* Update the assertion
parent bf1de4d5
No related branches found
No related tags found
No related merge requests found
......@@ -210,3 +210,13 @@ function dashboardHasQuestions(cards) {
return false;
}
}
export function interceptIfNotPreviouslyDefined({ method, url, alias } = {}) {
const aliases = Object.keys(cy.state("aliases"));
const isAlreadyDefined = aliases.find(a => a === alias);
if (!isAlreadyDefined) {
cy.intercept(method, url).as(alias);
}
}
import { popover, modal, openQuestionActions } from "__support__/e2e/helpers";
import {
popover,
modal,
openQuestionActions,
interceptIfNotPreviouslyDefined,
} from "__support__/e2e/helpers";
export function assertQuestionIsBasedOnModel({
questionName,
......@@ -84,6 +89,12 @@ export function assertIsQuestion() {
}
export function turnIntoModel() {
interceptIfNotPreviouslyDefined({
method: "POST",
url: "/api/dataset",
alias: "dataset",
});
openQuestionActions();
popover().within(() => {
cy.icon("model").click();
......@@ -91,6 +102,7 @@ export function turnIntoModel() {
modal().within(() => {
cy.button("Turn this into a model").click();
});
cy.wait("@dataset");
}
export function selectFromDropdown(option, clickOpts) {
......
......@@ -50,7 +50,9 @@ describe("scenarios > models", () => {
.findByText("Between")
.click();
selectFromDropdown("Not empty");
cy.button("Apply").click();
cy.wait("@dataset");
assertQuestionIsBasedOnModel({
model: "Orders Model",
......@@ -103,6 +105,7 @@ describe("scenarios > models", () => {
selectFromDropdown("Not empty");
cy.button("Apply").click();
cy.wait("@dataset");
assertQuestionIsBasedOnModel({
model: "Orders Model",
......@@ -130,7 +133,7 @@ describe("scenarios > models", () => {
cy.icon("table");
});
cy.url().should("not.include", "/question/1");
cy.location("pathname").should("eq", "/collection/root");
});
it("changes model's display to table", () => {
......@@ -315,6 +318,7 @@ describe("scenarios > models", () => {
.click();
selectFromDropdown("Not empty");
cy.button("Apply").click();
cy.wait("@dataset");
assertQuestionIsBasedOnModel({
model: "Orders Model",
......@@ -325,6 +329,7 @@ describe("scenarios > models", () => {
summarize();
selectDimensionOptionFromSidebar("Created At");
cy.wait("@dataset");
cy.button("Done").click();
assertQuestionIsBasedOnModel({
......
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