From 7a8269ebf37ac15ff89eb9f78ff66ceb1d2acd53 Mon Sep 17 00:00:00 2001 From: movilla Date: Sat, 2 Mar 2013 23:20:13 +0100 Subject: [PATCH] * Add test for mobile page: Edit profile mobile, Conversations mobile, Getting Started mobile * Complete the existing: Post mobile. * Complete some test for no mobile: Edit profile, Post main. * Fix little error css and js mobile. * Add file-upload-custom javascripts to mobile.js. --- app/assets/javascripts/mobile.js | 4 +- app/assets/stylesheets/mobile.css.scss | 2 +- app/controllers/users_controller.rb | 5 +- app/views/profiles/_edit_public.mobile.haml | 1 - app/views/users/getting_started.mobile.haml | 3 +- features/conversations_mobile.feature | 24 +++++++++ features/edits_profile.feature | 20 ++++++++ features/edits_profile_mobile.feature | 50 +++++++++++++++++++ features/getting_started_mobile.feature | 28 +++++++++++ features/posts_from_main_page.feature | 3 ++ features/posts_from_main_page_mobile.feature | 7 ++- .../step_definitions/conversations_steps.rb | 12 +++++ features/step_definitions/mobile_steps.rb | 8 +++ 13 files changed, 160 insertions(+), 7 deletions(-) create mode 100644 features/conversations_mobile.feature create mode 100644 features/edits_profile_mobile.feature create mode 100644 features/getting_started_mobile.feature diff --git a/app/assets/javascripts/mobile.js b/app/assets/javascripts/mobile.js index cdeebc3a5..63d0b123b 100644 --- a/app/assets/javascripts/mobile.js +++ b/app/assets/javascripts/mobile.js @@ -7,7 +7,7 @@ //= require mbp-respond.min //= require mbp-helper //= require jquery.autoSuggest.custom - +//= require fileuploader-custom $(document).ready(function(){ @@ -309,7 +309,7 @@ function createUploader(){ }, onComplete: function(id, fileName, responseJSON) { - $('#fileInfo-publisher').text(Diaspora.I18n.t("photo_uploader.completed", file=fileName)); + $('#fileInfo-publisher').text(Diaspora.I18n.t("photo_uploader.completed", {'file': fileName})); var id = responseJSON.data.photo.id, url = responseJSON.data.photo.unprocessed_image.url, currentPlaceholder = $('li.loading').first(); diff --git a/app/assets/stylesheets/mobile.css.scss b/app/assets/stylesheets/mobile.css.scss index d70579900..5cf5fa554 100644 --- a/app/assets/stylesheets/mobile.css.scss +++ b/app/assets/stylesheets/mobile.css.scss @@ -1172,5 +1172,5 @@ input#q.search { position: absolute; right: 10px; text-align: right; - bottom: 40px; + bottom: 25px; } diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1a9d88b3b..f3fb55e4b 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -120,7 +120,10 @@ class UsersController < ApplicationController @css_framework = :bootstrap @include_application_css = true #Hack for multiple CSS frameworks and having two main styles - render "users/getting_started", layout: "with_header_with_footer" + respond_to do |format| + format.mobile { render "users/getting_started" } + format.all { render "users/getting_started", layout: "with_header_with_footer" } + end end def getting_started_completed diff --git a/app/views/profiles/_edit_public.mobile.haml b/app/views/profiles/_edit_public.mobile.haml index e750a8bd6..eab701ffe 100644 --- a/app/views/profiles/_edit_public.mobile.haml +++ b/app/views/profiles/_edit_public.mobile.haml @@ -4,7 +4,6 @@ - content_for :head do = javascript_include_tag :jquery - = javascript_include_tag 'fileuploader-custom' :javascript $(document).ready(function () { diff --git a/app/views/users/getting_started.mobile.haml b/app/views/users/getting_started.mobile.haml index 94d2f2ec1..bc90efcdb 100644 --- a/app/views/users/getting_started.mobile.haml +++ b/app/views/users/getting_started.mobile.haml @@ -3,7 +3,8 @@ -# the COPYRIGHT file. - content_for :head do - = javascript_include_tag :jquery, :home + = javascript_include_tag :jquery + = javascript_include_tag 'fileuploader-custom' :javascript $(document).ready(function () { diff --git a/features/conversations_mobile.feature b/features/conversations_mobile.feature new file mode 100644 index 000000000..6f15050b1 --- /dev/null +++ b/features/conversations_mobile.feature @@ -0,0 +1,24 @@ +@javascript +Feature: private messages mobile + In order to be talkative + As a mobile user + I want to converse with people + + Background: + Given a user with username "bob" + And a user named "Alice Awesome" with email "alice@alice.alice" + When I sign in as "bob@bob.bob" + And a user with username "bob" is connected with "alice_awesome" + And I toggle the mobile view + + Scenario: send a mobile message + Given I send a mobile message with subject "Greetings" and text "hello, alice!" to "Alice Awesome" + Then I should see "Greetings" within ".ltr" + And I should see "Greetings" within ".ltr" + And I press the first ".ltr" within ".conversation" + And "Alice Awesome" should be part of active conversation + And I should see "hello, alice!" within ".stream_element" + When I sign in as "alice@alice.alice" + And I reply with "hey, how you doing?" + And I press the first ".ltr" within ".conversation" + Then I should see "hey, how you doing?" diff --git a/features/edits_profile.feature b/features/edits_profile.feature index 23b105beb..0b3e08ab2 100644 --- a/features/edits_profile.feature +++ b/features/edits_profile.feature @@ -9,10 +9,15 @@ Feature: editing your profile | profile_first_name | Boba | | profile_last_name | Fett | | profile_bio | This is a bio | + | profile_location | Kamino | + And I select "1986" from "profile_date_year" And I select "30" from "profile_date_day" And I select "November" from "profile_date_month" + And I fill in "profile[tag_string]" with "#starwars" + And I press the first ".as-result-item" within ".as-results" + And I press "Update Profile" Then I should be on my edit profile page @@ -24,6 +29,21 @@ Feature: editing your profile And the "profile_date_year" field should be filled with "1986" And the "profile_date_month" field should be filled with "11" And the "profile_date_day" field should be filled with "30" + And the "profile_location" field should be filled with "Kamino" + And I should see "#starwars" within "ul#as-selections-tags" + + When I fill in "profile[tag_string]" with "#kamino" + And I press the first ".as-result-item" within ".as-results" + + And I press "Update Profile" + Then I should see "#kamino" within "ul#as-selections-tags" + And I should see "#starwars" within "ul#as-selections-tags" + + When I attach the file "spec/fixtures/bad_urls.txt" to "file" within "#file-upload" + And I preemptively confirm the alert + And I attach the file "spec/fixtures/button.png" to hidden element "file" within "#file-upload" + And I wait for the ajax to finish + Then I should see a "img" within "#profile_photo_upload" When I go to my new profile page # #commented out until we bring back the profile info on new profile diff --git a/features/edits_profile_mobile.feature b/features/edits_profile_mobile.feature new file mode 100644 index 000000000..89cbdf46f --- /dev/null +++ b/features/edits_profile_mobile.feature @@ -0,0 +1,50 @@ +@javascript +Feature: editing the profile in the mobile view + Scenario: editing profile fields + Given I am signed in + And I toggle the mobile view + And I go to the edit profile page + + When I fill in the following: + | profile_gender | Fearless | + | profile_first_name | Boba | + | profile_last_name | Fett | + | profile_bio | This is a bio | + | profile_location | Kamino | + + And I select "1986" from "profile_date_year" + And I select "30" from "profile_date_day" + And I select "November" from "profile_date_month" + + And I fill in "profile[tag_string]" with "#starwars" + And I press the first ".as-result-item" within ".as-results" + + And I press "Update Profile" + + Then I should be on my edit profile page + And I should see "Profile updated" + And the "profile_gender" field should contain "Fearless" + And the "profile_first_name" field should contain "Boba" + And the "profile_last_name" field should contain "Fett" + And I should see "This is a bio" + And the "profile_date_year" field should be filled with "1986" + And the "profile_date_month" field should be filled with "11" + And the "profile_date_day" field should be filled with "30" + And the "profile_location" field should be filled with "Kamino" + And I should see "#starwars" within "ul#as-selections-tags" + + When I fill in "profile[tag_string]" with "#kamino" + And I press the first ".as-result-item" within ".as-results" + + And I press "Update Profile" + Then I should see "#kamino" within "ul#as-selections-tags" + And I should see "#starwars" within "ul#as-selections-tags" + + When I attach the file "spec/fixtures/bad_urls.txt" to "file" within "#file-upload" + And I preemptively confirm the alert + And I attach the file "spec/fixtures/button.png" to hidden element "file" within "#file-upload" + And I wait for the ajax to finish + Then I should see a "img" within "#profile_photo_upload" + + When I go to my new profile page + And I should see "Boba Fett" diff --git a/features/getting_started_mobile.feature b/features/getting_started_mobile.feature new file mode 100644 index 000000000..daf3350d8 --- /dev/null +++ b/features/getting_started_mobile.feature @@ -0,0 +1,28 @@ +@javascript +Feature: editing the gettig started in the mobile view + + Scenario: editing gettig started fields + When I go to the new user registration page + And I fill in the following: + | user_username | amparito | + | user_email | amp@arito.com | + | user_password | secret | + | user_password_confirmation | secret | + And I press "Continue" + And I visit the mobile getting started page + And I should see "Well, hello there!" and "Who are you?" and "What are you into?" + And I should see "amparito" + + When I attach the file "spec/fixtures/bad_urls.txt" to "file" within "#file-upload" + And I preemptively confirm the alert + And I attach the file "spec/fixtures/button.png" to hidden element "file" within "#file-upload" + And I wait for the ajax to finish + Then I should see a "img" within "#profile_photo_upload" + + When I fill in "follow_tags" with "#men" + And I press the first ".as-result-item" within ".as-results" + Then I should see "#men" within "ul#as-selections-tags" + + When I follow "awesome_button" + Then I should be on the stream page + And I should not see "awesome_button" diff --git a/features/posts_from_main_page.feature b/features/posts_from_main_page.feature index 2657e0255..89a08f183 100644 --- a/features/posts_from_main_page.feature +++ b/features/posts_from_main_page.feature @@ -101,6 +101,9 @@ Feature: posting from the main page Scenario: back out of posting a photo-only post Given I expand the publisher And I have turned off jQuery effects + When I attach the file "spec/fixtures/bad_urls.txt" to "file" within "#file-upload" + And I preemptively confirm the alert + Then I should not see an uploaded image within the photo drop zone When I attach the file "spec/fixtures/button.png" to hidden element "file" within "#file-upload" And I wait for the ajax to finish And I click to delete the first uploaded photo diff --git a/features/posts_from_main_page_mobile.feature b/features/posts_from_main_page_mobile.feature index 14fc2c772..68e4c33be 100644 --- a/features/posts_from_main_page_mobile.feature +++ b/features/posts_from_main_page_mobile.feature @@ -1,5 +1,5 @@ @javascript -Feature: posting from the main page +Feature: posting from the mobile main page In order to navigate Diaspora* As a mobile user I want to tell the world I am eating a yogurt @@ -31,6 +31,7 @@ Feature: posting from the main page When I attach the file "spec/fixtures/button.png" to hidden element "file" within "#file-upload-publisher" And I wait for the ajax to finish Then I should see an uploaded image within the photo drop zone + And I should see "button.png completed" When I press "Share" And I wait for the ajax to finish When I visit the mobile stream page @@ -42,8 +43,12 @@ Feature: posting from the main page Scenario: back out of posting a photo-only post Given I publisher mobile page + When I attach the file "spec/fixtures/bad_urls.txt" to "file" within "#file-upload-publisher" + And I preemptively confirm the alert + Then I should not see an uploaded image within the photo drop zone When I attach the file "spec/fixtures/button.png" to hidden element "file" within "#file-upload-publisher" And I wait for the ajax to finish + And I should see "button.png completed" And I click to delete the first uploaded photo And I wait for the ajax to finish Then I should not see an uploaded image within the photo drop zone diff --git a/features/step_definitions/conversations_steps.rb b/features/step_definitions/conversations_steps.rb index d3b623cb4..90ffa4d5b 100644 --- a/features/step_definitions/conversations_steps.rb +++ b/features/step_definitions/conversations_steps.rb @@ -24,3 +24,15 @@ When /^I reply with "([^"]*)"$/ do |text| step %(I press "Reply") step %(I wait for the ajax to finish) end + +Then /^I send a mobile message with subject "([^"]*)" and text "([^"]*)" to "([^"]*)"$/ do |subject, text, person| + step %(I am on the conversations page) + step %(I follow "New Message") + step %(I wait for the ajax to finish) + step %(I fill in "contact_autocomplete" with "#{person}") + step %(I press the first ".as-result-item" within ".as-results") + step %(I fill in "conversation_subject" with "#{subject}") + step %(I fill in "conversation_text" with "#{text}") + step %(I press "Send") + step %(I wait for the ajax to finish) +end diff --git a/features/step_definitions/mobile_steps.rb b/features/step_definitions/mobile_steps.rb index bd009bd25..edeaa5d9e 100644 --- a/features/step_definitions/mobile_steps.rb +++ b/features/step_definitions/mobile_steps.rb @@ -13,3 +13,11 @@ end When /^I visit the mobile stream page$/ do visit('/stream.mobile') end + +When /^I toggle the mobile view$/ do + visit('/mobile/toggle') +end + +When /^I visit the mobile getting started page$/ do + visit('/getting_started.mobile') +end