A platform for community discussion. Free, open, simple.
DEV: fix null crash in dashboard-new-features on feed error (#38628)
Isaac Janzene88573a1e2d2
diff --git a/frontend/discourse/admin/components/dashboard-new-features.gjs b/frontend/discourse/admin/components/dashboard-new-features.gjsindex 2d9fb5c8161..1843f2b1e1e 100644--- a/frontend/discourse/admin/components/dashboard-new-features.gjs+++ b/frontend/discourse/admin/components/dashboard-new-features.gjs@@ -14,7 +14,7 @@ import { i18n } from "discourse-i18n";export default class DashboardNewFeatures extends Component {@service currentUser;- @tracked newFeatures = null;+ @tracked newFeatures = {};@tracked isLoading = true;@tracked feedError = false;@@ -34,8 +34,7 @@ export default class DashboardNewFeatures extends Component {"/admin/whats-new.json?force_refresh=" + opts.forceRefresh);- if (!json.new_features || json.new_features.length === 0) {- this.newFeatures = {};+ if (!json.new_features) {return;}@@ -48,6 +47,7 @@ export default class DashboardNewFeatures extends Component {return acc;}, {});} catch (err) {+ this.newFeatures = {};this.feedError = true;popupAjaxError(err);} finally {diff --git a/frontend/discourse/tests/acceptance/admin-whats-new-test.js b/frontend/discourse/tests/acceptance/admin-whats-new-test.jsnew file mode 100644index 00000000000..f2cb170dfe0--- /dev/null+++ b/frontend/discourse/tests/acceptance/admin-whats-new-test.js@@ -0,0 +1,27 @@+import { visit } from "@ember/test-helpers";+import { test } from "qunit";+import { acceptance } from "discourse/tests/helpers/qunit-helpers";++const RELEASE_NOTES_URL =+ "https://meta.discourse.org/tags/c/announcements/67/release-notes";++acceptance("Admin - What's New", function (needs) {+ needs.user();++ needs.pretender((server, helper) => {+ server.get("/admin/whats-new.json", () => {+ return helper.response(500, {+ errors: ["Internal Server Error"],+ });+ });+ });++ test("it shows a feed error when loading fails", async function (assert) {+ await visit("/admin/whats-new");++ assert.dom(".admin-config-area-empty-list").exists();+ assert+ .dom(`.admin-config-area-empty-list a[href="${RELEASE_NOTES_URL}"]`)+ .exists();+ });+});