Skip to content

Commit

Permalink
fix: locators fix
Browse files Browse the repository at this point in the history
  • Loading branch information
albinAppsmith committed Nov 1, 2024
1 parent 83a6965 commit 926a951
Show file tree
Hide file tree
Showing 13 changed files with 18 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe(
dataSources.EnterQuery("select * from users");

cy.EvaluateCurrentValue("select * from users");
cy.get(".t--action-name-edit-field").click({ force: true });

cy.get("@saveDatasource").then((httpResponse) => {
datasourceName = httpResponse.response.body.data.name;
PageLeftPane.switchSegment(PagePaneSegment.Queries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ describe(
dataSources.EnterQuery("select * from users");

cy.EvaluateCurrentValue("select * from users");
cy.get(".t--action-name-edit-field").click({ force: true });

entityExplorer.ActionContextMenuByEntityName({
entityNameinLeftSidebar: "Query1",
action: "Show bindings",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,7 @@ describe(
_.dataSources.CreateDataSource("Postgres");
_.dataSources.CreateQueryAfterDSSaved();

// Click the editing field
cy.get(".t--action-name-edit-field").click({ force: true });

// Click the editing field
cy.get(queryLocators.queryNameField).type("Query1");
_.agHelper.RenameQuery("Query1");

// switching off Use Prepared Statement toggle
_.dataSources.ToggleUsePreparedStatement(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,13 +189,8 @@ describe(
_.dataSources.CreateDataSource("Postgres");
cy.wait(1000);
_.dataSources.CreateQueryAfterDSSaved();
// Click the editing field
cy.get(".t--action-name-edit-field").click({
force: true,
});

// Click the editing field
cy.get(queryLocators.queryNameField).type("Query2");
_.agHelper.RenameQuery("Query2");

// switching off Use Prepared Statement toggle
_.dataSources.ToggleUsePreparedStatement(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ describe(
);
_.dataSources.ToggleUsePreparedStatement(false);
cy.wait("@saveAction");
cy.get(".t--run-query").click();
cy.get(_.dataSources._runQueryBtn).click();
cy.wait("@postExecute");
PageLeftPane.switchSegment(PagePaneSegment.UI);
cy.openPropertyPane("tablewidgetv2");
Expand Down
1 change: 0 additions & 1 deletion app/client/cypress/locators/ApiEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export default {
createBlankApiCard: ".t--createBlankApiCard",
eachProviderCard: ".t--eachProviderCard",
nameOfApi: ".t--nameOfApi",
ApiNameField: ".t--action-name-edit-field",
addToPageBtn: ".t--addToPageBtn",
ApiActionMenu: "[data-testid=\"t--more-action-trigger\"]",
ApiDeleteBtn: ".t--apiFormDeleteBtn",
Expand Down
2 changes: 1 addition & 1 deletion app/client/cypress/locators/JSEditor.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"runButton": ".run-js-action",
"runButton": "[data-testid='t--run-js-action']",
"editNameField": ".bp3-editable-text-input",
"outputConsole": ".CodeEditorTarget",
"jsObjectName": ".t--action-name-edit-field",
Expand Down
8 changes: 4 additions & 4 deletions app/client/cypress/support/ApiCommands.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ObjectsRegistry } from "./Objects/Registry";
let agHelper = ObjectsRegistry.AggregateHelper;
let dataSources = ObjectsRegistry.DataSources;
let apiPage = ObjectsRegistry.ApiPage;
let locator = ObjectsRegistry.CommonLocators;

export const initLocalstorage = () => {
cy.window().then((window) => {
Expand Down Expand Up @@ -191,11 +192,10 @@ Cypress.Commands.add("createAndFillApi", (url, parameters) => {
dataSources.NavigateToDSCreateNew();
cy.testCreateApiButton();
cy.get("@createNewApi").then((response) => {
cy.get(ApiEditor.ApiNameField).should("be.visible");
cy.get(locator._queryName).should("be.visible");
expect(response.response.body.responseMeta.success).to.eq(true);
cy.get(ApiEditor.ApiNameField)
.click()
.invoke("text")
cy.get(locator._queryName)
.invoke('text')
.then((text) => {
const someText = text;
expect(someText).to.equal(response.response.body.data.name);
Expand Down
2 changes: 1 addition & 1 deletion app/client/cypress/support/Pages/DataSources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export class DataSources {
"']";
_activeDSListReconnectModal = (dbName: string) =>
"//div[contains(@class, 't--ds-list')]//span[text()='" + dbName + "']";
_runQueryBtn = ".t--run-query";
_runQueryBtn = "[data-testid='t--run-action']";
_newDatabases = "#new-datasources";
_newDatasourceContainer = "#new-integrations-wrapper";
_selectDatasourceDropdown = "[data-testid=t--datasource-dropdown]";
Expand Down
13 changes: 4 additions & 9 deletions app/client/cypress/support/Pages/JSEditor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class JSEditor {
private assertHelper = ObjectsRegistry.AssertHelper;

//#region Element locators
_runButton = "button.run-js-action";
_runButton = "[data-testid='t--run-js-action']";
_settingsTab = "//span[text()='Settings']/parent::button";
_codeTab = "//span[text()='Code']/parent::button";
private _jsObjectParseErrorCallout =
Expand All @@ -43,8 +43,8 @@ export class JSEditor {
private _onPageLoadSwitchStatus = (functionName: string) =>
`//div[contains(@class, '${functionName}-on-page-load-setting')]//label/input`;

private _jsObjName = ".t--js-action-name-edit-field span";
public _jsObjTxt = ".t--js-action-name-edit-field input";
private _jsObjName = ".editor-tab.active > .ads-v2-text";
public _jsObjTxt = ".editor-tab.active > .ads-v2-text input";
public _newJSobj = "span:contains('New JS object')";
private _bindingsClose = ".t--entity-property-close";
public _propertyList = ".binding";
Expand Down Expand Up @@ -113,11 +113,6 @@ export class JSEditor {
);
//Checking JS object was created successfully
this.assertHelper.AssertNetworkStatus("@createNewJSCollection", 201);
this.agHelper.AssertElementVisibility(this._jsObjTxt);
// Assert that the name of the JS Object is focused when newly created
this.agHelper.PressEnter();
this.agHelper.PressEnter();
// Assert that the name of the JS Object is no longer in the editable form after pressing "enter"
this.agHelper.AssertElementAbsence(this._jsObjTxt);

this.agHelper.Sleep();
Expand Down Expand Up @@ -212,7 +207,7 @@ export class JSEditor {
}

public RenameJSObjFromPane(renameVal: string) {
cy.get(this._jsObjName).click({ force: true });
cy.get(this._jsObjName).dblclick({ force: true });
cy.get(this._jsObjTxt)
.clear()
.type(renameVal, { force: true })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const JSFunctionRun = (props: Props) => {
>
<Button
className={testLocators.runJSAction}
data-testid={testLocators.runJSActionTestID}
isDisabled={props.disabled}
isLoading={props.isLoading}
onClick={props.onButtonClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export function JSFunctionRun({
<span>
<Button
className={testLocators.runJSAction}
data-testid={testLocators.runJSActionTestID}
isDisabled={disabled}
isLoading={isLoading}
onClick={onButtonClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export const RUN_BUTTON_DEFAULTS = {
};
export const testLocators = {
runJSAction: "run-js-action",
runJSActionTestID: "t--run-js-action",
};
export const NO_FUNCTION_DROPDOWN_OPTION = {
label: "No function available",
Expand Down

0 comments on commit 926a951

Please sign in to comment.