|
1 | 1 | # frozen_string_literal: true |
2 | 2 |
|
3 | 3 | require 'rails_helper' |
| 4 | + |
| 5 | +RSpec.describe 'creating a platform invitation' do |
| 6 | + include BetterTogether::CapybaraFeatureHelpers |
| 7 | + |
| 8 | + let!(:host_platform) do |
| 9 | + configure_host_platform |
| 10 | + end |
| 11 | + let(:invitee_email) { Faker::Internet.unique.email } |
| 12 | + |
| 13 | + before do |
| 14 | + capybara_login_as_platform_manager |
| 15 | + end |
| 16 | + |
| 17 | + # TODO: This test requires proper authorization setup for platform invitations |
| 18 | + # The platform manager role needs index? permission for BetterTogether::PlatformInvitation |
| 19 | + # to access the invitations page |
| 20 | + scenario 'with valid inputs' do # rubocop:todo RSpec/ExampleLength |
| 21 | + visit better_together.platform_platform_invitations_path(host_platform, locale: I18n.locale) |
| 22 | + click_button I18n.t('better_together.platform_invitations.new_invitation') |
| 23 | + within '#newInvitationModal' do |
| 24 | + select 'Platform Invitation', from: 'platform_invitation[type]' |
| 25 | + select 'Community Facilitator', from: 'platform_invitation[community_role_id]' |
| 26 | + select 'Platform Manager', from: 'platform_invitation[platform_role_id]' |
| 27 | + fill_in 'platform_invitation[invitee_email]', with: invitee_email |
| 28 | + click_button 'Invite' |
| 29 | + end |
| 30 | + |
| 31 | + # After successful creation, we're redirected to the platform show page |
| 32 | + expect(page).to have_content(I18n.t('flash.generic.created', resource: I18n.t('resources.invitation'))) |
| 33 | + |
| 34 | + # Navigate to invitations to verify the invitation was created |
| 35 | + visit better_together.platform_platform_invitations_path(host_platform, locale: I18n.locale) |
| 36 | + expect(page).to have_content(invitee_email) |
| 37 | + end |
| 38 | +end |
0 commit comments