diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-10-21 10:08:36 +0300 |
commit | 48aff82709769b098321c738f3444b9bdaa694c6 (patch) | |
tree | e00c7c43e2d9b603a5a6af576b1685e400410dee /spec/features/triggers_spec.rb | |
parent | 879f5329ee916a948223f8f43d77fba4da6cd028 (diff) |
Add latest changes from gitlab-org/gitlab@13-5-stable-eev13.5.0-rc42
Diffstat (limited to 'spec/features/triggers_spec.rb')
-rw-r--r-- | spec/features/triggers_spec.rb | 186 |
1 files changed, 102 insertions, 84 deletions
diff --git a/spec/features/triggers_spec.rb b/spec/features/triggers_spec.rb index 4be27673adf..6fa805d8c74 100644 --- a/spec/features/triggers_spec.rb +++ b/spec/features/triggers_spec.rb @@ -19,114 +19,132 @@ RSpec.describe 'Triggers', :js do visit project_settings_ci_cd_path(@project) end - describe 'create trigger workflow' do - it 'prevents adding new trigger with no description' do - fill_in 'trigger_description', with: '' - click_button 'Add trigger' - - # See if input has error due to empty value - expect(page.find('form.gl-show-field-errors .gl-field-error')).to be_visible - end + shared_examples 'triggers page' do + describe 'create trigger workflow' do + it 'prevents adding new trigger with no description' do + fill_in 'trigger_description', with: '' + click_button 'Add trigger' + + # See if input has error due to empty value + expect(page.find('form.gl-show-field-errors .gl-field-error')).to be_visible + end - it 'adds new trigger with description' do - fill_in 'trigger_description', with: 'trigger desc' - click_button 'Add trigger' + it 'adds new trigger with description' do + fill_in 'trigger_description', with: 'trigger desc' + click_button 'Add trigger' - # See if "trigger creation successful" message displayed and description and owner are correct - expect(page.find('.flash-notice')).to have_content 'Trigger was created successfully.' - expect(page.find('.triggers-list')).to have_content 'trigger desc' - expect(page.find('.triggers-list .trigger-owner')).to have_content user.name + aggregate_failures 'display creation notice and trigger is created' do + expect(page.find('.flash-notice')).to have_content 'Trigger was created successfully.' + expect(page.find('.triggers-list')).to have_content 'trigger desc' + expect(page.find('.triggers-list .trigger-owner')).to have_content user.name + end + end end - end - - describe 'edit trigger workflow' do - let(:new_trigger_title) { 'new trigger' } - it 'click on edit trigger opens edit trigger page' do - create(:ci_trigger, owner: user, project: @project, description: trigger_title) - visit project_settings_ci_cd_path(@project) + describe 'edit trigger workflow' do + let(:new_trigger_title) { 'new trigger' } - # See if edit page has correct descrption - find('a[title="Edit"]').send_keys(:return) - expect(page.find('#trigger_description').value).to have_content 'trigger desc' - end + it 'click on edit trigger opens edit trigger page' do + create(:ci_trigger, owner: user, project: @project, description: trigger_title) + visit project_settings_ci_cd_path(@project) - it 'edit trigger and save' do - create(:ci_trigger, owner: user, project: @project, description: trigger_title) - visit project_settings_ci_cd_path(@project) + # See if edit page has correct descrption + find('a[title="Edit"]').send_keys(:return) + expect(page.find('#trigger_description').value).to have_content 'trigger desc' + end - # See if edit page opens, then fill in new description and save - find('a[title="Edit"]').send_keys(:return) - fill_in 'trigger_description', with: new_trigger_title - click_button 'Save trigger' + it 'edit trigger and save' do + create(:ci_trigger, owner: user, project: @project, description: trigger_title) + visit project_settings_ci_cd_path(@project) - # See if "trigger updated successfully" message displayed and description and owner are correct - expect(page.find('.flash-notice')).to have_content 'Trigger was successfully updated.' - expect(page.find('.triggers-list')).to have_content new_trigger_title - expect(page.find('.triggers-list .trigger-owner')).to have_content user.name - end - end + # See if edit page opens, then fill in new description and save + find('a[title="Edit"]').send_keys(:return) + fill_in 'trigger_description', with: new_trigger_title + click_button 'Save trigger' - describe 'trigger "Revoke" workflow' do - before do - create(:ci_trigger, owner: user2, project: @project, description: trigger_title) - visit project_settings_ci_cd_path(@project) + aggregate_failures 'display update notice and trigger is updated' do + expect(page.find('.flash-notice')).to have_content 'Trigger was successfully updated.' + expect(page.find('.triggers-list')).to have_content new_trigger_title + expect(page.find('.triggers-list .trigger-owner')).to have_content user.name + end + end end - it 'button "Revoke" has correct alert' do - expected_alert = 'By revoking a trigger you will break any processes making use of it. Are you sure?' - expect(page.find('a.btn-trigger-revoke')['data-confirm']).to eq expected_alert - end + describe 'trigger "Revoke" workflow' do + before do + create(:ci_trigger, owner: user2, project: @project, description: trigger_title) + visit project_settings_ci_cd_path(@project) + end - it 'revoke trigger' do - # See if "Revoke" on trigger works post trigger creation - page.accept_confirm do - find('a.btn-trigger-revoke').send_keys(:return) + it 'button "Revoke" has correct alert' do + expected_alert = 'By revoking a trigger you will break any processes making use of it. Are you sure?' + expect(page.find('[data-testid="trigger_revoke_button"]')['data-confirm']).to eq expected_alert end - expect(page.find('.flash-notice')).to have_content 'Trigger removed' - expect(page).to have_selector('p.settings-message.text-center.gl-mb-3') - end - end + it 'revoke trigger' do + # See if "Revoke" on trigger works post trigger creation + page.accept_confirm do + find('[data-testid="trigger_revoke_button"]').send_keys(:return) + end - describe 'show triggers workflow' do - it 'contains trigger description placeholder' do - expect(page.find('#trigger_description')['placeholder']).to eq 'Trigger description' + aggregate_failures 'trigger is removed' do + expect(page.find('.flash-notice')).to have_content 'Trigger removed' + expect(page).to have_css('[data-testid="no_triggers_content"]') + end + end end - it 'show "invalid" badge for trigger with owner having insufficient permissions' do - create(:ci_trigger, owner: guest_user, project: @project, description: trigger_title) - visit project_settings_ci_cd_path(@project) + describe 'show triggers workflow' do + it 'contains trigger description placeholder' do + expect(page.find('#trigger_description')['placeholder']).to eq 'Trigger description' + end - expect(page.find('.triggers-list')).to have_content 'invalid' - expect(page.find('.triggers-list')).not_to have_selector('a[title="Edit"]') - end + it 'show "invalid" badge for trigger with owner having insufficient permissions' do + create(:ci_trigger, owner: guest_user, project: @project, description: trigger_title) + visit project_settings_ci_cd_path(@project) + + aggregate_failures 'has invalid badge and no edit link' do + expect(page.find('.triggers-list')).to have_content 'invalid' + expect(page.find('.triggers-list')).not_to have_selector('a[title="Edit"]') + end + end - it 'do not show "Edit" or full token for not owned trigger' do - # Create trigger with user different from current_user - create(:ci_trigger, owner: user2, project: @project, description: trigger_title) - visit project_settings_ci_cd_path(@project) + it 'do not show "Edit" or full token for not owned trigger' do + # Create trigger with user different from current_user + create(:ci_trigger, owner: user2, project: @project, description: trigger_title) + visit project_settings_ci_cd_path(@project) + + aggregate_failures 'shows truncated token, no clipboard button and no edit link' do + expect(page.find('.triggers-list')).to have_content(@project.triggers.first.token[0..3]) + expect(page.find('.triggers-list')).not_to have_selector('[data-testid="clipboard-btn"]') + expect(page.find('.triggers-list .trigger-owner')).not_to have_content user.name + expect(page.find('.triggers-list')).not_to have_selector('a[title="Edit"]') + end + end - # See if trigger not owned by current_user shows only first few token chars and doesn't have copy-to-clipboard button - expect(page.find('.triggers-list')).to have_content(@project.triggers.first.token[0..3]) - expect(page.find('.triggers-list')).not_to have_selector('button.btn-clipboard') + it 'show "Edit" and full token for owned trigger' do + create(:ci_trigger, owner: user, project: @project, description: trigger_title) + visit project_settings_ci_cd_path(@project) - # See if trigger owner name doesn't match with current_user and trigger is non-editable - expect(page.find('.triggers-list .trigger-owner')).not_to have_content user.name - expect(page.find('.triggers-list')).not_to have_selector('a[title="Edit"]') + aggregate_failures 'shows full token, clipboard button and edit link' do + expect(page.find('.triggers-list')).to have_content @project.triggers.first.token + expect(page.find('.triggers-list')).to have_selector('[data-testid="clipboard-btn"]') + expect(page.find('.triggers-list .trigger-owner')).to have_content user.name + expect(page.find('.triggers-list')).to have_selector('a[title="Edit"]') + end + end end + end - it 'show "Edit" and full token for owned trigger' do - create(:ci_trigger, owner: user, project: @project, description: trigger_title) - visit project_settings_ci_cd_path(@project) - - # See if trigger shows full token and has copy-to-clipboard button - expect(page.find('.triggers-list')).to have_content @project.triggers.first.token - expect(page.find('.triggers-list')).to have_selector('button.btn-clipboard') + context 'when ci_pipeline_triggers_settings_vue_ui is enabled' do + it_behaves_like 'triggers page' + end - # See if trigger owner name matches with current_user and is editable - expect(page.find('.triggers-list .trigger-owner')).to have_content user.name - expect(page.find('.triggers-list')).to have_selector('a[title="Edit"]') + context 'when ci_pipeline_triggers_settings_vue_ui is disabled' do + before do + stub_feature_flags(ci_pipeline_triggers_settings_vue_ui: false) end + + it_behaves_like 'triggers page' end end |