From 01009bfbdefa6b8f4e38dd06ed2c580eb9a03bed Mon Sep 17 00:00:00 2001 From: Ryosuke Niwa Date: Fri, 26 Jan 2024 16:37:28 -0800 Subject: [PATCH 1/2] This PR fixes the issue #365: jQuery test only ever marks the first todo item as completed The bug was caused by jQuery replacing the whole todo list whenever each todo item is toggled. Fixed it by running querySelectorAll in each iteration. --- resources/tests.mjs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/resources/tests.mjs b/resources/tests.mjs index 300517c75..8ec075505 100644 --- a/resources/tests.mjs +++ b/resources/tests.mjs @@ -566,9 +566,8 @@ Suites.push({ } }), new BenchmarkTestStep("CompletingAllItems", (page) => { - const checkboxes = page.querySelectorAll(".toggle"); for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + page.querySelectorAll(".toggle")[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { for (let i = numberOfItemsToAdd - 1; i >= 0; i--) @@ -596,9 +595,8 @@ Suites.push({ } }), new BenchmarkTestStep("CompletingAllItems", (page) => { - const checkboxes = page.querySelectorAll(".toggle"); for (let i = 0; i < numberOfItemsToAdd; i++) - checkboxes[i].click(); + page.querySelectorAll(".toggle")[i].click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { for (let i = numberOfItemsToAdd - 1; i >= 0; i--) From 1cdc5ea530a4f9450a1c791b104e21133e53ce73 Mon Sep 17 00:00:00 2001 From: Julien Wajsberg Date: Tue, 30 Jan 2024 12:05:32 +0100 Subject: [PATCH 2/2] Use nth-child so that we don't need to use querySelectorAll --- resources/tests.mjs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/tests.mjs b/resources/tests.mjs index 8ec075505..625ae4f89 100644 --- a/resources/tests.mjs +++ b/resources/tests.mjs @@ -566,8 +566,8 @@ Suites.push({ } }), new BenchmarkTestStep("CompletingAllItems", (page) => { - for (let i = 0; i < numberOfItemsToAdd; i++) - page.querySelectorAll(".toggle")[i].click(); + for (let i = 1; i <= numberOfItemsToAdd; i++) + page.querySelector(`li:nth-child(${i}) .toggle`).click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { for (let i = numberOfItemsToAdd - 1; i >= 0; i--) @@ -595,8 +595,8 @@ Suites.push({ } }), new BenchmarkTestStep("CompletingAllItems", (page) => { - for (let i = 0; i < numberOfItemsToAdd; i++) - page.querySelectorAll(".toggle")[i].click(); + for (let i = 1; i <= numberOfItemsToAdd; i++) + page.querySelector(`li:nth-child(${i}) .toggle`).click(); }), new BenchmarkTestStep("DeletingAllItems", (page) => { for (let i = numberOfItemsToAdd - 1; i >= 0; i--)