Skip to content
This repository was archived by the owner on Jun 7, 2023. It is now read-only.

Commit 47c1394

Browse files
author
Brad Miller
committed
test page progress with no services
1 parent c5c7aa5 commit 47c1394

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

runestone/activecode/test/test_activecode.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,4 +79,22 @@ def test_livecode_datafile(self):
7979
try:
8080
self.assertLess(count, 20)
8181
except:
82-
print("WARNING - No response from JOBE server")
82+
print("WARNING - No response from JOBE server")
83+
84+
def test_activity_count(self):
85+
self.driver.get(self.host + "/index.html")
86+
t2 = self.driver.find_element_by_id("test1")
87+
self.assertIsNotNone(t2)
88+
rb = t2.find_element_by_class_name("run-button")
89+
self.assertIsNotNone(rb)
90+
rb.click()
91+
pb = self.driver.find_element_by_id("subchapterprogress")
92+
self.assertIsNotNone(pb)
93+
total = self.driver.find_element_by_id("scprogresstotal").text.strip()
94+
self.assertEqual(2, int(total))
95+
possible = self.driver.find_element_by_id("scprogressposs").text.strip()
96+
self.assertEqual(5, int(possible))
97+
# count should not increment after a second click
98+
rb.click()
99+
total = self.driver.find_element_by_id("scprogresstotal").text.strip()
100+
self.assertEqual(2, int(total))

runestone/common/js/bookfuncs.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,15 @@ class PageProgressBar {
109109
constructor(actDict) {
110110
this.possible = 0;
111111
this.total = 1;
112-
this.activities = actDict || {};
112+
if(actDict) {
113+
this.activities = actDict;
114+
} else {
115+
let activities = {}
116+
$(".runestone").each(function (idx, e) {
117+
activities[e.firstElementChild.id] = 0;
118+
})
119+
this.activities = activities;
120+
}
113121
this.calculateProgress();
114122
this.renderProgress()
115123

0 commit comments

Comments
 (0)