2020-05-24 23:13:21 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe 'Groups > Members > Owner adds member with expiration date', :js do
|
2020-05-24 23:13:21 +05:30
|
|
|
include Select2Helper
|
2021-01-29 00:20:46 +05:30
|
|
|
include Spec::Support::Helpers::Features::MembersHelpers
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
let_it_be(:user1) { create(:user, name: 'John Doe') }
|
|
|
|
let_it_be(:group) { create(:group) }
|
|
|
|
let(:new_member) { create(:user, name: 'Mary Jane') }
|
2020-05-24 23:13:21 +05:30
|
|
|
|
|
|
|
before do
|
2021-03-08 18:12:59 +05:30
|
|
|
stub_feature_flags(invite_members_group_modal: false)
|
2020-05-24 23:13:21 +05:30
|
|
|
group.add_owner(user1)
|
|
|
|
sign_in(user1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'expiration date is displayed in the members list' do
|
2021-01-03 14:25:43 +05:30
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
page.within invite_users_form do
|
2021-01-03 14:25:43 +05:30
|
|
|
select2(new_member.id, from: '#user_ids', multiple: true)
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
fill_in 'expires_at', with: 5.days.from_now.to_date
|
2021-01-03 14:25:43 +05:30
|
|
|
find_field('expires_at').native.send_keys :enter
|
|
|
|
|
|
|
|
click_on 'Invite'
|
|
|
|
end
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
page.within second_row do
|
|
|
|
expect(page).to have_content(/in \d days/)
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it 'changes expiration date' do
|
|
|
|
group.add_developer(new_member)
|
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
page.within second_row do
|
|
|
|
fill_in 'Expiration date', with: 5.days.from_now.to_date
|
2021-01-03 14:25:43 +05:30
|
|
|
find_field('Expiration date').native.send_keys :enter
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
wait_for_requests
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
expect(page).to have_content(/in \d days/)
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
it 'clears expiration date' do
|
2021-01-29 00:20:46 +05:30
|
|
|
create(:group_member, :developer, user: new_member, group: group, expires_at: 5.days.from_now.to_date)
|
2021-01-03 14:25:43 +05:30
|
|
|
visit group_group_members_path(group)
|
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
page.within second_row do
|
|
|
|
expect(page).to have_content(/in \d days/)
|
2021-01-03 14:25:43 +05:30
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
find('[data-testid="clear-button"]').click
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-01-03 14:25:43 +05:30
|
|
|
wait_for_requests
|
2020-05-24 23:13:21 +05:30
|
|
|
|
2021-01-29 00:20:46 +05:30
|
|
|
expect(page).to have_content('No expiration set')
|
2020-05-24 23:13:21 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|