<commit_before>Feature: create an administrative user

  As a sys admin.
  I want to be able to create an administrative user
  So that I can have specific people 

Background: some users have been added to database

  Given the following users exist:
  | name          | email              | password  | password_confirmation | login              | admin |
  | Administrator | <EMAIL>  | pass      | pass                  | <EMAIL>  | true  |
  | <NAME> | <EMAIL>      | jojo      | jojo                  | <EMAIL>      | false |
  | <NAME>    | <EMAIL> | snarks    | snarks                | <EMAIL> | false |
  | <NAME>   | <EMAIL>      | apple     | apple                 | <EMAIL>      | false |
  | <NAME>    | <EMAIL>   | laddybuck | laddybuck             | <EMAIL>   | false |

  And I am logged in as admin

Scenario: create an admin user
	Given I am logged in as admin
  	And I am on the new user page
	When I fill in "user_name" with "<NAME>"
	And I fill in "user_email" with "<EMAIL>"
	And I fill in "user_password" with "<PASSWORD>"
	And I fill in "user_password_confirmation" with "<PASSWORD>"
	And I press "Register"
	Then I should be on the user page
	And I should see "Your account has been created."
	
Scenario: login (happy path)
 	And I am on the login page
 	And I fill in "user_session_email" with "<EMAIL>"
 	And I fill in "user_session_password" with "<PASSWORD>"
 	And I press "Login"
 	Then I should see "Login successful!"

Scenario: attempt to access page when not logged in (sad path)
  Given I am not logged in
  And I am on the new user page
  Then I should see "You must be logged in to access this page"

Scenario: delete last admin attempt
  Given I am logged in as admin
  And I am on the user page
  And I remove admin
  And I confirm the popup
  Then I should see "Unable to delete the last admistrator."


Scenario: change password
	Given I am logged in as admin
	And I am on the edit user page for "Administrator"
	When I fill in "user_name" with "<NAME>"
	And I fill in "user_email" with "<EMAIL>"
	And I fill in "user_password" with "<PASSWORD>"
	And I fill in "user_password_confirmation" with "<PASSWORD>"
	And I press "Update User Info"
	Then I should be on the user page
	And I should see "Account updated!"

Scenario: Passwords not the same
	Given I am logged in as admin
	And I am on the edit user page for "Administrator"
	When I fill in "user_name" with "<NAME>"
	And I fill in "user_email" with "<EMAIL>"
	And I fill in "user_password" with "<PASSWORD>"
	And I fill in "user_password_confirmation" with "<PASSWORD>"
	And I press "Update User Info"
	Then I am on the edit user page for "Administrator"
	And I should see "Passwords aren't the same"<commit_msg>Amend tests for user feature<commit_after>Feature: create an administrative user

  As a sys admin.
  I want to be able to create an administrative user
  So that I can have specific people

Background: some users have been added to database

  Given the following users exist:
  | name          | email              | password  | password_confirmation | login              | admin |
  | Administrator | <EMAIL>  | pass      | pass                  | <EMAIL>  | true  |
  | <NAME> | <EMAIL>      | jojo      | jojo                  | <EMAIL>      | false |
  | <NAME>    | <EMAIL> | snarks    | snarks                | <EMAIL> | false |
  | <NAME>   | <EMAIL>      | apple     | apple                 | <EMAIL>      | false |
  | <NAME>    | <EMAIL>   | laddybuck | laddybuck             | <EMAIL>   | false |

  And I am logged in as admin

Scenario: create an admin user
	Given I am logged in as admin
  	And I am on the new user page
	When I fill in "user_name" with "<NAME>"
	And I fill in "user_email" with "<EMAIL>"
	And I fill in "user_password" with "<PASSWORD>"
	And I fill in "user_password_confirmation" with "<PASSWORD>"
	And I press "Register"
	Then I should be on the users page
	And I should see "<NAME>"
  And I should see "<EMAIL>"

Scenario: login (happy path)
 	And I am on the login page
 	And I fill in "user_session_email" with "<EMAIL>"
 	And I fill in "user_session_password" with "<PASSWORD>"
 	And I press "Log In"
 	Then I should see "History"
  And I should see "Edit Data"
  And I should see "Send Message"
  And I should see "User"

Scenario: attempt to access page when not logged in (sad path)
  Given I am not logged in
  And I am on the new user page
  Then I should see "Email"
  And I should see "Password"
  And I should see "Remember me"

Scenario: delete last admin attempt
  Given I am logged in as admin
  And I am on the users page
  And I remove admin
  And I confirm the popup
  Then I should see "Unable to delete the last admistrator."


Scenario: change password
	Given I am logged in as admin
	And I am on the edit user page for "Administrator"
	When I fill in "user_name" with "<NAME>"
	And I fill in "user_email" with "<EMAIL>"
	And I fill in "user_password" with "<PASSWORD>"
	And I fill in "user_password_confirmation" with "<PASSWORD>"
	And I press "Update User Info"
	Then I should be on the users page
  And I should see "<NAME>"
	And I should see "<EMAIL>"

Scenario: Passwords not the same
	Given I am logged in as admin
	And I am on the edit user page for "Administrator"
	When I fill in "user_name" with "<NAME>"
	And I fill in "user_email" with "<EMAIL>"
	And I fill in "user_password" with "<PASSWORD>"
	And I fill in "user_password_confirmation" with "<PASSWORD>"
	And I press "Update User Info"
	Then I am on the edit user page for "Administrator"
	And I should see "Passwords aren't the same"
{'fraction_non_alphanumeric': 0.0760381089340284, 'fraction_numerical': 0.0, 'mean_word_length': 2.845196959225985, 'pattern_counts': {'":': 0, '<': 63, '<?xml version=': 0, '>': 63, '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': '6920538', 'n_tokens_mistral': 1728, 'n_tokens_neox': 1676, 'n_words': 836}