summaryrefslogtreecommitdiff
path: root/fake-service/features
diff options
context:
space:
mode:
authorOla Bini <ola.bini@gmail.com>2014-07-31 19:35:40 -0300
committerOla Bini <ola.bini@gmail.com>2014-07-31 19:35:40 -0300
commite54e5ee931b3991cbb5e427e7e5d27b3f6c75e6e (patch)
tree1e0da33d22874c0ea5576818fe45958611ebda29 /fake-service/features
parent04cf441c5ae18400c6b4865b0b37a71718dc9d46 (diff)
Add fake-service
Diffstat (limited to 'fake-service/features')
-rw-r--r--fake-service/features/compose_save_draft_and_send.feature15
-rw-r--r--fake-service/features/forward_trash_archive.feature12
-rw-r--r--fake-service/features/search_and_destroy.feature11
-rw-r--r--fake-service/features/step_definitions/compose.rb27
-rw-r--r--fake-service/features/step_definitions/mail_list.rb55
-rw-r--r--fake-service/features/step_definitions/mail_view.rb67
-rw-r--r--fake-service/features/step_definitions/search.rb12
-rw-r--r--fake-service/features/step_definitions/tag_list.rb15
-rw-r--r--fake-service/features/support/env.rb31
-rw-r--r--fake-service/features/tag_and_reply.feature12
10 files changed, 257 insertions, 0 deletions
diff --git a/fake-service/features/compose_save_draft_and_send.feature b/fake-service/features/compose_save_draft_and_send.feature
new file mode 100644
index 00000000..d05db837
--- /dev/null
+++ b/fake-service/features/compose_save_draft_and_send.feature
@@ -0,0 +1,15 @@
+Feature: compose mail, save draft and send mail
+
+ @wip
+ Scenario: user composes and email, save the draft, later sends the draft and checks the sent message
+ Given I compose a message with
+ | subject | body |
+ | Smail rocks! | You should definitely use it. Cheers, User. |
+ And for the 'To' field I type 'ab' and chose the first contact that shows
+ And I save the draft
+ When I open the saved draft and send it
+ Then I see that mail under the 'sent' tag
+ When I open that mail
+ Then I see that the subject reads 'Smail rocks!'
+ And I see that the body reads 'You should definitely use it. Cheers, User.'
+
diff --git a/fake-service/features/forward_trash_archive.feature b/fake-service/features/forward_trash_archive.feature
new file mode 100644
index 00000000..999d0b3c
--- /dev/null
+++ b/fake-service/features/forward_trash_archive.feature
@@ -0,0 +1,12 @@
+Feature: forward_trash_archive
+ Scenario: User forwards a mail, add CC and BCC address, later trash and archive the mail
+ When I open the first mail in the 'inbox'
+ Then I choose to forward this mail
+ And for the 'CC' field I type 'ab' and chose the first contact that shows
+ And for the 'Bcc' field I type 'fu' and chose the first contact that shows
+ And I forward this mail
+ When I open the first mail in the 'sent'
+ Then I see the mail has a cc and a bcc recipient
+ And I remove all tags
+ And I choose to trash
+ Then I see that mail under the 'trash' tag
diff --git a/fake-service/features/search_and_destroy.feature b/fake-service/features/search_and_destroy.feature
new file mode 100644
index 00000000..4a41c3f8
--- /dev/null
+++ b/fake-service/features/search_and_destroy.feature
@@ -0,0 +1,11 @@
+Feature: search html mail and destroy
+
+ Scenario: User searches for a mail and deletes it
+ When I search for a mail with the words "this is a html mail"
+ When I open the first mail in the mail list
+ Then I see one or more mails in the search results
+ Then I see if the mail has html content
+ When I try to delete the first mail
+ # Then I learn that the mail was deleted
+ When I select the tag 'trash'
+ Then the deleted mail is there
diff --git a/fake-service/features/step_definitions/compose.rb b/fake-service/features/step_definitions/compose.rb
new file mode 100644
index 00000000..e92d16f6
--- /dev/null
+++ b/fake-service/features/step_definitions/compose.rb
@@ -0,0 +1,27 @@
+Given /^I compose a message with$/ do |table|
+ find('#compose-mails-trigger').click
+ data = table.hashes.first
+ fill_in('Subject', with: data['subject'])
+ fill_in('Body', with: data['body'])
+end
+
+Given /^for the '(.*)' field I type '(.*)' and chose the first contact that shows$/ do |recipients_field, to_type|
+ recipients_field.downcase!
+ within("#recipients-#{recipients_field}-area") do
+ find('.tt-input').native.send_keys(to_type)
+ sleep 1
+ first('.tt-dropdown-menu div div').click
+ end
+end
+
+Given /^I save the draft$/ do
+ click_button("Save Draft")
+end
+
+When /^I open the saved draft and send it$/ do
+ step "I select the tag 'drafts'"
+ step "I open the first mail in the mail list"
+ page.should_not have_css("#send-button[disabled]")
+ click_button('Send')
+ find('#user-alerts').should have_content("Your message was sent!")
+end
diff --git a/fake-service/features/step_definitions/mail_list.rb b/fake-service/features/step_definitions/mail_list.rb
new file mode 100644
index 00000000..d41a62a0
--- /dev/null
+++ b/fake-service/features/step_definitions/mail_list.rb
@@ -0,0 +1,55 @@
+When(/^I open the first mail in the '(.*)'$/) do |tag|
+ page.execute_script("window.scrollBy(0, -200)")
+ step "I select the tag '#{tag}'"
+ step 'I open the first mail in the mail list'
+end
+
+When(/^I open the first mail in the mail list$/) do
+ within('#mail-list') do
+ mail_link = first('a')
+ @current_mail_id = mail_link.native.attribute('href').scan(/\/(\d+)$/).flatten.first
+ begin
+ mail_link.click
+ rescue # in Chrome, the 'a' in mail_list is not clickable because it's hidden inside the 'li'
+ mail_link_parent_li = mail_link.find(:xpath, '../..')
+ mail_link_parent_li.click
+ end
+ end
+end
+
+When(/I see that mail under the '(.*)' tag/) do |tag|
+ step "I select the tag '#{tag}'"
+ check_current_mail_is_visible
+end
+
+And(/^I open the mail I previously tagged$/) do
+ open_current_mail
+end
+
+When(/^I open that mail$/) do
+ open_current_mail
+end
+
+Then(/^I see the mail I sent$/) do
+ check_current_mail_is_visible
+end
+
+Then(/^the deleted mail is there$/) do
+ check_current_mail_is_visible
+end
+
+def open_current_mail
+ within('#mail-list') do
+ begin
+ first("#mail-#{@current_mail_id} a").click
+ rescue # in Chrome, the 'a' in mail_list is not clickable because it's hidden inside the 'li'
+ first("#mail-#{@current_mail_id}").click
+ end
+ end
+end
+
+def check_current_mail_is_visible
+ within('#mail-list') do
+ have_selector?("#mail-#{@current_mail_id}").should be_true
+ end
+end
diff --git a/fake-service/features/step_definitions/mail_view.rb b/fake-service/features/step_definitions/mail_view.rb
new file mode 100644
index 00000000..19ca5736
--- /dev/null
+++ b/fake-service/features/step_definitions/mail_view.rb
@@ -0,0 +1,67 @@
+A_MAIL = /[^\s@]+@[^\s@]+\.[^\s@]+/
+
+Then(/^I see the mail has a cc and a bcc recipient$/) do
+ within('.msg-header') do
+ first('.cc').text.should =~ A_MAIL
+ first('.bcc').text.should =~ A_MAIL
+ end
+end
+
+Then(/^that email has the '(.*)' tag$/) do |tag|
+ within('#mail-view') do |e|
+ all('.tagsArea .tag').map(&:text).map(&:downcase).to_a.should include(tag)
+ end
+end
+
+When(/I add the tag '(.*)' to that mail/) do |tag|
+ page.execute_script("$('#new-tag-button').click();")
+ page.execute_script("$('#new-tag-input').val('#{tag}');")
+ find('#new-tag-input').native.send_keys [:return]
+end
+
+And(/^I reply to it$/) do
+ click_button('Reply')
+ click_button('Send')
+end
+
+Then(/^I choose to forward this mail$/) do
+ click_button('Forward')
+end
+
+Then(/^I forward this mail$/) do
+ click_button('Send')
+end
+
+
+Then(/^I remove all tags$/) do
+ within('.tagsArea') do
+ all('.tag').each do |tag|
+ tag.click
+ end
+ end
+end
+
+Then(/^I choose to trash$/) do
+ click_button('Trash message')
+end
+
+When(/^I try to delete the first mail$/) do
+ step 'I open the first mail in the mail list'
+ within('#mail-view') do
+ page.driver.find_css('#view-more-actions')[0].click
+ page.driver.execute_script("$('#delete-button-top').click();")
+ end
+ find('#user-alerts').text.should == 'Your message was moved to trash!'
+end
+
+Then(/^I see that the subject reads '(.*)'$/) do |expected_subject|
+ find('#mail-view .subject').text.should == expected_subject
+end
+
+Then(/^I see that the body reads '(.*)'$/) do |expected_body|
+ find('#mail-view .bodyArea').text.should == expected_body
+end
+
+Then(/^I see if the mail has html content/) do
+ find('#mail-view .bodyArea').should have_css('h2[style*=\'color: #3f4944\']', :text => "cborim")
+end
diff --git a/fake-service/features/step_definitions/search.rb b/fake-service/features/step_definitions/search.rb
new file mode 100644
index 00000000..de89759c
--- /dev/null
+++ b/fake-service/features/step_definitions/search.rb
@@ -0,0 +1,12 @@
+When(/^I search for a mail with the words "(.*)"$/) do |search_term|
+ search_field = find('#search-trigger input[type="search"]').native
+ search_field.send_keys(search_term)
+ search_field.send_keys(:return)
+end
+
+Then(/^I see one or more mails in the search results$/) do
+ within('#mail-list') do
+ all('li').length.should >= 1
+ end
+end
+
diff --git a/fake-service/features/step_definitions/tag_list.rb b/fake-service/features/step_definitions/tag_list.rb
new file mode 100644
index 00000000..678f5ce9
--- /dev/null
+++ b/fake-service/features/step_definitions/tag_list.rb
@@ -0,0 +1,15 @@
+When(/^I select the tag '(.*)'$/) do |tag|
+ wait_for_user_alert_to_disapear # in Chrome, the 'flash message is on top of the toggle
+ first('.left-off-canvas-toggle').click
+ page.execute_script("window.scrollBy(0, -200)")
+ within('#tag-list') { find('li', text: /#{tag}/i).click }
+end
+
+def wait_for_user_alert_to_disapear
+ begin
+ while find('#user-alerts')
+ sleep 0.1
+ end
+ rescue #if it couldn't find it, go ahead
+ end
+end
diff --git a/fake-service/features/support/env.rb b/fake-service/features/support/env.rb
new file mode 100644
index 00000000..932f259d
--- /dev/null
+++ b/fake-service/features/support/env.rb
@@ -0,0 +1,31 @@
+require 'capybara'
+require 'capybara-screenshot'
+require 'capybara-screenshot/cucumber'
+
+RACK_PORT = ENV['RACK_PORT'] || '4567'
+HOST = "http://localhost:#{RACK_PORT}"
+
+Capybara.register_driver :selenium_chrome do |app|
+ Capybara::Selenium::Driver.new(app, :browser => :chrome)
+end
+
+Capybara::Screenshot.register_driver(:selenium_chrome) do |driver, path|
+ driver.browser.save_screenshot(path)
+end
+
+driver = ENV['CUCUMBER_DRIVER'] ? ENV['CUCUMBER_DRIVER'].to_sym : :selenium_chrome
+
+Capybara.configure do |config|
+ config.run_server = false
+ config.default_driver = driver
+ config.app_host = HOST
+end
+
+include Capybara::DSL
+
+Before do
+ `curl -d '' #{HOST}/control/mailset/mediumtagged/load`
+ sleep 3
+ visit '/?lang=en'
+ page.driver.browser.manage.window.maximize
+end
diff --git a/fake-service/features/tag_and_reply.feature b/fake-service/features/tag_and_reply.feature
new file mode 100644
index 00000000..cd9c7aad
--- /dev/null
+++ b/fake-service/features/tag_and_reply.feature
@@ -0,0 +1,12 @@
+Feature: tagging and replying
+ Scenario: User tags a mail, replies to it then checks that mail is in the right tag
+ When I open the first mail in the 'inbox'
+ Then that email has the 'inbox' tag
+ When I add the tag 'website' to that mail
+ Then I see that mail under the 'website' tag
+ And I open the mail I previously tagged
+ And I reply to it
+ When I select the tag 'sent'
+ Then I see the mail I sent
+
+