Skip to content

Commit

Permalink
[webui-testsuite] implement some test for watchlist to play with IDE
Browse files Browse the repository at this point in the history
  • Loading branch information
coolo committed Nov 16, 2012
1 parent efda6e8 commit 9e91d9d
Show file tree
Hide file tree
Showing 8 changed files with 99 additions and 41 deletions.
10 changes: 10 additions & 0 deletions src/webui-testsuite/lib/common/Assertions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,16 @@ def assert test, message=nil
def assert_equal valueA, valueB
fail "not equal '#{valueA}' and '#{valueB}'" unless valueA == valueB
end

def assert_match pattern, string, message=""
pattern = case(pattern)
when String
Regexp.new(Regexp.escape(pattern))
else
pattern
end
fail "<#{string}> expected to be =~\n<#{pattern}>." unless string =~ pattern
end
end

class SkipTestError < StandardError; end
Expand Down
5 changes: 2 additions & 3 deletions src/webui-testsuite/lib/common/TestCase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
#
class TestCase

attr_reader :name, :status, :message, :screenshot,
:time_started, :time_completed, :stderr, :stdout
attr_writer :status
attr_reader :name, :message, :screenshot, :time_started, :time_completed, :stderr, :stdout
attr_accessor :status, :runtime

class LimitsHaveBeenExpanded < Exception; end

Expand Down
4 changes: 3 additions & 1 deletion src/webui-testsuite/lib/common/TestRunner.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require 'benchmark'

# ==============================================================================
# Provides functionality to find, load and run tests from one/many test-cases.
# @see TestCase
Expand Down Expand Up @@ -31,7 +33,7 @@ def self.run(stop_on_fail)
next
end
yield test if block_given?
test.run
test.runtime = Benchmark.realtime { test.run }
@@results[test.name] = test.status unless test.status == :rescheduled
@@previous_test = @@current_test
yield test if block_given?
Expand Down
6 changes: 3 additions & 3 deletions src/webui-testsuite/run_acceptance_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,17 +227,17 @@ def distribute(*args)
builder.testsuite do
TestRunner.run(options[:stop_on_fail]) do |test|
if test.status == :ready then
print((test.name.to_s+" ")[0,55])
print("#{test.name} "[0,55])
STDOUT.flush
else
puts case(test.status)
when :pass then
passed += 1
test.status.to_s.bold.green
test.status.to_s.bold.green + " (#{test.runtime})"
when :fail then
failed += 1
fail_details += "\n#{failed}) #{test.name}:\n#{test.message}".red
test.status.to_s.bold.red
test.status.to_s.bold.red + " (#{test.runtime})"
when :skip then
skipped += 1
test.status.to_s.bold.blue
Expand Down
59 changes: 27 additions & 32 deletions src/webui-testsuite/tests/TC03__CreateProject.rb
Original file line number Diff line number Diff line change
Expand Up @@ -151,38 +151,33 @@ class TC03__CreateProject < TestCase

# -------------------------------------------------------------------------------------- #
LONG_DESCRIPTION = <<LICENSE_END
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
This
is
a very
long
text
that
will
break
into
many
many
lines.
Way
more
than
what
might
be
reasonable
so
the
lines
are folded
away
by
default.
LICENSE_END
# -------------------------------------------------------------------------------------- #

Expand Down
52 changes: 52 additions & 0 deletions src/webui-testsuite/tests/TC24_Watchlist.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
class TC24__Groups < TestCase

test :watchlists do
navigate_to ProjectOverviewPage,
:user => $data[:user1],
:project => "BaseDistro"

# assert watchlist is empty
$page.driver.execute_script("$('#menu-favorites').show();")
assert_equal 0, $page.driver.find_elements(:css, "span.icons-project").count

$page.driver.execute_script("$('#menu-favorites').show();")

assert_match /^[\s\S]*Add this project to Watchlist[\s\S]*$/, $page.driver.find_element(:css, "#menu-favorites").text
$page.driver.find_element(:css, "#toggle_watch > span").click
$page.driver.execute_script("$('#menu-favorites').show();")

assert_equal "BaseDistro", $page.driver.find_element(:css, "span.icons-project").text
assert_match /^[\s\S]*Remove this project from Watchlist[\s\S]*$/, $page.driver.find_element(:css, "#menu-favorites").text
$page.driver.find_element(:css, "#toggle_watch > span").click
wait_for_page
$page.driver.execute_script("$('#menu-favorites').show();")
assert_match /^[\s\S]*Add this project to Watchlist[\s\S]*$/, $page.driver.find_element(:css, "#menu-favorites").text
$page.driver.find_element(:css, "#toggle_watch > span.desc").click
wait_for_page

$page.driver.find_element(:link, "Projects").click
wait_for_page
$page.driver.find_element(:link, "My:Maintenance").click
wait_for_page

$page.driver.execute_script("$('#menu-favorites').show();")
assert_match /^[\s\S]*Add this project to Watchlist[\s\S]*$/, $page.driver.find_element(:css, "#menu-favorites").text
$page.driver.find_element(:css, "#toggle_watch > span.desc").click
wait_for_page

$page.driver.execute_script("$('#menu-favorites').show();")
$page.driver.find_element(:css, "span.icons-project").click
wait_for_page

assert_match /^[\s\S]*This is a base distro[\s\S]*$/, $page.driver.find_element(:css, "#project_title").text
# teardown
$page.driver.execute_script("$('#menu-favorites').show();")
$page.driver.find_element(:css, "#toggle_watch > span.desc").click
$page.driver.execute_script("$('#menu-favorites').show();")
$page.driver.find_element(:link, "My:Maintenance").click
$page.driver.execute_script("$('#menu-favorites').show();")
$page.driver.find_element(:css, "#toggle_watch > span.desc").click
assert_equal 0, $page.driver.find_elements(:css, "span.icons-project").count
end

end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class TC20__DeletePackage < TestCase
class TC71__DeletePackage < TestCase


test :delete_subproject_package_for_user do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
class TC21__DeleteProject < TestCase
class TC72__DeleteProject < TestCase


test :delete_subproject do
Expand Down

0 comments on commit 9e91d9d

Please sign in to comment.