Skip to content

Commit 11dba5c

Browse files
committed
fix previously flaky test on itemSubmission tests on chapter8
1 parent 82192ac commit 11dba5c

File tree

8 files changed

+10
-6
lines changed

8 files changed

+10
-6
lines changed

chapter8/3_dealing_with_flakiness/2_stubbing_uncontrollable_factors/cypress/integration/itemSubmission.spec.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ describe("item submission", () => {
1717
InventoryManagement.visit();
1818
cy.window().then(w => cy.stub(w.Math, "random").returns(0.5));
1919
InventoryManagement.addItem("cheesecake", "10");
20-
InventoryManagement.findItemEntry("cheesecake", "10").should(
21-
"have.attr",
22-
"href",
23-
"http://example.com/always-the-same-url/second-recipe"
24-
);
20+
InventoryManagement.findItemEntry("cheesecake", "10")
21+
.get("a")
22+
.should(
23+
"have.attr",
24+
"href",
25+
"http://example.com/always-the-same-url/second-recipe"
26+
);
2527
});
2628

2729
it("can update an item's quantity", () => {

chapter8/client/domController.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@ const updateItemList = inventory => {
1919
const recipeList = (await recipeResponse.json()).recipes;
2020
const randomRecipe = Math.floor(Math.random() * recipeList.length - 1) + 1;
2121
listLink.innerHTML = `${itemName} - Quantity: ${quantity}`;
22-
listLink.href = recipeList[randomRecipe].href;
22+
listLink.href = recipeList[randomRecipe]
23+
? recipeList[randomRecipe].href
24+
: "#";
2325

2426
if (quantity < 5) {
2527
listItem.className = "almost-soldout";

0 commit comments

Comments
 (0)