Skip to content

Commit

Permalink
[webui] port another test to capybara
Browse files Browse the repository at this point in the history
  • Loading branch information
coolo committed Dec 3, 2012
1 parent eaef4fa commit c0b0e99
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 146 deletions.
142 changes: 0 additions & 142 deletions src/webui-testsuite/tests/TC10__BranchPackage.rb

This file was deleted.

151 changes: 151 additions & 0 deletions src/webui/test/functional/package_branch_test.rb
@@ -0,0 +1,151 @@
# -*- coding: utf-8 -*-
require File.expand_path(File.dirname(__FILE__) + "/..") + "/test_helper"

class PackageBranchTest < ActionDispatch::IntegrationTest

def create_package_branch new_branch
click_link 'Branch existing package'

assert page.has_text? "Add New Package Branch to #{@project}"
assert page.has_text? "Name of original project:"
assert page.has_text? "Name of package in original project:"
assert page.current_url =~ %r{/project/new_package_branch}

new_branch[:expect] ||= :success
new_branch[:name] ||= ""
new_branch[:original_name] ||= ""
new_branch[:original_project] ||= ""

fill_in "linked_project", with: new_branch[:original_project]
fill_in "linked_package", with: new_branch[:original_name]
fill_in "target_package", with: new_branch[:name]

click_button "Create Branch"

if new_branch[:expect] == :success
assert_equal "Branched package #{@project} / #{new_branch[:name]}", flash_message
assert_equal :info, flash_message_type
assert page.current_url.end_with? package_show_path(project: @project, package: new_branch[:name])
elsif new_branch[:expect] == :invalid_package_name
assert_equal "Invalid package name: '#{new_branch[:original_name]}'", flash_message
assert_equal :alert, flash_message_type
elsif new_branch[:expect] == :invalid_project_name
assert_equal "Invalid project name: '#{new_branch[:original_project]}'", flash_message
assert_equal :alert, flash_message_type
elsif new_branch[:expect] == :already_exists
assert_equal "Package '#{new_branch[:name]}' already exists in project '#{@project}'", flash_message
assert_equal :alert, flash_message_type
else
throw "Invalid value for argument <expect>."
end
end

def setup
@project = "home:Iggy"
super
end

test "branch_package_for_home_project" do

login_Iggy
visit project_show_path(:project => @project)

create_package_branch(
:name => "TestPack_link",
:original_name => "TestPack",
:original_project => "home:Iggy")
end

test "branch_package_for_global_project" do

login_Iggy
visit project_show_path(:project => @project)

create_package_branch(
:name => "PublicPackage1",
:original_name => "kdelibs",
:original_project => "kde4")
end


test "branch_package_twice_duplicate_name" do

login_Iggy
visit project_show_path(:project => @project)

create_package_branch(
:expect => :already_exists,
:name => "TestPack",
:original_name => "TestPack",
:original_project => "home:Iggy")
end


test "branch_package_twice" do

login_Iggy
visit project_show_path(:project => @project)

create_package_branch(
:name => "TestPack2",
:original_name => "kdelibs",
:original_project => "kde4")
visit project_show_path(:project => @project)
create_package_branch(
:name => "TestPack3",
:original_name => "kdelibs",
:original_project => "kde4")
end


test "branch_empty_package_name" do

login_Iggy
visit project_show_path(:project => @project)

create_package_branch(
:name => "",
:original_name => "",
:original_project => "home:Iggy",
:expect => :invalid_package_name)
end

test "branch_empty_project_name" do

login_Iggy
visit project_show_path(:project => @project)

create_package_branch(
:name => "TestPack",
:original_name => "TestPack",
:original_project => "",
:expect => :invalid_project_name)
end

test "branch_package_name_with_spaces" do

login_Iggy
visit project_show_path(:project => @project)

create_package_branch(
:name => "BranchedPackage",
:original_name => "invalid package name",
:original_project => "home:Iggy",
:expect => :invalid_package_name)
end


test "branch_project_name_with_spaces" do

login_Iggy
visit project_show_path(:project => @project)

create_package_branch(
:name => "BranchedPackage",
:original_name => "SomePackage",
:original_project => "invalid project name",
:expect => :invalid_project_name)
end


end
2 changes: 1 addition & 1 deletion src/webui/test/functional/package_edit_test.rb
Expand Up @@ -25,7 +25,7 @@ def package_description
# ============================================================================
#
def change_package_info new_info
assert (new_info[:title] or new_info[:description]) != nil
assert !new_info[:title].blank? || !new_info[:description].blank?

click_link('edit-description')

Expand Down
4 changes: 1 addition & 3 deletions src/webui/test/functional/spider_test.rb
Expand Up @@ -58,7 +58,7 @@ def raiseit(message, url)
$stderr.puts "#{indent}#{url} ('#{text}')"
indent += ' '
end
#raise "Found #{message}"
raise "Found #{message}"
end

def crawl
Expand All @@ -85,7 +85,6 @@ def crawl
next unless body
if !body.css("div#flash-messages div.ui-state-error").empty?
raiseit("flash alert", theone)
raise "Flash"
end
body.css('h1').each do |h|
if h.content == 'Internal Server Error'
Expand All @@ -94,7 +93,6 @@ def crawl
end
body.css("#exception-error").each do |e|
raiseit("error '#{e.content}'", theone)
raise "Found error"
end
getlinks(theone, body)
end
Expand Down

0 comments on commit c0b0e99

Please sign in to comment.