diff options
Diffstat (limited to 'spec/features/projects/members')
3 files changed, 20 insertions, 16 deletions
diff --git a/spec/features/projects/members/groups_with_access_list_spec.rb b/spec/features/projects/members/groups_with_access_list_spec.rb index 84a972b3027..eb32570448b 100644 --- a/spec/features/projects/members/groups_with_access_list_spec.rb +++ b/spec/features/projects/members/groups_with_access_list_spec.rb @@ -8,6 +8,7 @@ RSpec.describe 'Projects > Members > Groups with access list', :js do let_it_be(:user) { create(:user) } let_it_be(:group) { create(:group, :public) } let_it_be(:project) { create(:project, :public) } + let_it_be(:expiration_date) { 5.days.from_now.to_date } let(:additional_link_attrs) { {} } let!(:group_link) { create(:project_group_link, project: project, group: group, **additional_link_attrs) } @@ -37,27 +38,27 @@ RSpec.describe 'Projects > Members > Groups with access list', :js do it 'updates expiry date' do page.within find_group_row(group) do - fill_in 'Expiration date', with: 5.days.from_now.to_date + fill_in 'Expiration date', with: expiration_date find_field('Expiration date').native.send_keys :enter wait_for_requests - expect(page).to have_content(/in \d days/) + expect(page).to have_field('Expiration date', with: expiration_date) end end context 'when link has expiry date set' do - let(:additional_link_attrs) { { expires_at: 5.days.from_now.to_date } } + let(:additional_link_attrs) { { expires_at: expiration_date } } it 'clears expiry date' do page.within find_group_row(group) do - expect(page).to have_content(/in \d days/) + expect(page).to have_field('Expiration date', with: expiration_date) find('[data-testid="clear-button"]').click wait_for_requests - expect(page).to have_content('No expiration set') + expect(page).to have_field('Expiration date', with: '') end end end diff --git a/spec/features/projects/members/invite_group_spec.rb b/spec/features/projects/members/invite_group_spec.rb index 8c3646125a5..b674cad0312 100644 --- a/spec/features/projects/members/invite_group_spec.rb +++ b/spec/features/projects/members/invite_group_spec.rb @@ -165,6 +165,8 @@ RSpec.describe 'Project > Members > Invite group', :js do let(:project) { create(:project) } let!(:group) { create(:group) } + let_it_be(:expiration_date) { 5.days.from_now.to_date } + around do |example| freeze_time { example.run } end @@ -176,15 +178,14 @@ RSpec.describe 'Project > Members > Invite group', :js do visit project_project_members_path(project) - invite_group(group.name, role: 'Guest', expires_at: 5.days.from_now) + invite_group(group.name, role: 'Guest', expires_at: expiration_date) end it 'the group link shows the expiration time with a warning class' do setup click_link 'Groups' - expect(find_group_row(group)).to have_content(/in \d days/) - expect(find_group_row(group)).to have_selector('.gl-text-orange-500') + expect(page).to have_field('Expiration date', with: expiration_date) end end diff --git a/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb b/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb index c1b14cf60e7..830ada29a2e 100644 --- a/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb +++ b/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb @@ -9,6 +9,8 @@ RSpec.describe 'Projects > Members > Maintainer adds member with expiration date let_it_be(:maintainer) { create(:user) } let_it_be(:project) { create(:project) } + let_it_be(:three_days_from_now) { 3.days.from_now.to_date } + let_it_be(:five_days_from_now) { 5.days.from_now.to_date } let(:new_member) { create(:user) } @@ -22,39 +24,39 @@ RSpec.describe 'Projects > Members > Maintainer adds member with expiration date it 'expiration date is displayed in the members list' do visit project_project_members_path(project) - invite_member(new_member.name, role: 'Guest', expires_at: 5.days.from_now.to_date) + invite_member(new_member.name, role: 'Guest', expires_at: five_days_from_now) page.within find_member_row(new_member) do - expect(page).to have_content(/in \d days/) + expect(page).to have_field('Expiration date', with: five_days_from_now) end end it 'changes expiration date' do - project.team.add_users([new_member.id], :developer, expires_at: 3.days.from_now.to_date) + project.team.add_users([new_member.id], :developer, expires_at: three_days_from_now) visit project_project_members_path(project) page.within find_member_row(new_member) do - fill_in 'Expiration date', with: 5.days.from_now.to_date + fill_in 'Expiration date', with: five_days_from_now find_field('Expiration date').native.send_keys :enter wait_for_requests - expect(page).to have_content(/in \d days/) + expect(page).to have_field('Expiration date', with: five_days_from_now) end end it 'clears expiration date' do - project.team.add_users([new_member.id], :developer, expires_at: 5.days.from_now.to_date) + project.team.add_users([new_member.id], :developer, expires_at: five_days_from_now) visit project_project_members_path(project) page.within find_member_row(new_member) do - expect(page).to have_content(/in \d days/) + expect(page).to have_field('Expiration date', with: five_days_from_now) find('[data-testid="clear-button"]').click wait_for_requests - expect(page).to have_content('No expiration set') + expect(page).to have_field('Expiration date', with: '') end end |