Commit 073222d1 authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch '349058-refactor-js-data-attributes-as-variables' into 'master'

Refactor group security discover data attributes

See merge request gitlab-org/gitlab!77781
parents 5e2ad450 4330a96e
...@@ -35,4 +35,22 @@ module Groups::SecurityFeaturesHelper ...@@ -35,4 +35,22 @@ module Groups::SecurityFeaturesHelper
has_projects: group.projects.any?.to_s has_projects: group.projects.any?.to_s
} }
end end
def group_security_discover_data(group)
content = pql_three_cta_test_experiment_candidate?(group.root_ancestor) ? 'discover-group-security-pqltest' : 'discover-group-security'
data = {
group: {
id: group.id,
name: group.name
},
link: {
main: new_trial_registration_path(glm_source: 'gitlab.com', glm_content: content),
secondary: group_billings_path(group.root_ancestor, source: content),
feedback: 'https://gitlab.com/gitlab-org/growth/ui-ux/issues/25'
}
}
data.merge(hand_raise_props(group.root_ancestor))
end
end end
- breadcrumb_title _("Security") - breadcrumb_title _("Security")
- page_title _("Security") - page_title _("Security")
- add_page_specific_style 'page_bundles/security_discover' - add_page_specific_style 'page_bundles/security_discover'
- linkFeedback = 'https://gitlab.com/gitlab-org/growth/ui-ux/issues/25'
- content = pql_three_cta_test_experiment_candidate?(@group.root_ancestor) ? 'discover-group-security-pqltest' : 'discover-group-security'
- linkUpgrade = group_billings_path(@group.root_ancestor, source: content)
- data = { group: { id: @group.id, name: @group.name }, link: { main: new_trial_registration_path(glm_source: 'gitlab.com', glm_content: content), secondary: linkUpgrade, feedback: linkFeedback } }
- data.merge!(hand_raise_props(@group.root_ancestor))
#js-security-discover-app{ data: data } #js-security-discover-app{ data: group_security_discover_data(@group) }
...@@ -88,4 +88,45 @@ RSpec.describe Groups::SecurityFeaturesHelper do ...@@ -88,4 +88,45 @@ RSpec.describe Groups::SecurityFeaturesHelper do
it { is_expected.to eq(expected_data) } it { is_expected.to eq(expected_data) }
end end
describe '#group_security_discover_data' do
let_it_be(:group) { create(:group) }
let(:variant) { :control }
let(:content) { 'discover-group-security' }
let(:expected_group_security_discover_data) do
{
group: {
id: group.id,
name: group.name
},
link: {
main: new_trial_registration_path(glm_source: 'gitlab.com', glm_content: content),
secondary: group_billings_path(group.root_ancestor, source: content),
feedback: 'https://gitlab.com/gitlab-org/growth/ui-ux/issues/25'
}
}.merge(helper.hand_raise_props(group.root_ancestor))
end
subject(:group_security_discover_data) do
helper.group_security_discover_data(group)
end
before do
stub_experiments(pql_three_cta_test: variant)
end
it 'builds correct hash' do
expect(group_security_discover_data).to eq(expected_group_security_discover_data)
end
context 'candidate for pql_three_cta_test' do
let(:variant) { :candidate }
let(:content) { 'discover-group-security-pqltest' }
it 'renders a hash with pqltest content' do
expect(group_security_discover_data).to eq(expected_group_security_discover_data)
end
end
end
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