Commit 5e3c5d67 authored by Albert Salim's avatar Albert Salim

Test pushing of frontend feature flag

parent dc255db1
......@@ -6,28 +6,6 @@ RSpec.describe 'Group value stream analytics' do
let_it_be(:group) { create(:group) }
let_it_be(:user) { create(:user) }
RSpec::Matchers.define :have_pushed_frontend_feature_flags do |expected|
def to_js(key, value)
"\"#{key}\":#{value}"
end
match do |actual|
expected.all? do |feature_flag_name, enabled|
page.html.include?(to_js(feature_flag_name, enabled))
end
end
failure_message do |actual|
missing = expected.select do |feature_flag_name, enabled|
!page.html.include?(to_js(feature_flag_name, enabled))
end
formatted_missing_flags = missing.map { |feature_flag_name, enabled| to_js(feature_flag_name, enabled) }.join("\n")
"The following feature flag(s) cannot be found in the frontend HTML source: #{formatted_missing_flags}"
end
end
before do
stub_licensed_features(cycle_analytics_for_groups: true)
......
......@@ -111,6 +111,21 @@ RSpec.describe 'Issue Sidebar' do
expect(page).not_to have_selector('.block.health-status')
end
end
it 'pushes frontend feature flag saveIssuableHealthStatus' do
visit_issue(project, issue)
expect(page).to have_pushed_frontend_feature_flags(saveIssuableHealthStatus: true)
end
context 'when save_issuable_health_status feature flag is disabled' do
it 'pushes disabled frontend feature flag saveIssuableHealthStatus' do
stub_feature_flags(save_issuable_health_status: false)
visit_issue(project, issue)
expect(page).to have_pushed_frontend_feature_flags(saveIssuableHealthStatus: false)
end
end
end
def visit_issue(project, issue)
......
# frozen_string_literal: true
RSpec::Matchers.define :have_pushed_frontend_feature_flags do |expected|
def to_js(key, value)
"\"#{key}\":#{value}"
end
match do |actual|
expected.all? do |feature_flag_name, enabled|
page.html.include?(to_js(feature_flag_name, enabled))
end
end
failure_message do |actual|
missing = expected.select do |feature_flag_name, enabled|
!page.html.include?(to_js(feature_flag_name, enabled))
end
formatted_missing_flags = missing.map { |feature_flag_name, enabled| to_js(feature_flag_name, enabled) }.join("\n")
"The following feature flag(s) cannot be found in the frontend HTML source: #{formatted_missing_flags}"
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment