From acd71a7f7e08add208abe5390b6d69b6b8651ed1 Mon Sep 17 00:00:00 2001 From: Scott Walters Date: Thu, 19 Aug 2010 12:36:30 -0400 Subject: [PATCH] More exceptions for the Test::Class tests as to which labels should and don't need to appear in forms. --- t/tests/Test/WebGUI/Asset.pm | 11 +++++------ t/tests/Test/WebGUI/Asset/File/GalleryFile.pm | 2 ++ t/tests/Test/WebGUI/Asset/File/Image.pm | 2 +- t/tests/Test/WebGUI/Asset/RichEdit.pm | 2 ++ t/tests/Test/WebGUI/Asset/Shortcut.pm | 2 ++ t/tests/Test/WebGUI/Asset/Template.pm | 10 ++++++++++ t/tests/Test/WebGUI/Asset/Wobject/Poll.pm | 2 +- 7 files changed, 23 insertions(+), 8 deletions(-) diff --git a/t/tests/Test/WebGUI/Asset.pm b/t/tests/Test/WebGUI/Asset.pm index 4f9def3c7..76c2f8652 100644 --- a/t/tests/Test/WebGUI/Asset.pm +++ b/t/tests/Test/WebGUI/Asset.pm @@ -479,7 +479,7 @@ sub t_11_getEditForm : Tests { my $session = $test->session; my ( $tag, $asset, @parents ) = $test->getAnchoredAsset(); -local $SIG{__DIE__} = sub { use Carp; Carp::confess "@_"; }; + # local $SIG{__DIE__} = sub { use Carp; Carp::confess "@_"; }; my $f = $asset->getEditForm; @@ -504,13 +504,12 @@ local $SIG{__DIE__} = sub { use Carp; Carp::confess "@_"; }; # Properties use Data::Dumper; - # note( "f: " . Dumper $f->getFieldsRecursive ); - - # $asset->getProperties vs $asset->getEditForm->getFieldsRecursive + # compare $asset->getProperties to $asset->getEditForm->getFieldsRecursive my @properties = ( List::MoreUtils::uniq # no dups, please $test->dynamic_form_labels, # per-test hard-coded labels known to be added at runtime vs with property blocks + grep { ($_ ne 'Mobile Template') xor $session->setting->get('useMobileStyle') } grep $_, # a rare few property blocks have niether noFormPost nor label? XXX TODO tests/fix map { $asset->getFormProperties($_)->{label} } # getFormProperties returns a plain hash grep { ! $asset->meta->find_attribute_by_name( $_ )->noFormPost } @@ -519,13 +518,13 @@ local $SIG{__DIE__} = sub { use Carp; Carp::confess "@_"; }; my @form = ( List::MoreUtils::uniq - grep { $_ and $_ ne 'Keywords' and $_ ne 'Class Name' and $_ ne 'Asset ID' } + grep { $_ and $_ ne 'Keywords' and $_ ne 'Class Name' and $_ ne 'Asset ID' and $_ ne 'Approved' } map $_->get('label'), flattenFormObjects($f->getFieldsRecursive) # mixture of arrays of Form objects and arrays-of-arrays of them; flatten it out ); my %superlist = map { ( $_ => 1 ) } @form, @properties; - note "all labels: " . join ', ', keys %superlist; + # note "all labels: " . join ', ', keys %superlist; for my $label (keys %superlist) { no warnings 'uninitialized'; diff --git a/t/tests/Test/WebGUI/Asset/File/GalleryFile.pm b/t/tests/Test/WebGUI/Asset/File/GalleryFile.pm index 8664afde6..304b808d0 100644 --- a/t/tests/Test/WebGUI/Asset/File/GalleryFile.pm +++ b/t/tests/Test/WebGUI/Asset/File/GalleryFile.pm @@ -25,4 +25,6 @@ sub parent_list { return [qw/WebGUI::Asset::Wobject::Gallery WebGUI::Asset::Wobject::GalleryAlbum /]; } +sub dynamic_form_labels { return 'New file to upload' }; + 1; diff --git a/t/tests/Test/WebGUI/Asset/File/Image.pm b/t/tests/Test/WebGUI/Asset/File/Image.pm index b8aebb979..45fbdb24b 100644 --- a/t/tests/Test/WebGUI/Asset/File/Image.pm +++ b/t/tests/Test/WebGUI/Asset/File/Image.pm @@ -21,7 +21,7 @@ sub list_of_tables { return [qw/assetData FileAsset ImageAsset/]; } -sub dynamic_form_labels { return 'New file to upload', 'Approved'; } +sub dynamic_form_labels { return 'New file to upload'; } sub t_11_getEditForm : Tests( 2 ) { my $test = shift; diff --git a/t/tests/Test/WebGUI/Asset/RichEdit.pm b/t/tests/Test/WebGUI/Asset/RichEdit.pm index 79aaca088..febe0a8c9 100644 --- a/t/tests/Test/WebGUI/Asset/RichEdit.pm +++ b/t/tests/Test/WebGUI/Asset/RichEdit.pm @@ -25,4 +25,6 @@ sub list_of_tables { return [qw/assetData RichEdit/]; } +sub dynamic_form_labels { return 'Toolbar Buttons' } + 1; diff --git a/t/tests/Test/WebGUI/Asset/Shortcut.pm b/t/tests/Test/WebGUI/Asset/Shortcut.pm index 34e6bab61..648899fbb 100644 --- a/t/tests/Test/WebGUI/Asset/Shortcut.pm +++ b/t/tests/Test/WebGUI/Asset/Shortcut.pm @@ -24,4 +24,6 @@ sub list_of_tables { return [qw/assetData Shortcut/]; } +sub dynamic_form_labels { return 'Asset to Mirror' } + 1; diff --git a/t/tests/Test/WebGUI/Asset/Template.pm b/t/tests/Test/WebGUI/Asset/Template.pm index ffce3c836..3e0525b2f 100644 --- a/t/tests/Test/WebGUI/Asset/Template.pm +++ b/t/tests/Test/WebGUI/Asset/Template.pm @@ -21,4 +21,14 @@ sub list_of_tables { return [qw/assetData template/]; } +sub postProcessMergedProperties { + my $test = shift; + my $properties = shift; + if( exists $properties->{attachmentsJson} and ! defined $properties->{attachmentsJson} ) { + $properties->{attachmentsJson} = '[{"url":"/webgui.css","type":"stylesheet"}]'; + } +} + +sub dynamic_form_labels { return 'Template Type' }; + 1; diff --git a/t/tests/Test/WebGUI/Asset/Wobject/Poll.pm b/t/tests/Test/WebGUI/Asset/Wobject/Poll.pm index e7788c7ee..ab12587a5 100644 --- a/t/tests/Test/WebGUI/Asset/Wobject/Poll.pm +++ b/t/tests/Test/WebGUI/Asset/Wobject/Poll.pm @@ -22,7 +22,7 @@ sub list_of_tables { } sub dynamic_form_labels { - return 'Reset votes?', 'Answers', 'Generate image graph', 'Approved'; + return 'Reset votes?', 'Answers', 'Generate image graph'; } 1;