fix Cut assethelper tests
This commit is contained in:
parent
51d5f6bcb4
commit
d40fbc8255
1 changed files with 16 additions and 9 deletions
|
|
@ -20,6 +20,7 @@ use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||||
use WebGUI::Session;
|
use WebGUI::Session;
|
||||||
use WebGUI::Asset;
|
use WebGUI::Asset;
|
||||||
use WebGUI::AssetHelper::Cut;
|
use WebGUI::AssetHelper::Cut;
|
||||||
|
use WebGUI::Test::Mechanize;
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
# Init
|
# Init
|
||||||
|
|
@ -30,10 +31,10 @@ my $session = WebGUI::Test->session;
|
||||||
# Tests
|
# Tests
|
||||||
|
|
||||||
my $output;
|
my $output;
|
||||||
my $home = WebGUI::Asset->getDefault($session);
|
my $import = WebGUI::Asset->getImportNode($session);
|
||||||
|
|
||||||
$session->user({userId => 1});
|
$session->user({userId => 1});
|
||||||
$output = WebGUI::AssetHelper::Cut->process($home);
|
$output = WebGUI::AssetHelper::Cut->process($import);
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$output,
|
$output,
|
||||||
{
|
{
|
||||||
|
|
@ -43,7 +44,7 @@ cmp_deeply(
|
||||||
);
|
);
|
||||||
|
|
||||||
$session->user({userId => 3});
|
$session->user({userId => 3});
|
||||||
$output = WebGUI::AssetHelper::Cut->process($home);
|
$output = WebGUI::AssetHelper::Cut->process($import);
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$output,
|
$output,
|
||||||
{
|
{
|
||||||
|
|
@ -52,20 +53,26 @@ cmp_deeply(
|
||||||
'AssetHelper/Cut checks for system pages'
|
'AssetHelper/Cut checks for system pages'
|
||||||
);
|
);
|
||||||
|
|
||||||
my $safe_page = $home->getFirstChild;
|
my $safe_page = $import->getFirstChild;
|
||||||
$output = WebGUI::AssetHelper::Cut->process($safe_page);
|
$output = WebGUI::AssetHelper::Cut->process($safe_page);
|
||||||
cmp_deeply(
|
cmp_deeply(
|
||||||
$output,
|
$output,
|
||||||
{
|
{
|
||||||
message => re('was cut to the clipboard'),
|
openDialog => all( re('method=cut'), re('assetId=' . $safe_page->getId) ),
|
||||||
redirect => $home->getUrl,
|
|
||||||
},
|
},
|
||||||
'AssetHelper/Cut returns a message and a redirect'
|
'AssetHelper/Cut opens a dialog'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
my $mech = WebGUI::Test::Mechanize->new( config => WebGUI::Test->file );
|
||||||
|
$mech->get_ok( $output->{ openDialog } );
|
||||||
|
$mech->content_lacks( 'error', "Cut succeeded" );
|
||||||
|
|
||||||
|
$session->cache->clear;
|
||||||
|
$safe_page = WebGUI::Asset->newById( $session, $safe_page->assetId );
|
||||||
is $safe_page->state, 'clipboard', '... and the asset was really cut';
|
is $safe_page->state, 'clipboard', '... and the asset was really cut';
|
||||||
|
|
||||||
$session->asset($home);
|
$session->asset($import);
|
||||||
ok $home->paste($safe_page->getId), 'page pasted correctly';
|
ok $import->paste($safe_page->getId), 'page pasted correctly';
|
||||||
|
|
||||||
$session->cache->clear;
|
$session->cache->clear;
|
||||||
my $safe_page2 = WebGUI::Asset->newById($session, $safe_page->assetId);
|
my $safe_page2 = WebGUI::Asset->newById($session, $safe_page->assetId);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue