Skip to content
Snippets Groups Projects

Resolve "Sort updated comments chronoligically"

Merged Dominik Seeger requested to merge 167-sort-updated-comments-chronoligically into master
1 file
+ 4
5
Compare changes
  • Side-by-side
  • Inline
from django.test import LiveServerTestCase
from django.test import LiveServerTestCase
from selenium import webdriver
from selenium import webdriver
 
from selenium.webdriver import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support import expected_conditions as ec
 
from selenium.webdriver.common.by import By
from core.models import UserAccount, Submission, FeedbackComment
from core.models import UserAccount, Submission, FeedbackComment
from functional_tests.util import (login, create_browser, reset_browser_after_test,
from functional_tests.util import (login, create_browser, reset_browser_after_test,
go_to_subscription, wait_until_code_changes,
go_to_subscription, wait_until_code_changes,
reconstruct_submission_code)
reconstruct_submission_code, wait_until_element_count_equals)
from util import factory_boys as fact
from util import factory_boys as fact
@@ -223,6 +225,74 @@ class UntestedParent:
@@ -223,6 +225,74 @@ class UntestedParent:
self.assertEqual(0, submission_for_code.feedback.score)
self.assertEqual(0, submission_for_code.feedback.score)
self.assertEqual(1, submission_for_code.feedback.feedback_lines.count())
self.assertEqual(1, submission_for_code.feedback.feedback_lines.count())
 
def test_comments_are_sorted_by_last_updated(self):
 
self._login()
 
go_to_subscription(self)
 
 
code = reconstruct_submission_code(self)
 
self.browser.find_element_by_id('score-full').click()
 
 
# give feedback on first line
 
self.write_comments_on_lines([(1, 'first ever comment')])
 
 
submit_btn = self.browser.find_element_by_id('submit-feedback')
 
submit_btn.click()
 
 
WebDriverWait(self.browser, 10).until(
 
wait_until_code_changes(self, code)
 
)
 
 
reset_browser_after_test(self.browser, self.live_server_url) # logs out user
 
 
user_snd = 'tutor_snd'
 
password = 'p'
 
fact.UserAccountFactory(username=user_snd, password=password)
 
 
login(self.browser, self.live_server_url, user_snd, password)
 
go_to_subscription(self, stage='validate')
 
 
self.write_comments_on_lines([(1, 'the second comment')])
 
self.browser.find_element_by_id('score-full').click()
 
self.browser.find_element_by_class_name('final-checkbox').click()
 
self.browser.find_element_by_id('submit-feedback').click()
 
 
sub_url = 'subscription/' + str(self.sub_type.pk) + '/ended'
 
WebDriverWait(self.browser, 10).until(ec.url_contains(sub_url))
 
 
reset_browser_after_test(self.browser, self.live_server_url) # logs out user
 
self._login()
 
 
# goto history
 
self.browser.find_element_by_id('feedback').click()
 
feedback_entry = self.browser.find_element_by_class_name('feedback-row')
 
ActionChains(self.browser).move_to_element(feedback_entry).click().perform()
 
 
# validate that second comment is under the first comment
 
comments = self.browser.find_elements_by_class_name('dialog-box')
 
first_text = comments[0].find_element_by_class_name('message')
 
second_text = comments[1].find_element_by_class_name('message')
 
 
self.assertEqual(len(comments), 2)
 
self.assertEqual(first_text.text, 'first ever comment')
 
self.assertEqual(second_text.text, 'the second comment')
 
 
# give feedback on first line
 
self.write_comments_on_lines([(1, 'first comment updated')])
 
self.browser.find_element_by_id('score-full').click()
 
self.browser.find_element_by_id('submit-feedback').click()
 
 
WebDriverWait(self.browser, 5).until(
 
wait_until_element_count_equals(self, By.CLASS_NAME, "dialog-box", 2)
 
)
 
 
# validate that the edited first comment is under the second comment
 
comments = self.browser.find_elements_by_class_name('dialog-box')
 
first_text = comments[0].find_element_by_class_name('message')
 
second_text = comments[1].find_element_by_class_name('message')
 
 
self.assertEqual(first_text.text, 'the second comment')
 
self.assertEqual(second_text.text, 'first comment updated')
 
class TestFeedbackCreationTutor(UntestedParent.TestFeedbackCreationGeneric):
class TestFeedbackCreationTutor(UntestedParent.TestFeedbackCreationGeneric):
def setUp(self):
def setUp(self):
Loading