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: Api curl remaining cases #38753

Merged
merged 2 commits into from
Jan 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import ApiEditor from "../../../../locators/ApiEditor";
import {
apiPage,
agHelper,
dataManager,
assertHelper,
} from "../../../../support/Objects/ObjectsCore";

describe(
"API Panel request body",
{ tags: ["@tag.Datasource", "@tag.Git", "@tag.AccessControl"] },
function () {
it("1. Ensure that the run button is disabled when there are empty fields.", function () {
apiPage.CreateApi("FirstAPI");
apiPage.AssertRunButtonDisability(true);
});

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");
});
Comment on lines +18 to +26
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

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.

Suggested change
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");
});


// Cypress issue: https://github.com/cypress-io/cypress/issues/8267
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(
this.isMac ? "{cmd}{enter}" : "{ctrl}{enter}",
{
release: false,
},
);
assertHelper.AssertNetworkStatus("@postExecute");
});
},
);
Loading