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: Editor tests for renaming, copying, moving, and deleting APIs #38896

Merged
merged 3 commits into from
Jan 30, 2025

Conversation

shadabbuchh
Copy link
Contributor

@shadabbuchh shadabbuchh commented Jan 29, 2025

Description

This PR adds set of tests for API-related operations in the editor, including renaming, copying, moving, and validating tab behaviors triggered from debugger logs.

Automation

/ok-to-test tags="@tag.Datasource, @tag.Git, @tag.Sanity"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13047527270
Commit: 09e3929
Cypress dashboard.
Tags: @tag.Datasource, @tag.Git, @tag.Sanity
Spec:


Thu, 30 Jan 2025 08:38:58 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced API management testing capabilities
    • Added support for renaming, copying, and moving APIs
    • Improved log-based tab navigation and reopening functionality
  • Tests

    • Introduced comprehensive test suite for API operations
    • Added test cases for API renaming, copying, moving, and deletion
    • Implemented log-based tab interaction tests

These updates improve the testing infrastructure and validate key API management features in the application.

Copy link
Contributor

coderabbitai bot commented Jan 29, 2025

Walkthrough

This pull request enhances API testing capabilities in the Cypress testing framework by introducing a comprehensive test suite for API management functionalities. The changes include new methods in the ApiPage and PageList classes to support advanced API interactions such as renaming, copying, moving, and deleting APIs, along with improved tab navigation and log interaction testing.

Changes

File Change Summary
app/client/.../API_Additional_Tests_spec.ts Added new test suite with 4 test cases for API management: renaming, copying, moving, deleting, and tab navigation from logs
app/client/.../ApiPage.ts Introduced new methods: renameFromEditor(), performActionFromEditor(), deleteAPIFromEditor() and added supporting properties
app/client/.../PageList.ts Added numberOfPages property for page count selection

Sequence Diagram

sequenceDiagram
    participant User
    participant APIEditor
    participant PageManager
    User->>APIEditor: Rename API
    User->>APIEditor: Copy/Move API
    APIEditor->>PageManager: Validate Page Transition
    User->>APIEditor: Delete API
    APIEditor->>PageManager: Confirm Deletion
Loading

Possibly related PRs

Suggested labels

Git Product, Integrations Product

Suggested reviewers

  • ApekshaBhosale
  • sagar-qa007
  • NandanAnantharamu

Poem

🚀 APIs dancing, tests in flight,
Cypress scripts shining bright,
Rename, move, and copy with glee,
Testing magic, setting features free!
Code review's symphony plays on 🎉

✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @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.

@github-actions github-actions bot added skip-changelog Adding this label to a PR prevents it from being listed in the changelog Test labels Jan 29, 2025
@shadabbuchh
Copy link
Contributor Author

/ci-test-limit-count run_count=20 update_snapshot=true specs_to_run=cypress/e2e/Regression/ServerSide/ApiTests/API_Additional_Tests_spec.ts

Copy link

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: 3

🧹 Nitpick comments (3)
app/client/cypress/support/Pages/IDE/FileTabs.ts (1)

39-43: LGTM! Consider adding a custom error message.

The assertion chain is well structured. For better debugging, you could include a custom error message in the assertion.

   assertActiveTab(expectedTabName: string) {
     cy.get(this.locators.tabName(expectedTabName))
       .should("exist")
-      .and("have.class", "active");
+      .and("have.class", "active", `Tab ${expectedTabName} should be active`);
   }
app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Additional_Tests_spec.ts (1)

67-81: Consider adding cleanup in beforeEach hook.

The test assumes a clean state with specific API tabs. Consider adding cleanup in a beforeEach hook for better test isolation.

app/client/cypress/support/Pages/ApiPage.ts (1)

518-525: Consider adding retry logic for rename operation.

