remove request helper
This commit is contained in:
@@ -11,7 +11,6 @@ require 'capybara/rspec'
|
||||
require 'webmock/rspec'
|
||||
require 'sidekiq/testing'
|
||||
require 'signing_form_helper'
|
||||
require 'request_helper'
|
||||
|
||||
Sidekiq::Testing.fake!
|
||||
|
||||
@@ -55,7 +54,6 @@ RSpec.configure do |config|
|
||||
config.include FactoryBot::Syntax::Methods
|
||||
config.include Devise::Test::IntegrationHelpers
|
||||
config.include SigningFormHelper
|
||||
config.include RequestHelper
|
||||
|
||||
config.before(:each, type: :system) do
|
||||
if ENV['HEADLESS'] == 'false'
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module RequestHelper
|
||||
module_function
|
||||
|
||||
def wait_for_fetch
|
||||
page.execute_script(
|
||||
<<~JS
|
||||
if (!window.fetchInitialized) {
|
||||
window.pendingFetchCount = 0;
|
||||
|
||||
const originalFetch = window.fetch;
|
||||
|
||||
window.fetch = function(...args) {
|
||||
window.pendingFetchCount++;
|
||||
|
||||
return originalFetch.apply(this, args).finally(() => {
|
||||
window.pendingFetchCount--;
|
||||
});
|
||||
};
|
||||
|
||||
window.fetchInitialized = true;
|
||||
}
|
||||
JS
|
||||
)
|
||||
|
||||
yield
|
||||
|
||||
Timeout.timeout(Capybara.default_max_wait_time) do
|
||||
loop do
|
||||
break if page.evaluate_script('window.pendingFetchCount') == 0
|
||||
|
||||
sleep 0.1
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -21,14 +21,14 @@ RSpec.describe 'Template Builder' do
|
||||
doc.click
|
||||
|
||||
expect do
|
||||
wait_for_fetch do
|
||||
doc.find('.replace-document-button').click
|
||||
doc.find('.replace-document-button input[type="file"]', visible: false)
|
||||
.attach_file(Rails.root.join('spec/fixtures/sample-image.png'))
|
||||
end
|
||||
doc.find('.replace-document-button').click
|
||||
doc.find('.replace-document-button input[type="file"]', visible: false)
|
||||
.attach_file(Rails.root.join('spec/fixtures/sample-image.png'))
|
||||
|
||||
page.driver.wait_for_network_idle
|
||||
end.to change { template.documents.count }.by(1)
|
||||
|
||||
expect(template.reload['schema'][1]['name']).to eq('sample-image')
|
||||
expect(page).to have_content('sample-image')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user