From ebdfd4ab635842584f2b78643cb54c8580fd4c8c Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Tue, 11 May 2021 12:08:38 +0200 Subject: [PATCH] Re-enable oscillating tests --- config/docker.yml.erb.ci | 1 + spec/controllers/sessions_controller_spec.rb | 4 +-- spec/features/authentication_spec.rb | 3 +- spec/features/authorization_spec.rb | 3 +- spec/features/editor_spec.rb | 29 ++++++++++++++++---- spec/support/selenium.rb | 1 + 6 files changed, 32 insertions(+), 9 deletions(-) diff --git a/config/docker.yml.erb.ci b/config/docker.yml.erb.ci index 05b17d71..e878ca2f 100644 --- a/config/docker.yml.erb.ci +++ b/config/docker.yml.erb.ci @@ -56,3 +56,4 @@ test: <<: *default host: tcp://127.0.0.1:2376 workspace_root: <%= Rails.root.join('tmp', 'files', Rails.env) %> + ws_client_protocol: 'ws:' #set the websocket protocol to be used by the client to connect to the rails server (ws on development, wss on production) diff --git a/spec/controllers/sessions_controller_spec.rb b/spec/controllers/sessions_controller_spec.rb index b7216abf..043a7912 100644 --- a/spec/controllers/sessions_controller_spec.rb +++ b/spec/controllers/sessions_controller_spec.rb @@ -1,3 +1,5 @@ +# frozen_string_literal: true + require 'rails_helper' describe SessionsController do @@ -132,14 +134,12 @@ describe SessionsController do end it 'redirects to recommended exercise if requested token of proxy exercise' do - skip 'test is currently oscillating' FactoryBot.create(:proxy_exercise, exercises: [exercise]) post :create_through_lti, params: { custom_locale: locale, custom_token: ProxyExercise.first.token, oauth_consumer_key: consumer.oauth_key, oauth_nonce: nonce, oauth_signature: SecureRandom.hex, user_id: user.external_id } expect(controller).to redirect_to(implement_exercise_path(exercise.id)) end it 'recommends only exercises who are 1 degree more complicated than what user has seen' do - skip 'test is currently oscillating' # dummy user has no exercises finished, therefore his highest difficulty is 0 FactoryBot.create(:proxy_exercise, exercises: [exercise, exercise2]) exercise.expected_difficulty = 3 diff --git a/spec/features/authentication_spec.rb b/spec/features/authentication_spec.rb index 318c1b37..31fd39fe 100644 --- a/spec/features/authentication_spec.rb +++ b/spec/features/authentication_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'Authentication' do - before { skip 'feature specs fail randomly as of Nov 2019 on Travis' } let(:user) { FactoryBot.create(:admin) } let(:password) { FactoryBot.attributes_for(:admin)[:password] } diff --git a/spec/features/authorization_spec.rb b/spec/features/authorization_spec.rb index 5e75919d..97d7056d 100644 --- a/spec/features/authorization_spec.rb +++ b/spec/features/authorization_spec.rb @@ -1,7 +1,8 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'Authorization' do - before { skip 'feature specs fail randomly as of Nov 2019 on Travis' } context 'as an admin' do let(:user) { FactoryBot.create(:admin) } before(:each) { allow_any_instance_of(ApplicationController).to receive(:current_user).and_return(user) } diff --git a/spec/features/editor_spec.rb b/spec/features/editor_spec.rb index 5a504a82..f43451c8 100644 --- a/spec/features/editor_spec.rb +++ b/spec/features/editor_spec.rb @@ -1,11 +1,30 @@ +# frozen_string_literal: true + require 'rails_helper' describe 'Editor', js: true do - before { skip 'feature specs fail randomly as of Nov 2019 on Travis' } let(:exercise) { FactoryBot.create(:audio_video, description: Forgery(:lorem_ipsum).sentence) } + let(:scoring_response) do + [{ + status: 'ok', + stdout: '', + stderr: '', + waiting_for_container_time: 0, + container_execution_time: 0, + file_role: 'teacher_defined_test', + count: 1, + failed: 0, + error_messages: [], + passed: 1, + score: 1.0, + filename: 'index.html_spec.rb', + message: 'Well done.', + weight: 2.0 + }] + end let(:user) { FactoryBot.create(:teacher) } - before(:each) do + before do visit(sign_in_path) fill_in('email', with: user.email) fill_in('password', with: FactoryBot.attributes_for(:teacher)[:password]) @@ -35,7 +54,7 @@ describe 'Editor', js: true do end context 'when selecting a file' do - before(:each) do + before do within('#files') { click_link(file.name_with_extension) } end @@ -74,9 +93,9 @@ describe 'Editor', js: true do end end - it 'does not contains a button for submitting the exercise' do + it 'contains a button for submitting the exercise' do + allow_any_instance_of(SubmissionsController).to receive(:score_submission).and_return(scoring_response) click_button(I18n.t('exercises.editor.score')) - click_button('toggle-sidebar-output-collapsed') expect(page).not_to have_css('#submit_outdated') expect(page).to have_css('#submit') end diff --git a/spec/support/selenium.rb b/spec/support/selenium.rb index 4aeb28de..fd43b767 100644 --- a/spec/support/selenium.rb +++ b/spec/support/selenium.rb @@ -13,6 +13,7 @@ Capybara.register_driver :selenium do |app| profile['intl.accept_languages'] = 'en' capabilities = Selenium::WebDriver::Remote::Capabilities.firefox(elementScrollBehavior: 1) options = Selenium::WebDriver::Firefox::Options.new + options.headless! if ENV['CI'] == 'true' options.profile = profile driver = Capybara::Selenium::Driver.new(app, browser: :firefox, desired_capabilities: capabilities, options: options) driver.browser.manage.window.resize_to(1280, 960)