diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-09 06:09:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-12-09 06:09:24 +0300 |
commit | a25cab22f84ee674ebb32625a6da566acd454e8a (patch) | |
tree | f52667dd7f61cace3157fd55c1485cc2becbe3e3 /spec/features | |
parent | 77914793a349059bf523b131fc925b34349d6884 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/features')
-rw-r--r-- | spec/features/projects/terraform_spec.rb | 78 |
1 files changed, 55 insertions, 23 deletions
diff --git a/spec/features/projects/terraform_spec.rb b/spec/features/projects/terraform_spec.rb index 2680dfb2b13..0ad2f9a882d 100644 --- a/spec/features/projects/terraform_spec.rb +++ b/spec/features/projects/terraform_spec.rb @@ -4,44 +4,76 @@ require 'spec_helper' RSpec.describe 'Terraform', :js do let_it_be(:project) { create(:project) } + let_it_be(:terraform_state) { create(:terraform_state, :locked, :with_version, project: project) } - let(:user) { project.creator } + context 'when user is a terraform administrator' do + let(:admin) { project.creator } - before do - gitlab_sign_in(user) - end - - context 'when user does not have any terraform states and visits index page' do before do - visit project_terraform_index_path(project) + gitlab_sign_in(admin) end - it 'sees an empty state' do - expect(page).to have_content('Get started with Terraform') - end - end - - context 'when user has a terraform state' do - let_it_be(:terraform_state) { create(:terraform_state, :locked, project: project) } + context 'when user does not have any terraform states and visits the index page' do + let(:empty_project) { create(:project) } - context 'when user visits the index page' do before do - visit project_terraform_index_path(project) + empty_project.add_maintainer(admin) + visit project_terraform_index_path(empty_project) end - it 'displays a tab with states count' do - expect(page).to have_content("States #{project.terraform_states.size}") + it 'sees an empty state' do + expect(page).to have_content('Get started with Terraform') end + end + + context 'when user has a terraform state' do + context 'when user visits the index page' do + before do + visit project_terraform_index_path(project) + end + + it 'displays a tab with states count' do + expect(page).to have_content("States #{project.terraform_states.size}") + end + + it 'displays a table with terraform states' do + expect(page).to have_selector( + '[data-testid="terraform-states-table-name"]', + count: project.terraform_states.size + ) + end + + it 'displays terraform actions dropdown' do + expect(page).to have_selector( + '[data-testid*="terraform-state-actions"]', + count: project.terraform_states.size + ) + end - it 'displays a table with terraform states' do + it 'displays terraform information' do + expect(page).to have_content(terraform_state.name) + end + end + end + end + + context 'when user is a terraform developer' do + let_it_be(:developer) { create(:user) } + + before do + project.add_developer(developer) + gitlab_sign_in(developer) + visit project_terraform_index_path(project) + end + + context 'when user visits the index page' do + it 'displays a table without an action dropdown', :aggregate_failures do expect(page).to have_selector( - '[data-testid="terraform-states-table"] tbody tr', + '[data-testid="terraform-states-table-name"]', count: project.terraform_states.size ) - end - it 'displays terraform information' do - expect(page).to have_content(terraform_state.name) + expect(page).not_to have_selector('[data-testid*="terraform-state-actions"]') end end end |