adapt more tests

all tests are now succeeding again
(with firefox, chrome, htmlunit and phantomjs)
agranig/peering-route
Gerhard Jungwirth 13 years ago
parent 1a073dffd6
commit 562a9ccce6

@ -1,6 +1,6 @@
use Sipwise::Base;
use lib 't/lib';
use Test::More import => [qw(done_testing is)];
use Test::More import => [qw(done_testing is diag)];
use Test::WebDriver::Sipwise qw();
my $browsername = $ENV{BROWSER_NAME} || ""; #possible values: htmlunit, chrome
@ -10,11 +10,11 @@ my $uri = $ENV{CATALYST_SERVER} || 'http://localhost:3000';
$d->get_ok("$uri/logout"); #make sure we are logged out
$d->get_ok("$uri/login");
$d->find(link_text => 'Admin')->click;
diag("Do Admin Login");
$d->findtext_ok('Admin Sign In');
$d->find(name => 'username')->send_keys('administrator');
$d->find(name => 'password')->send_keys('administrator');
$d->find(name => 'submit')->click;
$d->findclick_ok(name => 'submit');
$d->title_is('Dashboard');

@ -16,7 +16,6 @@ my $admin = Test::WWW::Mechanize::Catalyst->new;
$admin->get_ok("http://localhost/reseller", "Check redirect");
#not yet tested: /reseller/ajax should give 403
$admin->content_contains("Sign In", "Should be on login page");
$admin->follow_link_ok( {text => 'Admin'}, "Go to admin Login");
$admin->submit_form(
fields => {
@ -31,18 +30,19 @@ $admin->content_contains('"iTotalRecords"');
$admin->content_contains('"sEcho"');
ok(valid_json($admin->content()), "Should be valid JSON"); #need JSON::Parse
$admin->get_ok("http://localhost/reseller/ajax?sEcho=1337&sSearch=a&iDisplayStart=0&iDisplayLength=2&iSortCol_0=0&sSortDir_0=asc", "Should get ajax now");
$admin->content_contains('"sEcho":"1337"');
$admin->content_contains('"sEcho":1337');
my $returndata = from_json($admin->content());
if($returndata->{aaData}->[0]->[1] eq "reseller 1") { #using mock data
ok($returndata->{aaData}->[0]->[0] == 1, "check id field");
ok($returndata->{aaData}->[0]->[2] == 1, "check contract.id field");
ok($returndata->{aaData}->[0]->[3] eq "active", "check status field");
ok($returndata->{iTotalRecords} == 6, "iTotalRecords (all mock data) should be 6");
ok($returndata->{iTotalDisplayRecords} == 4, "iTotalDisplayRecords (filtered mock data) should be 4");
ok($returndata->{sEcho} eq "1337");
if($returndata->{iTotalDisplayRecords} > 0) { #data available
ok(exists $returndata->{aaData}->[0]->{contract_id}, "contract_id there");
ok(exists $returndata->{aaData}->[0]->{status}, "status there");
ok(exists $returndata->{aaData}->[0]->{name}, "name there");
ok(exists $returndata->{aaData}->[0]->{id}, "id there");
ok($returndata->{iTotalRecords} >= $returndata->{iTotalDisplayRecords},
"iTotalRecords >= iTotalDisplayRecords");
}
is($returndata->{sEcho}, "1337", "sEcho is echoed back correctly");
####
done_testing();

@ -13,17 +13,15 @@ $d->get_ok("$uri/logout"); #make sure we are logged out
$d->get_ok("$uri/login");
$d->set_implicit_wait_timeout(1000);
diag("Go to Admin Login");
$d->findclick_ok(link_text => 'Admin');
diag("Logging In");
diag("Do Admin Login");
$d->findtext_ok('Admin Sign In');
$d->find(name => 'username')->send_keys('administrator');
$d->find(name => 'password')->send_keys('administrator');
$d->findclick_ok(name => 'submit');
diag("Go to reseller list");
$d->title_is('Dashboard');
$d->findclick_ok(xpath => '//a[@class="btn" and @href="/reseller"]');
$d->findclick_ok(xpath => '//a[@class="btn" and contains(@href,"/reseller")]');
diag("Search nonexisting reseller");
my $searchfield = $d->find(css => '#Resellers_table_filter label input');
@ -42,11 +40,10 @@ $d->find_ok(css => '#Resellers_table tr.sw_action_row');
is($d->find(xpath => '//table[@id="Resellers_table"]//tr[1]/td[1]')->get_text,'1');
diag("Going to create a reseller");
$d->findclick_ok(link_text => 'Create Resellers');
$d->findclick_ok(link_text => 'Create Reseller');
$d->findclick_ok(id => 'save');
$d->findtext_ok("Contract field is required");
$d->findtext_ok("Name field is required");
$d->findtext_ok("Status field is required");
$d->findclick_ok(id => 'mod_close');
diag("Click Edit on the first reseller shown (first row)");
@ -60,7 +57,7 @@ $btn->click;
#is($d->find(id => "name")->get_attribute("value"), "reseller 1");
$d->findclick_ok(id => 'mod_close');
diag("Click Delete on the first reseller shown");
diag("Click Terminate on the first reseller shown");
sleep 1; #prevent a StaleElementReferenceException
$row = $d->find(xpath => '//*[@id="Resellers_table"]/tbody/tr[1]');
ok($row);
@ -69,8 +66,7 @@ $btn = $d->find_child_element($row, './/a[contains(@class,"btn-secondary")]');
ok($btn);
$btn->click;
$d->findtext_ok("Are you sure?");
$d->findclick_ok(xpath => '//div[@id="dataConfirmModal"]//a[contains(text(),"Delete")]');
#is($d->find(css => 'div.alert-info')->get_text, 'Reseller delete not implemented!');
$d->findclick_ok(xpath => '//div[@id="dataConfirmModal"]//button[contains(text(),"Cancel")]');
done_testing;
# vim: filetype=perl

Loading…
Cancel
Save