debian-mirror-gitlab/spec/features/broadcast_messages_spec.rb

97 lines
2.7 KiB
Ruby
Raw Normal View History

2020-03-13 15:44:24 +05:30
# frozen_string_literal: true
require 'spec_helper'
2023-03-04 22:38:38 +05:30
RSpec.describe 'Broadcast Messages', feature_category: :onboarding do
2020-04-22 19:07:51 +05:30
let_it_be(:user) { create(:user) }
shared_examples 'a Broadcast Messages' do |type|
2020-04-08 14:13:33 +05:30
it 'shows broadcast message' do
2023-07-09 08:55:56 +05:30
visit explore_projects_path
2020-03-13 15:44:24 +05:30
2020-04-08 14:13:33 +05:30
expect(page).to have_content 'SampleMessage'
end
2020-04-22 19:07:51 +05:30
it 'renders styled links' do
create(:broadcast_message, type, message: "<a href='gitlab.com' style='color: purple'>click me</a>")
2023-07-09 08:55:56 +05:30
visit explore_projects_path
2020-04-22 19:07:51 +05:30
expected_html = "<p><a href=\"gitlab.com\" style=\"color: purple\">click me</a></p>"
expect(page.body).to include(expected_html)
end
2020-04-08 14:13:33 +05:30
end
2023-07-09 08:55:56 +05:30
shared_examples 'a dismissible Broadcast Messages' do
2023-04-23 21:23:45 +05:30
it 'hides broadcast message after dismiss', :js,
quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/390900' do
2023-07-09 08:55:56 +05:30
visit explore_projects_path
2020-04-08 14:13:33 +05:30
find('.js-dismiss-current-broadcast-notification').click
expect(page).not_to have_content 'SampleMessage'
end
2020-03-13 15:44:24 +05:30
2023-04-23 21:23:45 +05:30
it 'broadcast message is still hidden after refresh', :js,
quarantine: 'https://gitlab.com/gitlab-org/gitlab/-/issues/391406' do
2023-07-09 08:55:56 +05:30
visit explore_projects_path
2020-04-08 14:13:33 +05:30
find('.js-dismiss-current-broadcast-notification').click
2023-03-04 22:38:38 +05:30
wait_for_cookie_set("hide_broadcast_message_#{broadcast_message.id}")
2023-07-09 08:55:56 +05:30
visit explore_projects_path
2020-04-08 14:13:33 +05:30
expect(page).not_to have_content 'SampleMessage'
end
2020-03-13 15:44:24 +05:30
end
2020-04-08 14:13:33 +05:30
describe 'banner type' do
2023-07-09 08:55:56 +05:30
let_it_be(:broadcast_message) { create(:broadcast_message, message: 'SampleMessage') }
2020-03-13 15:44:24 +05:30
2020-04-08 14:13:33 +05:30
it_behaves_like 'a Broadcast Messages'
2020-03-13 15:44:24 +05:30
2023-07-09 08:55:56 +05:30
it 'is not dismissible' do
visit explore_projects_path
2020-04-08 14:13:33 +05:30
expect(page).not_to have_selector('.js-dismiss-current-broadcast-notification')
end
2020-04-22 19:07:51 +05:30
it 'does not replace placeholders' do
create(:broadcast_message, message: 'Hi {{name}}')
sign_in(user)
2023-07-09 08:55:56 +05:30
visit explore_projects_path
2020-04-22 19:07:51 +05:30
expect(page).to have_content 'Hi {{name}}'
end
2020-03-13 15:44:24 +05:30
end
2023-07-09 08:55:56 +05:30
describe 'dismissible banner type' do
let_it_be(:broadcast_message) { create(:broadcast_message, dismissable: true, message: 'SampleMessage') }
2020-04-08 14:13:33 +05:30
it_behaves_like 'a Broadcast Messages'
2023-07-09 08:55:56 +05:30
it_behaves_like 'a dismissible Broadcast Messages'
2020-04-08 14:13:33 +05:30
end
describe 'notification type' do
2023-07-09 08:55:56 +05:30
let_it_be(:broadcast_message) { create(:broadcast_message, :notification, message: 'SampleMessage') }
2020-04-08 14:13:33 +05:30
2020-04-22 19:07:51 +05:30
it_behaves_like 'a Broadcast Messages', :notification
2020-04-08 14:13:33 +05:30
2023-07-09 08:55:56 +05:30
it_behaves_like 'a dismissible Broadcast Messages'
2020-04-08 14:13:33 +05:30
2020-04-22 19:07:51 +05:30
it 'replaces placeholders' do
create(:broadcast_message, :notification, message: 'Hi {{name}}')
2020-04-08 14:13:33 +05:30
2020-04-22 19:07:51 +05:30
sign_in(user)
2020-03-13 15:44:24 +05:30
2023-07-09 08:55:56 +05:30
visit explore_projects_path
2020-03-13 15:44:24 +05:30
2020-04-22 19:07:51 +05:30
expect(page).to have_content "Hi #{user.name}"
end
2020-03-13 15:44:24 +05:30
end
end