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
|
2020-04-22 09:09:36 +00:00
|
|
|
include_context 'project service 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
|
|
|
|
expect(page).to have_content('This service allows users to perform common')
|
|
|
|
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
|
|
|
|
2020-06-17 18:09:08 +00:00
|
|
|
expect(current_path).to eq(edit_project_service_path(project, :slack_slash_commands))
|
2017-05-22 10:07:12 +00:00
|
|
|
expect(page).to have_content('Slack slash commands settings saved, but not activated.')
|
|
|
|
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
|
|
|
|
2020-06-17 18:09:08 +00:00
|
|
|
expect(current_path).to eq(edit_project_service_path(project, :slack_slash_commands))
|
2017-05-22 10:07:12 +00:00
|
|
|
expect(page).to have_content('Slack slash commands activated.')
|
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
|
|
|
|
end
|