Skip to content

Commit

Permalink
Updated fetch spec
Browse files Browse the repository at this point in the history
  • Loading branch information
sagar-qa007 committed Oct 1, 2024
1 parent 05d3822 commit 4b38812
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,28 @@ describe("Tests fetch calls", { tags: ["@tag.JS"] }, () => {
it("3. Tests if fetch works with store value", function () {
entityExplorer.DragDropWidgetNVerify("buttonwidget", 500, 200);
EditorNavigation.SelectEntityByName("Button1", EntityType.Widget);
propPane.TypeTextIntoField("Label", "getUserID");
propPane.TypeTextIntoField("Label", "getUserName");
propPane.EnterJSContext(
"onClick",
`{{fetch('https://jsonplaceholder.typicode.com/todos/1')
.then(res => res.json())
.then(json => storeValue('userId', json.userId))
.then(() => showAlert("UserId: " + appsmith.store.userId))}}`,
`{{fetch('http://host.docker.internal:5001/v1/genderize_agify?name=sagar')
.then(res => {
if (!res.ok) {
throw new Error('Network response was not ok');
}
return res.json();
})
.then(json => {
const name = json.name; // Get the name
showAlert("Name: " + name);
})
.catch(error => {
console.error("Fetch error:", error);
showAlert("Failed to fetch user data: " + error.message);
})}}`
);

agHelper.Sleep(2000);
agHelper.ClickButton("getUserID");
agHelper.AssertContains("UserId: 1", "exist");
agHelper.ClickButton("getUserName");
agHelper.AssertContains("Name: sagar", "exist");
});
});
2 changes: 1 addition & 1 deletion app/client/cypress/limited-tests.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# To run only limited tests - give the spec names in below format:
cypress/e2e/Regression/ClientSide/Templates/Fork_Template_spec.js
cypress/e2e/Regression/ServerSide/JsFunctionExecution/Fetch_Spec.ts

# For running all specs - uncomment below:
#cypress/e2e/**/**/*
Expand Down

0 comments on commit 4b38812

Please sign in to comment.