From 61a2a1a8f80245b2b8c68eef6397606bb27ace64 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Fri, 13 Oct 2017 16:48:50 -0700 Subject: [PATCH] Improve fixtures, restore InboxView rendering on the test page (#1562) --- js/conversation_controller.js | 4 +++ test/fixtures.js | 61 +++++++++++++++++++++++++++-------- test/fixtures_test.js | 3 +- test/index.html | 1 + 4 files changed, 55 insertions(+), 14 deletions(-) diff --git a/js/conversation_controller.js b/js/conversation_controller.js index 171122ed2..1d6b522d2 100644 --- a/js/conversation_controller.js +++ b/js/conversation_controller.js @@ -154,6 +154,10 @@ loadPromise: function() { return this._initialPromise; }, + reset: function() { + this._initialPromise = null; + conversations.reset([]); + }, load: function() { console.log('ConversationController: starting initial fetch'); if (this._initialPromise) { diff --git a/test/fixtures.js b/test/fixtures.js index 842b0638e..6c812cd86 100644 --- a/test/fixtures.js +++ b/test/fixtures.js @@ -50,6 +50,39 @@ Whisper.Fixtures = (function() { } ]); + var Vera = conversationCollection.get(VERA_ID); + Vera.messageCollection.add([ + { + conversationId: VERA_ID, + type: 'incoming', + sent_at: now - 10000000, + received_at: now - 10000000, + body: "My piece for Iskra is ready!", + } + ]); + + var Nestor = conversationCollection.get(NESTOR_ID); + Nestor.messageCollection.add([ + { + conversationId: NESTOR_ID, + type: 'incoming', + sent_at: now - 1000000000, + received_at: now - 1000000000, + body: "Need a ride?", + } + ]); + + var Fred = conversationCollection.get(FRED_ID); + Fred.messageCollection.add([ + { + conversationId: FRED_ID, + type: 'incoming', + sent_at: now - 500000000, + received_at: now - 500000000, + body: "It is my ambition to say in ten sentences what everyone else says in a whole book — what everyone else does not say in a whole book.", + } + ]); + var Michel = conversationCollection.get(MICHEL_ID); Michel.messageCollection.add([ { @@ -115,6 +148,7 @@ Whisper.Fixtures = (function() { body : m.body, sent_at : m.date, received_at : m.date, + timestamp : m.date, attachments : m.attachments, unread : m.unread, source : m.source, @@ -127,29 +161,30 @@ Whisper.Fixtures = (function() { active_at: now - 100000, timestamp: now - 100000, id: 'group1', - lastMessage: "See you all there!" + lastMessage: "See you all there!", + members: [MICHEL_ID, FRED_ID, NESTOR_ID], }); group.messageCollection.add([ { - date: now - 30000, + date: now - 60 * 1000 * 30, type: 'incoming', body: "If you knew when you began a book what you would say at the end, do you think that you would have the courage to write it?", source: MICHEL_ID, }, { - date: now - 20000, + date: now - 60 * 1000 * 20, type: 'incoming', body: "A book which has a strange knack of seeking out its fellow-revellers and enticing them on to new secret paths and dancing-places.", source: FRED_ID }, { - date: now - 4000, + date: now - 60 * 1000 * 4, type: 'incoming', body: "Let's meet in the library.", source: NESTOR_ID }, { - date: now - 1000, + date: now - 60 * 1000, type: 'incoming', body: "I'll be a little late.", source: NESTOR_ID @@ -157,19 +192,18 @@ Whisper.Fixtures = (function() { { date: now, type: 'outgoing', - body: "See you all there!" + body: "See you all there!", + recipients: [MICHEL_ID, FRED_ID, NESTOR_ID], + delivered_to: [MICHEL_ID, FRED_ID], + sent_to: [NESTOR_ID], }, ].map(function(m) { - return { + return Object.assign({}, m, { conversationId : group.id, - source : m.source, - type : m.type, - body : m.body, sent_at : m.date, received_at : m.date, - attachments : m.attachments, - unread : m.unread - }; + timestamp : m.date, + }); })); function dataURItoBlob(dataURI) { @@ -2651,3 +2685,4 @@ Whisper.Fixtures = (function() { return conversationCollection; })(); + diff --git a/test/fixtures_test.js b/test/fixtures_test.js index 546d05cca..173f62c56 100644 --- a/test/fixtures_test.js +++ b/test/fixtures_test.js @@ -11,7 +11,8 @@ describe("Fixtures", function() { }); it('renders', function(done) { - ConversationController.loadPromise().then(function() { + ConversationController.reset(); + ConversationController.load().then(function() { var view = new Whisper.InboxView({window: window}); view.onEmpty(); view.$el.prependTo($('#render-android')); diff --git a/test/index.html b/test/index.html index 4aa79da16..7f559aa8c 100644 --- a/test/index.html +++ b/test/index.html @@ -593,6 +593,7 @@ +