3 t/integration/ajax.t - Integration tests for AJAXy stuff
19 use Test::WWW::Mechanize;
23 my $base_url = $ENV{SGN_TEST_SERVER};
24 my $mech = Test::WWW::Mechanize->new;
27 "/image/ajax/image_ajax_form.pl?action=view" => '{"is_owner":0,"user_type":"user","html":" <table> <tr><td>Image Name:</td><td width=\"20\"> </td><td><b>\n</b></td></tr>\n<tr><td>Image Description: </td><td width=\"20\"> </td><td><b>\n</b></td></tr>\n<tr><td>Uploaded by: </td><td width=\"20\"> </td><td><b><a href=\"/solpeople/personal-info.pl?sp_person_id=\"> </a> </b></td></tr>\n </table> ","editable_form_id":null,"error":"No object_id provided"}',
28 "/image/ajax/image_ajax_form.pl?action=" => '{"is_owner":0,"user_type":"user","html":" <table> <tr><td>Image Name:</td><td width=\"20\"> </td><td><b>\n</b></td></tr>\n<tr><td>Image Description: </td><td width=\"20\"> </td><td><b>\n</b></td></tr>\n<tr><td>Uploaded by: </td><td width=\"20\"> </td><td><b><a href=\"/solpeople/personal-info.pl?sp_person_id=\"> </a> </b></td></tr>\n </table> ","editable_form_id":null,"error":"No object_id provided"}',
29 "/image/ajax/image_ajax_form.pl" => '{"is_owner":0,"user_type":"user","html":" <table> <tr><td>Image Name:</td><td width=\"20\"> </td><td><b>\n</b></td></tr>\n<tr><td>Image Description: </td><td width=\"20\"> </td><td><b>\n</b></td></tr>\n<tr><td>Uploaded by: </td><td width=\"20\"> </td><td><b><a href=\"/solpeople/personal-info.pl?sp_person_id=\"> </a> </b></td></tr>\n </table> ","editable_form_id":null,"error":"No object_id provided"}',
30 "/image/ajax/image_ajax_form.pl?action=edit" => '{"is_owner":0,"user_type":"user","html":"<form id =\"image_form\" method=\"get\" action=\"\"> <table> <tr><td>Image Name:</td><td width=\"20\"> </td><td> <input type=\"text\" id=\"\" name=\"name\" value=\"\" size=\"15\" />\n</td></tr>\n<tr><td>Image Description: </td><td width=\"20\"> </td><td> <input type=\"text\" id=\"\" name=\"description\" value=\"\" size=\"40\" />\n</td></tr>\n<tr><td>Uploaded by: </td><td width=\"20\"> </td><td><a href=\"/solpeople/personal-info.pl?sp_person_id=\"> </a> </td></tr>\n <tr><td colspan=\"3\" align=\"center\"> <input type=\"hidden\" id=\"\" name=\"object_id\" value=\"\" /> <input type=\"hidden\" id=\"\" name=\"action\" value=\"store\" /> </td></tr></table> ","editable_form_id":"image_form","error":"No object_id provided", "login":1}',
31 "/image/ajax/image_ajax_form.pl?object_id=0" => '{"is_owner":0,"user_type":"user","html":" <table> <tr><td>Image Name:</td><td width=\"20\"> </td><td><b>\n</b></td></tr>\n<tr><td>Image Description: </td><td width=\"20\"> </td><td><b>\n</b></td></tr>\n<tr><td>Uploaded by: </td><td width=\"20\"> </td><td><b><a href=\"/solpeople/personal-info.pl?sp_person_id=\"> </a> </b></td></tr>\n </table> ","editable_form_id":null}',
34 plan( tests => 3*(scalar keys %$ajax_urls));
36 while( my ($url, $json) = each %$ajax_urls) {
37 $mech->get_ok("$base_url/$url");
38 is_valid_json($mech->content, "$url is valid JSON");
39 is_json($mech->content, $ajax_urls->{$url}, "$url has the expected JSON");