Fix bad CSS link in the Edit Survey template. Fixes bug #10984.

Update test to scan for links and srcs in the template body, too.
This commit is contained in:
Colin Kuskie 2009-10-30 10:13:48 -07:00
parent 21223657a1
commit 6b88a8915a
3 changed files with 28 additions and 16 deletions

View file

@ -28,6 +28,7 @@
- fixed #11179: user.CanStartThread missing from help
- fixed #11183: Calendar List View
- fixed #11135: Tree Navigation menu template shows a drop down fly-out menu
- fixed #10984: Edit Survey Screen isn't right in demo
7.8.2
- Added scheduled vendor payout workflow activity. (Special thanks to Martin @ Oqapi)

View file

@ -26,11 +26,6 @@ use Test::More; # increment this value for each test you create
my $numTests = 0;
my $session = WebGUI::Test->session;
my $lib = WebGUI::Test->lib;
##Find the name of the International macro in the user's config file.
#note "International macro name = $international";
##Regexp setup for parsing out the Macro calls.
my $macro = qr{
@ -43,19 +38,28 @@ my $macro = qr{
$numTests = $session->db->quickScalar('select count(distinct(assetId)) from template');
plan tests => $numTests;
plan tests => 2*$numTests;
my $validLinks = 0;
my $nonRootLink = qr{
^
\s* #Optional whitespace
(?: \^ (?: / | Extras)) #Gateway or Extras macro
| # OR
<tmpl_var #A template variable
}x;
sub checkLinks {
my ($tag, $attrs) = @_;
if ($tag eq 'link' && $attrs->{href}) {
if ($attrs->{href} !~ /\s*\^(?:\/|Extras)/) {
diag sprintf '%s: %s', $tag, $attrs->{href};
if ($attrs->{href} !~ $nonRootLink) {
$validLinks = 0;
}
}
elsif ($tag eq 'script' && $attrs->{src}) {
if ($attrs->{src} !~ /\s*\^(?:\/|Extras)/) {
if ($attrs->{src} !~ $nonRootLink) {
$validLinks = 0;
}
}
@ -70,15 +74,22 @@ my $parser = HTML::Parser->new(
my $getATemplate = WebGUI::Asset::Template->getIsa($session);
TEMPLATE: while (my $templateAsset = $getATemplate->()) {
my $template = $templateAsset->get('template');
my $header = $templateAsset->get('extraHeadTags');
if(! $header) {
ok(1, sprintf "%s: %s (%s) has no rooted link urls", $templateAsset->getTitle, $templateAsset->getId, $templateAsset->getUrl);
next TEMPLATE;
ok(1, sprintf "%s: %s (%s) has no rooted link urls in the head tags", $templateAsset->getTitle, $templateAsset->getId, $templateAsset->getUrl);
}
else {
$validLinks = 1;
$parser->parse($header);
ok($validLinks, sprintf "%s: %s (%s) has no rooted link urls in the head tags", $templateAsset->getTitle, $templateAsset->getId, $templateAsset->getUrl);
}
my $template = $templateAsset->get('template');
if(! $template) {
ok(1, sprintf "%s: %s (%s) has no rooted link urls in the template", $templateAsset->getTitle, $templateAsset->getId, $templateAsset->getUrl);
}
else {
$validLinks = 1;
$parser->parse($template);
ok($validLinks, sprintf "%s: %s (%s) has no rooted link urls in the template", $templateAsset->getTitle, $templateAsset->getId, $templateAsset->getUrl);
}
$validLinks = 1;
$parser->parse($header);
ok($validLinks, sprintf "%s: %s (%s) has no rooted link urls", $templateAsset->getTitle, $templateAsset->getId, $templateAsset->getUrl);
}