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

[E2E] Fix model-revision-history flake (#28597)

* Wait for model to fully load

* Open revision history helper

* Revert to a point in history helper

* Greatly simplify test

Do not test things out we're covering elsewhere

* Update test title to match the assertions
parent 7f2932a0
Branches
Tags
No related merge requests found
import {
restore,
modal,
filter,
filterField,
visitQuestion,
openQuestionActions,
closeQuestionActions,
questionInfoButton,
} from "__support__/e2e/helpers";
import {
assertIsModel,
assertQuestionIsBasedOnModel,
saveQuestionBasedOnModel,
assertIsQuestion,
} from "./helpers/e2e-models-helpers";
import { restore, questionInfoButton } from "__support__/e2e/helpers";
describe("scenarios > models > revision history", () => {
beforeEach(() => {
......@@ -27,86 +11,41 @@ describe("scenarios > models > revision history", () => {
name: "Orders Model",
dataset: true,
});
cy.intercept("PUT", "/api/card/3").as("updateCard");
cy.intercept("POST", "/api/revision/revert").as("revertToRevision");
});
it("should allow reverting to a saved question state", () => {
cy.visit("/model/3");
openQuestionActions();
assertIsModel();
closeQuestionActions();
questionInfoButton().click();
it("should allow reverting to a saved question state and back into a model again", () => {
visitModel(3);
cy.findByText("History");
cy.findAllByTestId("question-revert-button").click();
cy.wait("@revertToRevision");
openRevisionHistory();
revertTo("You created this");
cy.wait("@dataset");
openQuestionActions();
assertIsQuestion();
cy.location("pathname").should("match", /^\/question\/3/);
cy.get(".LineAreaBarChart");
filter();
filterField("Discount", {
operator: "Not empty",
});
revertTo("^Turned this into a model");
cy.wait("@dataset");
cy.findByTestId("apply-filters").click();
cy.findByText("Save").click();
modal().within(() => {
cy.findByText(/Replace original question/i);
});
cy.location("pathname").should("match", /^\/model\/3/);
cy.get(".cellData");
});
});
it("should allow reverting to a model state", () => {
cy.request("PUT", "/api/card/3", { dataset: false });
visitQuestion(3);
openQuestionActions();
assertIsQuestion();
closeQuestionActions();
questionInfoButton().click();
cy.findByText("History");
cy.findByText(/Turned this into a model/i)
.closest("li")
.within(() => {
cy.findByTestId("question-revert-button").click();
});
cy.wait("@revertToRevision");
openQuestionActions();
assertIsModel();
closeQuestionActions();
cy.get(".LineAreaBarChart").should("not.exist");
function visitModel(id) {
cy.intercept("POST", "/api/dataset").as("dataset");
cy.visit(`/model/${id}`);
cy.wait("@dataset");
}
filter();
filterField("Count", {
placeholder: "min",
value: "2000",
});
cy.findByTestId("apply-filters").click();
assertQuestionIsBasedOnModel({
model: "Orders Model",
collection: "Our analytics",
table: "Orders",
});
function openRevisionHistory() {
cy.intercept("GET", "/api/user").as("user");
questionInfoButton().click();
cy.wait("@user");
saveQuestionBasedOnModel({ modelId: 3, name: "Q1" });
cy.findByText("History");
}
assertQuestionIsBasedOnModel({
questionName: "Q1",
model: "Orders Model",
collection: "Our analytics",
table: "Orders",
});
cy.url().should("not.include", "/question/3");
});
});
function revertTo(history) {
const r = new RegExp(history);
cy.findByText(r).closest("li").findByTestId("question-revert-button").click();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment