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

test: GitSyncedApps_spec - multiple IA changes #33257

Merged
merged 8 commits into from
May 10, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import EditorNavigation, {
EntityType,
PageLeftPane,
PagePaneSegment,
AppSidebar,
AppSidebarButton,
} from "../../../../../support/Pages/EditorNavigation";

const generatePage = require("../../../../../locators/GeneratePage.json");
Expand Down Expand Up @@ -99,7 +101,7 @@ describe("Git sync apps", { tags: ["@tag.Git"] }, function () {
cy.get("@gitRepoName").then((repName) => {
repoName = repName;
});
table.ReadTableRowColumnData(0, 1).then((cellData) => {
table.ReadTableRowColumnData(0, 1, "v2").then((cellData) => {
expect(cellData).to.be.equal("New Config");
});
// rename page to crud_page
Expand All @@ -109,31 +111,21 @@ describe("Git sync apps", { tags: ["@tag.Git"] }, function () {
false,
EntityItems.Page,
);
EditorNavigation.SelectEntityByName(pageName, EntityType.Page);
// create a clone of page
cy.get(`.t--entity-item:contains(${pageName})`).within(() => {
cy.get(".t--context-menu").click({ force: true });
});
cy.selectAction("Clone");
PageList.ClonePage(pageName);

cy.wait("@clonePage").should(
"have.nested.property",
"response.body.responseMeta.status",
201,
);
PageList.ShowList();
PageLeftPane.assertPresence(`${pageName} Copy`);
table.ReadTableRowColumnData(0, 1).then((cellData) => {
table.ReadTableRowColumnData(0, 1, "v2").then((cellData) => {
expect(cellData).to.be.equal("New Config");
});
});

it("2. Create api queries from api pane and cURL import , bind it to widget and clone page from page settings", () => {
cy.fixture("datasources").then((datasourceFormData) => {
cy.Createpage(newPage);
cy.get(`.t--entity-item:contains(${newPage})`).click();
cy.wait("@getConsolidatedData");
// create a get api call
EditorNavigation.SelectEntityByName(newPage, EntityType.Page);

// create a get api call
apiPage.CreateAndFillApi(datasourceFormData["echoApiUrl"], "get_data");
apiPage.EnterHeader("info", "This is a test");
apiPage.RunAPI();
Expand Down Expand Up @@ -172,17 +164,8 @@ describe("Git sync apps", { tags: ["@tag.Git"] }, function () {
"will be executed automatically on page load",
);
// clone the page from page settings
cy.get(`.t--entity-item:contains(${newPage})`).within(() => {
cy.get(".t--context-menu").click({ force: true });
});
cy.selectAction("Clone");
cy.wait("@clonePage").should(
"have.nested.property",
"response.body.responseMeta.status",
201,
);
cy.get(`.t--entity-item:contains(${newPage} Copy)`).click();
cy.wait("@getConsolidatedData");
PageList.ClonePage(newPage);
EditorNavigation.SelectEntityByName(newPage, EntityType.Page);
});
});

Expand All @@ -199,8 +182,9 @@ describe("Git sync apps", { tags: ["@tag.Git"] }, function () {
.find(".bp3-input")
.invoke("val")
.should("be.oneOf", ["morpheus", "This is a test"]);
cy.get(`.t--entity-item:contains(${newPage})`).first().click();
cy.wait("@getConsolidatedData");

PageList.ShowList();
EditorNavigation.SelectEntityByName(newPage, EntityType.Page);
cy.get(".t--draggable-inputwidgetv2")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you have almost rewitten the test can we make these 2 changes
"inputWidget": ".t--draggable-inputwidgetv2" —> available within Widget.json file
"dataclass": ".bp3-input" —> available in Widget.json file

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NandanAnantharamu sure makes sense! can you share the file please here. i failed to find these

.first()
.find(".bp3-input")
Expand All @@ -210,34 +194,30 @@ describe("Git sync apps", { tags: ["@tag.Git"] }, function () {
.find(".bp3-input")
.should("have.value", "This is a test");

cy.get(`.t--entity-item:contains(${pageName})`).first().click();
cy.wait("@getConsolidatedData");
cy.readTabledataPublish("0", "1").then((cellData) => {
PageList.ShowList();
EditorNavigation.SelectEntityByName(pageName, EntityType.Page);
table.ReadTableRowColumnData(0, 1, "v2").then((cellData) => {
expect(cellData).to.be.equal("New Config");
});

cy.get(`.t--entity-item:contains(${pageName} Copy)`).click();
cy.wait("@getConsolidatedData");
cy.readTabledataPublish("0", "1").then((cellData) => {
PageList.ShowList();
EditorNavigation.SelectEntityByName(`${pageName} Copy`, EntityType.Page);
table.ReadTableRowColumnData(0, 1, "v2").then((cellData) => {
expect(cellData).to.be.equal("New Config");
});
// commit and push the changes
gitSync.CommitAndPush(true);
// verify data binding on all pages in deploy mode
cy.latestDeployPreview();
cy.get(".t--page-switch-tab")
.contains(`${pageName}`)
.click({ force: true });
cy.readTabledataPublish("0", "1").then((cellData) => {
agHelper.GetNClickByContains(locators._deployedPage, pageName);
table.ReadTableRowColumnData(0, 1, "v2").then((cellData) => {
expect(cellData).to.be.equal("New Config");
});
cy.get(".t--page-switch-tab")
.contains(`${pageName} Copy`)
.click({ force: true });
cy.readTabledataPublish("0", "1").then((cellData) => {
agHelper.GetNClickByContains(locators._deployedPage, `${pageName} Copy`);
table.ReadTableRowColumnData(0, 1, "v2").then((cellData) => {
expect(cellData).to.be.equal("New Config");
});
cy.get(".t--page-switch-tab").contains(`${newPage}`).click({ force: true });
agHelper.GetNClickByContains(locators._deployedPage, `${newPage}`);
agHelper.RefreshPage("getConsolidatedData");
cy.get(".bp3-input")
.first()
Expand Down Expand Up @@ -266,7 +246,6 @@ describe("Git sync apps", { tags: ["@tag.Git"] }, function () {
});

it("4. Create a new branch tempBranch, add jsObject and datasource query, move them to new page i.e. Child_Page and bind to widgets", () => {
//cy.createGitBranch(tempBranch);
gitSync.CreateGitBranch(tempBranch, true);
cy.get("@gitbranchName").then((branName) => {
tempBranch = branName;
Expand Down Expand Up @@ -338,21 +317,15 @@ describe("Git sync apps", { tags: ["@tag.Git"] }, function () {
.last()
.invoke("val")
.should("be.oneOf", ["Success", "Test user 7"]);
cy.get(".t--page-switch-tab")
.contains(`${pageName}`)
.click({ force: true });
table.WaitUntilTableLoad();
cy.readTabledataPublish("0", "1").then((cellData) => {
agHelper.GetNClickByContains(locators._deployedPage, `${pageName}`);
table.ReadTableRowColumnData(0, 1, "v2").then((cellData) => {
expect(cellData).to.be.equal("New Config");
});
cy.get(".t--page-switch-tab")
.contains(`${pageName} Copy`)
.click({ force: true });
table.WaitUntilTableLoad();
cy.readTabledataPublish("0", "1").then((cellData) => {
agHelper.GetNClickByContains(locators._deployedPage, `${pageName} Copy`);
table.ReadTableRowColumnData(0, 1, "v2").then((cellData) => {
expect(cellData).to.be.equal("New Config");
});
cy.get(".t--page-switch-tab").contains(`${newPage}`).click({ force: true });
agHelper.GetNClickByContains(locators._deployedPage, `${newPage}`);
cy.get(".bp3-input")
.first()
.invoke("val")
Expand All @@ -361,9 +334,8 @@ describe("Git sync apps", { tags: ["@tag.Git"] }, function () {
.last()
.invoke("val")
.should("be.oneOf", ["morpheus", "This is a test"]);
cy.get(".t--page-switch-tab")
.contains(`${newPage} Copy`)
.click({ force: true });

agHelper.GetNClickByContains(locators._deployedPage, `${newPage} Copy`);
cy.get(".bp3-input")
.first()
.invoke("val")
Expand All @@ -373,46 +345,6 @@ describe("Git sync apps", { tags: ["@tag.Git"] }, function () {
.invoke("val")
.should("be.oneOf", ["morpheus", "This is a test"]);
deployMode.NavigateBacktoEditor();
// verfiy data binding on all pages in edit mode
/* cy.get(".t--draggable-inputwidgetv2").first().find(".bp3-input").should("have.value", "morpheus");
cy.get(".t--draggable-inputwidgetv2")
.last()
.find(".bp3-input")
.should("have.value", "This is a test");
cy.get(`.t--entity-item:contains(Child_Page)`)
.first()
.click();
cy.wait("@getPage");
cy.reload();
cy.wait(3000);
cy.get(".bp3-input")
.first()
.should("have.value", "Success");
cy.get(".bp3-input")
.last()
.should("have.value", "Test user 7");
cy.get(`.t--entity-item:contains(${newPage})`)
.first()
.click();
cy.wait("@getPage");
cy.get(".t--draggable-inputwidgetv2").first().find(".bp3-input").should("have.value", "morpheus");
cy.get(".t--draggable-inputwidgetv2")
.last()
.find(".bp3-input")
.should("have.value", "This is a test");

cy.get(`.t--entity-item:contains(${pageName} Copy)`).click();
cy.wait("@getPage");
cy.readTabledataPublish("0", "1").then((cellData) => {
expect(cellData).to.be.equal("New Config");
});
cy.get(`.t--entity-item:contains(${pageName})`)
.first()
.click();
cy.wait("@getPage");
cy.readTabledataPublish("0", "1").then((cellData) => {
expect(cellData).to.be.equal("New Config");
}); */
});

it("6. Switch to master and verify no uncommitted changes should be shown on master", () => {
Expand All @@ -432,19 +364,17 @@ describe("Git sync apps", { tags: ["@tag.Git"] }, function () {
PageList.ClonePage("Child_Page");
// change cloned page visiblity to hidden
EditorNavigation.SelectEntityByName("Child_Page Copy", EntityType.Page);
entityExplorer.ActionContextMenuByEntityName({
entityNameinLeftSidebar: "Child_Page",
action: "Hide",
});
PageList.HidePage("Child_Page");

EditorNavigation.SelectEntityByName("Child_Page", EntityType.Page);
cy.wait("@getConsolidatedData");
cy.get(homePageLocators.publishButton).click();
cy.get(gitSyncLocators.commitCommentInput).type("Initial Commit");
cy.get(gitSyncLocators.commitButton).click();
cy.get(gitSyncLocators.closeGitSyncModal).click();
cy.merge(mainBranch);
cy.get(gitSyncLocators.closeGitSyncModal).click();

gitSync.MergeToMaster();

cy.latestDeployPreview();
// verify page is hidden on deploy mode
agHelper.AssertContains("Child_Page Copy", "not.exist");
Expand Down
15 changes: 14 additions & 1 deletion app/client/cypress/support/Pages/PageList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import EditorNavigation, {
EntityType,
} from "./EditorNavigation";
import { EntityItems } from "./AssertHelper";
import { PAGE_ENTITY_NAME } from "../../../src/ce/constants/messages";

class PageList {
private locators = {
Expand All @@ -15,6 +16,8 @@ class PageList {
switcher: `.t--pages-switcher`,
};

public DefaultPageName = PAGE_ENTITY_NAME + "1";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cant you just use getNextEntityName to generate this? Why are we manually setting this up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes done!

Copy link
Contributor Author

@ApekshaBhosale ApekshaBhosale May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trishaanand i don't think we can do this. i am getting an error regarding dependecy https://github.com/appsmithorg/appsmith-ee/actions/runs/9000139783/job/24724479656

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok.


public AddNewPage(
option:
| "New blank page"
Expand Down Expand Up @@ -50,7 +53,7 @@ class PageList {
this.HideList();
}

public ClonePage(pageName = "Page1") {
public ClonePage(pageName = this.DefaultPageName) {
AppSidebar.navigate(AppSidebarButton.Editor);
EditorNavigation.SelectEntityByName(pageName, EntityType.Page);
ObjectsRegistry.EntityExplorer.ActionContextMenuByEntityName({
Expand Down Expand Up @@ -112,6 +115,16 @@ class PageList {
.should("eq", 200);
this.HideList();
}

public HidePage(pageName = this.DefaultPageName) {
AppSidebar.navigate(AppSidebarButton.Editor);
EditorNavigation.SelectEntityByName(pageName, EntityType.Page);
ObjectsRegistry.EntityExplorer.ActionContextMenuByEntityName({
entityNameinLeftSidebar: pageName,
action: "Hide",
entityType: EntityItems.Page,
});
}
}

export default new PageList();
2 changes: 1 addition & 1 deletion app/client/cypress/support/gitSync.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Cypress.Commands.add("latestDeployPreview", () => {
window.location.target = "_self";
});
});
cy.get(gitSyncLocators.bottomBarCommitButton).click();
agHelper.GetNClick(gitSync._bottomBarCommit);
cy.wait(2000); // wait for modal to load
cy.xpath("//span[text()='Latest deployed preview']").click();
cy.log("pagename: " + localStorage.getItem("PageName"));
Expand Down
2 changes: 2 additions & 0 deletions app/client/src/ce/constants/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2498,3 +2498,5 @@ export const EMPTY_CANVAS_HINTS = {
export const BETA_TAG = () => `Beta`;

export const BUTTON_WIDGET_DEFAULT_LABEL = () => "Do something";

export const PAGE_ENTITY_NAME = "Page";
3 changes: 2 additions & 1 deletion app/client/src/pages/Editor/IDE/EditorPane/PagesSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { getCurrentWorkspaceId } from "@appsmith/selectors/selectedWorkspaceSele
import { getInstanceId } from "@appsmith/selectors/tenantSelectors";
import { PageElement } from "pages/Editor/IDE/EditorPane/components/PageElement";
import { IDEHeaderDropdown } from "IDE";
import { PAGE_ENTITY_NAME } from "@appsmith/constants/messages";

const PagesSection = ({ onItemSelected }: { onItemSelected: () => void }) => {
const dispatch = useDispatch();
Expand All @@ -42,7 +43,7 @@ const PagesSection = ({ onItemSelected }: { onItemSelected: () => void }) => {

const createPageCallback = useCallback(() => {
const name = getNextEntityName(
"Page",
PAGE_ENTITY_NAME,
pages.map((page: Page) => page.pageName),
);
dispatch(
Expand Down
Loading