discourse-custom-header-links/spec/system/viewing_custom_header_links_spec.rb
Alan Guo Xiang Tan 167bc8cee9
FIX: Ensure that custom header links migration do not fail validation (#55)
This commit is a follow up to 73747938bde3c2d3f6f68350c48a320364be1b04
where the migration will fail because the objects created by the
migration will end up failing to save because the objects will fail the
validation given the new schema. This commit updates the migration to
ensure that we do not end up with invalid objects.
2024-04-26 12:57:46 +08:00

111 lines
2.9 KiB
Ruby

# frozen_string_literal: true
require_relative "page_objects/components/custom_header_link"
RSpec.describe "Viewing Custom Header Links", system: true do
fab!(:theme) { upload_theme_component }
let!(:custom_header_link) { PageObjects::Components::CustomHeaderLink.new }
before do
theme.update_setting(
:custom_header_links,
[
{
text: "External link",
title: "This link will open in a new tab",
url: "https://meta.discourse.org",
view: "vdo",
target: "blank",
hide_on_scroll: "remove",
},
{
text: "Most Liked",
title: "Posts with the most amount of likes",
url: "/latest/?order=op_likes",
view: "vdo",
target: "self",
hide_on_scroll: "keep",
},
{
text: "Privacy",
title: "Our Privacy Policy",
url: "/privacy",
view: "vdm",
target: "self",
hide_on_scroll: "keep",
},
],
)
theme.save!
end
context "when glimmer headers are enabled" do
before do
if SiteSetting.respond_to?(:experimental_glimmer_header_groups)
SiteSetting.experimental_glimmer_header_groups = Group::AUTO_GROUPS[:everyone]
else
SiteSetting.glimmer_header_mode = "enabled"
end
end
it "should display the custom header links" do
visit("/")
expect(custom_header_link).to be_visible
expect(custom_header_link).to have_custom_header_link(
"External link",
href: "https://meta.discourse.org",
title: "This link will open in a new tab",
)
expect(custom_header_link).to have_custom_header_link(
"Most Liked",
href: "/latest/?order=op_likes",
title: "Posts with the most amount of likes",
)
expect(custom_header_link).to have_custom_header_link(
"Privacy",
href: "/privacy",
title: "Our Privacy Policy",
)
end
end
context "when glimmer headers are disabled" do
before do
if SiteSetting.respond_to?(:experimental_glimmer_header_groups)
SiteSetting.experimental_glimmer_header_groups = nil
else
SiteSetting.glimmer_header_mode = "disabled"
end
end
it "should display the custom header links" do
visit("/")
expect(custom_header_link).to be_visible
expect(custom_header_link).to have_custom_header_link(
"External link",
href: "https://meta.discourse.org",
title: "This link will open in a new tab",
)
expect(custom_header_link).to have_custom_header_link(
"Most Liked",
href: "/latest/?order=op_likes",
title: "Posts with the most amount of likes",
)
expect(custom_header_link).to have_custom_header_link(
"Privacy",
href: "/privacy",
title: "Our Privacy Policy",
)
end
end
end