6 use SGN::Test::Fixture;
8 use Test::WWW::Mechanize;
12 use Spreadsheet::Read;
16 my $f = SGN::Test::Fixture->new();
17 my $schema = $f->bcs_schema;
18 my $people_schema = $f->people_schema();
20 my $mech = Test::WWW::Mechanize->new;
25 $mech->post_ok('http://localhost:3010/brapi/v1/token', [ "username"=> "janedoe", "password"=> "secretpw", "grant_type"=> "password" ], 'login with brapi call');
27 $response = decode_json $mech->content;
29 is($response->{'userDisplayName'}, 'Jane Doe', 'check login name');
31 # create a suitable dataset
33 my $ds = CXGN::Dataset->new( { schema=> $schema, people_schema => $people_schema });
35 $ds->trials( [ 139, 141 ]);
38 my $dataset_id = $ds->sp_dataset_id();
40 $mech->get_ok('http://localhost:3010/tools/stability', 'load stability input page');
42 $mech->get_ok('http://localhost:3010/ajax/stability/shared_phenotypes?dataset_id='.$dataset_id, 'get common traits for dataset');
44 my $sp_data = JSON::Any->decode($mech->content());
46 my $trait_id = $sp_data->{options}->[0]->[0];
48 $mech->get_ok('http://localhost:3010//ajax/stability/generate_results?dataset_id='.$dataset_id.'&trait_id='.$trait_id."&method_id=AMMI", 'run the AMMI analysis');
50 my $rdata = JSON::Any->decode($mech->content());
52 # check if files were created
54 ok( -e "static/".$rdata->{figure1}, "AMMI figure 1 created");
55 ok( -e "static/".$rdata->{figure2}, "AMMI figure 2 created");
56 ok( -e "static/".$rdata->{AMMITable}, "AMMI table created");
58 $mech->get_ok('http://localhost:3010//ajax/stability/generate_results?dataset_id='.$dataset_id.'&trait_id='.$trait_id."&method_id=GGE", 'run the GGE analysis');
60 my $rdata2 = JSON::Any->decode($mech->content());
62 # check if files were created
64 ok( -e "static/".$rdata2->{figure1}, "GGE figure 1 created");
65 ok( -e "static/".$rdata2->{figure2}, "GGE figure 2 created");
66 ok( -e "static/".$rdata2->{AMMITable}, "GGE table created");
68 # remove changes to the database