Skip to content

feat: added global logout feature#39942

Merged
AmanAgarwal041 merged 11 commits intoreleasefrom
feat/global-logout
Apr 2, 2025
Merged

feat: added global logout feature#39942
AmanAgarwal041 merged 11 commits intoreleasefrom
feat/global-logout

Conversation

@AmanAgarwal041
Copy link
Contributor

@AmanAgarwal041 AmanAgarwal041 commented Mar 26, 2025

Description

Added a global logoutUser function to expose the logout functionality for the users to implement their custom logout buttons.

Some examples how to use it :

  • logoutUser() -> redirects to /user/login with redirection url to the current page url
  • logoutUser(appsmith.URL.pathname) -> redirects to /user/login?redirectUrl=${redirectUrl} with redirectUrl is the value of appsmith.URL.pathname
  • logoutUser("/app/abc") -> redirects to /user/login?redirectUrl=/app/abc

Why we are doing it ?

This was the feature asked by one of our enterprise users because they were implementing the custom header and in that custom header they had a logout feature which they were doing via API. We changed the signature for the logout API and their logout functionality broke. Hence we thought of introducing a way to expose the logout function for the users to implement the logout functionality by themselves. They also wanted the redirect url functionality whenever the users logs out , on login they should be redirected to the application from where they logged out.
Slack thread : https://theappsmith.slack.com/archives/C08F9NSTJM9/p1742871711072179

Fixes https://github.com/appsmithorg/appsmith-ee/issues/6748
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="@tag.All"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/14195567720
Commit: 3f0ebad
Cypress dashboard.
Tags: @tag.All
Spec:


Tue, 01 Apr 2025 13:44:17 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

Summary by CodeRabbit

  • New Features

    • Introduced a streamlined logout functionality that allows users to sign out with optional redirection.
    • Enabled logout actions to be integrated into automated workflows, making them easily chainable with other actions.
    • Added a new function to facilitate user logout, enhancing the overall user experience.
    • Updated guidance and examples to help users implement the new logout feature.
    • Added new icons and headings for the logout action to improve user interface clarity.
    • Introduced a new message constant for logout actions to enhance clarity in messaging.
  • Bug Fixes

    • Improved test coverage for logout functionality to ensure proper redirection upon user sign-out.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 26, 2025

Walkthrough

This pull request integrates a new logout mechanism into the application’s execution flow. A new action type (LOGOUT_USER_INIT) is added in the action execution saga to call a dedicated logout function. Complementary adjustments are made across global functions, editor constants, and evaluation files to support this functionality. A new file encapsulates the logout process with a descriptor, type definition, and asynchronous handler, thereby standardizing the logout process with a customizable redirect URL.

Changes

File(s) Change Summary
app/.../ActionExecutionSagas.ts Added a new case for LOGOUT_USER_INIT in executeActionTriggers to call globalFunctionLogoutUser with a trigger parameter.
app/.../EntityDefinitions.ts Added logoutUser to GLOBAL_FUNCTIONS and ternDocsInfo with a documentation URL, description, and type signature.
app/.../ActionCreator/constants.ts
app/.../ActionCreator/utils.ts
Added logoutUser to the APPSMITH_GLOBAL_FUNCTIONS enum and included it in the chainableFns array.
app/.../fns/index.ts Updated ActionTriggerFunctionNames with LOGOUT_USER_INIT, added logoutUser to platformFns, and updated ActionDescription with TSLogoutActionType.
app/.../fns/logout.ts New file defining logoutFnDescriptor, exporting type TSLogoutActionType, and an async function logoutUser utilizing a promisify utility.
app/.../userSagas.tsx Added globalFunctionLogoutUser to handle user logout with a specified redirect URL.
app/.../messages.ts Introduced a new constant LOGOUT_USER for user logout messaging.
app/.../FieldGroupConfig.ts
app/.../FieldGroupConfig.test.ts
Added logoutUser to the FIELD_GROUP_CONFIG and corresponding test cases for validation.
app/.../commands.js
app/.../index.d.ts
Updated LoginFromAPI method signature to include an optional redirectUrl parameter for enhanced login flexibility.

Assessment against linked issues

