Skip to content
Snippets Groups Projects
Commit 2338785e authored by Oswaldo Ferreir's avatar Oswaldo Ferreir
Browse files

Use wait_for_requests to wait all JS request

parent 7f31768a
No related branches found
No related tags found
No related merge requests found
Showing
with 86 additions and 84 deletions
Loading
Loading
@@ -4,7 +4,7 @@ import VueResource from 'vue-resource';
Vue.use(VueResource);
 
// Maintain a global counter for active requests
// see: spec/support/wait_for_vue_resource.rb
// see: spec/support/wait_for_requests.rb
Vue.http.interceptors.push((request, next) => {
window.activeVueResources = window.activeVueResources || 0;
window.activeVueResources += 1;
Loading
Loading
---
title: Use wait_for_requests for both ajax and Vue requests
merge_request:
author:
class Spinach::Features::EventFilters < Spinach::FeatureSteps
include WaitForAjax
include WaitForRequests
include SharedAuthentication
include SharedPaths
include SharedProject
Loading
Loading
@@ -73,20 +73,20 @@ class Spinach::Features::EventFilters < Spinach::FeatureSteps
end
 
When 'I click "push" event filter' do
wait_for_ajax
wait_for_requests
click_link("Push events")
wait_for_ajax
wait_for_requests
end
 
When 'I click "team" event filter' do
wait_for_ajax
wait_for_requests
click_link("Team")
wait_for_ajax
wait_for_requests
end
 
When 'I click "merge" event filter' do
wait_for_ajax
wait_for_requests
click_link("Merge events")
wait_for_ajax
wait_for_requests
end
end
Loading
Loading
@@ -3,7 +3,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps
include SharedPaths
include SharedProject
include SharedUser
include WaitForAjax
include WaitForRequests
 
step '"John Doe" is a developer of project "Shop"' do
project.team << [john_doe, :developer]
Loading
Loading
@@ -140,7 +140,7 @@ class Spinach::Features::DashboardTodos < Spinach::FeatureSteps
step 'I should be directed to the corresponding page' do
page.should have_css('.identifier', text: 'Merge Request !1')
# Merge request page loads and issues a number of Ajax requests
wait_for_ajax
wait_for_requests
end
 
def should_see_todo(position, title, body, state: :pending)
Loading
Loading
class Spinach::Features::GroupMembers < Spinach::FeatureSteps
include WaitForAjax
include WaitForRequests
include SharedAuthentication
include SharedPaths
include SharedGroup
Loading
Loading
@@ -58,7 +58,7 @@ class Spinach::Features::GroupMembers < Spinach::FeatureSteps
click_link 'Developer'
end
 
wait_for_ajax
wait_for_requests
end
end
 
Loading
Loading
class Spinach::Features::GroupMilestones < Spinach::FeatureSteps
include WaitForAjax
include WaitForRequests
include SharedAuthentication
include SharedPaths
include SharedGroup
Loading
Loading
@@ -91,7 +91,7 @@ class Spinach::Features::GroupMilestones < Spinach::FeatureSteps
end
 
step 'I should see the list of labels' do
wait_for_ajax
wait_for_requests
 
page.within('#tab-labels') do
expect(page).to have_content 'bug'
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@ class Spinach::Features::ProjectBuildsArtifacts < Spinach::FeatureSteps
include SharedProject
include SharedBuilds
include RepoHelpers
include WaitForAjax
include WaitForRequests
 
step 'I click artifacts download button' do
click_link 'Download'
Loading
Loading
@@ -79,7 +79,7 @@ class Spinach::Features::ProjectBuildsArtifacts < Spinach::FeatureSteps
 
step 'I click a link to file within build artifacts' do
page.within('.tree-table') { find_link('ci_artifacts.txt').click }
wait_for_ajax
wait_for_requests
end
 
step 'I see a download link' do
Loading
Loading
Loading
Loading
@@ -4,8 +4,7 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps
include SharedNote
include SharedPaths
include Select2Helper
include WaitForVueResource
include WaitForAjax
include WaitForRequests
 
step 'I am a member of project "Shop"' do
@project = ::Project.find_by(name: "Shop")
Loading
Loading
@@ -34,7 +33,7 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps
expect(page).to have_content @merge_request.source_branch
expect(page).to have_content @merge_request.target_branch
 
wait_for_vue_resource
wait_for_requests
end
 
step 'I fill out a "Merge Request On Forked Project" merge request' do
Loading
Loading
@@ -48,7 +47,7 @@ class Spinach::Features::ProjectForkedMergeRequests < Spinach::FeatureSteps
first('.dropdown-target-project a', text: @project.path_with_namespace)
 
first('.js-source-branch').click
wait_for_ajax
wait_for_requests
first('.dropdown-source-branch .dropdown-content a', text: 'fix').click
 
click_button "Compare branches and continue"
Loading
Loading
Loading
Loading
@@ -7,11 +7,10 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
include SharedMarkdown
include SharedDiffNote
include SharedUser
include WaitForAjax
include WaitForVueResource
include WaitForRequests
 
after do
wait_for_ajax if javascript_test?
wait_for_requests if javascript_test?
end
 
step 'I click link "New Merge Request"' do
Loading
Loading
@@ -46,23 +45,23 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
page.within '.merge-request' do
expect(page).to have_content "Wiki Feature"
end
wait_for_vue_resource
wait_for_requests
end
 
step 'I should see closed merge request "Bug NS-04"' do
expect(page).to have_content "Bug NS-04"
expect(page).to have_content "Closed by"
wait_for_vue_resource
wait_for_requests
end
 
step 'I should see merge request "Bug NS-04"' do
expect(page).to have_content "Bug NS-04"
wait_for_vue_resource
wait_for_requests
end
 
step 'I should see merge request "Feature NS-05"' do
expect(page).to have_content "Feature NS-05"
wait_for_vue_resource
wait_for_requests
end
 
step 'I should not see "master" branch' do
Loading
Loading
@@ -99,7 +98,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
 
step 'I click button "Unsubscribe"' do
click_on "Unsubscribe"
wait_for_ajax
wait_for_requests
end
 
step 'I click link "Close"' do
Loading
Loading
@@ -353,7 +352,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
step 'I should see a discussion by user "John Doe" has started on diff' do
# Trigger a refresh of notes
execute_script("$(document).trigger('visibilitychange');")
wait_for_ajax
wait_for_requests
page.within(".notes .discussion") do
page.should have_content "#{user_exists("John Doe").name} #{user_exists("John Doe").to_reference} started a discussion"
page.should have_content sample_commit.line_code_path
Loading
Loading
@@ -363,12 +362,12 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
 
step 'I should see a badge of "1" next to the discussion link' do
expect_discussion_badge_to_have_counter("1")
wait_for_vue_resource
wait_for_requests
end
 
step 'I should see a badge of "0" next to the discussion link' do
expect_discussion_badge_to_have_counter("0")
wait_for_vue_resource
wait_for_requests
end
 
step 'I should see a discussion has started on commit diff' do
Loading
Loading
@@ -376,7 +375,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
page.should have_content "#{current_user.name} #{current_user.to_reference} started a discussion on commit"
page.should have_content sample_commit.line_code_path
page.should have_content "Line is wrong"
wait_for_vue_resource
wait_for_requests
end
end
 
Loading
Loading
@@ -384,7 +383,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
page.within(".notes .discussion") do
page.should have_content "#{current_user.name} #{current_user.to_reference} started a discussion on commit"
page.should have_content "One comment to rule them all"
wait_for_vue_resource
wait_for_requests
end
end
 
Loading
Loading
@@ -410,7 +409,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
step 'I should see merged request' do
page.within '.status-box' do
expect(page).to have_content "Merged"
wait_for_vue_resource
wait_for_requests
end
end
 
Loading
Loading
@@ -422,7 +421,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
page.within '.status-box' do
expect(page).to have_content "Open"
end
wait_for_vue_resource
wait_for_requests
end
 
step 'I click link "Hide inline discussion" of the third file' do
Loading
Loading
@@ -446,7 +445,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
step 'I should see a comment like "Line is wrong" in the third file' do
page.within '.files>div:nth-child(3) .note-body > .note-text' do
expect(page).to have_visible_content "Line is wrong"
wait_for_vue_resource
wait_for_requests
end
end
 
Loading
Loading
@@ -470,7 +469,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
click_button "Comment"
end
 
wait_for_ajax
wait_for_requests
 
page.within ".files>div:nth-child(2) .note-body > .note-text" do
expect(page).to have_content "Line is correct"
Loading
Loading
@@ -485,7 +484,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
click_button "Comment"
end
 
wait_for_ajax
wait_for_requests
end
 
step 'I should still see a comment like "Line is correct" in the second file' do
Loading
Loading
@@ -514,7 +513,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
step 'I should see comments on the side-by-side diff page' do
page.within '.files>div:nth-child(2) .parallel .note-body > .note-text' do
expect(page).to have_visible_content "Line is correct"
wait_for_vue_resource
wait_for_requests
end
end
 
Loading
Loading
@@ -538,7 +537,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
step 'I should see new target branch changes' do
expect(page).to have_content 'Request to merge fix into feature'
expect(page).to have_content 'changed target branch from merge-test to feature'
wait_for_ajax
wait_for_requests
end
 
step 'I click on "Email Patches"' do
Loading
Loading
@@ -572,7 +571,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
expect(page).to have_content /([0-9]+ commits behind)/
end
 
wait_for_vue_resource
wait_for_requests
end
 
step 'I should not see the diverged commits count' do
Loading
Loading
@@ -580,7 +579,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
expect(page).not_to have_content /([0-9]+ commit[s]? behind)/
end
 
wait_for_vue_resource
wait_for_requests
end
 
def merge_request
Loading
Loading
@@ -597,7 +596,7 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
click_button "Comment"
end
 
wait_for_ajax
wait_for_requests
 
page.within(".notes_holder", visible: true) do
expect(page).to have_content message
Loading
Loading
class Spinach::Features::ProjectMergeRequestsAcceptance < Spinach::FeatureSteps
include LoginHelpers
include GitlabRoutingHelper
include WaitForVueResource
include WaitForRequests
 
step 'I am on the Merge Request detail page' do
visit merge_request_path(@merge_request)
Loading
Loading
@@ -24,7 +24,7 @@ class Spinach::Features::ProjectMergeRequestsAcceptance < Spinach::FeatureSteps
 
# Wait for View Resource requests to complete so they don't blow up if they are
# only handled after `DatabaseCleaner` has already run
wait_for_vue_resource
wait_for_requests
end
 
step 'I should not see the Remove Source Branch button' do
Loading
Loading
@@ -32,7 +32,7 @@ class Spinach::Features::ProjectMergeRequestsAcceptance < Spinach::FeatureSteps
 
# Wait for View Resource requests to complete so they don't blow up if they are
# only handled after `DatabaseCleaner` has already run
wait_for_vue_resource
wait_for_requests
end
 
step 'There is an open Merge Request' do
Loading
Loading
class Spinach::Features::RevertMergeRequests < Spinach::FeatureSteps
include LoginHelpers
include GitlabRoutingHelper
include WaitForVueResource
include WaitForRequests
 
step 'I click on the revert button' do
find("a[href='#modal-revert-commit']").click
Loading
Loading
@@ -16,7 +16,7 @@ class Spinach::Features::RevertMergeRequests < Spinach::FeatureSteps
 
step 'I should see the revert merge request notice' do
page.should have_content('The merge request has been successfully reverted.')
wait_for_vue_resource
wait_for_requests
end
 
step 'I should not see the revert button' do
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@ class Spinach::Features::Project < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
include WaitForAjax
include WaitForRequests
 
step 'change project settings' do
fill_in 'project_name_edit', with: 'NewName'
Loading
Loading
@@ -87,7 +87,7 @@ class Spinach::Features::Project < Spinach::FeatureSteps
end
 
step 'I should see project "Shop" README' do
wait_for_ajax
wait_for_requests
page.within('.readme-holder') do
expect(page).to have_content 'testme'
end
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@ class Spinach::Features::ProjectMilestone < Spinach::FeatureSteps
include SharedAuthentication
include SharedProject
include SharedPaths
include WaitForAjax
include WaitForRequests
 
step 'milestone has issue "Bugfix1" with labels: "bug", "feature"' do
project = Project.find_by(name: "Shop")
Loading
Loading
@@ -35,7 +35,7 @@ class Spinach::Features::ProjectMilestone < Spinach::FeatureSteps
end
 
step 'I should see the labels "bug", "enhancement" and "feature"' do
wait_for_ajax
wait_for_requests
 
page.within('#tab-issues') do
expect(page).to have_content 'bug'
Loading
Loading
Loading
Loading
@@ -3,7 +3,7 @@ class Spinach::Features::ProjectSnippets < Spinach::FeatureSteps
include SharedProject
include SharedNote
include SharedPaths
include WaitForAjax
include WaitForRequests
 
step 'project "Shop" have "Snippet one" snippet' do
create(:project_snippet,
Loading
Loading
@@ -59,7 +59,7 @@ class Spinach::Features::ProjectSnippets < Spinach::FeatureSteps
find('.ace_editor').native.send_keys 'Content of snippet three'
end
click_button "Create snippet"
wait_for_ajax
wait_for_requests
end
 
step 'I should see snippet "Snippet three"' do
Loading
Loading
@@ -81,7 +81,7 @@ class Spinach::Features::ProjectSnippets < Spinach::FeatureSteps
fill_in "note_note", with: "Good snippet!"
click_button "Comment"
end
wait_for_ajax
wait_for_requests
end
 
step 'I should see comment "Good snippet!"' do
Loading
Loading
Loading
Loading
@@ -4,7 +4,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
include SharedProject
include SharedPaths
include RepoHelpers
include WaitForAjax
include WaitForRequests
 
step "I don't have write access" do
@project = create(:project, :repository, name: "Other Project", path: "other-project")
Loading
Loading
@@ -37,12 +37,12 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
end
 
step 'I should see its content' do
wait_for_ajax
wait_for_requests
expect(page).to have_content old_gitignore_content
end
 
step 'I should see its new content' do
wait_for_ajax
wait_for_requests
expect(page).to have_content new_gitignore_content
end
 
Loading
Loading
Loading
Loading
@@ -5,7 +5,7 @@ class Spinach::Features::ProjectSourceMarkdownRender < Spinach::FeatureSteps
include SharedAuthentication
include SharedPaths
include SharedMarkdown
include WaitForAjax
include WaitForRequests
 
step 'I own project "Delta"' do
@project = ::Project.find_by(name: "Delta")
Loading
Loading
@@ -35,7 +35,7 @@ class Spinach::Features::ProjectSourceMarkdownRender < Spinach::FeatureSteps
 
step 'I should see correct document rendered' do
expect(current_path).to eq namespace_project_blob_path(@project.namespace, @project, "markdown/doc/api/README.md")
wait_for_ajax
wait_for_requests
expect(page).to have_content "All API requests require authentication"
end
 
Loading
Loading
@@ -65,7 +65,7 @@ class Spinach::Features::ProjectSourceMarkdownRender < Spinach::FeatureSteps
 
step 'I should see correct maintenance file rendered' do
expect(current_path).to eq namespace_project_blob_path(@project.namespace, @project, "markdown/doc/raketasks/maintenance.md")
wait_for_ajax
wait_for_requests
expect(page).to have_content "bundle exec rake gitlab:env:info RAILS_ENV=production"
end
 
Loading
Loading
@@ -97,7 +97,7 @@ class Spinach::Features::ProjectSourceMarkdownRender < Spinach::FeatureSteps
 
step 'I see correct file rendered' do
expect(current_path).to eq namespace_project_blob_path(@project.namespace, @project, "markdown/doc/api/README.md")
wait_for_ajax
wait_for_requests
expect(page).to have_content "Contents"
expect(page).to have_link "Users"
expect(page).to have_link "Rake tasks"
Loading
Loading
@@ -120,7 +120,7 @@ class Spinach::Features::ProjectSourceMarkdownRender < Spinach::FeatureSteps
 
When 'I visit markdown branch' do
visit namespace_project_tree_path(@project.namespace, @project, "markdown")
wait_for_ajax
wait_for_requests
end
 
When 'I visit markdown branch "README.md" blob' do
Loading
Loading
@@ -143,7 +143,7 @@ class Spinach::Features::ProjectSourceMarkdownRender < Spinach::FeatureSteps
 
step 'I see correct file rendered in markdown branch' do
expect(current_path).to eq namespace_project_blob_path(@project.namespace, @project, "markdown/doc/api/README.md")
wait_for_ajax
wait_for_requests
expect(page).to have_content "Contents"
expect(page).to have_link "Users"
expect(page).to have_link "Rake tasks"
Loading
Loading
@@ -151,7 +151,7 @@ class Spinach::Features::ProjectSourceMarkdownRender < Spinach::FeatureSteps
 
step 'I should see correct document rendered for markdown branch' do
expect(current_path).to eq namespace_project_blob_path(@project.namespace, @project, "markdown/doc/api/README.md")
wait_for_ajax
wait_for_requests
expect(page).to have_content "All API requests require authentication"
end
 
Loading
Loading
@@ -169,7 +169,7 @@ class Spinach::Features::ProjectSourceMarkdownRender < Spinach::FeatureSteps
# Expected link contents
 
step 'The link with text "empty" should have url "tree/markdown"' do
wait_for_ajax
wait_for_requests
find('a', text: /^empty$/)['href'] == current_host + namespace_project_tree_path(@project.namespace, @project, "markdown")
end
 
Loading
Loading
@@ -205,7 +205,7 @@ class Spinach::Features::ProjectSourceMarkdownRender < Spinach::FeatureSteps
end
 
step 'The link with text "ID" should have url "blob/markdown/README.mdID"' do
wait_for_ajax
wait_for_requests
find('a', text: /^#id$/)['href'] == current_host + namespace_project_blob_path(@project.namespace, @project, "markdown/README.md") + '#id'
end
 
Loading
Loading
@@ -300,12 +300,12 @@ class Spinach::Features::ProjectSourceMarkdownRender < Spinach::FeatureSteps
 
step 'I should see the correct markdown' do
expect(current_path).to eq namespace_project_blob_path(@project.namespace, @project, "markdown/doc/api/users.md")
wait_for_ajax
wait_for_requests
expect(page).to have_content "List users"
end
 
step 'Header "Application details" should have correct id and link' do
wait_for_ajax
wait_for_requests
header_should_have_correct_id_and_link(2, 'Application details', 'application-details')
end
 
Loading
Loading
module SharedActiveTab
include Spinach::DSL
include WaitForAjax
include WaitForRequests
 
after do
wait_for_ajax if javascript_test?
wait_for_requests if javascript_test?
end
 
def ensure_active_main_tab(content)
Loading
Loading
module SharedDiffNote
include Spinach::DSL
include RepoHelpers
include WaitForAjax
include WaitForRequests
 
after do
wait_for_ajax if javascript_test?
wait_for_requests if javascript_test?
end
 
step 'I cancel the diff comment' do
Loading
Loading
module SharedNote
include Spinach::DSL
include WaitForAjax
include WaitForRequests
 
after do
wait_for_ajax if javascript_test?
wait_for_requests if javascript_test?
end
 
step 'I delete a comment' do
Loading
Loading
@@ -25,7 +25,7 @@ module SharedNote
click_button "Comment"
end
 
wait_for_ajax
wait_for_requests
end
 
step 'I preview a comment text like "Bug fixed :smile:"' do
Loading
Loading
@@ -40,7 +40,7 @@ module SharedNote
click_button "Comment"
end
 
wait_for_ajax
wait_for_requests
end
 
step 'I write a comment like ":+1: Nice"' do
Loading
Loading
@@ -127,7 +127,7 @@ module SharedNote
click_button "Comment"
end
 
wait_for_ajax
wait_for_requests
end
 
step 'The comment with the header should not have an ID' do
Loading
Loading
Loading
Loading
@@ -2,7 +2,7 @@ module SharedPaths
include Spinach::DSL
include RepoHelpers
include DashboardHelper
include WaitForVueResource
include WaitForRequests
 
step 'I visit new project page' do
visit new_project_path
Loading
Loading
@@ -378,28 +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
wait_for_requests
end
 
step 'I visit merge request page "Bug NS-05"' do
visit merge_request_path("Bug NS-05")
wait_for_vue_resource
wait_for_requests
end
 
step 'I visit merge request page "Bug NS-07"' do
visit merge_request_path("Bug NS-07")
wait_for_vue_resource
wait_for_requests
end
 
step 'I visit merge request page "Bug NS-08"' do
visit merge_request_path("Bug NS-08")
wait_for_vue_resource
wait_for_requests
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
wait_for_requests
end
 
step 'I visit project "Shop" merge requests page' do
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment