Merge branch 'master' into topic/dt_feature_search
[sgn.git] / t / legacy / integration / feature.t
blob5deeaf13290ef963aa7fcc0ece9fc492bd126fee
1 =head1 NAME
3 t/integration/feature.t - integration tests for generic feature URLs
5 =head1 DESCRIPTION
7 Tests for generic feature URLs
9 =head1 SYNOPSIS
11 These tests assume that a polypeptide does not have a specialized feature mason
12 component and gets rendered as a generic feature with mason/feature/default.mas
13 from SGN::Controller::Feature.
15 =head1 AUTHORS
17 Jonathan "Duke" Leto
19 =cut
21 use strict;
22 use warnings;
23 use Test::More;
24 use lib 't/lib';
25 use SGN::Test::WWW::Mechanize skip_cgi => 1;
26 use SGN::Test::Data qw/ create_test /;
28 my $mech = SGN::Test::WWW::Mechanize->new;
30 my $poly_cvterm     = create_test('Cv::Cvterm', { name  => 'polypeptide' });
31 my $poly_feature    = create_test('Sequence::Feature', { type => $poly_cvterm });
32 my $schema = $poly_feature->result_source->schema;
33 $poly_feature->add_to_featureprops({ value => 'Testing note one', type => $schema->get_cvterm_or_die('null:Note'), rank => 1 });
34 $poly_feature->add_to_featureprops({ value => 'Testing note two', type => $schema->get_cvterm_or_die('null:Note'), rank => 2 });
36 my $poly_featureloc = create_test('Sequence::Featureloc', { feature => $poly_feature });
38 for my $url ( "/feature/".$poly_feature->name.'/details',  "/feature/".$poly_feature->feature_id.'/details' ) {
40     $mech->get_ok( $url );
41     $mech->dbh_leak_ok;
42     $mech->html_lint_ok('valid HTML');
44     my ($name, $residues) = ($poly_feature->name, $poly_feature->residues);
46     like( $mech->findvalue( '/html/body//span[@class="sequence"]'), qr/>$name\s*/, "Found >$name\\n");
47     like( $mech->findvalue( '/html/body//div[@class="info_table_fieldval"]'), qr/polypeptide/i, "Found the polypeptide cvterm");
49     ok($mech->exists(
50         sprintf '/html/body//div[@class="info_table_fieldval"]/a[@href="/chado/cvterm?cvterm_id=%s"]',
51         $poly_cvterm->cvterm_id
52        ),'the proper cvterm id link exists');
54     $mech->content_contains('Polypeptide details');
55     $mech->content_contains($poly_feature->name);
57     $mech->content_contains('Testing note one');
58     $mech->content_contains('Testing note two');
61 done_testing;