<commit_before>(ns objective8.workflows.sign-up-test
  (:require [midje.sweet :refer :all]
            [cemerick.friend :as friend]
            [objective8.workflows.sign-up :refer :all]
            [objective8.utils :as utils]))

(fact "retain invitation information in session when signing in / signing up with redirect"
      (let [session-with-invitation {:invitation :invitation-data}]
        (authorised-redirect :user :some-url session-with-invitation)) => :authorised-response
        (provided
         (authorise (contains {:session (contains {:invitation :invitation-data})}) :user) => :authorised-response))<commit_msg>CM #53 - check username validity function<commit_after>(ns objective8.workflows.sign-up-test
  (:require [midje.sweet :refer :all]
            [cemerick.friend :as friend]
            [objective8.workflows.sign-up :refer :all]
            [objective8.utils :as utils]))

(fact "retain invitation information in session when signing in / signing up with redirect"
      (let [session-with-invitation {:invitation :invitation-data}]
        (authorised-redirect :user :some-url session-with-invitation)) => :authorised-response
        (provided
         (authorise (contains {:session (contains {:invitation :invitation-data})}) :user) => :authorised-response))

(fact "only usernames containing alphanumeric characters, and between 1 and 16 characters long are valid"
      (validate-username "1-a") => falsey
      (validate-username "") => falsey
      (validate-username "123456789abcdefgh") => falsey
      (validate-username "val1d") => "val1d")
{'fraction_non_alphanumeric': 0.1264222503160556, 'fraction_numerical': 0.014538558786346398, 'mean_word_length': 3.561959654178674, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2390438', 'n_tokens_mistral': 471, 'n_tokens_neox': 454, 'n_words': 122}