diff options
Diffstat (limited to 'features/steps/shared')
-rw-r--r-- | features/steps/shared/active_tab.rb | 5 | ||||
-rw-r--r-- | features/steps/shared/authentication.rb | 51 | ||||
-rw-r--r-- | features/steps/shared/builds.rb | 2 | ||||
-rw-r--r-- | features/steps/shared/markdown.rb | 2 | ||||
-rw-r--r-- | features/steps/shared/note.rb | 6 | ||||
-rw-r--r-- | features/steps/shared/paths.rb | 8 | ||||
-rw-r--r-- | features/steps/shared/project.rb | 11 |
7 files changed, 71 insertions, 14 deletions
diff --git a/features/steps/shared/active_tab.rb b/features/steps/shared/active_tab.rb index 4eef7aff213..8bae80a8707 100644 --- a/features/steps/shared/active_tab.rb +++ b/features/steps/shared/active_tab.rb @@ -1,5 +1,10 @@ module SharedActiveTab include Spinach::DSL + include WaitForAjax + + after do + wait_for_ajax if javascript_test? + end def ensure_active_main_tab(content) expect(find('.layout-nav li.active')).to have_content(content) diff --git a/features/steps/shared/authentication.rb b/features/steps/shared/authentication.rb index 5c3e724746b..97fac595d8e 100644 --- a/features/steps/shared/authentication.rb +++ b/features/steps/shared/authentication.rb @@ -1,23 +1,33 @@ -require Rails.root.join('spec', 'support', 'login_helpers') +require Rails.root.join('features', 'support', 'login_helpers') module SharedAuthentication include Spinach::DSL include LoginHelpers step 'I sign in as a user' do - login_as :user + sign_out(@user) if @user + + @user = create(:user) + sign_in(@user) + end + + step 'I sign in via the UI' do + gitlab_sign_in(create(:user)) end step 'I sign in as an admin' do - login_as :admin + sign_out(@user) if @user + + @user = create(:admin) + sign_in(@user) end step 'I sign in as "John Doe"' do - login_with(user_exists("John Doe")) + gitlab_sign_in(user_exists("John Doe")) end step 'I sign in as "Mary Jane"' do - login_with(user_exists("Mary Jane")) + gitlab_sign_in(user_exists("Mary Jane")) end step 'I should be redirected to sign in page' do @@ -25,14 +35,41 @@ module SharedAuthentication end step "I logout" do - logout + gitlab_sign_out end step "I logout directly" do - logout_direct + gitlab_sign_out end def current_user @user || User.reorder(nil).first end + + private + + def gitlab_sign_in(user) + visit new_user_session_path + + fill_in "user_login", with: user.email + fill_in "user_password", with: "12345678" + check 'user_remember_me' + click_button "Sign in" + + @user = user + end + + def gitlab_sign_out + return unless @user + + if Capybara.current_driver == Capybara.javascript_driver + find('.header-user-dropdown-toggle').click + click_link 'Sign out' + expect(page).to have_button('Sign in') + else + sign_out(@user) + end + + @user = nil + end end diff --git a/features/steps/shared/builds.rb b/features/steps/shared/builds.rb index 5bc3a1f5ac4..5549fc25525 100644 --- a/features/steps/shared/builds.rb +++ b/features/steps/shared/builds.rb @@ -47,7 +47,7 @@ module SharedBuilds end step 'recent build has a build trace' do - @build.trace = 'job trace' + @build.trace.set('job trace') end step 'download of build artifacts archive starts' do diff --git a/features/steps/shared/markdown.rb b/features/steps/shared/markdown.rb index 875d27d9383..6610b97ecb2 100644 --- a/features/steps/shared/markdown.rb +++ b/features/steps/shared/markdown.rb @@ -3,7 +3,7 @@ module SharedMarkdown def header_should_have_correct_id_and_link(level, text, id, parent = ".wiki") node = find("#{parent} h#{level} a#user-content-#{id}") - expect(node[:href]).to eq "##{id}" + expect(node[:href]).to end_with "##{id}" # Work around a weird Capybara behavior where calling `parent` on a node # returns the whole document, not the node's actual parent element diff --git a/features/steps/shared/note.rb b/features/steps/shared/note.rb index fd925e0d447..7d260025052 100644 --- a/features/steps/shared/note.rb +++ b/features/steps/shared/note.rb @@ -24,6 +24,8 @@ module SharedNote fill_in "note[note]", with: "XML attached" click_button "Comment" end + + wait_for_ajax end step 'I preview a comment text like "Bug fixed :smile:"' do @@ -37,6 +39,8 @@ module SharedNote page.within(".js-main-target-form") do click_button "Comment" end + + wait_for_ajax end step 'I write a comment like ":+1: Nice"' do @@ -141,7 +145,7 @@ module SharedNote page.within(".current-note-edit-form") do fill_in 'note[note]', with: '+1 Awesome!' - click_button 'Save Comment' + click_button 'Save comment' end end diff --git a/features/steps/shared/paths.rb b/features/steps/shared/paths.rb index d5b3bb34d7a..bef3eac4d26 100644 --- a/features/steps/shared/paths.rb +++ b/features/steps/shared/paths.rb @@ -2,6 +2,7 @@ module SharedPaths include Spinach::DSL include RepoHelpers include DashboardHelper + include WaitForVueResource step 'I visit new project page' do visit new_project_path @@ -151,7 +152,7 @@ module SharedPaths visit profile_preferences_path end - step 'I visit Audit Log page' do + step 'I visit Authentication log page' do visit audit_log_profile_path end @@ -377,23 +378,28 @@ module SharedPaths step 'I visit merge request page "Bug NS-04"' do visit merge_request_path("Bug NS-04") + wait_for_vue_resource end step 'I visit merge request page "Bug NS-05"' do visit merge_request_path("Bug NS-05") + wait_for_vue_resource end step 'I visit merge request page "Bug NS-07"' do visit merge_request_path("Bug NS-07") + wait_for_vue_resource end step 'I visit merge request page "Bug NS-08"' do visit merge_request_path("Bug NS-08") + wait_for_vue_resource end step 'I visit merge request page "Bug CO-01"' do mr = MergeRequest.find_by(title: "Bug CO-01") visit namespace_project_merge_request_path(mr.target_project.namespace, mr.target_project, mr) + wait_for_vue_resource end step 'I visit project "Shop" merge requests page' do diff --git a/features/steps/shared/project.rb b/features/steps/shared/project.rb index 345a28f27dc..c4f1c57836f 100644 --- a/features/steps/shared/project.rb +++ b/features/steps/shared/project.rb @@ -251,13 +251,14 @@ module SharedProject step 'project "Shop" has CI build' do project = Project.find_by(name: "Shop") - create :ci_pipeline, project: project, sha: project.commit.sha, ref: 'master', status: 'skipped' + pipeline = create :ci_pipeline, project: project, sha: project.commit.sha, ref: 'master' + pipeline.skip end step 'I should see last commit with CI status' do - page.within ".project-last-commit" do + page.within ".blob-commit-info" do expect(page).to have_content(project.commit.sha[0..6]) - expect(page).to have_content("skipped") + expect(page).to have_link("Commit: skipped") end end @@ -273,6 +274,10 @@ module SharedProject @project.update(public_builds: false) end + step 'project "Shop" has a "Bugfix MR" merge request open' do + create(:merge_request, title: "Bugfix MR", target_project: project, source_project: project, author: project.users.first) + end + def user_owns_project(user_name:, project_name:, visibility: :private) user = user_exists(user_name, username: user_name.gsub(/\s/, '').underscore) project = Project.find_by(name: project_name) |