Fakultas Ilmu Komputer UI

Commit adcc9e23 authored by Rani Lasma Uli's avatar Rani Lasma Uli
Browse files

add functional test for feedback feature

parent 321221e1
Pipeline #28378 passed with stages
in 4 minutes and 55 seconds
......@@ -5,12 +5,12 @@
<form class="feedback-form" method="POST" action ="{% url 'send_feedbacks' %}">
<label for="username">Username</label>
<input name="username" type="text" /> <br>
<input name="username" type="text" id="feedback_username" /> <br>
<label for="text">Text</label>
<input name="text" type="text" /> <br>
<input name="text" type="text" id="feedback_text" /> <br>
<input type="submit" class="submit_btn btn label-success" value="add" />
<input type="submit" class="submit_btn btn label-success" value="add" id="feedback_submit"/>
{% csrf_token %}
from django.conf import settings
from django.contrib.auth import BACKEND_SESSION_KEY, SESSION_KEY, get_user_model
from django.contrib.sessions.backends.db import SessionStore
from .base import FunctionalTest
User = get_user_model()
FEEDBACK_URI = '/feedbacks/'
class FeedbackTest(FunctionalTest):
def test_add_feedback(self):
# Edith goes to the home page and accidentally tries to submit
# an empty list item. She hits Enter on the empty input box
self.browser.get(self.BASE_URL + FEEDBACK_URI)
# The home page refreshes, and there is an error message saying
# that list items cannot be blank
self.wait_for(lambda: self.assertEqual(
# # She tries again with some text for the item, which now works
# self.browser.find_element_by_id('id_new_item').send_keys('Buy milk')
# self.browser.find_element_by_id('id_new_item').send_keys(Keys.ENTER)
# self.wait_for_row_in_list_table('1: Buy milk')
# # Perversely, she now decides to submit a second blank list item
# self.browser.find_element_by_id('id_new_item').send_keys(Keys.ENTER)
# # She receives a similar warning on the list page
# self.wait_for(lambda: self.assertEqual(
# self.browser.find_element_by_css_selector('.has-error').text,
# "You can't have an empty list item"
# ))
# # And she can correct it by filling some text in
# self.browser.find_element_by_id('id_new_item').send_keys('Make tea')
# self.browser.find_element_by_id('id_new_item').send_keys(Keys.ENTER)
# self.wait_for_row_in_list_table('1: Buy milk')
# self.wait_for_row_in_list_table('2: Make tea')
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment