Skip to content

Commit 4605394

Browse files
authored
Merge pull request #244 from Xronophobe/update--chapter-14_validation-first
update chapter 14
2 parents edda7a2 + 67855c6 commit 4605394

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

chapter_14_simple_form.asciidoc

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,11 @@ NOTE: Doing this sort of widget customisation would get tedious
178178
if we had a much larger, more complex form.
179179
Check out
180180
https://django-crispy-forms.readthedocs.org/[django-crispy-forms]
181-
and http://bit.ly/1rR5eyD[django-floppyforms] for some help.
182181
((("django-crispy-forms")))
183-
((("django-floppyforms")))
182+
//CSANAD: crispy forms still seems to be maintained and up-to-date, floppyforms
183+
// not so much. Some comments on floppyforms' issues say that its
184+
// functionality is built into Django as of 2020. I'm not sure if it's true for
185+
// crispyforms as well.
184186

185187

186188
[role="pagebreak-before less_space"]
@@ -535,8 +537,9 @@ the logic change:
535537
[subs="specialcharacters,quotes"]
536538
----
537539
$ *git diff* # review changes in base.html, views.py and its tests
538-
$ *git commit -am "use new form in home_page, simplify tests. NB breaks stuff"*
540+
$ *git commit -am "use new form in home_page. NB breaks stuff"*
539541
----
542+
// CSANAD: we didn't simplify the tests in this step. What's NB?
540543

541544

542545
Let's fix the functional tests.
@@ -613,6 +616,8 @@ $ *grep -r id_new_item src/lists/*
613616
----
614617

615618
Good, there are no references to `id_new_item` left.
619+
// CSANAD: we could mention *.pyc files under __pycache__ would probably still
620+
// show up in the results.
616621
What about `name`/ `item_text`?
617622

618623
[subs="specialcharacters,macros"]
@@ -645,33 +650,32 @@ Ran 17 tests in 0.126s
645650
OK
646651
----
647652

648-
And the functional tests too:
653+
And the functional tests too, where we can see three errors:
649654

650-
[subs="specialcharacters,macros"]
651655
----
652-
$ pass:quotes[*python src/manage.py test functional_tests*]
656+
ERROR: test_layout_and_styling (functional_tests.test_layout_and_styling.LayoutAndStylingTest.test_layout_and_styling)
653657
[...]
654-
File "...goat-book/src/functional_tests/test_layout_and_styling.py", line 27,
655-
in test_layout_and_styling
656-
inputbox = self.get_item_input_box()
657-
^^^^^^^^^^^^^^^^^^^^^^^^^
658-
File "...goat-book/src/functional_tests/base.py", line 45, in
659-
get_item_input_box
660-
return self.browser.find_element(By.ID, "id_text")
661-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
658+
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate
659+
element: [id="id_text"];
660+
[...]
661+
ERROR: test_can_start_a_todo_list (functional_tests.test_simple_list_creation.NewVisitorTest.test_can_start_a_todo_list)
662662
[...]
663663
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate
664-
element: [id="id_text"]; [...]
665-
664+
element: [id="id_text"];
666665
[...]
667-
FAILED (errors=3)
668666
----
669667

670-
Not quite! Let's look at where this is happening--if
671-
you check the line number from one of the failures,
672-
you'll see that each time after we've submitted a first item,
673-
the input box has disappeared from the lists page.
668+
and
674669

670+
----
671+
ERROR: test_cannot_add_empty_list_items (functional_tests.test_list_item_validation.ItemValidationTest.test_cannot_add_empty_list_items)
672+
[...]
673+
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate
674+
element: .invalid-feedback;
675+
[...]
676+
----
677+
678+
Let's start with the latter.
675679
Checking _views.py_ and the `new_list` view we can see
676680
it's because if we detect a validation error,
677681
we're not actually passing the form to the _home.html_ template:
@@ -1030,8 +1034,6 @@ or spin up the site manually with `manage.py runserver` if you prefer
10301034
(see <<html5_popup_screenshot>>).
10311035

10321036

1033-
// todo: update screenshot
1034-
10351037
[[html5_popup_screenshot]]
10361038
.HTML5 validation says no
10371039
image::images/twp2_1401.png["The input with a popup saying 'please fill out this field'"]

images/twp2_1401.png

-45.7 KB
Loading

0 commit comments

Comments
 (0)