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

#13751 Repro: Custom column based filter should allow strings (#13865)

* Extract `addPostgresDatabase()` to a global Cypress helper function

* Add repro for #13571

* Refactor tests
- Use API to add database
- Extract query test into a separate file
parent 407aba6c
No related branches found
No related tags found
No related merge requests found
......@@ -199,3 +199,38 @@ export function createBasicAlert({ firstAlert, includeNormal } = {}) {
cy.findByText("Done").click();
cy.findByText("Let's set up your alert").should("not.exist");
}
// Functions specific to QA databases that we started supporting recently in CI
export function addPostgresDatabase(db_display_name = "QA Postgres12") {
cy.request("POST", "/api/database", {
engine: "postgres",
name: db_display_name,
details: {
host: "localhost",
dbname: "sample",
port: 5432,
user: "metabase",
password: "metasample123", // NOTE: we're inconsistent in where we use `pass` vs `password` as a key
authdb: null,
"additional-options": null,
"use-srv": false,
"tunnel-enabled": false,
},
auto_run_queries: true,
is_full_sync: true,
schedules: {
cache_field_values: {
schedule_day: null,
schedule_frame: null,
schedule_hour: 0,
schedule_type: "daily",
},
metadata_sync: {
schedule_day: null,
schedule_frame: null,
schedule_hour: null,
schedule_type: "hourly",
},
},
});
}
......@@ -5,31 +5,6 @@ import {
typeAndBlurUsingLabel,
} from "__support__/cypress";
function addPostgresDatabase() {
cy.visit("/admin/databases/create");
cy.contains("Database type")
.closest(".Form-field")
.find("a")
.click();
cy.contains("PostgreSQL").click({ force: true });
cy.contains("Additional JDBC connection string options");
typeAndBlurUsingLabel("Name", "QA Postgres12");
typeAndBlurUsingLabel("Host", "localhost");
// TODO: "Port" label and input field are misconfigured (input field is missing `aria-labeledby` attribute)
// typeAndBlurUsingLabel("Port", "5432") => this will not work (switching to placeholder temporarily)
cy.findByPlaceholderText("5432")
.click()
.type("5432");
typeAndBlurUsingLabel("Database name", "sample");
typeAndBlurUsingLabel("Username", "metabase");
typeAndBlurUsingLabel("Password", "metasample123");
cy.findByText("Save")
.should("not.be.disabled")
.click();
}
describe("postgres > admin > add", () => {
beforeEach(() => {
restore();
......@@ -38,30 +13,31 @@ describe("postgres > admin > add", () => {
});
it("should add a database and redirect to listing", () => {
cy.route({
method: "POST",
url: "/api/database",
}).as("createDatabase");
addPostgresDatabase();
cy.wait("@createDatabase");
cy.route("POST", "/api/database").as("createDatabase");
cy.url().should("match", /\/admin\/databases\?created=\d+$/);
cy.contains("Your database has been added!");
modal()
.contains("I'm good thanks")
cy.visit("/admin/databases/create");
cy.contains("Database type")
.closest(".Form-field")
.find("a")
.click();
});
it("should show row details when clicked on its entity key (metabase#13263)", () => {
cy.route({
method: "POST",
url: "/api/database",
}).as("createDatabase");
addPostgresDatabase();
cy.contains("PostgreSQL").click({ force: true });
cy.contains("Additional JDBC connection string options");
typeAndBlurUsingLabel("Name", "QA Postgres12");
typeAndBlurUsingLabel("Host", "localhost");
// TODO: "Port" label and input field are misconfigured (input field is missing `aria-labeledby` attribute)
// typeAndBlurUsingLabel("Port", "5432") => this will not work (switching to placeholder temporarily)
cy.findByPlaceholderText("5432")
.click()
.type("5432");
typeAndBlurUsingLabel("Database name", "sample");
typeAndBlurUsingLabel("Username", "metabase");
typeAndBlurUsingLabel("Password", "metasample123");
cy.findByText("Save")
.should("not.be.disabled")
.click();
cy.wait("@createDatabase");
cy.url().should("match", /\/admin\/databases\?created=\d+$/);
......@@ -69,28 +45,5 @@ describe("postgres > admin > add", () => {
modal()
.contains("I'm good thanks")
.click();
// Repro starts here
cy.visit("/");
cy.findByText("Ask a question").click();
cy.findByText("Simple question").click();
cy.findByText("QA Postgres12").click();
cy.findByText("Orders").click();
// We're clicking on ID: 1 (the first order) => do not change!
// It is tightly coupled to the assertion ("37.65"), which is "Subtotal" value for that order.
cy.get(".Table-ID")
.eq(0)
.click();
// Wait until "doing science" spinner disappears (DOM is ready for assertions)
// TODO: if this proves to be reliable, extract it as a helper function for waiting on DOM to render
cy.get(".LoadingSpinner").should("not.exist");
// Assertions
cy.log("**Fails in v0.36.6**");
// This could be omitted because real test is searching for "37.65" on the page
cy.findByText("There was a problem with your question").should("not.exist");
cy.contains("37.65");
});
});
import {
signInAsAdmin,
restore,
addPostgresDatabase,
popover,
} from "__support__/cypress";
describe("postgres > question > custom columns", () => {
before(() => {
restore();
signInAsAdmin();
addPostgresDatabase();
});
it.skip("should allow using strings in filter based on a custom column (metabase#13751)", () => {
const CC_NAME = "C-States";
cy.visit("/question/new");
cy.findByText("Custom question").click();
cy.findByText("QA Postgres12").click();
cy.findByText("People").click();
cy.log("**-- 1. Create custom column using `regexextract()` --**");
cy.get(".Icon-add_data").click();
popover().within(() => {
cy.get("[contenteditable='true']").type(
'regexextract([State], "^C[A-Z]")',
);
cy.findByPlaceholderText("Something nice and descriptive").type(CC_NAME);
cy.get(".Button")
.contains("Done")
.should("not.be.disabled")
.click();
});
cy.log("**-- 2. Add filter based on custom column--**");
cy.findByText("Add filters to narrow your answer").click();
popover().within(() => {
cy.findByText(CC_NAME).click();
cy.get(".AdminSelect").click();
cy.log(
"**It fails here already because it doesn't find any condition for strings. Only numbers.**",
);
cy.findByText("Is");
cy.get("input").type("CO");
cy.get(".Button")
.contains("Add filter")
.should("not.be.disabled")
.click();
});
cy.findByText("Visualize").click();
cy.findByText("Arnold Adams");
});
});
import {
signInAsAdmin,
restore,
addPostgresDatabase,
} from "__support__/cypress";
describe("postgres > user > query", () => {
before(() => {
restore();
signInAsAdmin();
addPostgresDatabase();
});
it("should show row details when clicked on its entity key (metabase#13263)", () => {
cy.visit("/question/new");
cy.findByText("Simple question").click();
cy.findByText("QA Postgres12").click();
cy.findByText("Orders").click();
// We're clicking on ID: 1 (the first order) => do not change!
// It is tightly coupled to the assertion ("37.65"), which is "Subtotal" value for that order.
cy.get(".Table-ID")
.eq(0)
.click();
// Wait until "doing science" spinner disappears (DOM is ready for assertions)
// TODO: if this proves to be reliable, extract it as a helper function for waiting on DOM to render
cy.get(".LoadingSpinner").should("not.exist");
// Assertions
cy.log("**Fails in v0.36.6**");
// This could be omitted because real test is searching for "37.65" on the page
cy.findByText("There was a problem with your question").should("not.exist");
cy.contains("37.65");
});
});
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