|
| 1 | + |
| 2 | +require 'rails_helper' |
| 3 | + |
| 4 | +RSpec.describe "Facilitators can submit a workshop idea", type: :system do |
| 5 | + describe "Navigate to Workshop Idea page" do |
| 6 | + context "When Facilitator is logged in" do |
| 7 | + before do |
| 8 | + create(:windows_type, :adult) |
| 9 | + create(:windows_type, :children) |
| 10 | + create(:windows_type, :combined) |
| 11 | + |
| 12 | + user = create(:user) |
| 13 | + create(:facilitator, user: user) |
| 14 | + sign_in user |
| 15 | + |
| 16 | + visit new_workshop_idea_path |
| 17 | + end |
| 18 | + |
| 19 | + it "shows the new workshop form" do |
| 20 | + expect(page).to have_content("New Workshop idea") |
| 21 | + end |
| 22 | + |
| 23 | + it "submits the form when clicking Submit" do |
| 24 | + fill_in 'workshop_idea_title', with: 'My Amazing Workshop' |
| 25 | + select 'ADULT WINDOWS', from: 'workshop_idea_windows_type_id' |
| 26 | + # select 'Adult', from:'workshop_idea_age_range' |
| 27 | + fill_in 'workshop_idea_objective', with: 'Learn something new' |
| 28 | + fill_in 'workshop_idea_description', with: 'This is a test workshop description.' |
| 29 | + fill_in 'workshop_idea_materials', with: 'Paper, markers' |
| 30 | + fill_in 'workshop_idea_optional_materials', with: 'Scissors, glue' |
| 31 | + fill_in 'workshop_idea_setup', with: 'Arrange tables' |
| 32 | + fill_in 'workshop_idea_introduction', with: 'Start with a story' |
| 33 | + fill_in 'workshop_idea_time_intro', with: 10 |
| 34 | + fill_in 'workshop_idea_opening_circle', with: 'Welcome and warm up' |
| 35 | + fill_in 'workshop_idea_time_opening_circle', with: 5 |
| 36 | + fill_in 'workshop_idea_demonstration', with: 'Show how it works' |
| 37 | + fill_in 'workshop_idea_time_demonstration', with: 15 |
| 38 | + fill_in 'workshop_idea_warm_up', with: 'Stretching and breathing' |
| 39 | + fill_in 'workshop_idea_time_warm_up', with: 5 |
| 40 | + fill_in 'workshop_idea_creation', with: 'Hands-on creation' |
| 41 | + fill_in 'workshop_idea_time_creation', with: 30 |
| 42 | + fill_in 'workshop_idea_closing', with: 'Reflection and clean up' |
| 43 | + fill_in 'workshop_idea_time_closing', with: 10 |
| 44 | + fill_in 'workshop_idea_notes', with: 'Some notes' |
| 45 | + fill_in 'workshop_idea_tips', with: 'Some tips' |
| 46 | + attach_file('workshop_primary_media', Rails.root.join('spec/fixtures/some_file.png')) if page.has_field?('workshop_idea_primary_asset_attributes_file') |
| 47 | + # Submit |
| 48 | + click_button 'Submit' |
| 49 | + expect(page).to have_content('Workshop idea was successfully created') |
| 50 | + end |
| 51 | + |
| 52 | + it "cancels the form when clicking Cancel" do |
| 53 | + fill_in 'workshop_idea_title', with: 'My unsubmitted Workshop' |
| 54 | + select 'ADULT WINDOWS', from: 'workshop_idea_windows_type_id' |
| 55 | + # select 'Adult', from:'workshop_idea_age_range' |
| 56 | + fill_in 'workshop_idea_objective', with: 'Learn nothing new' |
| 57 | + fill_in 'workshop_idea_description', with: 'This is a test workshop description.' |
| 58 | + fill_in 'workshop_idea_materials', with: 'Paper, markers' |
| 59 | + fill_in 'workshop_idea_optional_materials', with: 'Scissors, glue' |
| 60 | + fill_in 'workshop_idea_setup', with: 'Arrange tables' |
| 61 | + fill_in 'workshop_idea_introduction', with: 'Start with a story' |
| 62 | + fill_in 'workshop_idea_time_intro', with: 10 |
| 63 | + fill_in 'workshop_idea_opening_circle', with: 'Welcome and warm up' |
| 64 | + fill_in 'workshop_idea_time_opening_circle', with: 5 |
| 65 | + fill_in 'workshop_idea_demonstration', with: 'Show how it works' |
| 66 | + fill_in 'workshop_idea_time_demonstration', with: 15 |
| 67 | + fill_in 'workshop_idea_warm_up', with: 'Stretching and breathing' |
| 68 | + fill_in 'workshop_idea_time_warm_up', with: 5 |
| 69 | + fill_in 'workshop_idea_creation', with: 'Hands-on creation' |
| 70 | + fill_in 'workshop_idea_time_creation', with: 30 |
| 71 | + fill_in 'workshop_idea_closing', with: 'Reflection and clean up' |
| 72 | + fill_in 'workshop_idea_time_closing', with: 10 |
| 73 | + fill_in 'workshop_idea_notes', with: 'Some notes' |
| 74 | + fill_in 'workshop_idea_tips', with: 'Some tips' |
| 75 | + attach_file('workshop_primary_media', Rails.root.join('spec/fixtures/some_file.png')) if page.has_field?('workshop_idea_primary_asset_attributes_file') |
| 76 | + # Cancel |
| 77 | + click_link 'Cancel' |
| 78 | + expect(page).to have_content('Featured Workshops') |
| 79 | + expect(page).to have_content('Community News') |
| 80 | + end |
| 81 | + end |
| 82 | + end |
| 83 | +end |
0 commit comments