## Description Added following new events for gaps inside analytics - ActionBackButton - CanvasClick Fixes #21417 ## Type of change - Chore (housekeeping or task changes that don't impact user perception) ## How Has This Been Tested? - Manual ### Test Plan ### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) ## Checklist: ### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag ### QA activity: - [ ] Test plan has been approved by relevant developers - [ ] Test plan has been peer reviewed by QA - [ ] Cypress test cases have been added and approved by either SDET or manual QA - [ ] Organized project review call with relevant stakeholders after Round 1/2 of QA - [ ] Added Test Plan Approved label after reveiwing all Cypress test
76 lines
2.3 KiB
TypeScript
76 lines
2.3 KiB
TypeScript
import type { ReactElement } from "react";
|
|
import React from "react";
|
|
import type { RenderOptions } from "@testing-library/react";
|
|
import { render, queries } from "@testing-library/react";
|
|
import { Provider } from "react-redux";
|
|
import { ThemeProvider } from "styled-components";
|
|
import { getCurrentThemeDetails } from "selectors/themeSelectors";
|
|
import * as customQueries from "./customQueries";
|
|
import { BrowserRouter } from "react-router-dom";
|
|
import type { AppState } from "@appsmith/reducers";
|
|
import appReducer from "@appsmith/reducers";
|
|
import { applyMiddleware, compose, createStore } from "redux";
|
|
import { reduxBatch } from "@manaflair/redux-batch";
|
|
import createSagaMiddleware from "redux-saga";
|
|
import store, { testStore } from "store";
|
|
import { sagasToRunForTests } from "./sagas";
|
|
import { all, call, spawn } from "redux-saga/effects";
|
|
|
|
const testSagaMiddleware = createSagaMiddleware();
|
|
|
|
const testStoreWithTestMiddleWare = (initialState: Partial<AppState>) =>
|
|
createStore(
|
|
appReducer,
|
|
initialState,
|
|
compose(reduxBatch, applyMiddleware(testSagaMiddleware), reduxBatch),
|
|
);
|
|
|
|
const rootSaga = function* (sagasToRun = sagasToRunForTests) {
|
|
yield all(
|
|
sagasToRun.map((saga) =>
|
|
spawn(function* () {
|
|
while (true) {
|
|
yield call(saga);
|
|
break;
|
|
}
|
|
}),
|
|
),
|
|
);
|
|
};
|
|
|
|
const customRender = (
|
|
ui: ReactElement,
|
|
state?: {
|
|
url?: string;
|
|
initialState?: Partial<AppState>;
|
|
sagasToRun?: typeof sagasToRunForTests;
|
|
},
|
|
options?: Omit<RenderOptions, "queries">,
|
|
) => {
|
|
let reduxStore = store;
|
|
window.history.pushState({}, "Appsmith", state?.url || "/");
|
|
if (state && state.initialState) {
|
|
reduxStore = testStore(state.initialState || {});
|
|
}
|
|
if (state && state.sagasToRun) {
|
|
reduxStore = testStoreWithTestMiddleWare(reduxStore.getState());
|
|
testSagaMiddleware.run(() => rootSaga(state.sagasToRun));
|
|
}
|
|
const defaultTheme = getCurrentThemeDetails(reduxStore.getState());
|
|
return render(
|
|
<BrowserRouter>
|
|
<Provider store={reduxStore}>
|
|
<ThemeProvider theme={defaultTheme}>{ui}</ThemeProvider>
|
|
</Provider>
|
|
</BrowserRouter>,
|
|
{
|
|
queries: { ...queries, ...customQueries },
|
|
...options,
|
|
},
|
|
);
|
|
};
|
|
|
|
export * from "@testing-library/react";
|
|
|
|
export { customRender as render };
|