Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: MaintainContext&Focus test #36581

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import reconnectDatasourceModal from "../../../../locators/ReconnectLocators";
import {
agHelper,
apiPage,
dataSources,
homePage,
locators,
} from "../../../../support/Objects/ObjectsCore";
import EditorNavigation, {
PageLeftPane,
EntityType,
} from "../../../../support/Pages/EditorNavigation";

Expand Down Expand Up @@ -36,6 +36,7 @@ describe("MaintainContext&Focus", { tags: ["@tag.IDE"] }, function () {
});

it("1. Focus on different entities", () => {
PageLeftPane.closeAddView();
hetunandu marked this conversation as resolved.
Show resolved Hide resolved
EditorNavigation.SelectEntityByName("Text1", EntityType.Widget, {}, [
"Container1",
]);
Expand All @@ -56,7 +57,7 @@ describe("MaintainContext&Focus", { tags: ["@tag.IDE"] }, function () {
EditorNavigation.SelectEntityByName("Rest_Api_2", EntityType.Api);

cy.wait(1000);
cy.xpath("//span[contains(text(), 'Headers')]").click();
agHelper.GetNClick("//span[contains(text(), 'Headers')]", 0);
cy.updateCodeInput(apiwidget.headerValue, "test");
cy.wait("@saveAction");

Expand Down Expand Up @@ -160,30 +161,7 @@ describe("MaintainContext&Focus", { tags: ["@tag.IDE"] }, function () {
cy.assertCursorOnCodeInput(".js-editor", { ch: 2, line: 2 });
});

it("3. Check if selected tab on right tab persists", () => {
EditorNavigation.SelectEntityByName("Rest_Api_1", EntityType.Api);
apiPage.SelectRightPaneTab("Connections");
EditorNavigation.SelectEntityByName("SQL_Query", EntityType.Query);
EditorNavigation.SelectEntityByName("Rest_Api_1", EntityType.Api);
apiPage.AssertRightPaneSelectedTab("Connections");

//Check if the URL is persisted while switching pages
cy.Createpage("Page2");

EditorNavigation.SelectEntityByName("Page1", EntityType.Page);
EditorNavigation.SelectEntityByName("Rest_Api_1", EntityType.Api);

EditorNavigation.SelectEntityByName("Page2", EntityType.Page);
cy.dragAndDropToCanvas("textwidget", { x: 300, y: 200 });

EditorNavigation.SelectEntityByName("Page1", EntityType.Page);
cy.get(".t--nameOfApi .bp3-editable-text-content").should(
"contain",
"Rest_Api_1",
);
});

it("4. Datasource edit mode has to be maintained", () => {
it("3. Datasource edit mode has to be maintained", () => {
EditorNavigation.SelectEntityByName("Appsmith", EntityType.Datasource);
dataSources.EditDatasource();
EditorNavigation.SelectEntityByName("Github", EntityType.Datasource);
Expand All @@ -192,7 +170,7 @@ describe("MaintainContext&Focus", { tags: ["@tag.IDE"] }, function () {
dataSources.AssertDSEditViewMode("Edit");
});

it("5. Maintain focus of form control inputs", () => {
it("4. Maintain focus of form control inputs", () => {
EditorNavigation.SelectEntityByName("SQL_Query", EntityType.Query);
dataSources.ToggleUsePreparedStatement(false);
EditorNavigation.SelectEntityByName("S3_Query", EntityType.Query);
Expand All @@ -202,14 +180,15 @@ describe("MaintainContext&Focus", { tags: ["@tag.IDE"] }, function () {

EditorNavigation.SelectEntityByName("SQL_Query", EntityType.Query);
cy.get(".bp3-editable-text-content").should("contain.text", "SQL_Query");
cy.get(".t--form-control-SWITCH input").should("be.focused");
cy.xpath(queryLocators.querySettingsTab).click();
agHelper.GetElement(dataSources._usePreparedStatement).should("be.focused");
hetunandu marked this conversation as resolved.
Show resolved Hide resolved
EditorNavigation.SelectEntityByName("S3_Query", EntityType.Query);
agHelper.Sleep();
cy.xpath(queryLocators.querySettingsTab).click();
cy.xpath(queryLocators.queryTimeout).should("be.focused");
});

it("6. Bug 21999 Maintain focus of code editor when Escape is pressed with autcomplete open + Bug 22960", () => {
it("5. Bug 21999 Maintain focus of code editor when Escape is pressed with autcomplete open + Bug 22960", () => {
hetunandu marked this conversation as resolved.
Show resolved Hide resolved
EditorNavigation.SelectEntityByName("JSObject1", EntityType.JSObject);

cy.assertCursorOnCodeInput(".js-editor", { ch: 2, line: 4 });
Expand Down
9 changes: 8 additions & 1 deletion app/client/cypress/support/Pages/IDE/LeftPane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,13 @@ export class LeftPane {
if (!this.segments) {
throw Error("No Segments configured");
}
ObjectsRegistry.AggregateHelper.GetNClick(this.locators.segment(name));
ObjectsRegistry.AggregateHelper.GetElement(
this.locators.segment(name),
).then(($body) => {
if ($body.first().attr("data-selected") !== "true") {
ObjectsRegistry.AggregateHelper.GetNClick(this.locators.segment(name));
}
});
hetunandu marked this conversation as resolved.
Show resolved Hide resolved
}

public selectItem(
Expand Down Expand Up @@ -90,6 +96,7 @@ export class LeftPane {
}
});
}

public selectedItem(
exists?: "exist" | "not.exist" | "noVerify",
): Cypress.Chainable {
Expand Down
Loading