Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Allow title to be blank when migrating custom_header_links #56

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions migrations/settings/0002-migrate-custom-header-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@ export default function migrate(settings) {
.split(",")
.map((s) => s.trim());

if (text && title && url) {
if (text && url) {
const newLink = {
text,
title,
url,
};

if (title) {
newLink.title = title;
}

if (["vdm", "vdo", "vmo"].includes(view)) {
newLink.view = view;
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,35 @@ module(
);
});

test("migrate when title is not provided", function (assert) {
const settings = new Map(
Object.entries({
custom_header_links: "External link, , https://meta.discourse.org",
})
);

const result = migrate(settings);

const expectedResult = new Map(
Object.entries({
custom_header_links: [
{
text: "External link",
url: "https://meta.discourse.org",
view: "vdm",
target: "blank",
hide_on_scroll: "keep",
},
],
})
);

assert.deepEqual(
Object.fromEntries(result.entries()),
Object.fromEntries(expectedResult.entries())
);
});

test("migrate", function (assert) {
const settings = new Map(
Object.entries({
Expand Down
Loading