Skip to content

Commit

Permalink
Merge branch 'release' into fix/user-login-source-overwrite
Browse files Browse the repository at this point in the history
  • Loading branch information
trishaanand committed Dec 9, 2024
2 parents 4c357b7 + 57618ed commit 9f3eebb
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 24 deletions.
2 changes: 1 addition & 1 deletion .github/config.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ describe(
PageLeftPane.switchSegment(PagePaneSegment.UI);
PageLeftPane.assertPresence("Table1");
PageLeftPane.switchSegment(PagePaneSegment.Queries);
cy.RenameEntity(apiName);
cy.validateMessage(apiName);
cy.CreationOfUniqueAPIcheck(apiName);
});
},
);
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ describe(
//Create and run query.

_.dataSources.EnterQuery(
"SELECT * FROM users ORDER BY id LIMIT 10;",
"SELECT * FROM users ORDER BY username LIMIT 10;",
1000,
);
_.dataSources.RunQuery();
Expand Down
21 changes: 9 additions & 12 deletions app/client/cypress/support/ApiCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
require("cy-verify-downloads").addCustomCommand();
require("cypress-file-upload");
import ApiEditor from "../locators/ApiEditor";

const apiwidget = require("../locators/apiWidgetslocator.json");
const explorer = require("../locators/explorerlocators.json");
import { ObjectsRegistry } from "./Objects/Registry";
Expand Down Expand Up @@ -114,12 +115,10 @@ Cypress.Commands.add("CreationOfUniqueAPIcheck", (apiname) => {
cy.wait("@createNewApi");
// cy.wait("@getUser");
cy.get(apiwidget.resourceUrl).should("be.visible");
agHelper.RenameQuery(apiname);
cy.get(".ads-v2-tooltip .ads-v2-text").should(($x) => {
expect($x).contain(
apiname.concat(" is already being used or is a restricted keyword."),
);
});
agHelper.RenameQuery(
apiname,
apiname.concat(" is already being used or is a restricted keyword."),
);
});

Cypress.Commands.add("RenameEntity", (value, selectFirst) => {
Expand All @@ -138,12 +137,10 @@ Cypress.Commands.add("CreateApiAndValidateUniqueEntityName", (apiname) => {
agHelper.GetNClick(apiwidget.createapi);
cy.wait("@createNewApi");
cy.get(apiwidget.resourceUrl).should("be.visible");
agHelper.RenameQuery(apiname);
cy.get(".ads-v2-tooltip .ads-v2-text").should(($x) => {
expect($x).contain(
apiname.concat(" is already being used or is a restricted keyword."),
);
});
agHelper.RenameQuery(
apiname,
apiname.concat(" is already being used or is a restricted keyword."),
);
});

Cypress.Commands.add("validateMessage", (value) => {
Expand Down
23 changes: 18 additions & 5 deletions app/client/cypress/support/Pages/AggregateHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ interface DeleteParams {
entityType?: EntityItemsType;
toastToValidate?: string;
}

interface SubActionParams {
subAction: string;
index?: number;
force?: boolean;
toastToValidate?: string;
}

interface SelectAndValidateParams {
clickOptions?: Partial<ClickOptions>;
widgetName: string;
Expand All @@ -33,6 +35,7 @@ interface SelectAndValidateParams {
}

let LOCAL_STORAGE_MEMORY: any = {};

export interface IEnterValue {
propFieldName: string;
directInput: boolean;
Expand All @@ -53,12 +56,15 @@ export class AggregateHelper {
public get isMac() {
return Cypress.platform === "darwin";
}

private selectLine = `${
this.isMac ? "{cmd}{shift}{leftArrow}" : "{shift}{home}"
}`;

public get removeLine() {
return "{backspace}";
}

public _modifierKey = `${this.isMac ? "meta" : "ctrl"}`;
private selectAll = `${this.isMac ? "{cmd}{a}" : "{ctrl}{a}"}`;
private lazyCodeEditorFallback = ".t--lazyCodeEditor-fallback";
Expand Down Expand Up @@ -226,6 +232,7 @@ export class AggregateHelper {
textInputLocator: string;
renameVal: string;
dblClick?: boolean;
willFailError?: string;
}) {
const { dblClick = false, nameLocator, renameVal, textInputLocator } = args;

Expand All @@ -240,11 +247,15 @@ export class AggregateHelper {
cy.get(textInputLocator)
.clear({ force: true })
.type(renameVal, { force: true, delay: 0 })
.should("have.value", renameVal)
.blur();

this.PressEnter();
.should("have.value", renameVal);

if (args.willFailError) {
this.AssertContains(args.willFailError, "exist", ".ads-v2-tooltip");
cy.get(textInputLocator).blur();
} else {
cy.get(textInputLocator).blur();
this.PressEnter();
}
this.Sleep();
}

Expand All @@ -257,12 +268,13 @@ export class AggregateHelper {
this.AssertElementVisibility(this.locator._editIcon);
}

public RenameQuery(renameVal: string) {
public RenameQuery(renameVal: string, willFailError?: string) {
this.rename({
nameLocator: this.locator._queryName,
textInputLocator: this.locator._queryNameTxt,
renameVal,
dblClick: true,
willFailError,
});
}

Expand Down Expand Up @@ -937,6 +949,7 @@ export class AggregateHelper {
this.TypeText(selector, totype, index);
}
}

public ClickNClear(selector: string, force = false, index = 0) {
this.GetNClick(selector, index, force);
this.ClearTextField(selector, force, index);
Expand Down
18 changes: 16 additions & 2 deletions app/client/src/workers/Evaluation/__tests__/evaluation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import WidgetFactory from "WidgetProvider/factory";
import { generateDataTreeWidget } from "entities/DataTree/dataTreeWidget";
import { sortObjectWithArray } from "../../../utils/treeUtils";
import klona from "klona";

import { APP_MODE } from "entities/App";

const klonaFullSpy = jest.fn();
Expand All @@ -31,6 +32,17 @@ jest.mock("klona/full", () => ({
return klona.klona(arg);
},
}));
const klonaJsonSpy = jest.fn();

jest.mock("klona/json", () => ({
// TODO: Fix this the next time the file is edited
// eslint-disable-next-line @typescript-eslint/no-explicit-any
klona: (arg: any) => {
klonaJsonSpy(arg);

return klona.klona(arg);
},
}));

export const WIDGET_CONFIG_MAP: WidgetTypeConfigMap = {
CONTAINER_WIDGET: {
Expand Down Expand Up @@ -581,7 +593,8 @@ describe("DataTreeEvaluator", () => {
);
evaluator.evalAndValidateFirstTree();
// Hard check to not regress on the number of clone operations. Try to improve this number.
expect(klonaFullSpy).toBeCalledTimes(41);
expect(klonaFullSpy).toBeCalledTimes(40);
expect(klonaJsonSpy).toBeCalledTimes(3);
});

it("Evaluates a binding in first run", () => {
Expand Down Expand Up @@ -1102,6 +1115,7 @@ describe("DataTreeEvaluator", () => {
unEvalUpdates,
);
// Hard check to not regress on the number of clone operations. Try to improve this number.
expect(klonaFullSpy).toBeCalledTimes(7);
expect(klonaFullSpy).toBeCalledTimes(6);
expect(klonaJsonSpy).toBeCalledTimes(2);
});
});
2 changes: 1 addition & 1 deletion app/client/src/workers/common/DataTreeEvaluator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1059,7 +1059,7 @@ export default class DataTreeEvaluator {
staleMetaIds: string[];
contextTree: DataTree;
} {
const safeTree = klona(unEvalTree);
const safeTree = klonaJSON(unEvalTree);
const dataStore = DataStore.getDataStore();
const dataStoreClone = klonaJSON(dataStore);

Expand Down

0 comments on commit 9f3eebb

Please sign in to comment.