mirror of
https://github.com/discourse/discourse.git
synced 2025-09-07 12:02:53 +08:00
FIX: tracking of new/unread/latest in category/subcategory was broken
This commit is contained in:
parent
da23735062
commit
f74c21d2e7
3 changed files with 74 additions and 3 deletions
|
@ -1,4 +1,5 @@
|
|||
import TopicTrackingState from 'discourse/models/topic-tracking-state';
|
||||
import createStore from 'helpers/create-store';
|
||||
|
||||
module("model:topic-tracking-state");
|
||||
|
||||
|
@ -17,3 +18,33 @@ test("sync", function (assert) {
|
|||
state.sync(list, "new");
|
||||
assert.equal(list.topics.length, 0, "expect new topic to be removed as it was seen");
|
||||
});
|
||||
|
||||
test("subscribe to category", function(assert){
|
||||
|
||||
const store = createStore();
|
||||
const darth = store.createRecord('category', {id: 1, slug: 'darth'}),
|
||||
luke = store.createRecord('category', {id: 2, slug: 'luke', parentCategory: darth}),
|
||||
categoryList = [darth, luke];
|
||||
|
||||
sandbox.stub(Discourse.Category, 'list').returns(categoryList);
|
||||
|
||||
|
||||
const state = TopicTrackingState.create();
|
||||
|
||||
state.trackIncoming('c/darth/l/latest');
|
||||
|
||||
state.notify({message_type: 'new_topic', topic_id: 1, payload: {category_id: 2, topic_id: 1}});
|
||||
state.notify({message_type: 'new_topic', topic_id: 2, payload: {category_id: 3, topic_id: 2}});
|
||||
state.notify({message_type: 'new_topic', topic_id: 3, payload: {category_id: 1, topic_id: 3}});
|
||||
|
||||
assert.equal(state.get("incomingCount"), 2, "expect to properly track incoming for category");
|
||||
|
||||
state.resetTracking();
|
||||
state.trackIncoming('c/darth/luke/l/latest');
|
||||
|
||||
state.notify({message_type: 'new_topic', topic_id: 1, payload: {category_id: 2, topic_id: 1}});
|
||||
state.notify({message_type: 'new_topic', topic_id: 2, payload: {category_id: 3, topic_id: 2}});
|
||||
state.notify({message_type: 'new_topic', topic_id: 3, payload: {category_id: 1, topic_id: 3}});
|
||||
|
||||
assert.equal(state.get("incomingCount"), 1, "expect to properly track incoming for subcategory");
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue