Skip to content
Merged
Show file tree
Hide file tree
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
34 changes: 19 additions & 15 deletions app/client/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,23 @@ module.exports = {
],
roots: ["<rootDir>/src"],
transform: {
"^.+\\.(png|js|ts|tsx)$": "ts-jest",
"^.+\\.(png|js|ts|tsx)$": [
"ts-jest",
{
isolatedModules: true,
diagnostics: {
ignoreCodes: [1343],
},
astTransformers: {
before: [
{
path: "node_modules/ts-jest-mock-import-meta",
options: { metaObjectReplacement: { url: "https://www.url.com" } },
},
],
},
}
],
},
testEnvironment: "jsdom",
testTimeout: 9000,
Expand Down Expand Up @@ -52,22 +68,10 @@ module.exports = {
"<rootDir>/node_modules/@blueprintjs/select/lib/esnext",
"@appsmith/ads": "<rootDir>/node_modules/@appsmith/ads",
"^canvas$": "jest-canvas-mock",
"^entities/(.*)$": "<rootDir>/src/entities/$1", // Match 'entities/*'

},
globals: {
"ts-jest": {
isolatedModules: true,
diagnostics: {
ignoreCodes: [1343],
},
astTransformers: {
before: [
{
path: "node_modules/ts-jest-mock-import-meta",
options: { metaObjectReplacement: { url: "https://www.url.com" } },
},
],
},
},
APPSMITH_FEATURE_CONFIGS: {
sentry: {
dsn: parseConfig("__APPSMITH_SENTRY_DSN__"),
Expand Down
8 changes: 4 additions & 4 deletions app/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@
"@types/deep-diff": "^1.0.0",
"@types/dom-view-transitions": "^1.0.5",
"@types/downloadjs": "^1.4.2",
"@types/jest": "^27.4.1",
"@types/jest": "^29.5.3",
"@types/jshint": "^2.12.0",
"@types/lodash": "^4.14.120",
"@types/mixpanel-browser": "^2.50.1",
Expand Down Expand Up @@ -329,9 +329,9 @@
"eslint-plugin-testing-library": "^6.2.0",
"factory.ts": "^0.5.1",
"husky": "^8.0.0",
"jest": "^27.4.1",
"jest": "^29.6.1",
"jest-canvas-mock": "^2.3.1",
"jest-environment-jsdom": "^27.4.1",
"jest-environment-jsdom": "^29.6.1",
"jest-styled-components": "^7.0.8",
"json5": "^2.2.3",
"knip": "^5.30.2",
Expand All @@ -354,7 +354,7 @@
"redux-devtools-extension": "^2.13.8",
"redux-mock-store": "^1.5.4",
"redux-saga-test-plan": "^4.0.6",
"ts-jest": "29.1.0",
"ts-jest": "^29.1.0",
"ts-jest-mock-import-meta": "^0.12.0",
"ts-node": "^10.9.1",
"xlsx": "https://cdn.sheetjs.com/xlsx-0.19.3/xlsx-0.19.3.tgz"
Expand Down
21 changes: 8 additions & 13 deletions app/client/packages/ast/src/actionCreator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ export const setCallbackFunctionField = (
currentValueAstWithComments,
0,
undefined,
(type, node) => isCallExpressionNode(node),
(_type, node) => isCallExpressionNode(node),
);

if (found) {
Expand Down Expand Up @@ -717,7 +717,7 @@ export const replaceActionInQuery = (
});

simple(astWithComments, {
CallExpression(node) {
CallExpression(node: Node) {
if (
isCallExpressionNode(node) &&
isMemberExpressionNode(node.callee) &&
Expand Down Expand Up @@ -800,16 +800,13 @@ export function canTranslateToUI(
simple(astWithComments, {
ConditionalExpression(node) {
if (
// @ts-expect-error: types not matched
isCallExpressionNode(node.consequent) ||
// @ts-expect-error: types not matched
isCallExpressionNode(node.alternate)
) {
canTranslate = false;
}
},
LogicalExpression(node) {
// @ts-expect-error: types not matched
if (isCallExpressionNode(node.left) || isCallExpressionNode(node.right)) {
canTranslate = false;
}
Expand Down Expand Up @@ -912,12 +909,10 @@ export function getMainAction(
ExpressionStatement(node) {
simple(node, {
CallExpression(node) {
// @ts-expect-error: types not matched
if (node.callee.type === NodeTypes.Identifier) {
mainAction = generate(node, { comments: true }).trim();
} else {
mainAction =
// @ts-expect-error: types not matched
generate(node.callee, { comments: true }).trim() + "()";
}
},
Expand Down Expand Up @@ -989,7 +984,7 @@ export function getThenCatchBlocksFromQuery(
astWithComments,
0,
undefined,
function (type, node) {
function (_type, node) {
if (isCallExpressionNode(node)) {
if (isMemberExpressionNode(node.callee)) {
if (node.callee.object === rootCallExpression) {
Expand Down Expand Up @@ -1020,7 +1015,7 @@ export function getThenCatchBlocksFromQuery(
}

const secondBlockType = firstBlockType === "then" ? "catch" : "then";
const secondBlock = findNodeAt(ast, 0, undefined, function (type, node) {
const secondBlock = findNodeAt(ast, 0, undefined, function (_type, node) {
if (isCallExpressionNode(node)) {
if (isMemberExpressionNode(node.callee)) {
if (node.callee.object === firstBlock) {
Expand Down Expand Up @@ -1073,7 +1068,7 @@ export function setThenBlockInQuery(
astWithComments,
0,
undefined,
function (type, node) {
function (_type, node) {
if (isCallExpressionNode(node)) {
if (isMemberExpressionNode(node.callee)) {
if (node.callee.object === rootCallExpression) {
Expand Down Expand Up @@ -1117,7 +1112,7 @@ export function setThenBlockInQuery(
astWithComments,
0,
undefined,
function (type, node) {
function (_type, node) {
if (isCallExpressionNode(node)) {
if (isMemberExpressionNode(node.callee)) {
if (node.callee.object === rootCallExpression) {
Expand Down Expand Up @@ -1393,7 +1388,7 @@ function findNodeWithCalleeAndProperty(
) {
if (!ast || !callee || !property) return undefined;

return findNodeAt(ast, 0, undefined, function (type, node) {
return findNodeAt(ast, 0, undefined, function (_type, node) {
if (isCallExpressionNode(node)) {
if (isMemberExpressionNode(node.callee)) {
if (node.callee.object === callee) {
Expand Down Expand Up @@ -1431,7 +1426,7 @@ export function getFunctionParams(code: string, evaluationVersion: number) {

export function getQueryParam(
code: string,
number: number,
_number: number,
evaluationVersion: number,
) {
try {
Expand Down
2 changes: 1 addition & 1 deletion app/client/packages/ast/src/jsObject/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const parseJSObject = (code: string) => {
let JSObjectProperties: NodeWithLocation<PropertyNode>[] = [];

simple(ast, {
ExportDefaultDeclaration(node) {
ExportDefaultDeclaration(node: Node) {
if (
!isExportDefaultDeclarationNode(node) ||
!isObjectExpression(node.declaration)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ DOMTokenList {
`;

exports[`<IconSelectControl /> - Keyboard navigation Pressing '{Enter}' or ' ' should select the icon 3`] = `
Array [
[
"iconName",
"add-row-top",
true,
Expand All @@ -115,7 +115,7 @@ DOMTokenList {
`;

exports[`<IconSelectControl /> - Keyboard navigation Pressing '{Enter}' or ' ' should select the icon 5`] = `
Array [
[
"iconName",
"add-to-artifact",
true,
Expand Down
11 changes: 7 additions & 4 deletions app/client/test/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@ import { handlers } from "./__mocks__/apiHandlers";
import "../src/polyfills/requestIdleCallback";
import { Crypto } from "@peculiar/webcrypto";

// since global crypto is immutable, we need to first delete it and then use the
// peculiar crypto lisrc/sagas/helper.test.tsb
delete global['crypto'];
global.crypto = new Crypto();

export const server = setupServer(...handlers);

jest.mock("api/Api", () => ({
__esModule: true,
default: class Api {},
default: class Api { },
}));

window.scrollTo = jest.fn();
Expand All @@ -18,7 +21,7 @@ Element.prototype.scrollBy = jest.fn();

jest.mock("../src/api/Api.ts", () => ({
__esModule: true,
default: class Api {},
default: class Api { },
}));

beforeAll(() => {
Expand Down Expand Up @@ -83,15 +86,15 @@ document.createRange = () => {
};

// jest events doesnt seem to be handling scrollTo
Element.prototype.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 = () => {};
this.onmessage = () => { };
}

postMessage(msg) {
Expand Down
Loading