Skip to content

Commit

Permalink
DEV: Fix custom_header_links migration to handle blank string (#69)
Browse files Browse the repository at this point in the history
If the old theme setting value is set to a blank string, we will end up
not migrating it and thus cause an error to be raised.
  • Loading branch information
tgxworld authored Aug 26, 2024
1 parent 82d5925 commit 1edd930
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion migrations/settings/0002-migrate-custom-header-links.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function migrate(settings) {
return settings;
}

if (oldSetting) {
if (typeof oldSetting === "string") {
const newLinks = [];

oldSetting.split("|").forEach((link) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ module(
);
});

test("migrate when old setting value is an empty string", function (assert) {
const settings = new Map(Object.entries({ custom_header_links: "" }));

const result = migrate(settings);

const expectedResult = new Map(
Object.entries({ custom_header_links: [] })
);

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

test("migrate when old setting value is invalid", function (assert) {
const settings = new Map(
Object.entries({
Expand Down

0 comments on commit 1edd930

Please sign in to comment.