Skip to content

Commit

Permalink
test: Cypress | Helpers improved + Flaky fixes (#30735)
Browse files Browse the repository at this point in the history
## Description
- This PR fixes the RenameApplication flakyness in CI with added dynamic
check
- Also replacing js cy.renameApp to TS helper 
- Flaky fixes -
cypress/e2e/Regression/ClientSide/Workspace/MemberRoles_Spec.ts (entire
spec updates for EnableGAC, removed signout from 'it' blocks)
- cypress/e2e/Regression/ClientSide/Workspace/ShareAppTests_Spec.ts (7th
flaky fixed)
-
cypress/e2e/Regression/ClientSide/SetProperty/WidgetPropertySetters2_spec.ts
(5th test)
-
cypress/e2e/Regression/ClientSide/Templates/Fork_Template_Existing_app_spec.js
(2nd - added validation to match the test description, 1st & 3rd -
removed static waits, Added multiple dynamic checks)
-
cypress/e2e/Regression/ClientSide/OtherUIFeatures/ApplicationURL_spec.js
(3rd & 4th flaky tests)
- homePage.AssertViewPageLoad() created
- homePage.LaunchAppFromAppHover() improved
- homePage.Signout() - added dynamic checks
- Added more validation to homePage.Signup() method with Dynamic checks
- homePage.LeaveWorkspace() removed redundant SelectWorkspace call
- admingSettings.EnableGAC() - added dynamic checks
- featureFlagIntercept - removed static sleep, reload check improved
- agHelper.VisitNAssert() - removed static sleep
- homePage.OpenMembersPageForWorkspace() - removed sleep, added dynamic
checks

#### Type of change
- Script fix (non-breaking change which fixes an issue)

## Testing
#### How Has This Been Tested?
- [X] Cypress CI runs

## Checklist:
#### QA activity:
- [X] Added `Test Plan Approved` label after Cypress tests were reviewed

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

## Summary by CodeRabbit

- **Refactor**
- Enhanced Cypress test commands across multiple test suites for
improved efficiency and readability.
- Refactored conditional checks and method invocations for better test
scenario handling.
- **Tests**
- Updated testing approaches for application deployment, workspace
management, and error handling.
- Introduced new assertions for UI visibility and functional behavior in
automated tests.
- **Chores**
- Optimized GitHub Actions workflow by adjusting the matrix count for
build processes.
- Added new test specs for limited tests in the client-side regression
suite.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
Aishwarya-U-R authored Feb 1, 2024
1 parent 5d6e07a commit 67d20d9
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 155 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe("Slug URLs", () => {
cy.generateUUID().then((appName) => {
applicationName = appName;
homePage.RenameApplication(applicationName);
assertHelper.AssertNetworkStatus("updateApplication");
cy.location("pathname").then((pathname) => {
const pageId = pathname.split("/")[3]?.split("-").pop();
expect(pathname).to.be.equal(`/app/${appName}/page1-${pageId}/edit`);
Expand Down Expand Up @@ -84,21 +83,23 @@ describe("Slug URLs", () => {
});
entityExplorer.DragDropWidgetNVerify(draggableWidgets.TEXT);

cy.updateCodeInput(
".t--property-control-text",
`{{appsmith.URL.pathname}}`,
propPane.UpdatePropertyFieldValue(
"Text",
"{{appsmith.URL.pathname}}",
);

cy.get(".t--draggable-textwidget .bp3-ui-text").should(
"contain.text",
`/applications/${application.id}/pages/${currentPageId}/edit`,
);

cy.get(".t--upgrade").click({ force: true });
agHelper.GetNClick(".t--upgrade");

cy.get(".t--upgrade-confirm").click({ force: true });
agHelper.ClickButton("Update");

cy.wait("@getConsolidatedData").then((intercept) => {
assertHelper.AssertNetworkStatus("getConsolidatedData");

cy.get("@getConsolidatedData").then((intercept) => {
const { application, pages } =
intercept.response.body.data.pages.data;

Expand All @@ -109,7 +110,9 @@ describe("Slug URLs", () => {
`/app/${application.slug}/${currentPage.slug}-${currentPage.id}`,
);
});

agHelper.AssertElementVisibility(
locators._widgetInCanvas(draggableWidgets.TEXT),
);
cy.get(".t--draggable-textwidget .bp3-ui-text").should(
"contain.text",
`/app/${application.slug}/${currentPage.slug}-${currentPage.id}/edit`,
Expand All @@ -124,6 +127,9 @@ describe("Slug URLs", () => {
`/app/${application.slug}/${currentPage.slug}-${currentPage.id}/edit`,
);
});
agHelper.AssertElementVisibility(
locators._widgetInCanvas(draggableWidgets.TEXT),
);
});
});
});
Expand All @@ -133,7 +139,7 @@ describe("Slug URLs", () => {
it("4. Checks redirect url", () => {
cy.url().then((url) => {
homePage.Signout(true);
agHelper.VisitNAssert(url + "?embed=true&a=b", "getConsolidatedData");
agHelper.VisitNAssert(url + "?embed=true&a=b"); //removing 'getConsolidatedData' api check due to its flakyness
agHelper.AssertURL(
`?redirectUrl=${encodeURIComponent(url + "?embed=true&a=b")}`,
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,10 +174,7 @@ describe(
false,
);
jsEditor.EnableDisableAsyncFuncSettings("myFun1", true, false);
deployMode.DeployApp();
agHelper.AssertElementVisibility(
locators._widgetInDeployed(draggableWidgets.BUTTON), //Asserting before setTimeout JS function execution, button is visible
);
deployMode.DeployApp(locators._widgetInDeployed(draggableWidgets.BUTTON)); //Asserting before setTimeout JS function execution, button is visible
agHelper.Sleep(2000); //waiting for settimeout to execute
agHelper.AssertElementAbsence(
locators._widgetInDeployed(draggableWidgets.BUTTON),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import widgetLocators from "../../../../locators/Widgets.json";
import template from "../../../../locators/TemplatesLocators.json";
import { agHelper, templates } from "../../../../support/Objects/ObjectsCore";
import {
agHelper,
assertHelper,
locators,
templates,
} from "../../../../support/Objects/ObjectsCore";
import EditorNavigation, {
EntityType,
} from "../../../../support/Pages/EditorNavigation";
Expand All @@ -23,13 +28,15 @@ describe(
it("1. Fork template from page section", () => {
//Fork template button to be visible always
PageList.AddNewPage("Add page from template");
agHelper.Sleep(5000);
agHelper.AssertElementExist(template.templateDialogBox);
agHelper.AssertElementVisibility(template.templateDialogBox);
agHelper.AssertElementVisibility(templates.locators._templateCard);
agHelper.Sleep(4000);
agHelper.AssertElementVisibility(template.vehicleMaintenenceApp);
agHelper.GetNClick(template.vehicleMaintenenceApp);
agHelper.WaitUntilEleDisappear("//*[text()='Loading template details']");
agHelper.Sleep();
agHelper.AssertElementAbsence(
"//*[text()='Loading template details']",
Cypress.config().pageLoadTimeout,
);
agHelper.FailIfErrorToast(
"Internal server error while processing request",
);
Expand All @@ -40,60 +47,46 @@ describe(
}
}
});
cy.get(widgetLocators.toastAction).should(
"contain",
"template added successfully",
agHelper.AssertElementAbsence(
locators._visibleTextSpan("Setting up the template"),
Cypress.config().pageLoadTimeout,
);
agHelper.ValidateToastMessage("template added successfully");
agHelper.AssertElementVisibility(locators._itemContainerWidget);
agHelper.WaitUntilAllToastsDisappear();
});

it("2. Add selected page of template from page section", () => {
PageList.AddNewPage("Add page from template");
agHelper.AssertElementVisibility(template.templateDialogBox);
agHelper.AssertElementVisibility(
templates.locators._templateCard,
true,
0,
30000,
);
agHelper.AssertElementVisibility(templates.locators._templateCard);
agHelper.AssertElementVisibility(template.vehicleMaintenenceApp);
agHelper.GetNClick(template.vehicleMaintenenceApp);
//agHelper.WaitUntilEleDisappear("//*[text()='Loading template details']");
cy.wait("@getTemplatePages").should(
"have.nested.property",
"response.body.responseMeta.status",
200,
agHelper.AssertElementAbsence(
"//*[text()='Loading template details']",
Cypress.config().pageLoadTimeout,
);

//cy.xpath(template.selectAllPages).next().click();
// cy.xpath("//span[text()='CALENDAR MOBILE']").parent().next().click();
agHelper.GetNClick(template.templateViewForkButton);
cy.wait("@fetchTemplate").should(
"have.nested.property",
"response.body.responseMeta.status",
200,
assertHelper.AssertNetworkStatus("getTemplatePages");
agHelper.CheckUncheck(template.selectAllPages, false);
agHelper.CheckUncheck(
"div:has(> span:contains('New vehicle')) + label input[type='checkbox']",
);
agHelper.GetNAssertElementText(
widgetLocators.toastAction,
"template added successfully",
"contain.text",
agHelper.GetNClick(template.templateViewForkButton);
agHelper.AssertElementAbsence(
locators._visibleTextSpan("Setting up the template"),
Cypress.config().pageLoadTimeout,
);
assertHelper.AssertNetworkStatus("fetchTemplate");
agHelper.WaitUntilToastDisappear("template added successfully");
agHelper.AssertElementVisibility(locators._itemContainerWidget);
});

it("3. Templates card should take user to 'select pages from template' page", () => {
//agHelper.RefreshPage();

PageList.AddNewPage("Add page from template");
agHelper.AssertElementVisibility(
templates.locators._templateCard,
true,
0,
30000,
);
agHelper.AssertElementVisibility(templates.locators._templateCard);
agHelper.GetNClick(templates.locators._templateCard);
agHelper.Sleep(2000);
agHelper.AssertElementVisibility(template.templateViewForkButton);
agHelper.Sleep(2000);
agHelper.GetNClick(templates.locators._closeTemplateDialogBoxBtn);
agHelper.Sleep();

//Similar templates add icon should take user to 'select pages from template'
//agHelper.RefreshPage();
Expand All @@ -102,9 +95,7 @@ describe(
agHelper.GetNClick(templates.locators._templateCard);
// Here we are on template detail page, with similar templates at the bottom
agHelper.GetNClick(templates.locators._templateCard);
agHelper.Sleep(2000);
agHelper.AssertElementVisibility(template.templateViewForkButton);
agHelper.Sleep(2000);
agHelper.GetNClick(templates.locators._closeTemplateDialogBoxBtn);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,8 @@ describe("Migration Validate", { tags: ["@tag.ImportExport"] }, function () {
//Renaming imported app!
const uuid = () => Cypress._.random(0, 1e4);
const name = uuid();
cy.wait(2000);
cy.AppSetupForRename();
cy.get(homePage.applicationName).type(`app${name}`);
homePageHelpers.RenameApplication(`app${name}`);
cy.wrap(`app${name}`).as("appname");
cy.wait(2000);

// Validating data binding for the imported application - Page1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ describe(
{ tags: ["@tag.Workspace"] },
() => {
it("1. Create new Workspace, Share with a user from UI & verify", () => {
_.adminSettings.EnableGAC(true, true);
if (CURRENT_REPO === REPO.EE) _.adminSettings.EnableGAC(true, false);
_.agHelper.GenerateUUID();
cy.get("@guid").then((uid) => {
workspaceId = uid;
appid = uid;
_.homePage.CreateNewWorkspace(workspaceId);
_.homePage.CreateNewWorkspace(workspaceId, true);
_.homePage.CheckWorkspaceShareUsersCount(workspaceId, 1);
_.homePage.InviteUserToWorkspaceErrorMessage(workspaceId, "abcdef");
cy.visit("/applications", { timeout: 60000 });
Expand All @@ -27,12 +27,11 @@ describe(
_.homePage.CheckWorkspaceShareUsersCount(workspaceId, 2);
_.homePage.CreateAppInWorkspace(workspaceId, appid);
});
_.homePage.LogOutviaAPI();
});

it("2. Login as Administrator and search for users using search bar", () => {
_.homePage.LogintoApp(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
_.adminSettings.EnableGAC(false, true);
if (CURRENT_REPO === REPO.EE) _.adminSettings.EnableGAC(false, true);
_.homePage.SelectWorkspace(workspaceId);
_.agHelper.GetNClick(_.homePage._shareWorkspace(workspaceId));
_.agHelper.GetNClick(_.homePage._visibleTextSpan("Manage users"));
Expand All @@ -44,7 +43,6 @@ describe(
cy.get(".search-highlight")
.should("exist")
.contains(Cypress.env("TESTUSERNAME1"));
_.homePage.Signout();
});

it("3. Login as Invited user and validate Viewer role", function () {
Expand All @@ -53,8 +51,8 @@ describe(
Cypress.env("TESTPASSWORD1"),
"App Viewer",
);
_.adminSettings.EnableGAC(false, true, "home");
_.agHelper.RefreshPage();
if (CURRENT_REPO === REPO.EE)
_.adminSettings.EnableGAC(false, true, "home");
_.homePage.SelectWorkspace(workspaceId);
cy.get(_.homePage._applicationCard).first().trigger("mouseover");
cy.get(_.homePage._appHoverIcon("edit")).should("not.exist");
Expand All @@ -67,22 +65,19 @@ describe(
.should("have.length", 1)
.and("contain.text", `App Viewer`);
_.agHelper.GetNClick(HomePage.closeBtn);
_.homePage.LaunchAppFromAppHover();
//_.deployMode.NavigateToHomeDirectly();
_.homePage.Signout(false);
_.homePage.LaunchAppFromAppHover(_.locators._emptyPageTxt);
});

it("4. Login as Workspace owner and Update the Invited user role to Developer", function () {
_.homePage.LogintoApp(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
_.adminSettings.EnableGAC(false, true);
if (CURRENT_REPO === REPO.EE) _.adminSettings.EnableGAC(false, true);
_.homePage.SelectWorkspace(workspaceId);
_.homePage.UpdateUserRoleInWorkspace(
workspaceId,
Cypress.env("TESTUSERNAME1"),
"App Viewer",
"Developer",
);
_.homePage.Signout();
});

it("5. Login as Invited user and validate Developer role", function () {
Expand All @@ -91,7 +86,8 @@ describe(
Cypress.env("TESTPASSWORD1"),
"Developer",
);
_.adminSettings.EnableGAC(false, true, "home");
if (CURRENT_REPO === REPO.EE)
_.adminSettings.EnableGAC(false, true, "home");
_.homePage.SelectWorkspace(workspaceId);
cy.get(_.homePage._applicationCard).first().trigger("mouseover");
_.agHelper.AssertElementExist(_.homePage._appHoverIcon("edit"));
Expand All @@ -114,21 +110,18 @@ describe(

_.agHelper.GetNClick(HomePage.closeBtn);
_.agHelper.GetNClick(_.homePage._appHoverIcon("edit"));

_.homePage.Signout();
});

it("6. Login as Workspace owner and Update the Invited user role to Administrator", function () {
_.homePage.LogintoApp(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
_.adminSettings.EnableGAC(false, true);
if (CURRENT_REPO === REPO.EE) _.adminSettings.EnableGAC(false, true);
_.homePage.SelectWorkspace(workspaceId);
_.homePage.UpdateUserRoleInWorkspace(
workspaceId,
Cypress.env("TESTUSERNAME1"),
"Developer",
"Administrator",
);
_.homePage.Signout();
});

it("7. Login as Invited user and validate Administrator role", function () {
Expand All @@ -137,11 +130,13 @@ describe(
Cypress.env("TESTPASSWORD1"),
"Administrator",
);
_.adminSettings.EnableGAC(false, true, "home");
if (CURRENT_REPO === REPO.EE)
_.adminSettings.EnableGAC(false, true, "home");
_.homePage.InviteUserToWorkspace(
workspaceId,
Cypress.env("TESTUSERNAME2"),
"App Viewer",
false,
);
_.agHelper.GetNClick(HomePage.closeBtn);
_.agHelper.Sleep();
Expand Down Expand Up @@ -169,13 +164,11 @@ describe(
cy.get(".rc-select-item-option").should("contain.text", `Administrator`);
_.agHelper.GetNClick(HomePage.closeBtn);
_.agHelper.GetNClick(_.homePage._appHoverIcon("edit"));

_.homePage.Signout();
});

it("8. Login as Workspace owner and verify all 3 users are present", function () {
_.homePage.LogintoApp(Cypress.env("USERNAME"), Cypress.env("PASSWORD"));
_.adminSettings.EnableGAC(false, true);
if (CURRENT_REPO === REPO.EE) _.adminSettings.EnableGAC(false, true);
_.homePage.SelectWorkspace(workspaceId);
_.homePage.UpdateUserRoleInWorkspace(
workspaceId,
Expand All @@ -200,9 +193,9 @@ describe(
Cypress.env("TESTUSERNAME1"),
Cypress.env("TESTPASSWORD1"),
);
_.adminSettings.EnableGAC(false, true, "home");
if (CURRENT_REPO === REPO.EE)
_.adminSettings.EnableGAC(false, true, "home");
_.homePage.LeaveWorkspace(workspaceId);
_.homePage.Signout();
});

it("10. Login as App Viewer, Verify leave workspace flow", () => {
Expand All @@ -211,10 +204,10 @@ describe(
Cypress.env("TESTPASSWORD2"),
"App Viewer",
);
_.adminSettings.EnableGAC(false, true, "home");
if (CURRENT_REPO === REPO.EE)
_.adminSettings.EnableGAC(false, true, "home");
_.homePage.SelectWorkspace(workspaceId);
_.homePage.LeaveWorkspace(workspaceId);
_.homePage.LogOutviaAPI();
});
},
);
Loading

0 comments on commit 67d20d9

Please sign in to comment.