AproJo
view release on metacpan or search on metacpan
subtest 'Logging Out' => sub {
# This is essentially a repeat of the first test
$t->get_ok('/logout')
->status_is(200)
->text_like( 'a[href*="login"]' => qr/Login/ );
};
=comment
subtest 'Edit Page' => sub {
# page editor
$t->get_ok('/edit/home')
->status_is(200)
->text_like( '#wmd-input' => qr/Welcome to AproJo!/ )
->element_exists( '#wmd-preview' );
# save page
my $text = 'I changed this text';
my $data = encode_json({
name => 'home',
title => 'New Home',
html => "<p>$text</p>",
md => $text,
});
$t->websocket_ok( '/store/page' )
->send_ok( $data )
->message_is( 'Changes saved' )
->finish_ok;
# see that the changes are reflected
$t->get_ok('/page/home')
->status_is(200)
->text_is( h1 => 'New Home' )
->text_like( p => qr/$text/ );
# author request non-existant page => create new page
$t->get_ok('/page/doesntexist')
->status_is(200)
->text_like( '#wmd-input' => qr/Hello World/ )
->element_exists( '#wmd-preview' );
# save page without title (error)
my $data_notitle = encode_json({
name => 'notitle',
title => '',
html => '<p>Hmmm no title</p>',
md => 'Hmmm no title',
});
$t->websocket_ok( '/store/page' )
->send_ok( $data_notitle )
->message_is( 'Not saved! A title is required!' )
->finish_ok;
};
subtest 'Edit Main Navigation Menu' => sub {
my $title = 'About AproJo';
# check about page is in nav
$t->get_ok('/admin/menu')
->status_is(200)
->text_is( 'ul#main > li:nth-of-type(3) > a' => $title )
->text_is( '#list-active-pages > #pages-2 > span' => $title );
# remove about page from list
my $data = encode_json({
name => 'main',
list => [],
});
$t->websocket_ok('/store/menu')
->send_ok( $data )
->message_is( 'Changes saved' )
->finish_ok;
# check that item is removed
$t->get_ok('/admin/menu')
->status_is(200)
->element_exists_not( 'ul#main > li:nth-of-type(3) > a' )
->text_is( '#list-inactive-pages > #pages-2 > span' => $title );
# put about page back
$data = encode_json({
name => 'main',
list => ['pages-2'],
});
$t->websocket_ok('/store/menu')
->send_ok( $data )
->message_is( 'Changes saved' )
->finish_ok;
# check about page is back in nav (same as first test block)
$t->get_ok('/admin/menu')
->status_is(200)
->text_is( 'ul#main > li:nth-of-type(3) > a' => $title )
->text_is( '#list-active-pages > #pages-2 > span' => $title );
};
subtest 'Administrative Overview: All Users' => sub {
# test the admin pages
$t->get_ok('/admin/users')
->status_is(200)
->text_is( h1 => 'Administration: Users' )
->text_is( 'tr > td:nth-of-type(2)' => 'admin' )
->text_is( 'tr > td:nth-of-type(3)' => 'Joe Admin' );
};
subtest 'Administrative Overview: All Pages' => sub {
$t->get_ok('/admin/pages')
->status_is(200)
->text_is( h1 => 'Administration: Pages' )
->text_is( 'tr > td:nth-of-type(2)' => 'home' );
( run in 1.070 second using v1.01-cache-2.11-cpan-f56aa216473 )