Objective Addressed Explanation
Global logout function with custom redirect (#6748)
Logout redirection issue (#6748)

Possibly related issues

  • appsmithorg/appsmith-ee#6748: The changes in the main issue, specifically the addition of the LOGOUT_USER_INIT case in the executeActionTriggers function, are directly related to the global logout functionality described in the retrieved issue, which also involves modifying logout behavior and handling a configurable redirect URL. Both issues focus on enhancing the logout process within the application.

Possibly related PRs

  • fix: Added login for better flow #38569: The changes in the main PR, which introduce a new case for handling the LOGOUT_USER_INIT action type, are related to the modifications in the retrieved PR that involve a logout action, as both pertain to user logout functionality within the application.
  • test: replace LogintoApp with LoginFromAPI #34040: The changes in the main PR, which introduce a new case for handling the LOGOUT_USER_INIT action type, are related to the retrieved PR that replaces LogintoApp with LoginFromAPI, as both involve modifications to the user logout functionality within the application.
  • chore: Fixing email verification on signup #39838: The changes in the main PR, which introduce a new case for handling user logout in the executeActionTriggers function, are related to the retrieved PR that addresses user logout during email verification, as both involve modifications to the logout functionality within the application.

Suggested labels

Task, IDE Product

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007
  • rahulbarwal

Poem

In lines of code, a logout unfolds,
A trigger sparks the flow of gold.
From sagas deep to functions grand,
A logout journey is now at hand.
Farewell login, with redirect so bright—code sings day and night!
🚀🌟


🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@AmanAgarwal041
Copy link
Contributor Author

/build-deploy-preview skip-tests=true

@github-actions github-actions bot added the Enhancement New feature or request label Mar 26, 2025
@github-actions
Copy link

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/14091998430.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 39942.
recreate: .

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (3)
app/client/src/workers/Evaluation/fns/logout.ts (1)

5-5: Consider using a constant for the action type.

Using string literals directly in code can lead to issues if the action type needs to be referenced elsewhere in the codebase.

+import { LogoutActionTypes } from "../constants/actionTypes";
+
 function logoutFnDescriptor(redirectURL: string) {
   return {
-    type: "LOGOUT_USER_INIT" as const,
+    type: LogoutActionTypes.LOGOUT_USER_INIT,
     payload: {
       redirectURL,
     },
   };
 }
app/client/src/ce/utils/autocomplete/EntityDefinitions.ts (2)

282-282: Enhance the function documentation.

The current description is very brief compared to other function descriptions in the file. A more comprehensive description would be helpful for developers.

   logoutUser: {
     "!url":
       "https://docs.appsmith.com/reference/appsmith-framework/widget-actions/store-value",
-    "!doc": "Logout user",
+    "!doc": "Logs out the current user and redirects to the specified URL. Useful for implementing custom logout buttons within the application.",
     "!type": "fn(redirectURL: string) -> void",
   },

339-339: Improve the example argument for logoutUser.

The current example ["url"] is not clear enough. It would be more helpful to provide a clearer example with string literals to show actual usage.

   logoutUser: {
-    exampleArgs: ["url"],
+    exampleArgs: ["'/login'", "'/auth/login'"],
   },
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c6b1b9a and 766e06d.

📒 Files selected for processing (6)
  • app/client/src/ce/sagas/ActionExecution/ActionExecutionSagas.ts (2 hunks)
  • app/client/src/ce/utils/autocomplete/EntityDefinitions.ts (2 hunks)
  • app/client/src/components/editorComponents/ActionCreator/constants.ts (1 hunks)
  • app/client/src/components/editorComponents/ActionCreator/utils.ts (1 hunks)
  • app/client/src/workers/Evaluation/fns/index.ts (4 hunks)
  • app/client/src/workers/Evaluation/fns/logout.ts (1 hunks)
🧰 Additional context used
🧬 Code Definitions (2)
app/client/src/workers/Evaluation/fns/index.ts (1)
app/client/src/workers/Evaluation/fns/logout.ts (2)
  • logoutUser (14-18)
  • TSLogoutActionType (12-12)
app/client/src/components/editorComponents/ActionCreator/utils.ts (1)
app/client/src/components/editorComponents/ActionCreator/constants.ts (1)
  • AppsmithFunction (32-37)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
🔇 Additional comments (9)
app/client/src/components/editorComponents/ActionCreator/constants.ts (1)

17-17: Addition of logoutUser to APPSMITH_GLOBAL_FUNCTIONS enum looks good.

The addition of logoutUser to the APPSMITH_GLOBAL_FUNCTIONS enum is clean and follows the existing pattern. This makes the function available as a global function throughout the application.

app/client/src/components/editorComponents/ActionCreator/utils.ts (1)

118-121: logoutUser added to chainableFns array correctly.

The logoutUser function is properly added to the chainableFns array, making it available as a chainable function in the action creator. This follows the established pattern for other platform functions.

app/client/src/ce/sagas/ActionExecution/ActionExecutionSagas.ts (2)

48-48: Import of logoutSaga correctly added.

The logoutSaga is properly imported from "../userSagas", which will be used to handle the logout action.


135-137: Correctly implemented handler for LOGOUT_USER_INIT action type.

The new case for "LOGOUT_USER_INIT" in the switch statement correctly calls the logoutSaga with the trigger parameter. This follows the same pattern as other action types in the function.

app/client/src/workers/Evaluation/fns/index.ts (4)

63-63: Import of logoutUser function and type looks good.

The import statement correctly brings in both the logoutUser function and the TSLogoutActionType type from the "./logout" module.


118-121: logoutUser added to platformFns array correctly.

The logoutUser function is properly added to the platformFns array with the correct name and function reference, following the same pattern as other platform functions.


223-223: LOGOUT_USER_INIT added to ActionTriggerFunctionNames.

The "LOGOUT_USER_INIT" action type is properly mapped to the "logoutUser" function name in the ActionTriggerFunctionNames record.


243-244: TSLogoutActionType correctly added to ActionDescription union type.

The TSLogoutActionType is properly added to the ActionDescription union type, ensuring type safety when handling logout actions.

app/client/src/workers/Evaluation/fns/logout.ts (1)

1-18: Implementation looks good.

The implementation follows TypeScript best practices with proper type definitions and reuse of parameter types. The function structure is clean and well-organized.

@github-actions
Copy link

Deploy-Preview-URL: https://ce-39942.dp.appsmith.com

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
app/client/src/ce/sagas/userSagas.tsx (2)

727-739: Function implementation looks good, but URL handling could be improved.

The new globalFunctionLogoutUser function properly handles the logout flow with redirect URL support, but there are opportunities to enhance security and robustness.

export function* globalFunctionLogoutUser(
  action: ReduxAction<{ redirectURL: string }>,
) {
-  const redirectURL = `${AUTH_LOGIN_URL}${action.payload?.redirectURL ? "?redirectUrl=" + action.payload?.redirectURL : ""}`;
+  const redirectURL = `${AUTH_LOGIN_URL}${action.payload?.redirectURL ? "?redirectUrl=" + encodeURIComponent(action.payload.redirectURL) : ""}`;

  yield call(logoutSaga, {
    type: ReduxActionTypes.LOGOUT_USER_INIT,
    payload: {
      redirectURL,
    },
  });
}

727-739: Consider adding JSDoc documentation for this global function.

Since this function is intended to be used as a global logout mechanism, adding documentation would help other developers understand its purpose and usage.

+/**
+ * Global function to logout user with optional redirect URL
+ * @param action Redux action containing redirectURL in payload
+ */
export function* globalFunctionLogoutUser(
  action: ReduxAction<{ redirectURL: string }>,
) {
  const redirectURL = `${AUTH_LOGIN_URL}${action.payload?.redirectURL ? "?redirectUrl=" + action.payload?.redirectURL : ""}`;

  yield call(logoutSaga, {
    type: ReduxActionTypes.LOGOUT_USER_INIT,
    payload: {
      redirectURL,
    },
  });
}
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 766e06d and 09ffeed.

📒 Files selected for processing (2)
  • app/client/src/ce/sagas/ActionExecution/ActionExecutionSagas.ts (2 hunks)
  • app/client/src/ce/sagas/userSagas.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/src/ce/sagas/ActionExecution/ActionExecutionSagas.ts
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (1)
app/client/src/ce/sagas/userSagas.tsx (1)

731-731:

Details

✅ Verification successful

Verify the queryParam name for consistency.

Ensure that the queryParam name redirectUrl matches what the login page expects. I notice you're using camelCase here, but check if the receiving end expects this exact casing.


🏁 Script executed:

#!/bin/bash
# Check for references to redirectUrl parameter in login page handling
rg -i "redirectUrl|redirect_url|REDIRECT_URL" --type ts --type tsx app/client/src | grep -i login

Length of output: 127


Action Required:
The previous search produced an error due to an unrecognized file type for tsx files. Please run the above revised script to confirm whether the login page (or related authentication logic) is referencing the query parameter "redirectUrl" (camelCase) or a different variant. Once you verify which casing the login page expects, update the code in app/client/src/ce/sagas/userSagas.tsx (line 731) accordingly to ensure consistency.


🏁 Script executed:

#!/bin/bash
# Corrected search for 'redirectUrl' references in login-related TypeScript files.
# This command uses glob patterns for both .tsx and .ts files.
rg -i -g "*.tsx" -g "*.ts" "redirectUrl|redirect_url|REDIRECT_URL" app/client/src | grep -i login

Length of output: 1907


Query Parameter Naming Verified

  • Verified that the login page and other related modules consistently expect the query parameter to be redirectUrl (camelCase).
  • The code in app/client/src/ce/sagas/userSagas.tsx correctly appends ?redirectUrl=... based on the payload, which aligns with what the login page expects.

No changes are needed here.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between 7e2de4c and c895e69.

📒 Files selected for processing (5)
  • app/client/cypress/e2e/Regression/ClientSide/ActionExecution/ActionSelector_JsToNonJSMode_4_spec.ts (2 hunks)
  • app/client/src/ce/constants/messages.ts (1 hunks)
  • app/client/src/components/editorComponents/ActionCreator/FieldGroup/FieldGroupConfig.test.ts (1 hunks)
  • app/client/src/components/editorComponents/ActionCreator/FieldGroup/FieldGroupConfig.ts (2 hunks)
  • app/client/src/components/editorComponents/ActionCreator/viewComponents/ActionBlockTree/utils.tsx (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`app/client/cypress/**/**.*`: Review the following e2e test code written using the Cypress test library. Ensure that: - Follow best practices for Cypress code and e2e automation. ...

app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
  • app/client/cypress/e2e/Regression/ClientSide/ActionExecution/ActionSelector_JsToNonJSMode_4_spec.ts
🧬 Code Definitions (1)
app/client/src/components/editorComponents/ActionCreator/FieldGroup/FieldGroupConfig.ts (1)
app/client/src/ce/constants/messages.ts (1)
  • LOGOUT_USER (632-632)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (6)
app/client/src/ce/constants/messages.ts (1)

632-632: New logout message constant added correctly.

This addition creates a new message constant for the logout user functionality, maintaining consistency with the application's internationalization pattern.

app/client/src/components/editorComponents/ActionCreator/viewComponents/ActionBlockTree/utils.tsx (2)

92-94: Logout icon handler implemented properly.

The new case for AppsmithFunction.logoutUser correctly returns the appropriate icon component.


212-215: Proper action heading for logout functionality.

The implementation correctly retrieves the URL field or defaults to a prompt for adding a redirect URL when the field is empty.

app/client/src/components/editorComponents/ActionCreator/FieldGroup/FieldGroupConfig.ts (2)

12-12: Message import added for logout functionality.

The LOGOUT_USER constant is properly imported to be used in the field group configuration.


171-176: Logout user field group configuration implemented correctly.

The configuration properly defines the label, fields, default parameters, and icon for the logout functionality.

app/client/cypress/e2e/Regression/ClientSide/ActionExecution/ActionSelector_JsToNonJSMode_4_spec.ts (1)

18-18: Test case numbering updated

The test case has been renumbered to "1", which helps maintain sequential ordering in the test suite.

@AmanAgarwal041 AmanAgarwal041 added the ok-to-test Required label for CI label Mar 31, 2025
@rahulbarwal
Copy link
Contributor

/build-deploy-preview skip-tests=true

@github-actions
Copy link

github-actions bot commented Apr 1, 2025

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/14187453341.
Workflow: On demand build Docker image and deploy preview.
skip-tests: true.
env: ``.
PR: 39942.
recreate: .

@github-actions
Copy link

github-actions bot commented Apr 1, 2025

Deploy-Preview-URL: https://ce-39942.dp.appsmith.com

Copy link
Contributor

@rahulbarwal rahulbarwal left a comment

Choose a reason for hiding this comment

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

Overall this looks good. It's great to see this functionality coming in so quickly. Few points:

  1. Can you please update the PR description with: What is the current method for accomplishing this? What were its shortcomings? What is the motivation behind this change?
  2. Would setting the default redirect URL to the current URL, rather than directing to the /applications route, be more beneficial? Can we obtain some product insights on this?

@AmanAgarwal041
Copy link
Contributor Author

AmanAgarwal041 commented Apr 1, 2025

Overall this looks good. It's great to see this functionality coming in so quickly. Few points:

  1. Can you please update the PR description with: What is the current method for accomplishing this? What were its shortcomings? What is the motivation behind this change?
  2. Would setting the default redirect URL to the current URL, rather than directing to the /applications route, be more beneficial? Can we obtain some product insights on this?

Updated the thread for 1
Changed the implementation to have redirectUrl to current logout page instead of /applications redirection.
cc @rahulbarwal

rahulbarwal
rahulbarwal previously approved these changes Apr 1, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
app/client/cypress/support/commands.js (1)

174-194: Updated function signature to enhance flexibility

The LoginFromAPI command now accepts an optional redirectUrl parameter to enable custom redirection after login. This is a good enhancement that supports the global logout feature implementation.

Consider adding JSDoc documentation for the new parameter:

+/**
+ * Logs in a user via API
+ * @param {string} uname - The username
+ * @param {string} pword - The password
+ * @param {string} [redirectUrl] - Optional URL to redirect to after login
+ */
 Cypress.Commands.add("LoginFromAPI", (uname, pword, redirectUrl) => {
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro (Legacy)

📥 Commits

Reviewing files that changed from the base of the PR and between bcd77b1 and 3f0ebad.

📒 Files selected for processing (1)
  • app/client/cypress/support/commands.js (3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`app/client/cypress/**/**.*`: Review the following e2e test code written using the Cypress test library. Ensure that: - Follow best practices for Cypress code and e2e automation. ...

app/client/cypress/**/**.*: Review the following e2e test code written using the Cypress test library. Ensure that:

  • Follow best practices for Cypress code and e2e automation.
  • Avoid using cy.wait in code.
  • Avoid using cy.pause in code.
  • Avoid using agHelper.sleep().
  • Use locator variables for locators and do not use plain strings.
  • Use data-* attributes for selectors.
  • Avoid Xpaths, Attributes and CSS path.
  • Avoid selectors like .btn.submit or button[type=submit].
  • Perform logins via API with LoginFromAPI.
  • Perform logout via API with LogOutviaAPI.
  • Perform signup via API with SignupFromAPI.
  • Avoid using it.only.
  • Avoid using after and aftereach in test cases.
  • Use multiple assertions for expect statements.
  • Avoid using strings for assertions.
  • Do not use duplicate filenames even with different paths.
  • Avoid using agHelper.Sleep, this.Sleep in any file in code.
  • app/client/cypress/support/commands.js
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: client-lint / client-lint
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (2)
app/client/cypress/support/commands.js (2)

211-217: Redirect logic properly implemented

The conditional check ensures the location assertion validates against the provided redirectUrl if present, otherwise falls back to the default "/applications" path.


222-225:

Details

✅ Verification successful

Network request assertion conditionally applied

Good implementation that only checks for the "getAllWorkspaces" network request when using the default redirect path.

Verify that all test cases using the LoginFromAPI command without the redirectUrl parameter continue to work as expected:


🏁 Script executed:

#!/bin/bash
# Find all cases where LoginFromAPI is called in tests
rg "cy\.LoginFromAPI\(" --type js app/client/cypress/

Length of output: 3308


Network Request Assertion and Test Usage Verified

  • The code in app/client/cypress/support/commands.js (lines 222-225) correctly applies the getAllWorkspaces network status assertion only when the redirectUrl parameter is not provided.
  • A grep search across the test files confirmed that all calls to cy.LoginFromAPI pass only the username and password (i.e., without a redirectUrl), ensuring they rely on the default behavior.
  • The current implementation appears sound; please ensure that any future tests that might introduce a custom redirect path handle the network assertions appropriately.

@AmanAgarwal041 AmanAgarwal041 merged commit 703363f into release Apr 2, 2025
83 checks passed
@AmanAgarwal041 AmanAgarwal041 deleted the feat/global-logout branch April 2, 2025 06:50
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Apr 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request ok-to-test Required label for CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants