mirror of
https://github.com/TracksApp/tracks.git
synced 2026-01-07 01:38:50 +01:00
migrate calendar feature
This commit is contained in:
parent
75f2afc2e1
commit
de309c8ee8
14 changed files with 87 additions and 224 deletions
|
|
@ -10,48 +10,49 @@ Feature: Show all due actions in a calendar view
|
|||
And I have logged in as "testuser" with password "secret"
|
||||
And I have a context called "@calendar"
|
||||
|
||||
@selenium
|
||||
@javascript
|
||||
Scenario: Setting due date of a todo will show it in the calendar
|
||||
When I submit a new action with description "a new next action" in the context "@calendar"
|
||||
When I submit a new action with description "something new" in the context "@calendar"
|
||||
And I go to the calendar page
|
||||
Then the badge should show 0
|
||||
And I should not see "a new next action"
|
||||
And I should not see "something new"
|
||||
When I go to the home page
|
||||
And I edit the due date of "a new next action" to tomorrow
|
||||
Then I should see "something new"
|
||||
When I edit the due date of "something new" to tomorrow
|
||||
And I go to the calendar page
|
||||
Then the badge should show 1
|
||||
And I should see "a new next action"
|
||||
Then I should see "something new"
|
||||
And the badge should show 1
|
||||
|
||||
@selenium
|
||||
@javascript
|
||||
Scenario: Clearing the due date of a todo will remove it from the calendar
|
||||
When I go to the home page
|
||||
And I submit a new action with description "a new next action" in the context "@calendar"
|
||||
And I edit the due date of "a new next action" to tomorrow
|
||||
And I submit a new action with description "something new" in the context "@calendar"
|
||||
And I edit the due date of "something new" to tomorrow
|
||||
And I go to the calendar page
|
||||
Then I should see "a new next action"
|
||||
When I clear the due date of "a new next action"
|
||||
Then I should not see "a new next action"
|
||||
Then I should see "something new"
|
||||
When I clear the due date of "something new"
|
||||
Then I should not see "something new"
|
||||
|
||||
@selenium
|
||||
@javascript
|
||||
Scenario: Marking a todo complete will remove it from the calendar
|
||||
Given I have a todo "a new next action" in the context "@calendar" which is due tomorrow
|
||||
Given I have a todo "something new" in the context "@calendar" which is due tomorrow
|
||||
When I go to the calendar page
|
||||
Then I should see "a new next action"
|
||||
When I clear the due date of "a new next action"
|
||||
Then I should not see "a new next action"
|
||||
Then I should see "something new"
|
||||
When I clear the due date of "something new"
|
||||
Then I should not see "something new"
|
||||
|
||||
@selenium
|
||||
@javascript
|
||||
Scenario: Deleting a todo will remove it from the calendar
|
||||
Given I have a todo "a new next action" in the context "@calendar" which is due tomorrow
|
||||
Given I have a todo "something new" in the context "@calendar" which is due tomorrow
|
||||
When I go to the calendar page
|
||||
Then I should see "a new next action"
|
||||
When I delete the action "a new next action"
|
||||
Then I should not see "a new next action"
|
||||
Then I should see "something new"
|
||||
When I delete the action "something new"
|
||||
Then I should not see "something new"
|
||||
|
||||
@selenium
|
||||
@javascript
|
||||
Scenario: Changing due date of a todo will move it in the calendar
|
||||
Given I have a todo "a new next action" in the context "@calendar" which is due tomorrow
|
||||
Given I have a todo "something new" in the context "@calendar" which is due tomorrow
|
||||
When I go to the calendar page
|
||||
Then I should see "a new next action"
|
||||
When I edit the due date of "a new next action" to next month
|
||||
Then I should see "a new next action" in the due next month container
|
||||
Then I should see "something new"
|
||||
When I edit the due date of "something new" to next month
|
||||
Then I should see "something new" in the due next month container
|
||||
|
|
|
|||
|
|
@ -193,10 +193,8 @@ Then /^I should see "([^"]*)" in the due next month container$/ do |todo_descrip
|
|||
todo = @current_user.todos.find_by_description(todo_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
xpath = "//div[@id='due_after_this_month']//div[@id='line_todo_#{todo.id}']"
|
||||
|
||||
wait_for :timeout => 5 do
|
||||
selenium.is_element_present(xpath)
|
||||
within "div#due_after_this_month" do
|
||||
find("div#line_todo_#{todo.id}").should_not be_nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -11,18 +11,7 @@ Given /^I am working on the mobile interface$/ do
|
|||
end
|
||||
|
||||
Then /the badge should show (.*)/ do |number|
|
||||
badge = -1
|
||||
xpath= "//span[@id='badge_count']"
|
||||
|
||||
if response.respond_to? :selenium
|
||||
response.should have_xpath(xpath)
|
||||
badge = response.selenium.get_text("xpath=#{xpath}").to_i
|
||||
else
|
||||
response.should have_xpath(xpath) do |node|
|
||||
badge = node.first.content.to_i
|
||||
end
|
||||
end
|
||||
|
||||
badge = find("span#badge_count").text.to_i
|
||||
badge.should == number.to_i
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ Given /^I have logged in as "(.*)" with password "(.*)"$/ do |username, password
|
|||
click_button "Sign in »"
|
||||
|
||||
logout_regexp = @mobile_interface ? "Logout" : "Logout \(#{username}\)"
|
||||
response.should contain(logout_regexp)
|
||||
page.should have_content(logout_regexp)
|
||||
@current_user = User.find_by_login(username)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -117,7 +117,12 @@ When /^I clear the due date of "([^"]*)"$/ do |action_description|
|
|||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
open_edit_form_for(todo)
|
||||
selenium.click("//div[@id='edit_todo_#{todo.id}']//a[@id='due_x_todo_#{todo.id}']/img", :wait_for => :ajax, :javascript_framework => :jquery)
|
||||
within "div#edit_todo_#{todo.id}" do
|
||||
find("a#due_x_todo_#{todo.id}").click
|
||||
wait_until do
|
||||
find("input#due_todo_#{todo.id}").value == ""
|
||||
end
|
||||
end
|
||||
submit_edit_todo_form(todo)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -4,13 +4,11 @@ When /^I delete the action "([^"]*)"$/ do |action_description|
|
|||
todo = @current_user.todos.find_by_description(action_description)
|
||||
todo.should_not be_nil
|
||||
|
||||
delete_todo_button = "xpath=//a[@id='delete_todo_#{todo.id}']/img"
|
||||
selenium.click delete_todo_button
|
||||
selenium.get_confirmation.should == "Are you sure that you want to delete the action '#{todo.description}'?"
|
||||
|
||||
wait_for :timeout => 5 do
|
||||
!selenium.is_element_present("//div[@id='line_todo_#{todo.id}']")
|
||||
handle_js_confirm do
|
||||
open_submenu_for(todo)
|
||||
find("a#delete_todo_#{todo.id}").click
|
||||
end
|
||||
get_confirm_text.should == "Are you sure that you want to delete the action '#{todo.description}'?"
|
||||
end
|
||||
|
||||
When /^I delete the todo "([^"]*)"$/ do |action_description|
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ require 'capybara/cucumber'
|
|||
require 'capybara/session'
|
||||
# BUG in this version of cucumber/capybara: require 'cucumber/rails/capybara_javascript_emulation' # Lets you click links with onclick javascript handlers without using @culerity or @javascript
|
||||
|
||||
Capybara.default_wait_time = 5
|
||||
|
||||
# Capybara defaults to XPath selectors rather than Webrat's default of CSS3. In
|
||||
# order to ease the transition to Capybara we set the default here. If you'd
|
||||
# prefer to use XPath just remove this line and adjust any selectors in your
|
||||
|
|
@ -48,6 +50,7 @@ ActionController::Base.allow_rescue = false
|
|||
# subsequent scenarios. If you do this, we recommend you create a Before
|
||||
# block that will explicitly put your database in a known state.
|
||||
Cucumber::Rails::World.use_transactional_fixtures = true
|
||||
|
||||
# How to clean your database when transactions are turned off. See
|
||||
# http://github.com/bmabey/database_cleaner for more info.
|
||||
if defined?(ActiveRecord::Base)
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
if ENV["RAILS_ENV"] == "selenium"
|
||||
puts "Configuring to use Selenium with Webrat for Cucumber stories"
|
||||
Webrat.configure do |config|
|
||||
config.mode = :selenium
|
||||
|
||||
config.application_environment = :selenium
|
||||
# use only if you run a separate rails test server instance and do not
|
||||
# want webrat to start one for you
|
||||
# config.application_port = 3001
|
||||
|
||||
config.selenium_browser_startup_timeout = 30
|
||||
# use only if you run a separate selenium server instance and do not
|
||||
# want webrat to start one for you
|
||||
# config.selenium_server_address = "localhost"
|
||||
# config.selenium_server_port = "4444"
|
||||
end
|
||||
|
||||
Cucumber::Rails::World.use_transactional_fixtures = false
|
||||
end
|
||||
|
|
@ -4,7 +4,9 @@ module TracksStepHelper
|
|||
end
|
||||
|
||||
def submit_next_action_form
|
||||
selenium.click("xpath=//form[@id='todo-form-new-action']//button[@id='todo_new_action_submit']", :wait_for => :ajax, :javascript_framework => :jquery)
|
||||
within("#todo-form-new-action") do
|
||||
click_button("todo_new_action_submit")
|
||||
end
|
||||
sleep(1)
|
||||
end
|
||||
|
||||
|
|
@ -16,11 +18,16 @@ module TracksStepHelper
|
|||
selenium.click("xpath=//form[@id='project_form']//button[@id='project_new_project_submit']", :wait_for => :ajax, :javascript_framework => :jquery)
|
||||
end
|
||||
|
||||
def wait_for_form_to_go_away(todo)
|
||||
page.should_not have_content("button#submit_todo_#{todo.id}")
|
||||
end
|
||||
|
||||
def submit_edit_todo_form (todo)
|
||||
selenium.click("//div[@id='edit_todo_#{todo.id}']//button[@id='submit_todo_#{todo.id}']", :wait_for => :ajax, :javascript_framework => :jquery)
|
||||
wait_for do
|
||||
!selenium.is_element_present("//form[@id='form_todo_#{todo.id}']")
|
||||
within "div#edit_todo_#{todo.id}" do
|
||||
click_button "submit_todo_#{todo.id}"
|
||||
end
|
||||
wait_for_form_to_go_away(todo)
|
||||
wait_for_animations_to_end
|
||||
end
|
||||
|
||||
def format_date(date)
|
||||
|
|
@ -29,7 +36,7 @@ module TracksStepHelper
|
|||
end
|
||||
|
||||
def execute_javascript(js)
|
||||
selenium.get_eval "(function() {with(this) {#{js}}}).call(selenium.browserbot.getCurrentWindow());"
|
||||
page.execute_script(js)
|
||||
end
|
||||
|
||||
def clear_context_name_from_next_action_form
|
||||
|
|
@ -39,19 +46,37 @@ module TracksStepHelper
|
|||
def clear_project_name_from_next_action_form
|
||||
execute_javascript("$('#todo_project_name').val('');")
|
||||
end
|
||||
|
||||
|
||||
def open_edit_form_for(todo)
|
||||
edit_button = "xpath=//div[@id='line_todo_#{todo.id}']//img[@id='edit_icon_todo_#{todo.id}']"
|
||||
|
||||
wait_for :timeout => 5 do
|
||||
selenium.is_element_present(edit_button)
|
||||
within "div#line_todo_#{todo.id}" do
|
||||
find("a#icon_edit_todo_#{todo.id}").click
|
||||
end
|
||||
wait_for_animations_to_end
|
||||
end
|
||||
|
||||
def wait_for_animations_to_end
|
||||
wait_until do
|
||||
page.evaluate_script('$(":animated").length') == 0
|
||||
end
|
||||
|
||||
selenium.click(edit_button, :wait_for => :ajax, :javascript_framework => :jquery)
|
||||
end
|
||||
|
||||
def wait_for_ajax
|
||||
selenium.wait_for :wait_for => :ajax, :javascript_framework => :jquery
|
||||
def handle_js_confirm(accept=true)
|
||||
page.execute_script "window.original_confirm_function = window.confirm"
|
||||
page.execute_script "window.confirmMsg = null"
|
||||
page.execute_script "window.confirm = function(msg) { window.confirmMsg = msg; return #{!!accept}; }"
|
||||
yield
|
||||
ensure
|
||||
page.execute_script "window.confirm = window.original_confirm_function"
|
||||
end
|
||||
|
||||
def get_confirm_text
|
||||
page.evaluate_script "window.confirmMsg"
|
||||
end
|
||||
|
||||
def open_submenu_for(todo)
|
||||
within "div#line_todo_#{todo.id}" do
|
||||
find("img#todo-submenu").click
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue