                   (tu/has-focus? (rfd/input-selector :registration-first-name)))
 
          (testing "submitting form with only valid first-name"
-                  (tu/enter-text (rfd/input-selector :registration-first-name) valid-name)
+                  (clean-setup!)
+                  (tu/set-value (rfd/input-selector :registration-first-name) valid-name)
                   (tu/press-submit rfd/register-form-element-selector)
                   (check-last-name-has-blank-validation-errors)
                   (check-email-address-has-invalid-validation-errors)



(deftest losing-focus
         (setup-index-page!)
         (app/start)

         (testing "first-name"
                  (testing "- losing focus when blank adds invalid field class and validation message"
                           (tu/lose-focus (rfd/input-selector :registration-first-name))
                           (check-first-name-has-blank-validation-errors)))

         (testing "- losing focus when too-long adds invalid field class and validation message"
                  (tu/set-value (rfd/input-selector :registration-first-name) too-long-name)
                  (tu/lose-focus (rfd/input-selector :registration-first-name))
                  (tu/test-field-has-class (rfd/form-row-selector :registration-first-name) rfd/field-invalid-class)
                  (tu/element-has-text (rfd/validation-selector :registration-first-name)
                                         (get-in dom/translations [:index :register-first-name-too-long-validation-message])))

         (testing "- losing focus when valid removes invalid field class and validation message"
                  (tu/test-field-has-class (rfd/form-row-selector :registration-first-name) rfd/field-invalid-class)
                  (tu/element-has-text (rfd/validation-selector :registration-first-name)
                                         (get-in dom/translations [:index :register-first-name-too-long-validation-message]))

                  (tu/set-value (rfd/input-selector :registration-first-name) valid-name)
                  (tu/lose-focus (rfd/input-selector :registration-first-name))

                  (tu/test-field-doesnt-have-class (rfd/form-row-selector :registration-first-name) rfd/field-invalid-class)
                  (tu/element-has-no-text (rfd/validation-selector :registration-first-name)))

         (testing "last-name"
                  (testing "- losing focus when blank adds invalid field class and validation message"
                           (tu/lose-focus (rfd/input-selector :registration-last-name))
                           (check-last-name-has-blank-validation-errors))

                  (testing "- losing focus when too-long adds invalid field class and validation message"
                           (tu/set-value (rfd/input-selector :registration-last-name) too-long-name)
                           (tu/lose-focus (rfd/input-selector :registration-last-name))
                           (tu/test-field-has-class (rfd/form-row-selector :registration-last-name) rfd/field-invalid-class)
                           (tu/element-has-text (rfd/validation-selector :registration-last-name)
                                                  (get-in dom/translations [:index :register-last-name-too-long-validation-message])))

                  (testing "- losing focus when valid removes invalid field class and validation message"
                           (tu/test-field-has-class (rfd/form-row-selector :registration-last-name) rfd/field-invalid-class)
                           (tu/element-has-text (rfd/validation-selector :registration-last-name)
                                                  (get-in dom/translations [:index :register-last-name-too-long-validation-message]))

                           (tu/set-value (rfd/input-selector :registration-last-name) valid-name)
                           (tu/lose-focus (rfd/input-selector :registration-last-name))


                  (tu/has-focus? (rfd/input-selector :registration-last-name)))

         (testing "submitting form with only valid first-name and last-name"
                  (clean-setup!)
                  (tu/set-value (rfd/input-selector :registration-first-name) valid-name)
                  (tu/set-value (rfd/input-selector :registration-last-name) valid-name)
                  (tu/press-submit rfd/register-form-element-selector)
                  (check-email-address-has-invalid-validation-errors)
                  (check-password-has-blank-validation-errors)
                  (tu/has-focus? (rfd/input-selector :registration-email)))

         (testing "submitting form with only valid first-name, last-name and email-address"
                  (clean-setup!)
                  (tu/set-value (rfd/input-selector :registration-first-name) valid-name)
                  (tu/set-value (rfd/input-selector :registration-last-name) valid-name)
                  (tu/set-value (rfd/input-selector :registration-email) valid-email)
                  (tu/press-submit rfd/register-form-element-selector)
                  (check-password-has-blank-validation-errors)
                  (tu/has-focus? (rfd/input-selector :registration-password))))

(deftest prevent-default-submit
         (testing "prevents default when page has errors"
                  (clean-setup!)
                  (let [submit-event (tu/create-event :submit)]
                    (rfc/block-invalid-submit app/registration-form-state submit-event)
                    (tu/default-prevented? submit-event true)))

         (testing "doesn't prevent default when inputs are valid"
                  (clean-setup!)
                  (let [submit-event (tu/create-event :submit)]
                    (tu/enter-text (rfd/input-selector :registration-first-name) valid-name)
                    (tu/enter-text (rfd/input-selector :registration-last-name) valid-name)
                    (tu/enter-text (rfd/input-selector :registration-email) valid-email)
                    (tu/enter-text (rfd/input-selector :registration-password) valid-password)
                    (rfc/block-invalid-submit app/registration-form-state submit-event)
                    (testing "all error classes are removed"
                             (tu/test-field-doesnt-have-class (rfd/form-row-selector :registration-first-name) rfd/field-invalid-class)
                             (tu/test-field-doesnt-have-class (rfd/form-row-selector :registration-last-name) rfd/field-invalid-class)
