2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-12-13 11:52:58 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
describe 'Admin Broadcast Messages' do
|
2016-12-13 11:52:58 -05:00
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in(create(:admin))
|
2016-12-13 11:52:58 -05:00
|
|
|
create(:broadcast_message, :expired, message: 'Migration to new server')
|
|
|
|
visit admin_broadcast_messages_path
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'See broadcast messages list' do
|
2016-12-13 11:52:58 -05:00
|
|
|
expect(page).to have_content 'Migration to new server'
|
|
|
|
end
|
|
|
|
|
2020-01-09 19:07:56 -05:00
|
|
|
it 'creates a customized broadcast banner message' do
|
2016-12-13 11:52:58 -05:00
|
|
|
fill_in 'broadcast_message_message', with: 'Application update from **4:00 CST to 5:00 CST**'
|
|
|
|
fill_in 'broadcast_message_color', with: '#f2dede'
|
2019-12-02 10:06:36 -05:00
|
|
|
fill_in 'broadcast_message_target_path', with: '*/user_onboarded'
|
2016-12-13 11:52:58 -05:00
|
|
|
fill_in 'broadcast_message_font', with: '#b94a48'
|
|
|
|
select Date.today.next_year.year, from: 'broadcast_message_ends_at_1i'
|
|
|
|
click_button 'Add broadcast message'
|
|
|
|
|
|
|
|
expect(current_path).to eq admin_broadcast_messages_path
|
|
|
|
expect(page).to have_content 'Application update from 4:00 CST to 5:00 CST'
|
2019-12-02 10:06:36 -05:00
|
|
|
expect(page).to have_content '*/user_onboarded'
|
2016-12-13 11:52:58 -05:00
|
|
|
expect(page).to have_selector 'strong', text: '4:00 CST to 5:00 CST'
|
|
|
|
expect(page).to have_selector %(div[style="background-color: #f2dede; color: #b94a48"])
|
|
|
|
end
|
|
|
|
|
2020-01-09 19:07:56 -05:00
|
|
|
it 'creates a customized broadcast notification message' do
|
|
|
|
fill_in 'broadcast_message_message', with: 'Application update from **4:00 CST to 5:00 CST**'
|
|
|
|
fill_in 'broadcast_message_target_path', with: '*/user_onboarded'
|
|
|
|
select 'Notification', from: 'broadcast_message_broadcast_type'
|
|
|
|
select Date.today.next_year.year, from: 'broadcast_message_ends_at_1i'
|
|
|
|
click_button 'Add broadcast message'
|
|
|
|
|
|
|
|
expect(current_path).to eq admin_broadcast_messages_path
|
|
|
|
expect(page).to have_content 'Application update from 4:00 CST to 5:00 CST'
|
|
|
|
expect(page).to have_content '*/user_onboarded'
|
|
|
|
expect(page).to have_content 'Notification'
|
|
|
|
expect(page).to have_selector 'strong', text: '4:00 CST to 5:00 CST'
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'Edit an existing broadcast message' do
|
2016-12-13 11:52:58 -05:00
|
|
|
click_link 'Edit'
|
|
|
|
fill_in 'broadcast_message_message', with: 'Application update RIGHT NOW'
|
|
|
|
click_button 'Update broadcast message'
|
|
|
|
|
|
|
|
expect(current_path).to eq admin_broadcast_messages_path
|
|
|
|
expect(page).to have_content 'Application update RIGHT NOW'
|
|
|
|
end
|
|
|
|
|
2018-07-05 02:32:05 -04:00
|
|
|
it 'Remove an existing broadcast message' do
|
2016-12-13 11:52:58 -05:00
|
|
|
click_link 'Remove'
|
|
|
|
|
|
|
|
expect(current_path).to eq admin_broadcast_messages_path
|
|
|
|
expect(page).not_to have_content 'Migration to new server'
|
|
|
|
end
|
|
|
|
|
2020-01-09 19:07:56 -05:00
|
|
|
it 'updates a preview of a customized broadcast banner message', :js do
|
|
|
|
fill_in 'broadcast_message_message', with: "Live **Markdown** previews. :tada:"
|
|
|
|
|
|
|
|
page.within('.js-broadcast-banner-message-preview') do
|
|
|
|
expect(page).to have_selector('strong', text: 'Markdown')
|
|
|
|
expect(page).to have_emoji('tada')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates a preview of a customized broadcast notification message', :js do
|
2016-12-13 11:52:58 -05:00
|
|
|
fill_in 'broadcast_message_message', with: "Live **Markdown** previews. :tada:"
|
2020-01-09 19:07:56 -05:00
|
|
|
select 'Notification', from: 'broadcast_message_broadcast_type'
|
2016-12-13 11:52:58 -05:00
|
|
|
|
2020-01-09 19:07:56 -05:00
|
|
|
page.within('.js-broadcast-notification-message-preview') do
|
2016-12-13 11:52:58 -05:00
|
|
|
expect(page).to have_selector('strong', text: 'Markdown')
|
2018-04-11 04:34:42 -04:00
|
|
|
expect(page).to have_emoji('tada')
|
2016-12-13 11:52:58 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|