Improve reporting of number of manual tests left
authorAryeh Gregor <AryehGregor+gitcommit@gmail.com>
Sun, 12 Jun 2011 14:11:32 -0600
changeset 259 e8f0d7967654
parent 258 e9814a4d057b
child 260 b380de7b4ecf
Improve reporting of number of manual tests left
backspacetest.html
linebreaktest.html
manualtest.js
--- a/backspacetest.html	Sun Jun 12 14:01:42 2011 -0600
+++ b/backspacetest.html	Sun Jun 12 14:11:32 2011 -0600
@@ -23,7 +23,7 @@
 <div id=overlay>Tap backspace repeatedly until this annoying message
 disappears!  (But not too quickly.  And don't hit any other keys or click with
 the mouse anywhere, it will mess it up.<span id=testcount>  <span></span>
-test(s) remain.</span>)</div>
+manual test(s) remain.</span>)</div>
 
 <script src=implementation.js></script>
 <script src=tests.js></script>
--- a/linebreaktest.html	Sun Jun 12 14:01:42 2011 -0600
+++ b/linebreaktest.html	Sun Jun 12 14:11:32 2011 -0600
@@ -22,8 +22,8 @@
 
 <div id=overlay>Tap enter repeatedly until this annoying message
 disappears!  (But not too quickly.  And don't hit any other keys or click with
-the mouse anywhere, it will mess it up.<span id=testcount>  <span></span> test(s)
-remain.</span>)</div>
+the mouse anywhere, it will mess it up.<span id=testcount>  <span></span>
+manual test(s) remain.</span>)</div>
 
 <script src=implementation.js></script>
 <script src=tests.js></script>
--- a/manualtest.js	Sun Jun 12 14:01:42 2011 -0600
+++ b/manualtest.js	Sun Jun 12 14:11:32 2011 -0600
@@ -10,7 +10,17 @@
 	}
 }
 
+var numManualTests = 0;
+
 function runTests() {
+	// We don't ask the user to hit a key on all tests, so make sure not to
+	// claim more tests are going to be run than actually are.
+	for (var i = 0; i < tests.length; i++) {
+		if (localStorage.getItem(keyname + "test-" + tests[i]) === null) {
+			numManualTests++;
+		}
+	}
+
 	testsRunning = true;
 	var runTestsButton = document.querySelector("#tests input[type=button]");
 	runTestsButton.parentNode.removeChild(runTestsButton);
@@ -31,10 +41,12 @@
 	doInputCell(tr, test);
 	doSpecCell(tr, test, command, false);
 	if (localStorage.getItem(keyname + "test-" + test) !== null) {
-		// Yay, I get to cheat
+		// Yay, I get to cheat.  Remove the overlay div so the user doesn't
+		// keep hitting the key, in case it takes a while.
 		var browserCell = document.createElement("td");
 		tr.appendChild(browserCell);
 		browserCell.innerHTML = localStorage[keyname + "test-" + test];
+		document.getElementById("overlay").style.display = "";
 		doSameCell(tr);
 		runNextTest(test);
 	} else {
@@ -49,7 +61,7 @@
 	doTearDown();
 	var input = document.querySelector("#tests label input");
 	if (!testsRunning) {
-		document.getElementById("overlay").style.display = "none";
+		document.getElementById("overlay").style.display = "";
 		return;
 	}
 	var idx = tests.indexOf(test);
@@ -58,7 +70,7 @@
 		document.body.textContent = "Duplicate test: " + test;
 	}
 	if (idx + 1 >= tests.length) {
-		document.getElementById("overlay").style.display = "none";
+		document.getElementById("overlay").style.display = "";
 		testsRunning = false;
 		input.value = "";
 		return;
@@ -90,7 +102,8 @@
 			document.getElementById("testcount").style.display = "none";
 		} else {
 			document.getElementById("testcount").style.display = "";
-			document.querySelector("#testcount > span").textContent = tests.length - idx;
+			document.querySelector("#testcount > span").textContent = numManualTests;
+			numManualTests--;
 		}
 		document.getElementById("overlay").style.display = "block";
 		testDiv.focus();