                       (th/test-translations "index page" (constantly page)))))
 
        (facts "when email is too long"
-              (let [long-email-address (apply str (repeat 255 "x"))
+              (let [long-email-address (string-of-length 255)
                     errors {:sign-in-email :too-long}
                     params {:sign-in-email long-email-address}
                     page (-> (th/create-request {} errors params) index)]

            [stonecutter.test.view.test-helpers :as th]
            [stonecutter.view.index :refer [index]]))


(facts "about index page"
       (let [page (-> (th/create-request) index)]

                (fact "correct error message is displayed"
                      (html/select page [[:.clj--registration-email__validation (html/attr= :data-l8n error-translation)]]) =not=> empty?)
                (fact "invalid value is preserved in input field"
                      (-> page (html/select [:.clj--registration-email__input]) first :attrs :value) => ?input)
                (fact "there are no missing translations"
                      (th/test-translations "index page" (constantly page)))))

         ?error      ?input                 ?translation-key
         :invalid    "invalidEmail"         "register-email-address-invalid-validation-message"
         :duplicate  "valid@email.com"      "register-email-address-duplicate-validation-message"
         :too-long   (string-of-length 255) "register-email-address-too-long-validation-message")

       (tabular
         (facts "password validations"
                (let [errors {:registration-password ?error}
                      params {:registration-password ?input}
                      page (-> (th/create-request {} errors params) index)
                      error-translation (str "content:index/" ?translation-key)]
                  (fact "validation summary includes the error message"
                        (html/select page [[:.clj--registration-validation-summary__item (html/attr= :data-l8n error-translation)]]) =not=> empty?)
                  (fact "the class for styling errors is added"
                        (html/select page [[:.clj--registration-password :.form-row--invalid]]) =not=> empty?)
                  (fact "password validation element is present"
                        (html/select page [:.clj--registration-password__validation]) =not=> empty?)
                  (fact "correct error message is displayed"
                        (html/select page [[:.clj--registration-password__validation (html/attr= :data-l8n error-translation)]]) =not=> empty?)
                  (fact "the input is not preserved"
                        (-> page (html/select [:.clj--registration-password__input]) first :attrs :value) => nil)
                  (fact "there are no missing translations"
                        (th/test-translations "index page" (constantly page)))))
         ?error     ?input                 ?translation-key
         :blank     ""                     "register-password-blank-validation-message"
         :too-short "2short"               "register-password-too-short-validation-message"
         :too-long  (string-of-length 255) "register-password-too-long-validation-message"))
