DEV: Set `ExtraNavItem` count property to be a tracked property (#25806)

Why this change?

This regressed in b797434376 where
the count property in `ExtraNavItem` needs to be tracked as plugins can
be updating the count property directly.
This commit is contained in:
Alan Guo Xiang Tan 2024-02-22 11:52:49 +08:00 committed by GitHub
parent 31e44cfa82
commit 5dba5c4208
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 27 additions and 2 deletions

View File

@ -325,9 +325,9 @@ export default class NavItem extends EmberObject {
}
}
class ExtraNavItem extends NavItem {
export class ExtraNavItem extends NavItem {
@tracked href;
count = 0;
@tracked count = 0;
customFilter = null;
}

View File

@ -0,0 +1,25 @@
import { setupTest } from "ember-qunit";
import { module, test } from "qunit";
import { ExtraNavItem } from "discourse/models/nav-item";
module("Unit | Model | extra-nav-item", function (hooks) {
setupTest(hooks);
test("displayName updates when count property changes", function (assert) {
const extraNavItem = ExtraNavItem.create({
name: "something",
});
assert.strictEqual(
extraNavItem.displayName,
"[en.filters.something.title count=0]"
);
extraNavItem.count = 2;
assert.strictEqual(
extraNavItem.displayName,
"[en.filters.something.title_with_count count=2]"
);
});
});