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

Fix `snippet` Cypress error (#13312)

* Fix `snippet` Cypress error

- this was very annoying flake responsible for a lot of failed builds => it shouldn't fail again
- added "hack" function for typing inside autocomplete fields
- added simple math in the second case with altered assertion
parent 207d8146
No related branches found
No related tags found
No related merge requests found
import { signInAsNormalUser, restore, modal } from "__support__/cypress";
// HACK which lets us type (even very long words) without losing focus
// this is needed for fields where autocomplete suggestions are enabled
function _clearAndIterativelyTypeUsingLabel(label, string) {
cy.findByLabelText(label).clear();
for (const char of string) {
cy.findByLabelText(label).type(char);
}
}
describe("scenarios > question > snippets", () => {
before(restore);
beforeEach(signInAsNormalUser);
......@@ -17,6 +27,7 @@ describe("scenarios > question > snippets", () => {
// add a snippet of that text
cy.get(".Icon-snippet").click();
cy.contains("Create a snippet").click();
modal()
.find("input[name=name]")
.type("stuff-snippet");
......@@ -40,20 +51,21 @@ describe("scenarios > question > snippets", () => {
// update the name and content
modal().within(() => {
cy.findByText("Editing stuff-snippet");
cy.findByLabelText("Enter some SQL here so you can reuse it later").type(
"{selectall}{del}'foo'",
);
cy.findByLabelText("Give your snippet a name").type(
"{selectall}{del}foo",
_clearAndIterativelyTypeUsingLabel(
"Enter some SQL here so you can reuse it later",
"1+1",
);
_clearAndIterativelyTypeUsingLabel("Give your snippet a name", "Math");
cy.findByText("Save").click();
});
// SQL editor should get updated automatically
cy.get(".ace_content").contains("select {{snippet: foo}}");
cy.get(".ace_content").contains("select {{snippet: Math}}");
// run the query and check the displayed scalar
cy.get(".NativeQueryEditor .Icon-play").click();
cy.get(".ScalarValue").contains("foo");
cy.get(".ScalarValue").contains("2");
});
});
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