-
Notifications
You must be signed in to change notification settings - Fork 444
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
Cypress tests replace cy.wait with cy.intercept or dynamic waits #8963
base: develop
Are you sure you want to change the base?
Changes from all commits
bb972f2
f5d5cc8
a6f10ee
f8cd9c8
814aebc
568c7e2
f5734f6
ac1072c
277fb42
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,15 +25,20 @@ describe("Inventory Management Section", () => { | |
|
||
it("Add New Inventory | Modify data and delete last entry ", () => { | ||
// add a new item | ||
cy.intercept("GET", "/api/v1/items/**").as("getItems"); | ||
facilityPage.clickManageInventory(); | ||
cy.wait("@getItems").its("response.statusCode").should("eq", 200); | ||
facilityPage.fillInventoryDetails("PPE", "Add Stock", "10"); | ||
facilityPage.clickAddInventory(); | ||
facilityPage.verifySuccessNotification("Inventory created successfully"); | ||
cy.closeNotification(); | ||
facilityPage.clickManageInventory(); | ||
// modify the new item | ||
facilityPage.fillInventoryDetails("PPE", "Use Stock", "5"); | ||
facilityPage.clickAddInventory(); | ||
facilityPage.verifySuccessNotification("Inventory created successfully"); | ||
facilityPage.verifySuccessNotification( | ||
"Inventory use stock updated successfully", | ||
); | ||
// verify the new modification | ||
facilityPage.verifyPpeQuantity("PPE"); | ||
facilityPage.verifyPpeQuantity("5"); | ||
|
@@ -43,7 +48,6 @@ describe("Inventory Management Section", () => { | |
// verify the last entry deletion | ||
facilityPage.verifyStockInRow("#row-0", "Added Stock"); | ||
facilityPage.verifyStockInRow("#row-1", "Used Stock"); | ||
cy.wait(3000); | ||
facilityHome.navigateBack(); | ||
facilityPage.verifyPpeQuantity("PPE"); | ||
}); | ||
|
@@ -57,9 +61,12 @@ describe("Inventory Management Section", () => { | |
cy.closeNotification(); | ||
// Verify Backend minimum badge | ||
facilityPage.verifyBadgeWithText(".badge-danger", "Low Stock"); | ||
cy.intercept("GET", "**/api/v1/facility/*/min_quantity/**").as( | ||
"getMinQuantity", | ||
); | ||
// modify with manual minimum badge | ||
facilityPage.clickAddMinimumQuanitity(); | ||
cy.wait(3000); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the intercept and API Verification is missing here |
||
cy.wait("@getMinQuantity").its("response.statusCode").should("eq", 200); | ||
cy.get("body").then(($body) => { | ||
if ($body.find("#update-minimum-quantity").is(":visible")) { | ||
// If the 'update-minimum-quantity' element is visible, click it | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -284,8 +284,7 @@ class FacilityPage { | |
cy.get("#facility-location-button").click(); | ||
cy.wait("@mapApi").its("response.statusCode").should("eq", 200); | ||
cy.get("input#pac-input").type(location).type("{enter}"); | ||
cy.wait(2000); | ||
cy.get("div#map-close").click(); | ||
cy.get("div#map-close").should("be.visible").click(); | ||
} | ||
|
||
fillMiddleWareAddress(url: string) { | ||
|
@@ -355,16 +354,14 @@ class FacilityPage { | |
} | ||
|
||
fillInventoryDetails(name: string, status: string, quantity: string) { | ||
cy.wait(2000); | ||
cy.get("div#id").click(); | ||
cy.get("div#id ul li").contains(name).click(); | ||
cy.get("div#isIncoming").click(); | ||
cy.get("div#isIncoming ul li").contains(status).click(); | ||
cy.get("div#id").click(); | ||
cy.get("div#id ul li").contains(name).click(); | ||
Comment on lines
+359
to
+360
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Avoid using generic IDs like Using |
||
cy.get("[name='quantity']").type(quantity); | ||
} | ||
|
||
fillInventoryMinimumDetails(name: string, quantity: string) { | ||
cy.wait(2000); | ||
cy.get("div#id").click(); | ||
cy.get("div#id ul li").contains(name).click(); | ||
cy.get("[name='quantity']").type(quantity); | ||
|
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.
the intercept and API Verification is missing here