The rename operation might be flaky due to UI state transitions. Consider adding retry logic for better stability.

   public renameFromEditor(renameVal: string) {
     cy.get(this.moreActionsTrigger).click();
-    cy.contains("Rename").should("be.visible").click();
+    cy.contains("Rename", { timeout: 10000 })
+      .should("be.visible")
+      .click();
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 927383b and 5acb13b.

📒 Files selected for processing (5)
  • app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Additional_Tests_spec.ts (1 hunks)
  • app/client/cypress/limited-tests.txt (1 hunks)
  • app/client/cypress/support/Pages/ApiPage.ts (4 hunks)
  • app/client/cypress/support/Pages/IDE/FileTabs.ts (1 hunks)
  • app/client/cypress/support/Pages/PageList.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
app/client/cypress/support/Pages/PageList.ts (1)

Pattern 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/Pages/IDE/FileTabs.ts (1)

Pattern 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/limited-tests.txt (1)

Pattern 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/Pages/ApiPage.ts (1)

Pattern 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/ServerSide/ApiTests/API_Additional_Tests_spec.ts (1)

Pattern 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.
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-build / client-build
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (4)
app/client/cypress/support/Pages/PageList.ts (1)

19-19: LGTM! Selector follows established patterns.

The new selector follows the existing pattern and uses data-testid attributes as recommended.

app/client/cypress/support/Pages/ApiPage.ts (1)

592-609: LGTM! Deletion flow is well implemented.

The deletion method follows a clear flow with proper assertions and confirmations.

app/client/cypress/limited-tests.txt (2)

2-2: LGTM! Test specification follows naming conventions.

The new test file path correctly follows TypeScript naming conventions and is appropriately placed in the ServerSide/ApiTests directory.


4-5: Configuration changes align with limited test execution.

The changes appropriately restrict test execution to focus on API tests by:

  1. Keeping the all-specs execution commented out
  2. Excluding the Widgets test path

Comment on lines 51 to 65
it("3. Validate whether correct tab opens up after clicking on link from logs", () => {
// Create a new application
homePage.NavigateToHome();
homePage.CreateNewApplication();
for (let i = 0; i < 4; i++) {
apiPage.CreateApi(``, "GET");
}
debuggerHelper.OpenDebugger();
//Navigate to the "Logs" tab in the debugger
debuggerHelper.ClickLogsTab();
// Click on the entity link in the log entry at index 2
debuggerHelper.ClicklogEntityLink(false, 2);
// Assert that the correct tab ("Api3") opens
FileTabs.assertActiveTab("Api3");
});
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Improve test isolation and avoid hardcoded indices.

The test relies on hardcoded index (2) for log entry selection, which could make the test brittle.

-      debuggerHelper.ClicklogEntityLink(false, 2);
+      const LOG_INDEX = 2;
+      debuggerHelper.ClicklogEntityLink(false, LOG_INDEX);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it("3. Validate whether correct tab opens up after clicking on link from logs", () => {
// Create a new application
homePage.NavigateToHome();
homePage.CreateNewApplication();
for (let i = 0; i < 4; i++) {
apiPage.CreateApi(``, "GET");
}
debuggerHelper.OpenDebugger();
//Navigate to the "Logs" tab in the debugger
debuggerHelper.ClickLogsTab();
// Click on the entity link in the log entry at index 2
debuggerHelper.ClicklogEntityLink(false, 2);
// Assert that the correct tab ("Api3") opens
FileTabs.assertActiveTab("Api3");
});
it("3. Validate whether correct tab opens up after clicking on link from logs", () => {
// Create a new application
homePage.NavigateToHome();
homePage.CreateNewApplication();
for (let i = 0; i < 4; i++) {
apiPage.CreateApi(``, "GET");
}
debuggerHelper.OpenDebugger();
//Navigate to the "Logs" tab in the debugger
debuggerHelper.ClickLogsTab();
// Click on the entity link in the log entry at index 2
const LOG_INDEX = 2;
debuggerHelper.ClicklogEntityLink(false, LOG_INDEX);
// Assert that the correct tab ("Api3") opens
FileTabs.assertActiveTab("Api3");
});

Comment on lines +19 to +32
it("1. Validate renaming & copying API from editor", () => {
// Create first API
apiPage.CreateApi();
// Rename the API
apiPage.renameFromEditor("changedName");
// Create second API
apiPage.CreateApi("secondApi", "GET");
// Add a new blank page to the application
PageList.AddNewPage("New blank page");
// Copy the API to the same page
apiPage.performActionFromEditor("copy", "changedName", "Page1", "Page1");
// Copy the API to a different page
apiPage.performActionFromEditor("copy", "secondApi", "Page1", "Page2");
});
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

Add PageLeftPane assertions after API copy operations

Add the following verifications:

  • After copying "changedName" API within Page1:
    PageLeftPane.assertPresence("changedName");
    PageLeftPane.assertPresence("changedName_Copy");
  • After copying "secondApi" to Page2:
    PageLeftPane.assertPresence("secondApi");
    PageLeftPane.assertPresence("secondApi_Copy");
🔗 Analysis chain

Add assertions for API presence after copy operations.

The test should verify that the copied API exists in both source and target pages.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify the presence of API-related assertions in the test file
rg -A 2 "assertPresence.*Api" app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Additional_Tests_spec.ts

Length of output: 114


Script:

#!/bin/bash
# Search for any assertions in the test file
rg "expect|should|assert" app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Additional_Tests_spec.ts

# Look for apiPage method implementations
ast-grep --pattern 'apiPage.$_($$$)' app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Additional_Tests_spec.ts

# Search for verification methods in apiPage definition
fd -e ts -e js apiPage

Length of output: 2086


Script:

#!/bin/bash
# Search for apiPage class implementation
fd -t f -e ts -e js -H -I "apiPage" app/client/cypress/

# Search for performActionFromEditor implementation
rg -A 5 "performActionFromEditor.*{" app/client/cypress/

Length of output: 230


Script:

#!/bin/bash
# Search for performActionFromEditor implementation with fixed pattern
rg -A 5 "performActionFromEditor" app/client/cypress/

# Search for any verification methods in apiPage
rg -A 5 "verify.*Api|assert.*Api" app/client/cypress/

Length of output: 13943

Comment on lines 527 to 590
public performActionFromEditor(
action: "copy" | "move",
apiName: string,
sourcePage: string,
targetPage: string,
) {
// Navigate to the source page and select the API item
EditorNavigation.NavigateToPage(sourcePage);
PageLeftPane.selectItem(apiName);
FileTabs.assertActiveTab(apiName);

PageList.ShowList();
cy.get(PageList.numberOfPages).then(($el) => {
// Open the 'More Actions' menu and select the action
cy.get(this.moreActionsTrigger).should("be.visible").click(); // Open the 'More Actions' dropdown
cy.contains(action === "copy" ? "Copy to page" : "Move to page")
.should("be.visible")
.trigger("click", { force: true });
if (action === "move" && $el.text().includes("All Pages (1)")) {
// Handle case where the target page list is empty during move operation
cy.get(this.pageList).should("have.text", "No pages");
} else if (action === "move" && /All Pages \(\d+\)/.test($el.text())) {
cy.get(this.pageList)
.should("be.visible")
.should("not.have.text", sourcePage)
.contains(targetPage)
.should("be.visible")
.trigger("click", { force: true });

this.agHelper.ValidateToastMessage(
apiName + " action moved to page " + targetPage + " successfully",
);
PageList.VerifyIsCurrentPage(targetPage); // Verify the target page is active
PageLeftPane.assertPresence(apiName); // Assert the API is present on the target page
EditorNavigation.NavigateToPage(sourcePage);
PageLeftPane.assertAbsence(apiName); // Assert the API is removed from the source page
} else {
// Select the target page from the page list
cy.get(this.pageList)
.should("be.visible")
.contains(targetPage)
.should("be.visible")
.trigger("click", { force: true });

// Validate the toast message and the current page
this.agHelper.ValidateToastMessage(
`${apiName} action ${action === "copy" ? "copied" : "moved"} to page ${targetPage} successfully`,
);
PageList.VerifyIsCurrentPage(targetPage); // Verify the target page is active

// Assert the presence of the API on the target page
apiName =
action === "copy" && sourcePage === targetPage
? `${apiName}Copy`
: apiName;
PageLeftPane.assertPresence(apiName);

if (action === "move") {
EditorNavigation.NavigateToPage(sourcePage);
PageLeftPane.assertAbsence(apiName); // Assert the API is removed from the source page
}
}
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Refactor complex conditional logic in performActionFromEditor.

The method has complex nested conditions. Consider extracting the page list handling logic into separate methods.

+ private handleSinglePageMove(apiName: string, sourcePage: string) {
+   cy.get(this.pageList).should("have.text", "No pages");
+ }
+
+ private handleMultiPageMove(apiName: string, sourcePage: string, targetPage: string) {
+   cy.get(this.pageList)
+     .should("be.visible")
+     .should("not.have.text", sourcePage)
+     .contains(targetPage)
+     .should("be.visible")
+     .trigger("click", { force: true });
+ }

Committable suggestion skipped: line range outside the PR's diff.

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/13030488733.
Cypress dashboard: Click here!
The following are new failures, please fix them before merging the PR:
To know the list of identified flaky tests - Refer here

***** Repeat Run Summary ***** Total Tests with repeat: 80 Total Passed: 80 Total Failed: 0 Total Skipped: 0 *****************************

@shadabbuchh shadabbuchh added ok-to-test Required label for CI and removed ok-to-test Required label for CI labels Jan 29, 2025

// Open the 'More Actions' menu and select the action
cy.get(this.moreActionsTrigger).should("be.visible").click();
cy.contains("Delete")
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we please use aghelper functions here?

Please apply same for all the cy commands.

@@ -36,6 +36,12 @@ class FileTabs {
});
}

assertActiveTab(expectedTabName: string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use aghelper function.

app/client/cypress/support/Pages/ApiPage.ts Show resolved Hide resolved
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: 3

🧹 Nitpick comments (2)
app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Additional_Tests_spec.ts (2)

54-56: Replace magic number with named constant.

Define the number of APIs as a constant for better maintainability:

const NUM_TEST_APIS = 4;
for (let i = 0; i < NUM_TEST_APIS; i++) {
  apiPage.CreateApi(`TestApi${i + 1}`, "GET");
}

68-70: Replace magic numbers with named constants.

Define the range of API numbers as constants:

const FIRST_API_NUM = 1;
const LAST_API_NUM = 4;
for (let i = FIRST_API_NUM; i <= LAST_API_NUM; i++) {
  FileTabs.closeTab(`Api${i}`);
}
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 5acb13b and 09e3929.

📒 Files selected for processing (2)
  • app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Additional_Tests_spec.ts (1 hunks)
  • app/client/cypress/support/Pages/ApiPage.ts (4 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/client/cypress/support/Pages/ApiPage.ts
🧰 Additional context used
📓 Path-based instructions (1)
app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Additional_Tests_spec.ts (1)

Pattern 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.
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: perform-test / rts-build / build
  • GitHub Check: perform-test / client-build / client-build
  • GitHub Check: perform-test / server-build / server-unit-tests
  • GitHub Check: client-build / client-build
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-prettier / prettier-check
🔇 Additional comments (3)
app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_Additional_Tests_spec.ts (3)

1-12: LGTM! Well-organized imports.

The imports are logically grouped and all are being used in the test suite.


14-17: LGTM! Well-structured test suite declaration.

Good use of tags for categorizing tests under Datasource and Git categories.


18-31: Add PageLeftPane assertions after API copy operations.

Add assertions to verify the presence of both original and copied APIs:

// After copying "changedName" API within Page1
PageLeftPane.assertPresence("changedName");
PageLeftPane.assertPresence("changedName_Copy");

// After copying "secondApi" to Page2
PageLeftPane.assertPresence("secondApi");
PageLeftPane.assertPresence("secondApi_Copy");

Comment on lines +33 to +48
it("2. Validate moving & deleting API from editor", () => {
// Create a new application
homePage.NavigateToHome();
homePage.CreateNewApplication();
// Create first API
apiPage.CreateApi("ApiToBeMoved", "GET");
apiPage.CreateApi("ApiNotToBeMoved", "GET");
// Having only one page in the app, check if the API is moved to the same page
apiPage.performActionFromEditor("move", "ApiToBeMoved", "Page1", "Page1");
// Add a new blank page to the application
PageList.AddNewPage("New blank page");
// Move the API to a different page & check if the source page does not have the API anymore
apiPage.performActionFromEditor("move", "ApiToBeMoved", "Page1", "Page2");
apiPage.performActionFromEditor("move", "ApiToBeMoved", "Page2", "Page1");
apiPage.deleteAPIFromEditor("ApiToBeMoved", "Page1");
});
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Add assertions to verify API move and delete operations.

Add assertions after each operation to verify the expected state:

// After moving API within same page
PageLeftPane.assertPresence("ApiToBeMoved");

// After moving API to different page
PageLeftPane.assertNotPresence("ApiToBeMoved", "Page1");
PageLeftPane.assertPresence("ApiToBeMoved", "Page2");

// After deleting API
PageLeftPane.assertNotPresence("ApiToBeMoved", "Page1");

Comment on lines +61 to +63
debuggerHelper.ClicklogEntityLink(false, 2);
// Assert that the correct tab ("Api3") opens
agHelper.AssertClassExists(FileTabs.locators.tabName("Api3"), "active");
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid hardcoded index in log selection.

The test relies on a hardcoded index (2) which makes it brittle. Consider using a more reliable way to identify the correct log entry, such as searching for specific content or using test data attributes.

Comment on lines +77 to +79
debuggerHelper.ClicklogEntityLink(false, 1);
// Assert that the correct tab ("Api2") reopens
agHelper.AssertClassExists(FileTabs.locators.tabName("Api2"), "active");
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid hardcoded index in log selection.

Similar to the previous test, using a hardcoded index (1) makes the test brittle. Consider a more reliable way to identify the correct log entry.

@shadabbuchh shadabbuchh merged commit 213db55 into release Jan 30, 2025
45 checks passed
@shadabbuchh shadabbuchh deleted the test/ApiAdditionalTests branch January 30, 2025 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ok-to-test Required label for CI skip-changelog Adding this label to a PR prevents it from being listed in the changelog Test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants