The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Fix auto-wiring dashboard filters to dashcards with multiple series (#81913)
Kevin Kelleher94e58da90d7e
diff --git a/frontend/src/metabase/dashboard/actions/auto-wire-parameters/actions.ts b/frontend/src/metabase/dashboard/actions/auto-wire-parameters/actions.tsindex f64605bf011..dd55805e3cd 100644--- a/frontend/src/metabase/dashboard/actions/auto-wire-parameters/actions.ts+++ b/frontend/src/metabase/dashboard/actions/auto-wire-parameters/actions.ts@@ -6,6 +6,7 @@ import {import {getAllDashboardCardsWithUnmappedParameters,getAutoWiredMappingsForDashcards,+ getDashcardCards,getMatchingParameterOption,getParameterMappings,} from "metabase/dashboard/actions/auto-wire-parameters/utils";@@ -27,17 +28,18 @@ import {import type { Dispatch, GetState, StoreDashcard } from "metabase/redux/store";import { isQuestionDashCard } from "metabase/utils/dashboard";import type {+ CardId,DashCardId,DashboardParameterMapping,DashboardTabId,ParameterId,ParameterTarget,- QuestionDashboardCard,} from "metabase-types/api";export function showAutoWireToast(parameter_id: ParameterId,- dashcard: QuestionDashboardCard,+ dashcardId: DashCardId,+ cardId: CardId | null,target: ParameterTarget,selectedTabId: DashboardTabId,) {@@ -52,14 +54,24 @@ export function showAutoWireToast(return;}+ const dashcard = getDashCardById(getState(), dashcardId);+ if (!dashcard || !isQuestionDashCard(dashcard)) {+ return;+ }++ const targetCard = getDashcardCards(dashcard).find(+ (card) => card.id === cardId,+ );+ if (!targetCard) {+ return;+ }+const dashcardsToAutoApply = getAllDashboardCardsWithUnmappedParameters({dashboards: dashboardState.dashboards,dashcards: dashboardState.dashcards,dashboardId: dashboardState.dashboardId,parameterId: parameter_id,selectedTabId,- // exclude current dashcard as it's being updated in another action- excludeDashcardIds: [dashcard.id],});const dashcards = Object.values(dashboardState.dashcards);@@ -88,6 +100,7 @@ export function showAutoWireToast(const mappingOption = getMatchingParameterOption(parameter,dashcard,+ targetCard,target,questions,dashcards,@@ -99,7 +112,7 @@ export function showAutoWireToast(return;}- dispatch(+ return dispatch(showAutoWireParametersToast({dashcardAttributes,originalDashcardAttributes,diff --git a/frontend/src/metabase/dashboard/actions/auto-wire-parameters/actions.unit.spec.ts b/frontend/src/metabase/dashboard/actions/auto-wire-parameters/actions.unit.spec.tsnew file mode 100644index 00000000000..e8f2f0c3a76--- /dev/null+++ b/frontend/src/metabase/dashboard/actions/auto-wire-parameters/actions.unit.spec.ts@@ -0,0 +1,89 @@+import { getMainStore } from "__support__/entities-store";+import { performUndo } from "metabase/redux/undo";+import { createMockParameterMapping } from "metabase-types/api/mocks";++import { showAutoWireToast } from "./actions";+import {+ MATCHING_TARGET,+ PARAMETER_ID,+ createAutoWireState,+ createOrdersDashcard,+ getAutoConnectToasts,+} from "./tests/setup";+import { closeAutoWireParameterToast } from "./toasts";++describe("showAutoWireToast", () => {+ it("auto-wires an unmapped sibling card and preserves the selected mapping", async () => {+ const existingMapping = createMockParameterMapping({+ parameter_id: PARAMETER_ID,+ card_id: 2,+ target: MATCHING_TARGET,+ });+ const dashcard = createOrdersDashcard({+ seriesCardIds: [2],+ parameterMappings: [existingMapping],+ });+ const store = getMainStore(createAutoWireState([dashcard]));++ await store.dispatch(+ showAutoWireToast(PARAMETER_ID, dashcard.id, 2, MATCHING_TARGET, 1),+ );++ const autoWireToast = getAutoConnectToasts(store.getState())[0];+ expect(autoWireToast?.message).toContain("Created At");++ await store.dispatch(performUndo(autoWireToast!.id));++ expect(+ store.getState().dashboard.dashcards[dashcard.id].parameter_mappings,+ ).toEqual([+ existingMapping,+ {+ parameter_id: PARAMETER_ID,+ card_id: 1,+ target: MATCHING_TARGET,+ },+ ]);++ const undoToast = store+ .getState()+ .undo.find(({ type }) => type === "filterAutoConnectDone");+ await store.dispatch(performUndo(undoToast!.id));++ expect(+ store.getState().dashboard.dashcards[dashcard.id].parameter_mappings,+ ).toEqual([existingMapping]);+ });++ it("replaces an existing auto-wire offer toast", async () => {+ const dashcards = [1, 2, 3].map((id) =>+ createOrdersDashcard({ id, cardId: id }),+ );+ const store = getMainStore(createAutoWireState(dashcards));++ await store.dispatch(+ showAutoWireToast(+ PARAMETER_ID,+ dashcards[0].id,+ dashcards[0].card.id,+ MATCHING_TARGET,+ 1,+ ),+ );+ expect(getAutoConnectToasts(store.getState())).toHaveLength(1);++ store.dispatch(closeAutoWireParameterToast());+ expect(getAutoConnectToasts(store.getState())).toHaveLength(0);++ await store.dispatch(+ showAutoWireToast(+ PARAMETER_ID,+ dashcards[1].id,+ dashcards[1].card.id,+ MATCHING_TARGET,+ 1,+ ),+ );+ expect(getAutoConnectToasts(store.getState())).toHaveLength(1);+ });+});diff --git a/frontend/src/metabase/dashboard/actions/auto-wire-parameters/tests/setup.ts b/frontend/src/metabase/dashboard/actions/auto-wire-parameters/tests/setup.tsnew file mode 100644index 00000000000..e6d1fd051a7--- /dev/null+++ b/frontend/src/metabase/dashboard/actions/auto-wire-parameters/tests/setup.ts@@ -0,0 +1,109 @@+import { createMockMetadata } from "__support__/metadata";+import {+ createMockDashboardState,+ createMockState,+ createMockStoreDashboard,+} from "__support__/state";+import { createMockEntitiesState } from "__support__/store";+import type { State } from "metabase/redux/store";+import Question from "metabase-lib/v1/Question";+import type {+ CardId,+ QuestionDashboardCard,+ StructuredParameterDimensionTarget,+} from "metabase-types/api";+import {+ createMockCard,+ createMockDashboardCard,+ createMockParameter,+ createMockStructuredDatasetQuery,+} from "metabase-types/api/mocks";+import {+ ORDERS,+ ORDERS_ID,+ createSampleDatabase,+} from "metabase-types/api/mocks/presets";++export const PARAMETER_ID = "parameter";++export const PARAMETER = createMockParameter({+ id: PARAMETER_ID,+ name: "Created At",+ slug: "created_at",+ type: "date/all-options",+});++const metadata = createMockMetadata({+ databases: [createSampleDatabase()],+});++const ORDERS_DATASET_QUERY = createMockStructuredDatasetQuery({+ query: { "source-table": ORDERS_ID },+});++export function createOrdersCard(id: CardId) {+ return createMockCard({+ id,+ name: `Orders ${id}`,+ dataset_query: ORDERS_DATASET_QUERY,+ });+}++export function createOrdersDashcard({+ id = 1,+ cardId = 1,+ seriesCardIds = [],+ parameterMappings,+}: {+ id?: number;+ cardId?: CardId;+ seriesCardIds?: CardId[];+ parameterMappings?: QuestionDashboardCard["parameter_mappings"];+} = {}) {+ return createMockDashboardCard({+ id,+ dashboard_tab_id: 1,+ card_id: cardId,+ card: createOrdersCard(cardId),+ series: seriesCardIds.map(createOrdersCard),+ parameter_mappings: parameterMappings,+ });+}++export function getOrdersQuestions(cardIds: CardId[]) {+ return Object.fromEntries(+ cardIds.map((id) => [id, new Question(createOrdersCard(id), metadata)]),+ );+}++export const MATCHING_TARGET: StructuredParameterDimensionTarget = [+ "dimension",+ ["field", ORDERS.CREATED_AT, { "base-type": "type/DateTime" }],+ { "stage-number": 0 },+];++export function createAutoWireState(dashcards: QuestionDashboardCard[]) {+ return createMockState({+ entities: createMockEntitiesState({+ databases: [createSampleDatabase()],+ }),+ dashboard: createMockDashboardState({+ dashboardId: 1,+ selectedTabId: 1,+ dashboards: {+ 1: createMockStoreDashboard({+ id: 1,+ dashcards: dashcards.map(({ id }) => id),+ parameters: [PARAMETER],+ }),+ },+ dashcards: Object.fromEntries(+ dashcards.map((dashcard) => [dashcard.id, dashcard]),+ ),+ }),+ });+}++export function getAutoConnectToasts(state: State) {+ return state.undo.filter(({ actionLabel }) => actionLabel === "Auto-connect");+}diff --git a/frontend/src/metabase/dashboard/actions/auto-wire-parameters/toasts.ts b/frontend/src/metabase/dashboard/actions/auto-wire-parameters/toasts.tsindex c8381a171c7..8203d6411d1 100644--- a/frontend/src/metabase/dashboard/actions/auto-wire-parameters/toasts.ts+++ b/frontend/src/metabase/dashboard/actions/auto-wire-parameters/toasts.ts@@ -21,7 +21,7 @@ import {AUTO_WIRE_UNDO_TOAST_TIMEOUT,} from "./constants";-export const AUTO_WIRE_TOAST_ID = _.uniqueId();+const SHOW_AUTO_WIRE_PARAMETERS_TOAST_TYPE = "SHOW_AUTO_WIRE_PARAMETERS_TOAST";export const showAutoWireParametersToast =({@@ -42,20 +42,6 @@ export const showAutoWireParametersToast =? t`Auto-connect this filter to all questions containing “${columnName}”, in the current tab?`: t`Auto-connect this filter to all questions containing “${columnName}”?`;- dispatch(- addUndo({- icon: null,- message,- actionLabel: t`Auto-connect`,- showProgress: true,- timeout: AUTO_WIRE_TOAST_TIMEOUT,- action: () => {- connectAll();- showUndoToast();- },- }),- );-function connectAll() {dispatch(setMultipleDashCardAttributes({@@ -88,6 +74,21 @@ export const showAutoWireParametersToast =}),);}++ return dispatch(+ addUndo({+ icon: null,+ type: SHOW_AUTO_WIRE_PARAMETERS_TOAST_TYPE,+ message,+ actionLabel: t`Auto-connect`,+ showProgress: true,+ timeout: AUTO_WIRE_TOAST_TIMEOUT,+ action: () => {+ connectAll();+ showUndoToast();+ },+ }),+ );};export const showAddedCardAutoWireParametersToast =@@ -120,7 +121,7 @@ export const showAddedCardAutoWireParametersToast =showProgress: true,timeout: AUTO_WIRE_TOAST_TIMEOUT,action: () => {- closeAutoWireParameterToast(toastId);+ dispatch(dismissUndo({ undoId: toastId }));autoWireParametersToNewCard();showUndoToast();},@@ -167,9 +168,14 @@ export const showAddedCardAutoWireParametersToast =};export const closeAutoWireParameterToast =- (toastId: string = AUTO_WIRE_TOAST_ID) =>- (dispatch: Dispatch) => {- dispatch(dismissUndo({ undoId: toastId }));+ () => (dispatch: Dispatch, getState: GetState) => {+ const undos = getState().undo;++ for (const undo of undos) {+ if (undo.type === SHOW_AUTO_WIRE_PARAMETERS_TOAST_TYPE) {+ dispatch(dismissUndo({ undoId: undo.id }));+ }+ }};const autoWireToastTypes = ["filterAutoConnect", "filterAutoConnectDone"];diff --git a/frontend/src/metabase/dashboard/actions/auto-wire-parameters/utils.ts b/frontend/src/metabase/dashboard/actions/auto-wire-parameters/utils.tsindex 02b5d6c66aa..cf67d81dc27 100644--- a/frontend/src/metabase/dashboard/actions/auto-wire-parameters/utils.ts+++ b/frontend/src/metabase/dashboard/actions/auto-wire-parameters/utils.ts@@ -15,8 +15,8 @@ import {} from "metabase/utils/dashboard";import type Question from "metabase-lib/v1/Question";import type {+ Card,CardId,- DashCardId,DashboardCard,DashboardId,DashboardTabId,@@ -34,14 +34,12 @@ export function getAllDashboardCardsWithUnmappedParameters({dashboardId,parameterId,selectedTabId,- excludeDashcardIds = [],}: {dashboards: DashboardState["dashboards"];dashcards: DashboardState["dashcards"];dashboardId: DashboardId;parameterId: ParameterId;selectedTabId: DashboardTabId;- excludeDashcardIds?: DashCardId[];}): QuestionDashboardCard[] {const existingDashcards = getExistingDashCards(dashboards,@@ -53,9 +51,23 @@ export function getAllDashboardCardsWithUnmappedParameters({return existingDashcards.filter((dashcard): dashcard is QuestionDashboardCard =>isQuestionDashCard(dashcard) &&- !excludeDashcardIds.includes(dashcard.id) &&+ getUnmappedCards(dashcard, parameterId).length > 0,+ );+}++export function getDashcardCards(dashcard: QuestionDashboardCard): Card[] {+ return [dashcard.card, ...(dashcard.series ?? [])];+}++function getUnmappedCards(+ dashcard: QuestionDashboardCard,+ parameterId: ParameterId,+): Card[] {+ return getDashcardCards(dashcard).filter(+ (card) =>!dashcard.parameter_mappings?.some(- (mapping) => mapping.parameter_id === parameterId,+ (mapping) =>+ mapping.parameter_id === parameterId && mapping.card_id === card.id,),);}@@ -63,24 +75,20 @@ export function getAllDashboardCardsWithUnmappedParameters({export function getMatchingParameterOption(parameter: Parameter,targetDashcard: QuestionDashboardCard,+ targetCard: Card,targetDimension: ParameterTarget,questions: Record<CardId, Question>,dashcards: DashboardCard[],-): ParameterMappingOption | null | undefined {- if (!targetDashcard) {- return null;- }-- const targetQuestion = questions[targetDashcard.card.id];+): ParameterMappingOption | null {+ const targetQuestion = questions[targetCard.id];const parameterDashcard = findDashCardForInlineParameter(parameter.id,dashcards,);-const mappingOptions = getParameterMappingOptions(targetQuestion,parameter,- targetDashcard.card,+ targetCard,targetDashcard,parameterDashcard,);@@ -94,6 +102,33 @@ export function getMatchingParameterOption(return matchedOption ?? null;}+function getMatchingParameterOptions(+ parameter: Parameter,+ targetDashcard: QuestionDashboardCard,+ targetDimension: ParameterTarget,+ questions: Record<CardId, Question>,+ dashcards: DashboardCard[],+): Map<CardId, ParameterMappingOption> {+ return getUnmappedCards(targetDashcard, parameter.id).reduce(+ (matchedOptions, card) => {+ const matchedOption = getMatchingParameterOption(+ parameter,+ targetDashcard,+ card,+ targetDimension,+ questions,+ dashcards,+ );++ if (matchedOption) {+ matchedOptions.set(card.id, matchedOption);+ }+ return matchedOptions;+ },+ new Map<CardId, ParameterMappingOption>(),+ );+}+export function getAutoWiredMappingsForDashcards(parameter: Parameter,targetDashcards: QuestionDashboardCard[],@@ -108,7 +143,7 @@ export function getAutoWiredMappingsForDashcards(const targetDashcardMappings: SetMultipleDashCardAttributesOpts = [];for (const targetDashcard of targetDashcards) {- const selectedMappingOption = getMatchingParameterOption(+ const selectedMappingOptions = getMatchingParameterOptions(parameter,targetDashcard,target,@@ -116,15 +151,14 @@ export function getAutoWiredMappingsForDashcards(dashcards,);- if (selectedMappingOption && targetDashcard.card_id) {+ if (selectedMappingOptions.size > 0) {targetDashcardMappings.push({id: targetDashcard.id,attributes: {- parameter_mappings: getParameterMappings(+ parameter_mappings: getParameterMappingsForCards(targetDashcard,parameter.id,- targetDashcard.card_id,- selectedMappingOption.target,+ selectedMappingOptions,),},});@@ -132,6 +166,24 @@ export function getAutoWiredMappingsForDashcards(}return targetDashcardMappings;}++function getParameterMappingsForCards(+ dashcard: QuestionDashboardCard,+ parameterId: ParameterId,+ mappingOptions: Map<CardId, ParameterMappingOption>,+): NonNullable<QuestionDashboardCard["parameter_mappings"]> {+ return Array.from(mappingOptions).reduce(+ (parameterMappings, [cardId, mappingOption]) =>+ getParameterMappings(+ { ...dashcard, parameter_mappings: parameterMappings },+ parameterId,+ cardId,+ mappingOption.target,+ ),+ dashcard.parameter_mappings ?? [],+ );+}+export function getParameterMappings<DC extends DashboardCard>(dashcard: DC,parameter_id: ParameterId,diff --git a/frontend/src/metabase/dashboard/actions/auto-wire-parameters/utils.unit.spec.ts b/frontend/src/metabase/dashboard/actions/auto-wire-parameters/utils.unit.spec.tsnew file mode 100644index 00000000000..069cd4ca85c--- /dev/null+++ b/frontend/src/metabase/dashboard/actions/auto-wire-parameters/utils.unit.spec.ts@@ -0,0 +1,135 @@+import { createMockStoreDashboard } from "__support__/state";+import type { QuestionDashboardCard } from "metabase-types/api";+import { createMockParameterMapping } from "metabase-types/api/mocks";++import {+ MATCHING_TARGET,+ PARAMETER,+ PARAMETER_ID,+ createOrdersDashcard,+ getOrdersQuestions,+} from "./tests/setup";+import {+ getAllDashboardCardsWithUnmappedParameters,+ getAutoWiredMappingsForDashcards,+} from "./utils";++function createDashcard({+ parameterMappings = [],+}: {+ parameterMappings?: QuestionDashboardCard["parameter_mappings"];+} = {}) {+ return createOrdersDashcard({+ seriesCardIds: [2, 3],+ parameterMappings,+ });+}++const questions = getOrdersQuestions([1, 2, 3]);++describe("getAllDashboardCardsWithUnmappedParameters", () => {+ function getUnmappedDashcards(dashcard: QuestionDashboardCard) {+ return getAllDashboardCardsWithUnmappedParameters({+ dashboards: {+ 1: createMockStoreDashboard({ id: 1, dashcards: [dashcard.id] }),+ },+ dashcards: { [dashcard.id]: dashcard },+ dashboardId: 1,+ parameterId: PARAMETER_ID,+ selectedTabId: 1,+ });+ }++ it("includes a dashcard when one of its cards is unmapped", () => {+ const dashcard = createDashcard({+ parameterMappings: [+ createMockParameterMapping({+ parameter_id: PARAMETER_ID,+ card_id: 1,+ }),+ ],+ });++ expect(getUnmappedDashcards(dashcard)).toEqual([dashcard]);+ });++ it("excludes a dashcard when all of its cards are mapped", () => {+ const dashcard = createDashcard({+ parameterMappings: [1, 2, 3].map((cardId) =>+ createMockParameterMapping({+ parameter_id: PARAMETER_ID,+ card_id: cardId,+ }),+ ),+ });++ expect(getUnmappedDashcards(dashcard)).toEqual([]);+ });+});++describe("getAutoWiredMappingsForDashcards", () => {+ it("creates a mapping for every card in a dashcard", () => {+ const dashcard = createDashcard();++ expect(+ getAutoWiredMappingsForDashcards(+ PARAMETER,+ [dashcard],+ MATCHING_TARGET,+ questions,+ [dashcard],+ ),+ ).toEqual([+ {+ id: dashcard.id,+ attributes: {+ parameter_mappings: [1, 2, 3].map((cardId) => ({+ parameter_id: PARAMETER_ID,+ card_id: cardId,+ target: MATCHING_TARGET,+ })),+ },+ },+ ]);+ });++ it("preserves existing mappings and only maps unmapped cards", () => {+ const existingMapping = createMockParameterMapping({+ parameter_id: PARAMETER_ID,+ card_id: 1,+ target: ["dimension", ["field", 999, null]],+ });+ const dashcard = createDashcard({+ parameterMappings: [existingMapping],+ });++ expect(+ getAutoWiredMappingsForDashcards(+ PARAMETER,+ [dashcard],+ MATCHING_TARGET,+ questions,+ [dashcard],+ ),+ ).toEqual([+ {+ id: dashcard.id,+ attributes: {+ parameter_mappings: [+ existingMapping,+ {+ parameter_id: PARAMETER_ID,+ card_id: 2,+ target: MATCHING_TARGET,+ },+ {+ parameter_id: PARAMETER_ID,+ card_id: 3,+ target: MATCHING_TARGET,+ },+ ],+ },+ },+ ]);+ });+});diff --git a/frontend/src/metabase/dashboard/actions/parameters.tsx b/frontend/src/metabase/dashboard/actions/parameters.tsxindex 589d61dcb0b..9a333d0e9bb 100644--- a/frontend/src/metabase/dashboard/actions/parameters.tsx+++ b/frontend/src/metabase/dashboard/actions/parameters.tsx@@ -429,18 +429,9 @@ export const setParameterMapping = createThunkAction(const dashcards = Object.values(getDashcards(getState()));const dashcard = getDashCardById(getState(), dashcardId);- if (- target !== null &&- isQuestionDashCard(dashcard) &&- !isDashcardInlineParameter(parameterId, dashcards)- ) {- const selectedTabId = getSelectedTabId(getState());-- dispatch(- showAutoWireToast(parameterId, dashcard, target, selectedTabId),- );- }-+ // this has to run first so auto-wire can see the updated dashcard+ // otherwise the toast will be shown when it shouldn't be shown+ // and undo would wipe the mapping the user just set.dispatch(setDashCardAttributes({id: dashcardId,@@ -455,6 +446,24 @@ export const setParameterMapping = createThunkAction(}),);+ if (+ target !== null &&+ isQuestionDashCard(dashcard) &&+ !isDashcardInlineParameter(parameterId, dashcards)+ ) {+ const selectedTabId = getSelectedTabId(getState());++ dispatch(+ showAutoWireToast(+ parameterId,+ dashcardId,+ cardId,+ target,+ selectedTabId,+ ),+ );+ }+// QUE2-326: when an ID parameter is mapped to a field, replace the// placeholder "id" type with a concrete type based on the field.if (target !== null && isDimensionTarget(target)) {diff --git a/frontend/src/metabase/dashboard/actions/parameters.unit.spec.ts b/frontend/src/metabase/dashboard/actions/parameters.unit.spec.tsindex d7f0bff40d5..a6f0520df67 100644--- a/frontend/src/metabase/dashboard/actions/parameters.unit.spec.ts+++ b/frontend/src/metabase/dashboard/actions/parameters.unit.spec.ts@@ -7,6 +7,7 @@ import {} from "__support__/state";import { getParameters } from "metabase/dashboard/selectors";import type { State } from "metabase/redux/store";+import { performUndo } from "metabase/redux/undo";import {createMockCard,createMockDashboardCard,@@ -16,6 +17,13 @@ import {createMockStructuredDatasetQuery,} from "metabase-types/api/mocks";+import {+ MATCHING_TARGET,+ PARAMETER,+ createAutoWireState,+ createOrdersDashcard,+ getAutoConnectToasts,+} from "./auto-wire-parameters/tests/setup";import {REMOVE_PARAMETER,removeParameter,@@ -218,6 +226,52 @@ describe("removeParameter", () => {});describe("setParameterMapping", () => {+ it("snapshots the mapping just set so auto-wire undo does not clear it", async () => {+ const dashcard = createOrdersDashcard({ seriesCardIds: [2] });+ const store = setup(createAutoWireState([dashcard]));+ const userMapping = {+ parameter_id: PARAMETER.id,+ card_id: dashcard.card.id,+ target: MATCHING_TARGET,+ };++ await store.dispatch(+ setParameterMapping(+ PARAMETER.id,+ dashcard.id,+ dashcard.card.id,+ MATCHING_TARGET,+ ),+ );++ expect(+ store.getState().dashboard.dashcards[dashcard.id].parameter_mappings,+ ).toEqual([userMapping]);++ const autoWireToast = getAutoConnectToasts(store.getState())[0];+ await store.dispatch(performUndo(autoWireToast.id));++ expect(+ store.getState().dashboard.dashcards[dashcard.id].parameter_mappings,+ ).toEqual([+ userMapping,+ {+ parameter_id: PARAMETER.id,+ card_id: 2,+ target: MATCHING_TARGET,+ },+ ]);++ const undoToast = store+ .getState()+ .undo.find(({ type }) => type === "filterAutoConnectDone");+ await store.dispatch(performUndo(undoToast!.id));++ expect(+ store.getState().dashboard.dashcards[dashcard.id].parameter_mappings,+ ).toEqual([userMapping]);+ });+describe("QUE2-326: updates ID parameter type when mapped to a field", () => {function setupIdMapping({fieldId,