#!/usr/bin/perl use Test::WWW::Mechanize::CGIApp; # use HTML::TreeBuilder; use Data::Dumper; use strict; use warnings; use Test::More tests => 14; # use Test::More 'no_plan'; BEGIN { require 't/test-lib.pl'; } my $mech = get_mech(); do_login(); my $dbh; eval { $dbh = get_dbh() or die 'no database handle recieved from get_dbh'; }; warn $@ if $@; # need to drop & re-create following tables: foreach ( qw/clinical_trials/ ) { drop_and_recreate($_); } $mech->get_ok('/config/trials'); # print_and_exit(); ### check title: $mech->content_contains( 'Admin » Clinical Trials', 'title matches', ); # print_and_exit(); # add 2 trials: { my $trial_name = 'NCRI Myeloma X'; $mech->field('trial_name', $trial_name); $mech->submit_form(); # print_and_exit(); ### check section found: $mech->content_contains( qq!value="$trial_name"!, 'new entry value correct', ); # print_and_exit(); } { my $trial_name = 'HMDS Community monitoring'; $mech->field('trial_name', $trial_name); $mech->submit_form(); # print_and_exit(); ### check section found: $mech->content_contains( qq!value="$trial_name"!, 'new entry value correct', ); # print_and_exit(); } # edit 2nd entry: $mech->get_ok('/config/trials/edit/2'); # print_and_exit(); { my $old_term = 'HMDS Community monitoring'; my $new_term = 'HMDS outreach'; $mech->field('trial_name',$new_term); $mech->submit_form(); # print_and_exit(); ### check section found: $mech->content_contains( qq!value="$new_term"!, 'new entry value correct', ); # print_and_exit(); ### check section found: $mech->content_lacks( qq!value="$old_term"!, 'previous entry value not detected', ); # print_and_exit(); } # inactivate 1st entry: { # 1st check for absence of inactive record: $mech->content_lacks( qq!