-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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: Api curl remaining cases #38753
Conversation
WalkthroughThis pull request introduces a new Cypress end-to-end test file Changes
Sequence DiagramsequenceDiagram
participant User
participant APIPanel
participant RunButton
User->>APIPanel: Enter API details
alt Empty Fields
APIPanel-->>RunButton: Disable Run Button
end
User->>APIPanel: Enter Invalid URL
User->>APIPanel: Click Import
APIPanel-->>User: Display Error Message
User->>APIPanel: Focus on Data Source
User->>APIPanel: Cmd + Enter
APIPanel->>RunButton: Trigger Run
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (7)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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
🧹 Nitpick comments (2)
app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_RunValidations_spec.ts (2)
9-12
: Consider using a more descriptive test suite name.The current description "API Panel request body" could be more specific about what aspects are being tested, e.g., "API Panel Run Button and URL Validation Tests".
13-16
: Add more assertions for comprehensive validation.While the test checks for button disability, consider adding assertions for:
- Button state before API creation
- Visual indicators of the disabled state
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_RunValidations_spec.ts
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_RunValidations_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: perform-test / rts-build / build
- GitHub Check: perform-test / server-build / server-unit-tests
- GitHub Check: client-unit-tests / client-unit-tests
- GitHub Check: client-prettier / prettier-check
🔇 Additional comments (1)
app/client/cypress/e2e/Regression/ServerSide/ApiTests/API_RunValidations_spec.ts (1)
1-8
: LGTM! Clean imports following best practices.
it('2. Validate we get an appropriate error message when an invalid URL is entered. Error should show up when nothing is entered & we click on "Import".', function () { | ||
apiPage.CreateAndFillApi( | ||
"htt://failedurlfortest", | ||
"WhatTrumpThinks", | ||
"SecondAPI", | ||
); | ||
agHelper.GetNClick(apiPage._apiRunBtn, 0, true, 10000); | ||
apiPage.ResponseStatusCheck("PE-RST-5000"); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Replace GetNClick wait time with proper assertions.
The use of hardcoded wait time (10000) in GetNClick violates the Cypress best practices.
Replace with:
- agHelper.GetNClick(apiPage._apiRunBtn, 0, true, 10000);
+ agHelper.GetNAssertElementPresence(apiPage._apiRunBtn)
+ agHelper.GetNClick(apiPage._apiRunBtn);
📝 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.
it('2. Validate we get an appropriate error message when an invalid URL is entered. Error should show up when nothing is entered & we click on "Import".', function () { | |
apiPage.CreateAndFillApi( | |
"htt://failedurlfortest", | |
"WhatTrumpThinks", | |
"SecondAPI", | |
); | |
agHelper.GetNClick(apiPage._apiRunBtn, 0, true, 10000); | |
apiPage.ResponseStatusCheck("PE-RST-5000"); | |
}); | |
it('2. Validate we get an appropriate error message when an invalid URL is entered. Error should show up when nothing is entered & we click on "Import".', function () { | |
apiPage.CreateAndFillApi( | |
"htt://failedurlfortest", | |
"WhatTrumpThinks", | |
"SecondAPI", | |
); | |
agHelper.GetNAssertElementPresence(apiPage._apiRunBtn) | |
agHelper.GetNClick(apiPage._apiRunBtn); | |
apiPage.ResponseStatusCheck("PE-RST-5000"); | |
}); |
it("3. Validate keyboard navigation e.g. Cmd + Enter should trigger the Run button", function () { | ||
apiPage.CreateAndFillApi( | ||
dataManager.dsValues[dataManager.defaultEnviorment].randomTrumpApi, | ||
"WhatTrumpThinks", | ||
"ThirdAPI", | ||
); | ||
agHelper.GetNClick(ApiEditor.dataSourceField, 0, true); | ||
cy.get(ApiEditor.dataSourceField).type("{cmd}{enter}", { | ||
release: false, | ||
}); | ||
assertHelper.AssertNetworkStatus("@postExecute"); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Improve cross-platform compatibility for keyboard shortcuts.
The current implementation might not work correctly across different operating systems.
Consider:
- Using a platform-agnostic approach
- Adding assertions for both Windows (Ctrl+Enter) and Mac (Cmd+Enter)
- cy.get(ApiEditor.dataSourceField).type("{cmd}{enter}", {
+ cy.get(ApiEditor.dataSourceField).type(Cypress.platform === 'darwin' ? '{cmd}{enter}' : '{ctrl}{enter}', {
release: false,
});
📝 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.
it("3. Validate keyboard navigation e.g. Cmd + Enter should trigger the Run button", function () { | |
apiPage.CreateAndFillApi( | |
dataManager.dsValues[dataManager.defaultEnviorment].randomTrumpApi, | |
"WhatTrumpThinks", | |
"ThirdAPI", | |
); | |
agHelper.GetNClick(ApiEditor.dataSourceField, 0, true); | |
cy.get(ApiEditor.dataSourceField).type("{cmd}{enter}", { | |
release: false, | |
}); | |
assertHelper.AssertNetworkStatus("@postExecute"); | |
}); | |
it("3. Validate keyboard navigation e.g. Cmd + Enter should trigger the Run button", function () { | |
apiPage.CreateAndFillApi( | |
dataManager.dsValues[dataManager.defaultEnviorment].randomTrumpApi, | |
"WhatTrumpThinks", | |
"ThirdAPI", | |
); | |
agHelper.GetNClick(ApiEditor.dataSourceField, 0, true); | |
cy.get(ApiEditor.dataSourceField).type(Cypress.platform === 'darwin' ? '{cmd}{enter}' : '{ctrl}{enter}', { | |
release: false, | |
}); | |
assertHelper.AssertNetworkStatus("@postExecute"); | |
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
## Description New test cases Fixes # https://app.zenhub.com/workspaces/qa-63316faf86bb2e170ed2e46b/issues/gh/appsmithorg/appsmith/38478 ## Automation /ok-to-test tags="@tag.Datasource" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/12850322339> > Commit: 308c60e > <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=12850322339&attempt=2" target="_blank">Cypress dashboard</a>. > Tags: `@tag.Datasource` > Spec: > <hr>Sun, 19 Jan 2025 09:01:49 UTC <!-- end of auto-generated comment: Cypress test results --> ## Communication Should the DevRel and Marketing teams inform users about this change? - [ ] Yes - [x] No <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Tests** - Added comprehensive Cypress end-to-end tests for API panel functionality - Validated run button state with empty fields - Verified error handling for invalid URL inputs - Confirmed keyboard navigation for running API tests <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Description
New test cases
Fixes # https://app.zenhub.com/workspaces/qa-63316faf86bb2e170ed2e46b/issues/gh/appsmithorg/appsmith/38478
Automation
/ok-to-test tags="@tag.Datasource"
🔍 Cypress test results
Tip
🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/12850322339
Commit: 308c60e
Cypress dashboard.
Tags:
@tag.Datasource
Spec:
Sun, 19 Jan 2025 09:01:49 UTC
Communication
Should the DevRel and Marketing teams inform users about this change?
Summary by CodeRabbit