## Description
- This PR renames the `SAVE_QUERY` and `SAVE_API` events to a generic
`SAVE_ACTION` analytics event.
- The new event will include the following new properties
- `originalActionId` - The `originalActionId` of the action from which
this action was copied or the `id` action from which this action was
copied.
- `hash` - A unique hash of the `actionConfiguration` of this action
- `actionType` - The plugin type for this action
- This PR also fixes an issue where the `originalActionId` was not set
correctly when an action was copied
#### PR fixes following issue(s)
Fixes #25971
#### Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## Testing
#### How Has This Been Tested?
- [x] Manual
- [x] Jest
- [ ] Cypress
#### Test Plan
#### Issues raised during DP testing
103 lines
2.3 KiB
TypeScript
103 lines
2.3 KiB
TypeScript
import { setupServer } from "msw/node";
|
|
import { handlers } from "./__mocks__/apiHandlers";
|
|
import "../src/polyfills/requestIdleCallback";
|
|
import { Crypto } from "@peculiar/webcrypto";
|
|
|
|
global.crypto = new Crypto();
|
|
|
|
export const server = setupServer(...handlers);
|
|
|
|
jest.mock("api/Api", () => ({
|
|
__esModule: true,
|
|
default: class Api {},
|
|
}));
|
|
|
|
window.scrollTo = jest.fn();
|
|
Element.prototype.scrollIntoView = jest.fn();
|
|
Element.prototype.scrollBy = jest.fn();
|
|
|
|
jest.mock("../src/api/Api.ts", () => ({
|
|
__esModule: true,
|
|
default: class Api {},
|
|
}));
|
|
|
|
beforeAll(() => {
|
|
window.IntersectionObserver = jest
|
|
.fn()
|
|
.mockImplementation((fn: (entry: any) => any) => {
|
|
return {
|
|
observe: () => {
|
|
fn([
|
|
{
|
|
isIntersecting: true,
|
|
boundingClientRect: {
|
|
top: 64,
|
|
left: 293,
|
|
},
|
|
intersectionRect: {
|
|
width: 1296,
|
|
height: 424,
|
|
top: 64,
|
|
left: 293,
|
|
},
|
|
},
|
|
]);
|
|
},
|
|
unobserve: jest.fn(),
|
|
disconnect: jest.fn(),
|
|
};
|
|
});
|
|
|
|
window.ResizeObserver = jest.fn().mockImplementation(() => {
|
|
return {
|
|
observe: jest.fn(),
|
|
unobserve: jest.fn(),
|
|
disconnect: jest.fn(),
|
|
};
|
|
});
|
|
});
|
|
|
|
// establish API mocking before all tests
|
|
beforeAll(() => server.listen());
|
|
// reset any request handlers that are declared as a part of our tests
|
|
// (i.e. for testing one-time error scenarios)
|
|
afterEach(() => server.resetHandlers());
|
|
// clean up once the tests are done
|
|
afterAll(() => server.close());
|
|
|
|
// popper.js fix for jest tests
|
|
document.createRange = () => {
|
|
const range = new Range();
|
|
|
|
range.getBoundingClientRect = jest.fn();
|
|
|
|
range.getClientRects = () => {
|
|
return {
|
|
item: () => null,
|
|
length: 0,
|
|
[Symbol.iterator]: jest.fn(),
|
|
};
|
|
};
|
|
|
|
return range;
|
|
};
|
|
|
|
// jest events doesnt seem to be handling scrollTo
|
|
Element.prototype.scrollTo = () => {};
|
|
|
|
class WorkerStub {
|
|
url: string;
|
|
onmessage: CallableFunction;
|
|
constructor(stringUrl: string) {
|
|
this.url = stringUrl;
|
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
this.onmessage = () => {};
|
|
}
|
|
|
|
postMessage(msg) {
|
|
this.onmessage(msg);
|
|
}
|
|
}
|
|
|
|
window.Worker = WorkerStub as any;
|