> Pull Request Template > > Use this template to quickly create a well written pull request. Delete all quotes before creating the pull request. > ## Description > Add a TL;DR when description is extra long (helps content team) > > Please include a summary of the changes and which issue has been fixed. Please also include relevant motivation > and context. List any dependencies that are required for this change > > Links to Notion, Figma or any other documents that might be relevant to the PR > > #### PR fixes following issue(s) Fixes # (issue number) > if no issue exists, please create an issue and ask the maintainers about this first > > #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### Type of change > Please delete options that are not relevant. - Bug fix (non-breaking change which fixes an issue) - New feature (non-breaking change which adds functionality) - Breaking change (fix or feature that would cause existing functionality to not work as expected) - Chore (housekeeping or task changes that don't impact user perception) - This change requires a documentation update > > > ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [ ] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Added new workspace search functionality in the search bar. - Introduced a help button for user assistance. - Implemented new UI components for workspace selection and management. - Enhanced application card with edit permission checks. - Integrated workspace actions for creating and fetching workspaces directly from the UI. - **Improvements** - Improved workspace and application fetching logic. - Enhanced Global Search with updated import paths and logic. - Refined the layout and styling of the applications page and sub-header components. - Optimized workspace-related sagas and reducers for better performance and maintainability. - **Bug Fixes** - Fixed tooltip functionality in "Reconnect Datasources" within templates. - Corrected test logic for forking templates and applications. - Updated Cypress test commands for consistency and reliability. - Addressed issues with application URL test cases and workspace import logic. - **Documentation** - Updated messages and constants related to workspace and application UI elements for clearer user communication. - **Chores** - Cleaned up unused code and simplified selectors across various components and tests. - Refactored application and workspace selectors for improved code organization. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Dipyaman Biswas <dipyaman@appsmith.com> Co-authored-by: Abhijeet <abhi.nagarnaik@gmail.com> Co-authored-by: Nidhi <nidhi@appsmith.com> Co-authored-by: Goutham Pratapa <goutham@appsmith.com> Co-authored-by: Ankita Kinger <ankita@appsmith.com> Co-authored-by: albinAppsmith <87797149+albinAppsmith@users.noreply.github.com> Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com> Co-authored-by: Nayan <nayan@appsmith.com> Co-authored-by: Rishabh Rathod <rishabh.rathod@appsmith.com>
333 lines
11 KiB
JavaScript
333 lines
11 KiB
JavaScript
/* eslint-disable cypress/no-unnecessary-waiting */
|
|
/* eslint-disable cypress/no-assigning-return-values */
|
|
/* Contains all methods related to Workspace features*/
|
|
|
|
import { AppSidebar } from "./Pages/EditorNavigation";
|
|
|
|
require("cy-verify-downloads").addCustomCommand();
|
|
require("cypress-file-upload");
|
|
import homePage from "../locators/HomePage";
|
|
import { ObjectsRegistry } from "../support/Objects/Registry";
|
|
|
|
const agHelper = ObjectsRegistry.AggregateHelper;
|
|
const assertHelper = ObjectsRegistry.AssertHelper;
|
|
const homePageTS = ObjectsRegistry.HomePage;
|
|
|
|
export const initLocalstorage = () => {
|
|
cy.window().then((window) => {
|
|
window.localStorage.setItem("ShowCommentsButtonToolTip", "");
|
|
window.localStorage.setItem("updateDismissed", "true");
|
|
});
|
|
};
|
|
|
|
Cypress.Commands.add("createWorkspace", () => {
|
|
cy.get(homePage.createWorkspace)
|
|
.should("be.visible")
|
|
.first()
|
|
.click({ force: true });
|
|
});
|
|
|
|
Cypress.Commands.add("navigateToWorkspaceSettings", (workspaceName) => {
|
|
cy.get(homePage.workspaceList.concat(workspaceName).concat(")"))
|
|
.first()
|
|
.scrollIntoView()
|
|
.should("be.visible");
|
|
cy.get(homePage.workspaceList.concat(workspaceName).concat(")"))
|
|
.closest(homePage.workspaceCompleteSection)
|
|
.find(homePage.optionsIcon)
|
|
.click({ force: true });
|
|
cy.xpath(homePage.MemberSettings).click({ force: true });
|
|
cy.wait("@getMembers").should(
|
|
"have.nested.property",
|
|
"response.body.responseMeta.status",
|
|
200,
|
|
);
|
|
cy.get(homePage.inviteUserMembersPage).should("be.visible");
|
|
});
|
|
|
|
Cypress.Commands.add("openWorkspaceOptionsPopup", (workspaceName) => {
|
|
cy.get(homePage.workspaceList.concat(workspaceName).concat(")"))
|
|
.first()
|
|
.scrollIntoView()
|
|
.should("be.visible");
|
|
|
|
cy.get(homePage.workspaceList.concat(workspaceName).concat(")"))
|
|
.closest(homePage.workspaceCompleteSection)
|
|
.find(homePage.optionsIcon)
|
|
.first()
|
|
.click({ force: true });
|
|
});
|
|
|
|
Cypress.Commands.add("inviteUserForWorkspace", (workspaceName, email, role) => {
|
|
cy.stubPostHeaderReq();
|
|
cy.get(homePage.workspaceList.concat(workspaceName).concat(")"))
|
|
.first()
|
|
.scrollIntoView()
|
|
.should("be.visible");
|
|
|
|
cy.get(
|
|
homePage.workspaceList
|
|
.concat(workspaceName)
|
|
.concat(homePage.shareWorkspace),
|
|
)
|
|
.first()
|
|
.should("be.visible")
|
|
.click({ force: true });
|
|
cy.xpath(homePage.email).click({ force: true }).type(email);
|
|
cy.xpath(homePage.selectRole).click({ force: true });
|
|
cy.wait(500);
|
|
cy.xpath(role).click({ force: true });
|
|
cy.xpath(homePage.inviteBtn).click({ force: true });
|
|
cy.wait("@mockPostInvite")
|
|
.its("request.headers")
|
|
.should("have.property", "origin", "Cypress");
|
|
cy.contains(email, { matchCase: false });
|
|
});
|
|
|
|
Cypress.Commands.add("CheckShareIcon", (workspaceName, count) => {
|
|
cy.get(homePage.workspaceList.concat(workspaceName).concat(")"))
|
|
.first()
|
|
.scrollIntoView()
|
|
.should("be.visible");
|
|
|
|
cy.get(
|
|
homePage.workspaceList
|
|
.concat(workspaceName)
|
|
.concat(") .t--workspace-share-user-icons"),
|
|
).should("have.length", count);
|
|
});
|
|
|
|
Cypress.Commands.add("shareApp", (email, role) => {
|
|
cy.stubPostHeaderReq();
|
|
cy.xpath(homePage.email).click({ force: true }).type(email);
|
|
cy.xpath(homePage.selectRole).should("be.visible");
|
|
cy.xpath("//span[@name='expand-more']").last().click();
|
|
cy.xpath(role).click({ force: true });
|
|
cy.xpath(homePage.inviteBtn).click({ force: true });
|
|
cy.wait("@mockPostInvite")
|
|
.its("request.headers")
|
|
.should("have.property", "origin", "Cypress");
|
|
cy.contains(email, { matchCase: false });
|
|
cy.get(homePage.closeBtn).click();
|
|
});
|
|
|
|
Cypress.Commands.add("shareAndPublic", (email, role) => {
|
|
cy.stubPostHeaderReq();
|
|
cy.xpath(homePage.email).click({ force: true }).type(email);
|
|
cy.xpath(homePage.selectRole).click({ force: true });
|
|
cy.xpath(role).click({ force: true });
|
|
cy.xpath(homePage.inviteBtn).click({ force: true });
|
|
cy.wait("@mockPostInvite")
|
|
.its("request.headers")
|
|
.should("have.property", "origin", "Cypress");
|
|
cy.contains(email, { matchCase: false });
|
|
cy.enablePublicAccess();
|
|
});
|
|
|
|
Cypress.Commands.add("enablePublicAccess", (editMode = false) => {
|
|
cy.xpath(homePage.enablePublicAccess).first().click({ force: true });
|
|
cy.wait("@changeAccess").should(
|
|
"have.nested.property",
|
|
"response.body.responseMeta.status",
|
|
200,
|
|
);
|
|
cy.wait(5000);
|
|
const closeButtonLocator = editMode
|
|
? homePage.editModeInviteModalCloseBtn
|
|
: homePage.closeBtn;
|
|
cy.get(closeButtonLocator).first().click({ force: true });
|
|
});
|
|
|
|
Cypress.Commands.add("deleteUserFromWorkspace", (workspaceName) => {
|
|
cy.get(homePage.workspaceList.concat(workspaceName).concat(")"))
|
|
.first()
|
|
.scrollIntoView()
|
|
.should("be.visible");
|
|
|
|
cy.get(homePage.workspaceList.concat(workspaceName).concat(")"))
|
|
.closest(homePage.workspaceCompleteSection)
|
|
.scrollIntoView()
|
|
.find(homePage.optionsIcon)
|
|
.click({ force: true });
|
|
cy.xpath(homePage.MemberSettings).click({ force: true });
|
|
cy.wait("@getRoles").should(
|
|
"have.nested.property",
|
|
"response.body.responseMeta.status",
|
|
200,
|
|
);
|
|
cy.get(homePage.DeleteBtn).last().click({ force: true });
|
|
cy.get(homePage.leaveWorkspaceConfirmModal).should("be.visible");
|
|
cy.get(homePage.leaveWorkspaceConfirmButton).click({ force: true });
|
|
cy.xpath(homePage.appHome).first().should("be.visible").click();
|
|
cy.wait("@applications").should(
|
|
"have.nested.property",
|
|
"response.body.responseMeta.status",
|
|
200,
|
|
);
|
|
});
|
|
|
|
Cypress.Commands.add(
|
|
"updateUserRoleForWorkspace",
|
|
(workspaceName, email, role) => {
|
|
cy.stubPostHeaderReq();
|
|
cy.get(homePage.workspaceList.concat(workspaceName).concat(")"))
|
|
.first()
|
|
.scrollIntoView()
|
|
.should("be.visible");
|
|
|
|
cy.get(homePage.workspaceList.concat(workspaceName).concat(")"))
|
|
.closest(homePage.workspaceCompleteSection)
|
|
.scrollIntoView()
|
|
.find(homePage.optionsIcon)
|
|
.click({ force: true });
|
|
cy.xpath(homePage.MemberSettings).click({ force: true });
|
|
cy.wait("@getMembers").should(
|
|
"have.nested.property",
|
|
"response.body.responseMeta.status",
|
|
200,
|
|
);
|
|
cy.get(homePage.inviteUserMembersPage).click({ force: true });
|
|
cy.xpath(homePage.email).click({ force: true }).type(email);
|
|
cy.xpath(homePage.selectRole).click({ force: true });
|
|
cy.xpath(role).click({ force: true });
|
|
cy.xpath(homePage.inviteBtn).click({ force: true });
|
|
cy.wait("@mockPostInvite")
|
|
.its("request.headers")
|
|
.should("have.property", "origin", "Cypress");
|
|
cy.contains(email, { matchCase: false });
|
|
cy.get(".bp3-icon-small-cross").click({ force: true });
|
|
cy.xpath(homePage.appHome).first().should("be.visible").click();
|
|
cy.wait("@applications").should(
|
|
"have.nested.property",
|
|
"response.body.responseMeta.status",
|
|
200,
|
|
);
|
|
},
|
|
);
|
|
|
|
Cypress.Commands.add("launchApp", () => {
|
|
cy.get(homePage.appView).should("be.visible").first().click();
|
|
cy.get("#loading").should("not.exist");
|
|
cy.wait("@getConsolidatedData").should(
|
|
"have.nested.property",
|
|
"response.body.responseMeta.status",
|
|
200,
|
|
);
|
|
});
|
|
|
|
Cypress.Commands.add("AppSetupForRename", () => {
|
|
cy.wait(2000); //wait a bit for app to load
|
|
cy.get(homePage.applicationName).then(($appName) => {
|
|
if (!$appName.hasClass(homePage.editingAppName)) {
|
|
cy.get(homePage.applicationName).click({ force: true });
|
|
cy.get(homePage.portalMenuItem)
|
|
.contains("Rename", { matchCase: false })
|
|
.click({ force: true });
|
|
}
|
|
});
|
|
});
|
|
|
|
Cypress.Commands.add("CreateAppForWorkspace", (workspaceName, appname) => {
|
|
cy.get(
|
|
homePage.workspaceList
|
|
.concat(workspaceName)
|
|
.concat(homePage.createAppFrWorkspace),
|
|
)
|
|
.first()
|
|
.scrollIntoView()
|
|
.should("be.visible")
|
|
.click({ force: true });
|
|
|
|
agHelper.GetNClick(homePage.newButtonCreateApplication, 0, true);
|
|
|
|
cy.wait("@createNewApplication").then((xhr) => {
|
|
const response = xhr.response;
|
|
expect(response.body.responseMeta.status).to.eq(201);
|
|
localStorage.setItem("applicationId", response.body.data.id);
|
|
cy.wrap(response.body.data.id).as("currentApplicationId");
|
|
});
|
|
|
|
cy.get("#loading").should("not.exist");
|
|
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
|
cy.wait(2000);
|
|
|
|
cy.AppSetupForRename();
|
|
cy.get(homePage.applicationName).type(appname + "{enter}");
|
|
|
|
cy.wait("@updateApplication").should(
|
|
"have.nested.property",
|
|
"response.body.responseMeta.status",
|
|
200,
|
|
);
|
|
agHelper.RemoveUIElement("Tooltip", "Rename application");
|
|
});
|
|
|
|
Cypress.Commands.add("CreateNewAppInNewWorkspace", () => {
|
|
let applicationId, appName;
|
|
let toNavigateToHome = false;
|
|
cy.get("body").then(($ele) => {
|
|
if ($ele.find(".t--appsmith-logo").length < 0) {
|
|
toNavigateToHome = false;
|
|
} else {
|
|
toNavigateToHome = true;
|
|
}
|
|
});
|
|
homePageTS.CreateNewWorkspace("", toNavigateToHome); //Creating a new workspace for every test, since we are deleting the workspace in the end of the test
|
|
cy.get("@workspaceName").then((workspaceName) => {
|
|
localStorage.setItem("workspaceName", workspaceName);
|
|
homePageTS.CreateAppInWorkspace(localStorage.getItem("workspaceName"));
|
|
});
|
|
cy.get("@createNewApplication").then((xhr) => {
|
|
const response = xhr.response;
|
|
expect(response.body.responseMeta.status).to.eq(201);
|
|
applicationId = response.body.data.id;
|
|
appName = response.body.data.name;
|
|
cy.log("appName", appName);
|
|
localStorage.setItem("applicationId", applicationId);
|
|
localStorage.setItem("appName", appName);
|
|
|
|
agHelper.AssertElementAbsence("#loading", Cypress.config().pageLoadTimeout);
|
|
|
|
cy.url().then((url) => {
|
|
if (url.indexOf("/applications") > -1) {
|
|
homePageTS.EditAppFromAppHover(appName);
|
|
}
|
|
});
|
|
});
|
|
AppSidebar.assertVisible();
|
|
|
|
// If the intro modal is open, close it
|
|
cy.skipSignposting();
|
|
|
|
//Removing renaming of app from all tests, since its also verified in other separate tests
|
|
// cy.AppSetupForRename();
|
|
// cy.get(homePage.applicationName).type(appname + "{enter}");
|
|
// assertHelper.AssertNetworkStatus("@updateApplication");
|
|
// // Remove tooltip on the Application Name
|
|
// agHelper.RemoveTooltip("Tooltip","Rename application");
|
|
|
|
/* The server created app always has an old dsl so the layout will migrate
|
|
* To avoid race conditions between that update layout and this one
|
|
* we wait for that to finish before updating layout here
|
|
*/
|
|
//cy.wait("@updateLayout");
|
|
});
|
|
|
|
Cypress.Commands.add("leaveWorkspace", (newWorkspaceName) => {
|
|
cy.openWorkspaceOptionsPopup(newWorkspaceName);
|
|
cy.get(homePage.workspaceNamePopoverContent)
|
|
.find("a")
|
|
.should("have.length", 1)
|
|
.first()
|
|
.contains("Leave Workspace")
|
|
.click();
|
|
cy.contains("Are you sure").click();
|
|
cy.wait("@leaveWorkspaceApiCall")
|
|
.its("response.body.responseMeta.status")
|
|
.should("eq", 200);
|
|
cy.get(homePage.toastMessage).should(
|
|
"contain",
|
|
"You have successfully left the workspace",
|
|
);
|
|
});
|