From 1471fedbc58b9ce83c092749d22e2494f22a37f1 Mon Sep 17 00:00:00 2001 From: Santiago Palenque Date: Fri, 24 Apr 2026 12:49:35 -0300 Subject: [PATCH] fix: test: --- .../__tests__/edit-cart-form.test.js | 87 ++++++++++--------- 1 file changed, 45 insertions(+), 42 deletions(-) diff --git a/src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/edit-form/__tests__/edit-cart-form.test.js b/src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/edit-form/__tests__/edit-cart-form.test.js index 2f7cf4ad5..d9492bff4 100644 --- a/src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/edit-form/__tests__/edit-cart-form.test.js +++ b/src/pages/sponsors/sponsor-page/tabs/sponsor-cart-tab/components/edit-form/__tests__/edit-cart-form.test.js @@ -15,50 +15,46 @@ jest.mock("../../../../../../../../actions/sponsor-cart-actions", () => ({ updateCartForm: (...args) => mockUpdateCartForm(...args) })); -// Mock foundation components used by EditForm - -// Mock history -const mockHistoryPush = jest.fn(); -jest.mock("../../../../../../../../history", () => ({ - __esModule: true, - default: { push: (...args) => mockHistoryPush(...args) } -})); - -// Mock sub-components used by FormItemTable -jest.mock( - "openstack-uicore-foundation/lib/components/mui/form-item-table", - () => { - const React = require("react"); - return { - __esModule: true, - default: ({ data, onNotesClick, onSettingsClick }) => ( -
- {data?.map((item) => ( -
- {item.name} - - -
- ))} -
+// Mock the uicore component bundle — prevents setTexts() crash on module init +jest.mock("openstack-uicore-foundation/lib/components", () => { + const React = require("react"); + return { + __esModule: true, + MuiFormItemTable: ({ data, onNotesClick, onSettingsClick }) => + React.createElement( + "div", + null, + (data || []).map((item) => + React.createElement( + "div", + { key: item.form_item_id }, + React.createElement("span", null, item.name), + React.createElement( + "button", + { + "aria-label": "edit", + onClick: () => onNotesClick && onNotesClick(item), + type: "button" + }, + "edit" + ), + React.createElement( + "button", + { + "aria-label": "settings", + onClick: () => onSettingsClick && onSettingsClick(item), + type: "button" + }, + "settings" + ) + ) + ) ), - getCurrentApplicableRate: () => "standard" - }; - } -); + getCurrentApplicableRate: () => "standard" + }; +}); +// Mock sub-components used directly by index.js jest.mock("openstack-uicore-foundation/lib/components/mui/notes-modal", () => { const React = require("react"); return { @@ -85,6 +81,13 @@ jest.mock( } ); +// Mock history +const mockHistoryPush = jest.fn(); +jest.mock("../../../../../../../../history", () => ({ + __esModule: true, + default: { push: (...args) => mockHistoryPush(...args) } +})); + // Avoid MUI ripple noise jest.mock("@mui/material/ButtonBase/TouchRipple", () => ({ __esModule: true,