diff --git a/e2e/test/scenarios/models/model-actions.cy.spec.js b/e2e/test/scenarios/models/model-actions.cy.spec.js index f1911d575bfa4ae20c05699bca21d39c32f08740..0b0e05720fcb14ce376abfa7da4a16bba5fcf350 100644 --- a/e2e/test/scenarios/models/model-actions.cy.spec.js +++ b/e2e/test/scenarios/models/model-actions.cy.spec.js @@ -14,7 +14,11 @@ import { queryWritableDB, } from "e2e/support/helpers"; -import { SAMPLE_DB_ID, USER_GROUPS, WRITABLE_DB_ID } from "e2e/support/cypress_data"; +import { + SAMPLE_DB_ID, + USER_GROUPS, + WRITABLE_DB_ID, +} from "e2e/support/cypress_data"; import { createMockActionParameter } from "metabase-types/api/mocks"; @@ -109,9 +113,9 @@ describe( cy.findByRole("button", { name: /Create basic actions/i }).click(); cy.findByLabelText("Action list").within(() => { - cy.findByText("Create").should("be.visible"); - cy.findByText("Update").should("be.visible"); - cy.findByText("Delete").should("be.visible"); + cy.get("li").eq(0).findByText("Create").should("be.visible"); + cy.get("li").eq(1).findByText("Update").should("be.visible"); + cy.get("li").eq(2).findByText("Delete").should("be.visible"); }); cy.findByRole("link", { name: "New action" }).click(); @@ -295,9 +299,8 @@ describe( }, ); -['postgres', 'mysql'].forEach((dialect) => { +["postgres", "mysql"].forEach(dialect => { describe(`Write actions on model detail page (${dialect})`, () => { - beforeEach(() => { cy.intercept("GET", "/api/card/*").as("getModel"); @@ -306,7 +309,10 @@ describe( cy.signInAsAdmin(); resyncDatabase({ dbId: WRITABLE_DB_ID, tableName: WRITABLE_TEST_TABLE }); - createModelFromTableName({ tableName: WRITABLE_TEST_TABLE, idAlias: "writableModelId" }); + createModelFromTableName({ + tableName: WRITABLE_TEST_TABLE, + idAlias: "writableModelId", + }); }); it("should allow action execution from the model detail page", () => { @@ -379,9 +385,9 @@ describe( cy.visit(url); cy.findByLabelText(TEST_PARAMETER.name).type("1"); cy.button(SAMPLE_QUERY_ACTION.name).click(); - cy.findByText(`${SAMPLE_WRITABLE_QUERY_ACTION.name} ran successfully`).should( - "be.visible", - ); + cy.findByText( + `${SAMPLE_WRITABLE_QUERY_ACTION.name} ran successfully`, + ).should("be.visible"); cy.findByRole("form").should("not.exist"); cy.button(SAMPLE_QUERY_ACTION.name).should("not.exist"); @@ -403,7 +409,6 @@ describe( cy.findByLabelText(/score/i).type("16"); cy.findByLabelText(/team name/i).type("Bouncy Bears"); - cy.button(IMPLICIT_ACTION_NAME).click(); cy.findByText(`${IMPLICIT_ACTION_NAME} ran successfully`).should( "be.visible", @@ -420,7 +425,7 @@ describe( expect(row.score).to.equal(16); expect(row.team_name).to.equal("Bouncy Bears"); // should not mutate form fields that we don't touch - expect(row.status).to.not.be.a('null'); + expect(row.status).to.not.be.a("null"); }); }); diff --git a/frontend/src/metabase/entities/actions/actions.ts b/frontend/src/metabase/entities/actions/actions.ts index 699c84de2a329969f12c5c81cc4da434309c557c..fa4f277b90c2de2a48d94c5b481c7448bf744964 100644 --- a/frontend/src/metabase/entities/actions/actions.ts +++ b/frontend/src/metabase/entities/actions/actions.ts @@ -57,43 +57,33 @@ const defaultImplicitActionCreateOptions = { const enableImplicitActionsForModel = async (modelId: number, options = defaultImplicitActionCreateOptions) => async (dispatch: Dispatch) => { - const requests = []; - if (options.insert) { - requests.push( - ActionsApi.create({ - name: t`Create`, - type: "implicit", - kind: "row/create", - model_id: modelId, - }), - ); + await ActionsApi.create({ + name: t`Create`, + type: "implicit", + kind: "row/create", + model_id: modelId, + }); } if (options.update) { - requests.push( - ActionsApi.create({ - name: t`Update`, - type: "implicit", - kind: "row/update", - model_id: modelId, - }), - ); + await ActionsApi.create({ + name: t`Update`, + type: "implicit", + kind: "row/update", + model_id: modelId, + }); } if (options.delete) { - requests.push( - ActionsApi.create({ - name: t`Delete`, - type: "implicit", - kind: "row/delete", - model_id: modelId, - }), - ); + await ActionsApi.create({ + name: t`Delete`, + type: "implicit", + kind: "row/delete", + model_id: modelId, + }); } - await Promise.all(requests); - dispatch(Actions.actions.invalidateLists()); }; diff --git a/package.json b/package.json index b38604e96443d8719450c57049c18bbb74783520..cfca876729c5fad4cc818543d4af4dfafe110786 100644 --- a/package.json +++ b/package.json @@ -349,6 +349,10 @@ "prettier --write", "node ./bin/verify-doc-links" ], + "e2e/**/*.{js,jsx,ts,jsx}": [ + "eslint --rulesdir frontend/lint/eslint-rules --max-warnings 0", + "prettier --write" + ], "e2e/test/scenarios/*/{*.js,!(helpers|shared)/*.js}": [ "eslint --rulesdir frontend/lint/eslint-rules --max-warnings 0", "node e2e/validate-e2e-test-files.js"