Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Collection of Practice
2019
1606885025-practice
Commits
adcc9e23
Commit
adcc9e23
authored
Dec 23, 2019
by
Rani Lasma Uli
Browse files
add functional test for feedback feature
parent
321221e1
Pipeline
#28378
passed with stages
in 4 minutes and 55 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
feedback/templates/feedback.html
View file @
adcc9e23
...
...
@@ -5,12 +5,12 @@
<section>
<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 %}
</form>
</section>
...
...
functional_tests/test_feedback.py
0 → 100644
View file @
adcc9e23
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
)
self
.
browser
.
find_element_by_id
(
'feedback_username'
).
send_keys
(
"ANONYMUS"
)
self
.
browser
.
find_element_by_id
(
'feedback_text'
).
send_keys
(
"TEST"
)
self
.
browser
.
find_element_by_id
(
'feedback_submit'
).
click
()
# The home page refreshes, and there is an error message saying
# that list items cannot be blank
self
.
wait_for
(
lambda
:
self
.
assertEqual
(
self
.
browser
.
find_element_by_id
(
'list_feedback'
).
text
,
"TEST"
))
# # 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')
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment