* Feature: Canvas layer enhancements(DIP) * feedback fixes * fixing build * dip * dip * dip * fixing build * dip * dev fixes * dip * Fixing top bottom resize handles * dip * reposition widget name on top edges. * dip * dip * dip * dip * renaming selectedWidget to lastSelectedWidget * code clean up * Fixing list widget as per grid scale. * Fixing existing specs. * Adding migration test cases. * dip * FIxing proppane in modal. * fixing modal z-indedx. * fix for modal name. * dip * dip * dip * adding test cases for hotkeys. * dip * dip * fixing build * Trying some performance improvements for jests. * 17 mins with runinband lets try without it. * minor bug fixes. * code clean up * save migrated app on fetch. * fixing few cypress tests * fixing cypress tests * fixing cypress tests. * fixing cypress * updated DSL * Addressing code review comments. * test fails * dip * eslint fixes. * fixing debugger cypress tests. * updating latest page version. * updating migration changes to cypress dsl's. * updating chart data fixes for cypress tests. Co-authored-by: Apple <nandan@thinkify.io>
82 lines
2.0 KiB
TypeScript
82 lines
2.0 KiB
TypeScript
import { getCanvasWidgetsPayload } from "sagas/PageSagas";
|
|
import { updateCurrentPage } from "actions/pageActions";
|
|
import { editorInitializer } from "utils/EditorUtils";
|
|
import { ReduxActionTypes } from "constants/ReduxActionConstants";
|
|
import { initEditor } from "actions/initActions";
|
|
import { useDispatch } from "react-redux";
|
|
|
|
export const useMockDsl = (dsl: any) => {
|
|
const dispatch = useDispatch();
|
|
const mockResp: any = {
|
|
data: {
|
|
id: "page_id",
|
|
name: "Page1",
|
|
applicationId: "app_id",
|
|
layouts: [
|
|
{
|
|
id: "layout_id",
|
|
dsl,
|
|
layoutOnLoadActions: [],
|
|
layoutActions: [],
|
|
},
|
|
],
|
|
},
|
|
};
|
|
const canvasWidgetsPayload = getCanvasWidgetsPayload(mockResp);
|
|
dispatch({
|
|
type: "UPDATE_LAYOUT",
|
|
payload: { widgets: canvasWidgetsPayload.widgets },
|
|
});
|
|
|
|
dispatch(updateCurrentPage(mockResp.data.id));
|
|
};
|
|
export function MockPageDSL({ dsl, children }: any) {
|
|
editorInitializer();
|
|
useMockDsl(dsl);
|
|
return children;
|
|
}
|
|
export function MockApplication({ children }: any) {
|
|
editorInitializer();
|
|
const dispatch = useDispatch();
|
|
dispatch(initEditor("app_id", "page_id"));
|
|
const mockResp: any = {
|
|
organizationId: "org_id",
|
|
pages: [{ id: "page_id", name: "Page1", isDefault: true }],
|
|
id: "app_id",
|
|
isDefault: true,
|
|
name: "Page1",
|
|
};
|
|
dispatch({
|
|
type: ReduxActionTypes.FETCH_APPLICATION_SUCCESS,
|
|
payload: mockResp,
|
|
});
|
|
return children;
|
|
}
|
|
|
|
//got it from @blueprintjs/test-commons to dispatch hotkeys events
|
|
export function dispatchTestKeyboardEventWithCode(
|
|
target: EventTarget,
|
|
eventType: string,
|
|
key: string,
|
|
keyCode: number,
|
|
shift = false,
|
|
meta = false,
|
|
) {
|
|
const event = document.createEvent("KeyboardEvent");
|
|
(event as any).initKeyboardEvent(
|
|
eventType,
|
|
true,
|
|
true,
|
|
window,
|
|
key,
|
|
0,
|
|
meta,
|
|
false,
|
|
shift,
|
|
);
|
|
Object.defineProperty(event, "key", { get: () => key });
|
|
Object.defineProperty(event, "which", { get: () => keyCode });
|
|
|
|
target.dispatchEvent(event);
|
|
}
|