Skip to content

Commit

Permalink
add test for assets being included in html and available
Browse files Browse the repository at this point in the history
  • Loading branch information
haarg committed May 1, 2024
1 parent 13d9c7a commit f0b4225
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions t/assets.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use strict;
use warnings;
use Test::More;
use MetaCPAN::Web::Test qw( app GET test_psgi tx );

test_psgi app, sub {
my $cb = shift;
{
ok( my $res = $cb->( GET '/' ), 'GET /' );
is( $res->code, 200, 'code 200' );

my $xpc = tx($res)->xpc;

my @assets = grep m{^/}, map $_->value,
$xpc->findnodes(q[//script/@src]),
$xpc->findnodes(q[//link[@rel="stylesheet"]/@href]);

ok( (grep /\.js$/, @assets), 'assets include a js file' );
ok( (grep /\.css$/, @assets), 'assets include a css file' );

for my $asset (@assets) {
ok( my $res = $cb->( GET $asset ), "GET $asset" );
is( $res->code, 200, 'code 200' );
}
}
};

done_testing;

0 comments on commit f0b4225

Please sign in to comment.