From d503b3c0f696d5d96b0203f9de5a1a6943ef9c7e Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Mon, 26 Feb 2018 09:22:28 +0100 Subject: [PATCH] Fix editor_spec and adopt to current design of implementation page Signed-off-by: Sebastian Serth --- spec/features/editor_spec.rb | 138 +++++++++++++++-------------------- 1 file changed, 59 insertions(+), 79 deletions(-) diff --git a/spec/features/editor_spec.rb b/spec/features/editor_spec.rb index 88e480d4..bba856e7 100644 --- a/spec/features/editor_spec.rb +++ b/spec/features/editor_spec.rb @@ -1,7 +1,7 @@ require 'rails_helper' describe 'Editor', js: true do - let(:exercise) { FactoryBot.create(:audio_video, instructions: Forgery(:lorem_ipsum).sentence) } + let(:exercise) { FactoryBot.create(:audio_video, description: Forgery(:lorem_ipsum).sentence) } let(:user) { FactoryBot.create(:teacher) } before(:each) do @@ -9,94 +9,74 @@ describe 'Editor', js: true do fill_in('email', with: user.email) fill_in('password', with: FactoryBot.attributes_for(:teacher)[:password]) click_button(I18n.t('sessions.new.link')) + expect_any_instance_of(LtiHelper).to receive(:lti_outcome_service?).and_return(true) visit(implement_exercise_path(exercise)) end - skip "is skipped" do - # selenium tests are currently not working locally. - it 'displays the exercise title' do - expect(page).to have_content(exercise.title) + it 'displays the exercise title' do + expect(page).to have_content(exercise.title) + end + + it 'displays the exercise description' do + expect(page).to have_content(exercise.description) + end + + it 'displays all visible files in a file tree' do + within('#files') do + exercise.files.select(&:visible).each do |file| + expect(page).to have_content(file.name_with_extension) + end end end - describe 'Instructions Tab' do - skip "is skipped" do + it "displays the main file's code" do + expect(page).to have_css(".frame[data-filename='#{exercise.files.detect(&:main_file?).name_with_extension}']") + end - before(:each) { click_link(I18n.t('activerecord.attributes.exercise.instructions')) } - - it 'displays the exercise instructions' do - expect(page).to have_content(exercise.instructions) + context 'when selecting a file' do + before(:each) do + within('#files') { click_link(file.name_with_extension) } end + + context 'when selecting a binary file' do + context 'when selecting an audio file' do + let(:file) { exercise.files.detect { |file| file.file_type.audio? } } + + it 'contains an