test: GitSyncedApps_spec - multiple IA changes (#33257)

## Description
In this spec, IA changes were required.
1. table version change ---
https://github.com/appsmithorg/appsmith/pull/29457
2. page related functionalities addition and replacement ie clone, hide
and show list to assert a page name
3. replaced as many as possible git related functionalities to gitSync
helpers


Link - **9th Spec** in
https://www.notion.so/appsmith/Cypress-tests-analysis-4090efa5e3064a2e87f262d3c399a339
**Phase 1**

EE - PR for runs -https://github.com/appsmithorg/appsmith-ee/pull/4140
EE run -- for Git and AccessControl tags
https://github.com/appsmithorg/appsmith-ee/actions/runs/9002744046


Fixes #`Issue Number`  
_or_  
Fixes `Issue URL`
> [!WARNING]  
> _If no issue exists, please create an issue first, and check with the
maintainers if the issue is valid._

## Automation

/ok-to-test tags=""

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!CAUTION]  
> If you modify the content in this section, you are likely to disrupt
the CI result for your PR.

<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No
This commit is contained in:
Apeksha Bhosale 2024-05-10 15:34:40 +05:30 committed by GitHub
parent abbf3264a3
commit d88b43165f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 75 additions and 129 deletions

View File

@ -2,6 +2,8 @@ import EditorNavigation, {
EntityType,
PageLeftPane,
PagePaneSegment,
AppSidebar,
AppSidebarButton,
} from "../../../../../support/Pages/EditorNavigation";
const generatePage = require("../../../../../locators/GeneratePage.json");
@ -10,6 +12,7 @@ const dynamicInputLocators = require("../../../../../locators/DynamicInput.json"
import gitSyncLocators from "../../../../../locators/gitSyncLocators";
import homePageLocators from "../../../../../locators/HomePage";
import datasource from "../../../../../locators/DatasourcesEditor.json";
import widgetsPage from "../../../../../locators/Widgets.json";
import {
agHelper,
@ -99,7 +102,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
@ -109,20 +112,11 @@ 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");
});
});
@ -130,10 +124,9 @@ describe("Git sync apps", { tags: ["@tag.Git"] }, function () {
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();
@ -172,89 +165,77 @@ 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);
});
});
it("3. Commit and push changes, validate data binding on all pages in edit and deploy mode on master", () => {
// verfiy data binding on all pages in edit mode
cy.get(".t--draggable-inputwidgetv2").should("be.visible");
cy.get(".t--draggable-inputwidgetv2")
cy.get(widgetsPage.inputWidget).should("be.visible");
cy.get(widgetsPage.inputWidget)
.first()
.find(".bp3-input")
.find(widgetsPage.dataclass)
.invoke("val")
.should("be.oneOf", ["morpheus", "This is a test"]);
cy.get(".t--draggable-inputwidgetv2")
cy.get(widgetsPage.inputWidget)
.last()
.find(".bp3-input")
.find(widgetsPage.dataclass)
.invoke("val")
.should("be.oneOf", ["morpheus", "This is a test"]);
cy.get(`.t--entity-item:contains(${newPage})`).first().click();
cy.wait("@getConsolidatedData");
cy.get(".t--draggable-inputwidgetv2")
PageList.ShowList();
EditorNavigation.SelectEntityByName(newPage, EntityType.Page);
cy.get(widgetsPage.inputWidget)
.first()
.find(".bp3-input")
.find(widgetsPage.dataclass)
.should("have.value", "morpheus");
cy.get(".t--draggable-inputwidgetv2")
cy.get(widgetsPage.inputWidget)
.last()
.find(".bp3-input")
.find(widgetsPage.dataclass)
.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")
cy.get(widgetsPage.dataclass)
.first()
.invoke("val")
.should("be.oneOf", ["morpheus", "This is a test"]);
cy.get(".bp3-input")
cy.get(widgetsPage.dataclass)
.last()
.invoke("val")
.should("be.oneOf", ["morpheus", "This is a test"]);
cy.get(".t--page-switch-tab")
.contains(`${newPage} Copy`)
.click({ force: true });
cy.get(".bp3-input")
cy.get(widgetsPage.dataclass)
.first()
.invoke("val")
.should("be.oneOf", ["morpheus", "This is a test"]);
cy.get(".bp3-input")
cy.get(widgetsPage.dataclass)
.last()
.invoke("val")
.should("be.oneOf", ["morpheus", "This is a test"]);
@ -266,7 +247,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;
@ -329,90 +309,43 @@ describe("Git sync apps", { tags: ["@tag.Git"] }, function () {
cy.get(gitSyncLocators.closeGitSyncModal).click();
// verfiy data binding on all pages in deploy mode
cy.latestDeployPreview();
cy.get(".bp3-input").should("be.visible");
cy.get(".bp3-input")
cy.get(widgetsPage.dataclass).should("be.visible");
cy.get(widgetsPage.dataclass)
.first()
.invoke("val")
.should("be.oneOf", ["Success", "Test user 7"]);
cy.get(".bp3-input")
cy.get(widgetsPage.dataclass)
.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 });
cy.get(".bp3-input")
agHelper.GetNClickByContains(locators._deployedPage, `${newPage}`);
cy.get(widgetsPage.dataclass)
.first()
.invoke("val")
.should("be.oneOf", ["morpheus", "This is a test"]);
cy.get(".bp3-input")
cy.get(widgetsPage.dataclass)
.last()
.invoke("val")
.should("be.oneOf", ["morpheus", "This is a test"]);
cy.get(".t--page-switch-tab")
.contains(`${newPage} Copy`)
.click({ force: true });
cy.get(".bp3-input")
agHelper.GetNClickByContains(locators._deployedPage, `${newPage} Copy`);
cy.get(widgetsPage.dataclass)
.first()
.invoke("val")
.should("be.oneOf", ["morpheus", "This is a test"]);
cy.get(".bp3-input")
cy.get(widgetsPage.dataclass)
.last()
.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", () => {
@ -432,10 +365,7 @@ 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");
@ -443,8 +373,9 @@ describe("Git sync apps", { tags: ["@tag.Git"] }, function () {
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");

View File

@ -5,7 +5,7 @@ import EditorNavigation, {
EntityType,
} from "./EditorNavigation";
import { EntityItems } from "./AssertHelper";
import { PAGE_ENTITY_NAME } from "../../../src/ce/constants/messages";
class PageList {
private locators = {
pageListItem: (pageName: string) =>
@ -15,6 +15,8 @@ class PageList {
switcher: `.t--pages-switcher`,
};
public DefaultPageName = PAGE_ENTITY_NAME + "1";
public AddNewPage(
option:
| "New blank page"
@ -50,7 +52,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({
@ -113,6 +115,16 @@ class PageList {
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,
});
}
assertAbsenceOfAddPage() {
this.ShowList();
ObjectsRegistry.AggregateHelper.AssertElementAbsence(

View File

@ -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"));

View File

@ -2499,3 +2499,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";

View File

@ -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();
@ -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(