Skip to content

fix: add missing modText and isMacOrIOS mocks to fix CI test failures #40389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,36 @@
import { useTableOrSpreadsheet } from "./useTableOrSpreadsheet";
import { renderHook } from "@testing-library/react-hooks";
import type { DatasourceTable } from "entities/Datasource";
import { PluginPackageName } from "entities/Plugin";
import { useTableOrSpreadsheet } from "./useTableOrSpreadsheet";

// Mock applicationSelectors
jest.mock("ee/selectors/applicationSelectors", () => ({
getApplications: jest.fn(() => []),
getCurrentApplication: jest.fn(() => ({})),
getApplicationSearchKeyword: jest.fn(),
getIsDeletingApplication: jest.fn(() => false),
getIsDuplicatingApplication: jest.fn(() => false),
getIsImportingApplication: jest.fn(() => false),
}));

// Mock AppState and create MockStore
jest.mock("store", () => ({
store: {
getState: jest.fn(() => ({
entities: {
app: {
mode: "EDIT",
},
},
ui: {
applications: {
searchKeyword: "",
deletingApplication: false,
},
},
})),
},
}));

// Mock pageListSelectors
jest.mock("selectors/pageListSelectors", () => ({
Expand Down Expand Up @@ -106,8 +135,11 @@ jest.mock("utils/editorContextUtils", () => ({

// Mock utils/helpers
jest.mock("utils/helpers", () => ({
getAppMode: jest.fn(),
getAppMode: jest.fn(() => "EDIT"),
isEllipsisActive: jest.fn(),
modText: jest.fn(() => "Ctrl +"),
isMacOrIOS: jest.fn(() => false),
shiftText: jest.fn(() => "Shift +"),
}));

// Mock WidgetOperationUtils
Expand All @@ -116,6 +148,12 @@ jest.mock("sagas/WidgetOperationUtils", () => ({}));
// Mock WidgetUtils
jest.mock("widgets/WidgetUtils", () => ({}));

// Mock environmentSelectors
jest.mock("ee/selectors/environmentSelectors", () => ({
getCurrentEnvironmentId: jest.fn(),
getCurrentEnvironmentName: jest.fn(),
}));

// Mock the context
jest.mock("react", () => {
const originalModule = jest.requireActual("react");
Expand All @@ -135,8 +173,8 @@ jest.mock("react", () => {
});

// Import after all mocks are set up
import { useSelector } from "react-redux";
import * as React from "react";
import { useSelector } from "react-redux";

// Create a simplified test
describe("useTableOrSpreadsheet", () => {
Expand Down
Loading