2019-07-25 05:24:42 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-13 16:53:01 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-05 18:08:19 +00:00
|
|
|
RSpec.describe 'Slack slash commands', :js do
|
2022-02-09 09:13:26 +00:00
|
|
|
include_context 'project integration activation'
|
2016-12-13 16:53:01 +00:00
|
|
|
|
2018-07-05 06:32:05 +00:00
|
|
|
before do
|
2020-04-22 09:09:36 +00:00
|
|
|
visit_project_integration('Slack slash commands')
|
2017-01-08 14:19:19 +00:00
|
|
|
end
|
2016-12-13 16:53:01 +00:00
|
|
|
|
2017-01-08 14:19:19 +00:00
|
|
|
it 'shows a token placeholder' do
|
2020-06-05 18:08:19 +00:00
|
|
|
token_placeholder = find_field('Token')['placeholder']
|
2016-12-13 16:53:01 +00:00
|
|
|
|
2017-01-08 14:19:19 +00:00
|
|
|
expect(token_placeholder).to eq('XXxxXXxxXXxxXXxxXXxxXXxx')
|
2016-12-13 16:53:01 +00:00
|
|
|
end
|
|
|
|
|
2017-01-08 14:19:19 +00:00
|
|
|
it 'shows a help message' do
|
2021-09-09 09:11:16 +00:00
|
|
|
expect(page).to have_content('Perform common operations in this project')
|
2017-01-08 14:19:19 +00:00
|
|
|
end
|
2016-12-13 16:53:01 +00:00
|
|
|
|
2020-06-05 18:08:19 +00:00
|
|
|
it 'redirects to the integrations page after saving but not activating' do
|
|
|
|
fill_in 'Token', with: 'token'
|
2020-08-24 12:10:17 +00:00
|
|
|
click_active_checkbox
|
2016-12-19 21:12:30 +00:00
|
|
|
click_on 'Save'
|
2016-12-13 16:53:01 +00:00
|
|
|
|
2022-05-25 18:08:15 +00:00
|
|
|
expect(page).to have_current_path(
|
|
|
|
edit_project_settings_integration_path(project, :slack_slash_commands),
|
|
|
|
ignore_query: true
|
|
|
|
)
|
|
|
|
|
2020-09-15 18:09:43 +00:00
|
|
|
expect(page).to have_content('Slack slash commands settings saved, but not active.')
|
2017-05-22 10:07:12 +00:00
|
|
|
end
|
|
|
|
|
2020-06-05 18:08:19 +00:00
|
|
|
it 'redirects to the integrations page after activating' do
|
|
|
|
fill_in 'Token', with: 'token'
|
2017-05-22 10:07:12 +00:00
|
|
|
click_on 'Save'
|
2016-12-13 16:53:01 +00:00
|
|
|
|
2022-05-25 18:08:15 +00:00
|
|
|
expect(page).to have_current_path(
|
|
|
|
edit_project_settings_integration_path(project, :slack_slash_commands),
|
|
|
|
ignore_query: true
|
|
|
|
)
|
|
|
|
|
2020-09-15 18:09:43 +00:00
|
|
|
expect(page).to have_content('Slack slash commands settings saved and active.')
|
2016-12-13 16:53:01 +00:00
|
|
|
end
|
|
|
|
|
2017-01-08 14:19:19 +00:00
|
|
|
it 'shows the correct trigger url' do
|
2016-12-19 21:12:30 +00:00
|
|
|
value = find_field('url').value
|
2017-07-18 20:32:40 +00:00
|
|
|
expect(value).to match("api/v4/projects/#{project.id}/services/slack_slash_commands/trigger")
|
2016-12-13 16:53:01 +00:00
|
|
|
end
|
2021-01-21 06:09:03 +00:00
|
|
|
|
|
|
|
it 'shows help content' do
|
2021-09-09 09:11:16 +00:00
|
|
|
expect(page).to have_content('Perform common operations in this project by entering slash commands in Slack.')
|
2021-01-21 06:09:03 +00:00
|
|
|
end
|
2016-12-13 16:53:01 +00:00
|
|
|
end
|