From d871c8b9a020020b210050f534e95a6a666d4d79 Mon Sep 17 00:00:00 2001 From: "Luke \"Jared\" Bennett" Date: Wed, 20 Jul 2016 02:05:57 +0100 Subject: added feature test --- spec/features/users_spec.rb | 27 +++++++++++++++++++++- .../fixtures/username_validator.html.haml | 0 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 spec/javascripts/fixtures/username_validator.html.haml diff --git a/spec/features/users_spec.rb b/spec/features/users_spec.rb index b5a94fe0383..7630d299349 100644 --- a/spec/features/users_spec.rb +++ b/spec/features/users_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -feature 'Users', feature: true do +feature 'Users', feature: true, js: true do let(:user) { create(:user, username: 'user1', name: 'User 1', email: 'user1@gitlab.com') } scenario 'GET /users/sign_in creates a new user account' do @@ -40,6 +40,31 @@ feature 'Users', feature: true do expect(number_of_errors_on_page(page)).to be(1), 'errors on page:\n #{errors_on_page page}' end + feature 'username validation' do + include WaitForAjax + let(:loading_icon) { '.fa.fa-spinner' } + let(:username_input) { 'new_user_username' } + + before(:each) do + visit new_user_session_path + @username_field = find '.username' + end + + scenario 'shows an error icon if the username already exists' do + fill_in username_input, with: user.username + expect(@username_field).to have_css loading_icon + wait_for_ajax + expect(@username_field).to have_css '.fa.error' + end + + scenario 'shows a success icon if the username is available' do + fill_in username_input, with: 'new-user' + expect(@username_field).to have_css loading_icon + wait_for_ajax + expect(@username_field).to have_css '.fa.success' + end + end + def errors_on_page(page) page.find('#error_explanation').find('ul').all('li').map{ |item| item.text }.join("\n") end diff --git a/spec/javascripts/fixtures/username_validator.html.haml b/spec/javascripts/fixtures/username_validator.html.haml new file mode 100644 index 00000000000..e69de29bb2d -- cgit v1.2.1