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

Remove and disallow H2 from E2E tests (#34364)

* Make it easy to add SQLite database

* Replace H2 with SQLite in E2E tests

* Remove long unused E2E reproduction

It's been sufficiently covered with backend tests.

* Remove H2 database helper from E2E tests
parent 23453f57
No related merge requests found
......@@ -23,7 +23,7 @@ import "./commands/user/authentication";
import "./commands/permissions/updatePermissions";
import "./commands/permissions/sandboxTable";
import "./commands/database/addH2SampleDatabase";
import "./commands/database/addSQLiteDatabase";
import "./commands/visibility/isVisibleInPopover";
import "./commands/visibility/findByTextEnsureVisible";
......
Cypress.Commands.add(
"addH2SampleDatabase",
({ name, auto_run_queries = false, is_full_sync = false } = {}) => {
cy.log(`Add another H2 sample database DB called "${name}"`);
cy.request("POST", "/api/database", {
engine: "h2",
name,
details: {
db: "zip:./target/uberjar/metabase.jar!/sample-database.db;USER=GUEST;PASSWORD=guest",
},
auto_run_queries,
is_full_sync,
schedules: {},
});
},
);
Cypress.Commands.add(
"addSQLiteDatabase",
({ name = "sqlite", auto_run_queries = true, is_full_sync = true } = {}) => {
cy.log(`Add SQLite database DB called "${name}"`);
cy.request("POST", "/api/database", {
engine: "sqlite",
name,
details: { db: "./resources/sqlite-fixture.db" },
auto_run_queries,
is_full_sync,
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",
},
},
});
},
);
......@@ -105,7 +105,7 @@ describeEE("database prompt banner", () => {
it("should not render for any other condition", () => {
// Adding a second database should prevent the database prompt
cy.addH2SampleDatabase({ name: "H2 DB" });
cy.addSQLiteDatabase();
visitFullAppEmbeddingUrl({
url: "/",
......
import { restore } from "e2e/support/helpers";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
const { PRODUCTS } = SAMPLE_DATABASE;
const filter = {
id: "774521fb-e03f-3df1-f2ae-e952c97035e3",
name: "FILTER",
"display-name": "Filter",
type: "dimension",
dimension: ["field-id", PRODUCTS.CATEGORY],
"widget-type": "category",
default: null,
};
const nativeQuery = {
name: "14145",
native: {
query: "SELECT COUNT(*) FROM products WHERE {{filter}}",
"template-tags": {
filter,
},
},
};
describe.skip("issue 14145", () => {
beforeEach(() => {
cy.intercept("POST", "/api/dataset").as("dataset");
restore();
cy.signInAsAdmin();
cy.addH2SampleDatabase({
name: "Sample2",
auto_run_queries: true,
is_full_sync: true,
});
cy.createNativeQuestion(nativeQuery, { visitQuestion: true });
});
it("`field-id` should update when database source is changed (metabase#14145)", () => {
// Change the source from "Sample Database" to the other database
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText(/Open Editor/i).click();
cy.get(".GuiBuilder-data").as("source").contains("Sample Database").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Sample2").click();
// First assert on the UI
cy.icon("variable").click();
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText(/Field to map to/)
.siblings("a")
.contains("Category");
// Rerun the query and assert on the dimension (field-id) that didn't change
cy.findByTestId("native-query-editor-container").icon("play").click();
cy.wait("@dataset").then(xhr => {
const { dimension } =
xhr.response.body.json_query.native["template-tags"].FILTER;
expect(dimension).not.to.contain(PRODUCTS.CATEGORY);
});
});
});
import { restore, openNativeEditor } from "e2e/support/helpers";
const dbName = "Sample2";
const dbName = "sqlite";
describe("issue 18148", () => {
beforeEach(() => {
restore();
cy.signInAsAdmin();
cy.addH2SampleDatabase({
cy.addSQLiteDatabase({
name: dbName,
});
......
......@@ -53,15 +53,15 @@ describe("scenarios > home > homepage", () => {
it("should display x-rays for a user database", () => {
cy.signInAsAdmin();
cy.addH2SampleDatabase({ name: "H2" });
cy.addSQLiteDatabase();
cy.visit("/");
cy.wait("@getXrayCandidates");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Here are some explorations of");
cy.findAllByRole("link").contains("H2");
cy.findAllByRole("link").contains("sqlite");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Orders").click();
cy.findByText("Number With Nulls").click();
cy.wait("@getXrayDashboard");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
......@@ -70,7 +70,7 @@ describe("scenarios > home > homepage", () => {
it("should allow switching between multiple schemas for x-rays", () => {
cy.signInAsAdmin();
cy.addH2SampleDatabase({ name: "H2" });
cy.addSQLiteDatabase({ name: "sqlite" });
cy.intercept("/api/automagic-*/database/**", getXrayCandidates());
cy.visit("/");
......@@ -78,7 +78,7 @@ describe("scenarios > home > homepage", () => {
cy.findByText(/Here are some explorations of the/);
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("public");
cy.findAllByRole("link").contains("H2");
cy.findAllByRole("link").contains("sqlite");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
cy.findByText("Orders");
// eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage
......
......@@ -66,7 +66,7 @@ describe("scenarios > reference > databases", () => {
describe("multiple databases sorting order", () => {
beforeEach(() => {
["d", "b", "a", "c"].forEach(name => {
cy.addH2SampleDatabase({ name });
cy.addSQLiteDatabase({ name });
});
});
......
......@@ -35,7 +35,7 @@ describe("scenarios > question > new", () => {
it("data selector popover should not be too small (metabase#15591)", () => {
// Add 10 more databases
for (let i = 0; i < 10; i++) {
cy.addH2SampleDatabase({ name: "Sample" + i });
cy.addSQLiteDatabase({ name: "Sample" + i });
}
startNewQuestion();
......
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