diff --git a/backend/experiment/rules/categorization.py b/backend/experiment/rules/categorization.py index 5097c0c39..1926ab9d5 100644 --- a/backend/experiment/rules/categorization.py +++ b/backend/experiment/rules/categorization.py @@ -12,6 +12,8 @@ from .base import Base import random +from django.conf import settings + SCORE_AVG_MIN_TRAINING = 0.8 @@ -288,7 +290,7 @@ def plan_experiment(self, session): participant=session.participant) # Check if this participant already has a previous session - if current_sessions.count() > 1: + if current_sessions.count() > 1 and not settings.TESTING: json_data = 'REPEAT' else: # Check wether a group falls behind in the count diff --git a/frontend/src/components/Question/Question.js b/frontend/src/components/Question/Question.js index 0026b6d4e..ae48751bd 100644 --- a/frontend/src/components/Question/Question.js +++ b/frontend/src/components/Question/Question.js @@ -81,6 +81,10 @@ const Question = ({ )}
{question.expected_response}
+ } ); }; diff --git a/frontend/src/components/Question/Question.scss b/frontend/src/components/Question/Question.scss index 498b85083..7de512f97 100644 --- a/frontend/src/components/Question/Question.scss +++ b/frontend/src/components/Question/Question.scss @@ -42,3 +42,7 @@ } + +.expected-response { + display:none; +} diff --git a/tests/tests-selenium.py b/tests/tests-selenium.py index ee014df9a..5a0f45b49 100644 --- a/tests/tests-selenium.py +++ b/tests/tests-selenium.py @@ -74,6 +74,7 @@ def tearDown(self): self.driver.quit() #warnings.simplefilter("default", ResourceWarning) + def test_beatalignment(self): self.driver.get("{}/{}".format(self.config['url']['root'], self.config['experiment_slugs']['beat_alignment'])) @@ -167,5 +168,62 @@ def test_eurovision(self): self.driver.find_element(By.XPATH, '//*[text()="Play again"]') + def test_categorization(self): + + self.driver.get("{}/{}".format(self.config['url']['root'], self.config['experiment_slugs']['categorization'])) + + # Explainer 1 + self.driver.find_element(By.XPATH, "//div[text()=\"Ok\"]").click() + + # If consent present, agree + if self.driver.find_element(By.TAG_NAME,"h4").text.lower() == "informed consent": + self.driver.find_element(By.XPATH, '//div[text()="I agree"]').click() + + # What is your age? + el = WebDriverWait(self.driver, 3).until(presence_of_element_located((By.CSS_SELECTOR,"input[type='number']"))) + el.send_keys(18) + self.driver.find_element(By.XPATH, '//*[text()="Continue"]').click() + + # What is your gender + self.driver.find_element(By.CSS_SELECTOR, ".radio:nth-child(1)").click() + self.driver.find_element(By.XPATH, '//*[text()="Continue"]').click() + + # What is your native language + select = Select(self.driver.find_element(By.TAG_NAME, 'select')) + select.select_by_value('nl') + self.driver.find_element(By.XPATH, '//*[text()="Continue"]').click() + + # Please select your level of musical experience + self.driver.find_element(By.CSS_SELECTOR, ".radio:nth-child(1)").click() + self.driver.find_element(By.XPATH, '//*[text()="Continue"]').click() + + # Explainer 2 + WebDriverWait(self.driver, 5) \ + .until(presence_of_element_located((By.XPATH, "//div[text()=\"Ok\"]"))) \ + .click() + + training_rounds = 20 + testing_rounds = 80 + training = True + for n in (training_rounds, testing_rounds): + for i in range(n): + + WebDriverWait(self.driver, 5) \ + .until(presence_of_element_located((By.CSS_SELECTOR, ".aha__play-button"))) \ + .click() + + expected_response = self.driver.execute_script('return document.querySelector(".expected-response").textContent') + button_to_click = self.driver.execute_script(f'return document.querySelector(\'input[value="{expected_response}"]\').parentElement') + WebDriverWait(self.driver, 5) \ + .until(lambda x: False if "disabled" in button_to_click.get_attribute("class") else button_to_click) \ + .click() + + if training: + WebDriverWait(self.driver, 5) \ + .until(presence_of_element_located((By.XPATH, "//div[text()=\"Ok\"]"))) \ + .click() + training = False + + if __name__ == '__main__': unittest.main()