Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Update table editing e2e tests to not add or remove rows in Sample Database (#64273)

Kamil Mielnikf914bf8714d0
diff --git a/e2e/test/scenarios/table-editing/table-editing.cy.spec.ts b/e2e/test/scenarios/table-editing/table-editing.cy.spec.ts
index 851c72522a1..810e1c66fce 100644
--- a/e2e/test/scenarios/table-editing/table-editing.cy.spec.ts
+++ b/e2e/test/scenarios/table-editing/table-editing.cy.spec.ts
@@ -1,6 +1,6 @@
import dayjs from "dayjs";
-import { SAMPLE_DB_ID } from "e2e/support/cypress_data";
+import { SAMPLE_DB_ID, WRITABLE_DB_ID } from "e2e/support/cypress_data";
import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";
import { resetSnowplow } from "e2e/support/helpers/e2e-snowplow-helpers";
@@ -403,35 +403,51 @@ describe("scenarios > table-editing", () => {
beforeEach(() => {
resetSnowplow();
- cy.intercept("GET", `/api/table/${ORDERS_ID}/query_metadata`).as(
- "getOrdersTable",
- );
+ H.restore("postgres-writable");
+ H.resetTestTable({ type: "postgres", table: "scoreboard_actions" });
+ H.resyncDatabase({
+ dbId: WRITABLE_DB_ID,
+ tableName: "scoreboard_actions",
+ });
+
+ H.activateToken("bleeding-edge");
+ setTableEditingEnabledForDB(WRITABLE_DB_ID);
+ cy.intercept("GET", "/api/table/*/query_metadata").as("getTableMetadata");
cy.intercept("POST", "api/dataset").as("getTableDataQuery");
cy.intercept("POST", "api/ee/action-v2/execute-bulk").as("executeBulk");
- cy.visit(`/browse/databases/${SAMPLE_DB_ID}/tables/${ORDERS_ID}/edit`);
+ H.getTableId({ name: "scoreboard_actions" }).then((tableId) => {
+ cy.visit(`/browse/databases/${WRITABLE_DB_ID}/tables/${tableId}/edit`);
+ });
- cy.wait("@getOrdersTable");
+ cy.wait("@getTableMetadata");
});
it("should allow to create a row", () => {
cy.findByTestId("new-record-button").click();
- H.modal().within(() => {
- cy.findByText("Create a new record").should("be.visible");
- cy.findByTestId("Tax-field-input").type("50");
- cy.findByTestId("Total-field-input").type("100");
- cy.findByTestId("Discount-field-input").type("10");
- cy.findByTestId("create-row-form-submit-button").click();
- });
+ H.modal().findByText("Create a new record").should("be.visible");
+
+ cy.findByTestId("Team Name-field-input").click();
+ H.popover().findByRole("textbox").type("New York Bricks");
+ H.popover()
+ .findByText(/Add option/)
+ .click();
+ cy.findByTestId("Score-field-input").type("987");
+ cy.findByTestId("Status-field-input").click();
+ H.popover().findByText("active").click();
+
+ cy.findByTestId("create-row-form-submit-button").click();
cy.wait("@executeBulk").then(({ response, request }) => {
expect(request.body.action).to.equal("data-grid.row/create");
expect(response?.body.outputs[0].op).to.equal("created");
- expect(response?.body.outputs[0].row.TAX).to.equal(50);
- expect(response?.body.outputs[0].row.TOTAL).to.equal(100);
- expect(response?.body.outputs[0].row.DISCOUNT).to.equal(10);
+ expect(response?.body.outputs[0].row.score).to.equal(987);
+ expect(response?.body.outputs[0].row.status).to.equal("active");
+ expect(response?.body.outputs[0].row.team_name).to.equal(
+ "New York Bricks",
+ );
});
H.undoToast().within(() => {
@@ -439,18 +455,25 @@ describe("scenarios > table-editing", () => {
cy.findByLabelText("close icon").click();
});
- H.expectUnstructuredSnowplowEvent({
- event: "edit_data_record_modified",
- event_detail: "create",
- target_id: ORDERS_ID,
- triggered_from: "modal",
- result: "success",
+ cy.findByTestId("table-root").within(() => {
+ cy.findByText("New York Bricks").should("be.visible");
+ cy.findByText("987").should("be.visible");
+ });
+
+ H.getTableId({ name: "scoreboard_actions" }).then((tableId) => {
+ H.expectUnstructuredSnowplowEvent({
+ event: "edit_data_record_modified",
+ event_detail: "create",
+ target_id: tableId,
+ triggered_from: "modal",
+ result: "success",
+ });
});
});
it("should allow to delete multiple rows (bulk)", () => {
- cy.findAllByTestId("row-select-checkbox").eq(15).click();
- cy.findAllByTestId("row-select-checkbox").eq(16).click();
+ cy.findAllByTestId("row-select-checkbox").eq(1).click();
+ cy.findAllByTestId("row-select-checkbox").eq(2).click();
cy.log("should not show edit icon when rows are selected");
cy.findByTestId("row-edit-icon").should("not.exist");