finally some working tests for "show more"

This commit is contained in:
Florian Staudacher 2012-03-16 02:00:50 +01:00
parent 813b706f8e
commit 5dae27c170
3 changed files with 44 additions and 25 deletions

View file

@ -0,0 +1,24 @@
@javascript
Feature: collapsing and expanding long posts
In order to tame the lengths of posts in my stream
As a rocket scientist
I want long posts to be collapsed and expand on click
Background:
Given a user with username "bob"
And I sign in as "bob@bob.bob"
And I am on the home page
Scenario: post a very long message
Given I post an extremely long status message
And I go to the home page
Then the post should be collapsed
Scenario: expand a very long message
Given I post an extremely long status message
And I go to the home page
And I expand the post
Then the post should be expanded

View file

@ -2,6 +2,17 @@ Then /^the post "([^"]*)" should be marked nsfw$/ do |text|
assert_nsfw(text)
end
Then /^the post should be collapsed$/ do
find(".collapsible").should have_css(".expander")
find(".collapsible").has_selector?(".collapsed")
end
Then /^the post should be expanded$/ do
find(".expander").should_not be_visible
find(".collapsible").has_no_selector?(".collapsed")
find(".collapsible").has_selector?(".opened")
end
Then /^I should see an uploaded image within the photo drop zone$/ do
find("#photodropzone img")["src"].should include("uploads/images")
end
@ -32,6 +43,10 @@ When /^I click on the first block button/ do
find(".block_user").click
end
When /^I expand the post$/ do
find(".expander").click
wait_until{ !find(".expander").visible? }
end
Then /^I should see "([^"]*)" as the first post in my stream$/ do |text|
first_post_text.should include(text)
@ -43,4 +58,8 @@ end
When /^I click the publisher and post "([^"]*)"$/ do |text|
click_and_post(text)
end
end
When /^I post an extremely long status message$/ do
click_and_post("I am a very interesting message " * 64)
end

View file

@ -39,30 +39,6 @@ describe("app.views.Stream", function() {
});
});
describe('clicking read more', function() {
var readMoreLink;
beforeEach(function() {
this.statusMessage = this.stream.posts.models[0];
this.statusElement = $(this.view.$(".stream_element")[0]);
readMoreLink = this.statusElement.find('.expander');
readMoreLink.text("read more");
$(this.view.el).find('.collapsible').css('width', 400); // make content narrow like in real stream
setFixtures(this.view.el);
this.view.postRender();
});
it('expands the post', function() {
// TODO
var textElement = this.statusElement.find('.collapsible');
expect(textElement.hasClass('collapsed')).toBeTruthy();
readMoreLink.click();
expect(textElement.hasClass('collapsed')).toBeFalsy();
expect(textElement.hasClass('opened')).toBeTruthy();
});
});
describe("infScroll", function() {
// NOTE: inf scroll happens at 500px