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

Commit 74999cc

Browse files
committed
Final tweaks, hopefully.
1 parent 1ec6362 commit 74999cc

2 files changed

Lines changed: 21 additions & 26 deletions

File tree

runestone/activecode/test/test_activecode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,8 @@ def test_activity_count(selenium_utils_progress):
126126
def test_sql_activecode(selenium_utils_get):
127127
div_id = "test_activecode_6"
128128
t2 = find_ac(selenium_utils_get, div_id)
129-
# Without this line, tests fail on Github actions. They run on my local Windows machine with no problem without this line. I don't know why.
130-
time.sleep(1)
129+
# TODO: We don't yet have a way for async operations in ActiveCode constructors to signal when they're complete. So, insert a delay to guesstimate when the async load of the SQL WASM code and other async functions complete.
130+
time.sleep(2)
131131
click_run(selenium_utils_get, t2)
132132
selenium_utils_get.wait.until(EC.text_to_be_present_in_element((By.ID, f"{div_id}_stdout"), "You"))
133133
res = selenium_utils_get.driver.find_element_by_id(f"{div_id}_sql_out")

runestone/shortanswer/test/test_shortanswer.py

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,65 +2,60 @@
22
Test Short Answer question directive
33
"""
44

5-
import pytest
6-
75
__author__ = "yasinovskyy"
86

97
DIV_ID = "test_short_answer_1"
108

119

12-
@pytest.fixture
13-
def selenium_utils_1(selenium_utils):
14-
selenium_utils.get("index.html")
10+
def get_sa(selenium_utils):
1511
selenium_utils.wait_until_ready(DIV_ID)
16-
return selenium_utils
12+
# See the notes in ``test_activecode.click_run`` on the need for this call.
13+
selenium_utils.driver.execute_script("window.scrollTo(0, 0);")
14+
return selenium_utils.driver.find_element_by_id(DIV_ID)
1715

1816

19-
def test_sa1(selenium_utils_1):
20-
"""No input. Button not clicked"""
21-
self = selenium_utils_1
22-
t1 = self.driver.find_element_by_id(DIV_ID)
17+
def click_button(sa_element):
18+
sa_element.find_element_by_tag_name("button").click()
19+
2320

21+
def test_sa1(selenium_utils_get):
22+
"""No input. Button not clicked"""
23+
t1 = get_sa(selenium_utils_get)
2424
fb = t1.find_element_by_id(f"{DIV_ID}_feedback")
2525
assert "alert-danger" in fb.get_attribute("class")
2626

2727

28-
def test_sa2(selenium_utils_1):
28+
def test_sa2(selenium_utils_get):
2929
"""No input. Button clicked"""
30-
t1 = selenium_utils_1.driver.find_element_by_id(DIV_ID)
31-
32-
btn_check = t1.find_element_by_tag_name("button")
33-
btn_check.click()
34-
30+
t1 = get_sa(selenium_utils_get)
31+
click_button(t1)
3532
fb = t1.find_element_by_id(f"{DIV_ID}_feedback")
3633
assert "alert-success" in fb.get_attribute("class")
3734

3835

39-
def test_sa3(selenium_utils_1):
36+
def test_sa3(selenium_utils_get):
4037
"""Answer entered"""
41-
t1 = selenium_utils_1.driver.find_element_by_id(DIV_ID)
38+
t1 = get_sa(selenium_utils_get)
4239
ta = t1.find_element_by_id(f"{DIV_ID}_solution")
4340
ta.clear()
4441
ta.send_keys("My answer")
4542

46-
btn_check = t1.find_element_by_tag_name("button")
47-
btn_check.click()
43+
click_button(t1)
4844

4945
fb = t1.find_element_by_id(f"{DIV_ID}_feedback")
5046
assert fb is not None
5147
assert "alert-success" in fb.get_attribute("class")
5248

5349

5450
# TODO: this is the same as ``_test_sa3``.
55-
def test_sa4(selenium_utils_1):
51+
def test_sa4(selenium_utils_get):
5652
"""Answer entered and cleared"""
57-
t1 = selenium_utils_1.driver.find_element_by_id(DIV_ID)
53+
t1 = get_sa(selenium_utils_get)
5854
ta = t1.find_element_by_id(f"{DIV_ID}_solution")
5955
ta.clear()
6056
ta.send_keys("My answer")
6157

62-
btn_check = t1.find_element_by_tag_name("button")
63-
btn_check.click()
58+
click_button(t1)
6459

6560
fb = t1.find_element_by_id(f"{DIV_ID}_feedback")
6661
assert fb is not None

0 commit comments

Comments
 (0)