From 932fb186e3d0ecb878a4639e52f970ce03ed0554 Mon Sep 17 00:00:00 2001 From: Florian Staudacher Date: Sat, 4 Aug 2012 16:04:44 +0200 Subject: [PATCH] fix failing bookmarklet specs (wait for js to finish) --- .../status_messages/bookmarklet.html.haml | 2 ++ spec/javascripts/bookmarklet-spec.js | 22 +++++++++++-------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/app/views/status_messages/bookmarklet.html.haml b/app/views/status_messages/bookmarklet.html.haml index 90df0c5f3..b1e7e2c36 100644 --- a/app/views/status_messages/bookmarklet.html.haml +++ b/app/views/status_messages/bookmarklet.html.haml @@ -24,6 +24,8 @@ window.setTimeout(window.close, 2000, true); }); + // this has to happen after the publisher has finished loading, otherwise + // the textarea is cleared again by the initialization of the mentions plugin $(function(){ $("#publisher #status_message_fake_text").val(contents); $("#publisher #status_message_text").val(contents); diff --git a/spec/javascripts/bookmarklet-spec.js b/spec/javascripts/bookmarklet-spec.js index 96f5c6da3..10a32dd6d 100644 --- a/spec/javascripts/bookmarklet-spec.js +++ b/spec/javascripts/bookmarklet-spec.js @@ -1,7 +1,7 @@ /* Copyright (c) 2010-2012, Diaspora Inc. This file is -* licensed under the Affero General Public License version 3 or later. See -* the COPYRIGHT file. -*/ + * licensed under the Affero General Public License version 3 or later. See + * the COPYRIGHT file. + */ describe("bookmarklet", function() { @@ -22,18 +22,22 @@ describe("bookmarklet", function() { describe("prefilled bookmarklet", function(){ it('fills in some text into the publisher', function(){ spec.loadFixture('prefilled_bookmarklet'); - expect($("#publisher #status_message_fake_text").val() == "").toBeFalsy(); - expect($("#publisher #status_message_text").val() == "").toBeFalsy(); + _.defer(function() { + expect($("#publisher #status_message_fake_text").val() == "").toBeFalsy(); + expect($("#publisher #status_message_text").val() == "").toBeFalsy(); + }); }); it('handles dirty input well', function(){ spec.loadFixture('prefilled_bookmarklet_dirty'); - expect($("#publisher #status_message_fake_text").val() == "").toBeFalsy(); - expect($("#publisher #status_message_text").val() == "").toBeFalsy(); + _.defer(function() { + expect($("#publisher #status_message_fake_text").val() == "").toBeFalsy(); + expect($("#publisher #status_message_text").val() == "").toBeFalsy(); + }; }); }); - - + + }); \ No newline at end of file