parent
2952a8dfa4
commit
e58e849906
5 changed files with 280 additions and 0 deletions
@ -0,0 +1,38 @@ |
||||
#!/usr/bin/env perl |
||||
use MJB::Web::Test; |
||||
|
||||
#== |
||||
# This test ensures that a blog page creator panel can be viewed.. |
||||
# |
||||
# 1. Create user and login. |
||||
# 2. Make a new blog. |
||||
# 3. Go to the blog page creator |
||||
#== |
||||
|
||||
my $t = Test::Mojo::MJB->new('MJB::Web'); |
||||
|
||||
my $blog_id = $t->create_user |
||||
->post_ok( '/blog/domain', form => { |
||||
domain => 'blog.example.com', |
||||
calling_route => 'show_blog_domain_owned', |
||||
}) |
||||
->get_ok( '/dashboard' ) |
||||
->stash->{blogs}->[0]->id; |
||||
|
||||
$t->get_ok( "/dashboard/blog/$blog_id" ) |
||||
->status_is( 200 ) |
||||
->code_block( sub { |
||||
my $self = shift; |
||||
ok exists $self->stash->{blog}, "The blog loads!"; |
||||
is $self->stash->{blog}->domain->name, 'blog.example.com', "Correct domain name for id."; |
||||
}); |
||||
|
||||
$t->get_ok( "/dashboard/blog/$blog_id/page" ) |
||||
->status_is( 200 ); |
||||
|
||||
#== |
||||
# Remove Jekyll blog repos that were created as a part of this test. |
||||
#== |
||||
$t->clear_tempdir; |
||||
|
||||
done_testing; |
||||
@ -0,0 +1,56 @@ |
||||
#!/usr/bin/env perl |
||||
use MJB::Web::Test; |
||||
|
||||
#== |
||||
# This test ensures that a blog page can be created. |
||||
# |
||||
# 1. Create user and login. |
||||
# 2. Make a new blog. |
||||
# 3. Make a new blog page. |
||||
# 4. Ensure that the blog page shows up in the blog page listing. |
||||
# 5. Make sure that the raw file for the blog page exists / right content |
||||
#== |
||||
|
||||
my $t = Test::Mojo::MJB->new('MJB::Web'); |
||||
|
||||
my $blog_id = $t->create_user |
||||
->post_ok( '/blog/domain', form => { |
||||
domain => 'blog.example.com', |
||||
calling_route => 'show_blog_domain_owned', |
||||
}) |
||||
->get_ok( '/dashboard' ) |
||||
->stash->{blogs}->[0]->id; |
||||
|
||||
$t->get_ok( "/dashboard/blog/$blog_id" ) |
||||
->status_is( 200 ) |
||||
->code_block( sub { |
||||
my $self = shift; |
||||
ok exists $self->stash->{blog}, "The blog loads!"; |
||||
is $self->stash->{blog}->domain->name, 'blog.example.com', "Correct domain name for id."; |
||||
}); |
||||
|
||||
$t->post_ok( "/dashboard/blog/$blog_id/page", form => { |
||||
pagePath => 'contact', |
||||
pageTitle => 'Contact Page', |
||||
pageHeaders => "title: Contact Page\nlayout: page\n", |
||||
pageContent => 'This is my contact page', |
||||
}) |
||||
->status_is( 302 ) |
||||
->header_is( location => "/dashboard/blog/$blog_id/pages" ); |
||||
|
||||
# See if we have the blog post entry on disk, then try to read the post we created and confirm it's correct. |
||||
ok -f $t->app->jekyll( 'blog.example.com' )->root . '/blog.example.com/contact.markdown', |
||||
'The new blog page was written to disk.'; |
||||
|
||||
# Try to re-read the page we edited and confirm it's correct. |
||||
my $page = $t->app->jekyll( 'blog.example.com' )->new_page( '/contact.markdown' )->read; |
||||
|
||||
is $page->headers->{title}, 'Contact Page', 'The title of the page is correct.'; |
||||
is $page->markdown, 'This is my contact page', 'The content of the page is correct.'; |
||||
|
||||
#== |
||||
# Remove Jekyll blog repos that were created as a part of this test. |
||||
#== |
||||
$t->clear_tempdir; |
||||
|
||||
done_testing; |
||||
@ -0,0 +1,53 @@ |
||||
#!/usr/bin/env perl |
||||
use MJB::Web::Test; |
||||
|
||||
#== |
||||
# This test ensures that a blog page can be opened in the editor panel. |
||||
# |
||||
# 1. Create user and login. |
||||
# 2. Make a new blog. |
||||
# 3. Make a new blog page. |
||||
# 4. Open the editor page with this file loaded and confirm the file |
||||
#== |
||||
|
||||
my $t = Test::Mojo::MJB->new('MJB::Web'); |
||||
|
||||
my $blog_id = $t->create_user |
||||
->post_ok( '/blog/domain', form => { |
||||
domain => 'blog.example.com', |
||||
calling_route => 'show_blog_domain_owned', |
||||
}) |
||||
->get_ok( '/dashboard' ) |
||||
->stash->{blogs}->[0]->id; |
||||
|
||||
$t->get_ok( "/dashboard/blog/$blog_id" ) |
||||
->status_is( 200 ) |
||||
->code_block( sub { |
||||
my $self = shift; |
||||
ok exists $self->stash->{blog}, "The blog loads!"; |
||||
is $self->stash->{blog}->domain->name, 'blog.example.com', "Correct domain name for id."; |
||||
}); |
||||
|
||||
$t->post_ok( "/dashboard/blog/$blog_id/page", form => { |
||||
pagePath => 'contact', |
||||
pageTitle => 'Contact Page', |
||||
pageHeaders => "title: Contact Page\nlayout: page\n", |
||||
pageContent => 'This is my contact page', |
||||
}) |
||||
->status_is( 302 ) |
||||
->header_is( location => "/dashboard/blog/$blog_id/pages" ); |
||||
|
||||
$t->get_ok( "/dashboard/blog/$blog_id/page/edit?file=/contact.markdown" ) |
||||
->status_is( 200 ) |
||||
->code_block( sub { |
||||
my $self = shift; |
||||
is $self->stash->{blog_page}->markdown, 'This is my contact page', 'Have expected content for page'; |
||||
is $self->stash->{blog_page}->headers->{title}, 'Contact Page', 'Have expected title for page'; |
||||
}); |
||||
|
||||
#== |
||||
# Remove Jekyll blog repos that were created as a part of this test. |
||||
#== |
||||
$t->clear_tempdir; |
||||
|
||||
done_testing; |
||||
@ -0,0 +1,72 @@ |
||||
#!/usr/bin/env perl |
||||
use MJB::Web::Test; |
||||
|
||||
#== |
||||
# This test ensures that a blog page can be edited. |
||||
# |
||||
# 1. Create user and login. |
||||
# 2. Make a new blog. |
||||
# 3. Make a new blog page. |
||||
# 4. Ensure that the blog page shows up in the blog page listing. |
||||
# 5. Make sure that the raw file for the blog page exists / right content |
||||
# 6. Edit the page. |
||||
# 7. Confirm the new changes. |
||||
#== |
||||
|
||||
my $t = Test::Mojo::MJB->new('MJB::Web'); |
||||
|
||||
my $blog_id = $t->create_user |
||||
->post_ok( '/blog/domain', form => { |
||||
domain => 'blog.example.com', |
||||
calling_route => 'show_blog_domain_owned', |
||||
}) |
||||
->get_ok( '/dashboard' ) |
||||
->stash->{blogs}->[0]->id; |
||||
|
||||
$t->get_ok( "/dashboard/blog/$blog_id" ) |
||||
->status_is( 200 ) |
||||
->code_block( sub { |
||||
my $self = shift; |
||||
ok exists $self->stash->{blog}, "The blog loads!"; |
||||
is $self->stash->{blog}->domain->name, 'blog.example.com', "Correct domain name for id."; |
||||
}); |
||||
|
||||
$t->post_ok( "/dashboard/blog/$blog_id/page", form => { |
||||
pagePath => 'contact', |
||||
pageTitle => 'Contact Page', |
||||
pageHeaders => "title: Contact Page\nlayout: page\n", |
||||
pageContent => 'This is my contact page', |
||||
}) |
||||
->status_is( 302 ) |
||||
->header_is( location => "/dashboard/blog/$blog_id/pages" ); |
||||
|
||||
# See if we have the blog post entry on disk, then try to read the post we created and confirm it's correct. |
||||
ok -f $t->app->jekyll( 'blog.example.com' )->root . '/blog.example.com/contact.markdown', |
||||
'The new blog page was written to disk.'; |
||||
|
||||
# Try to re-read the page we edited and confirm it's correct. |
||||
my $page = $t->app->jekyll( 'blog.example.com' )->new_page( '/contact.markdown' )->read; |
||||
|
||||
is $page->headers->{title}, 'Contact Page', 'The title of the page is correct.'; |
||||
is $page->markdown, 'This is my contact page', 'The content of the page is correct.'; |
||||
|
||||
$t->post_ok( "/dashboard/blog/$blog_id/page/edit", form => { |
||||
file => '/contact.markdown', |
||||
pageHeaders => "title: Contact Me\nlayout: page\n", |
||||
pageContent => 'You can contact me', |
||||
}) |
||||
->status_is( 302 ) |
||||
->header_is( location => "/dashboard/blog/$blog_id/pages" ); |
||||
|
||||
# Try to re-read the page we edited and confirm it's correct. |
||||
$page = $t->app->jekyll( 'blog.example.com' )->new_page( '/contact.markdown' )->read; |
||||
|
||||
is $page->headers->{title}, 'Contact Me', 'The title of the page is correct.'; |
||||
is $page->markdown, 'You can contact me', 'The content of the page is correct.'; |
||||
|
||||
#== |
||||
# Remove Jekyll blog repos that were created as a part of this test. |
||||
#== |
||||
$t->clear_tempdir; |
||||
|
||||
done_testing; |
||||
@ -0,0 +1,61 @@ |
||||
#!/usr/bin/env perl |
||||
use MJB::Web::Test; |
||||
|
||||
#== |
||||
# This test ensures that a blog page can be removed. |
||||
# |
||||
# 1. Create user and login. |
||||
# 2. Make a new blog. |
||||
# 3. Make a new blog page. |
||||
# 4. Make sure that the raw file for the blog page exists / right content |
||||
# 6. Remove the page. |
||||
# 7. Confirm the page has been removed. |
||||
#== |
||||
|
||||
my $t = Test::Mojo::MJB->new('MJB::Web'); |
||||
|
||||
my $blog_id = $t->create_user |
||||
->post_ok( '/blog/domain', form => { |
||||
domain => 'blog.example.com', |
||||
calling_route => 'show_blog_domain_owned', |
||||
}) |
||||
->get_ok( '/dashboard' ) |
||||
->stash->{blogs}->[0]->id; |
||||
|
||||
$t->get_ok( "/dashboard/blog/$blog_id" ) |
||||
->status_is( 200 ) |
||||
->code_block( sub { |
||||
my $self = shift; |
||||
ok exists $self->stash->{blog}, "The blog loads!"; |
||||
is $self->stash->{blog}->domain->name, 'blog.example.com', "Correct domain name for id."; |
||||
}); |
||||
|
||||
$t->post_ok( "/dashboard/blog/$blog_id/page", form => { |
||||
pagePath => 'contact', |
||||
pageTitle => 'Contact Page', |
||||
pageHeaders => "title: Contact Page\nlayout: page\n", |
||||
pageContent => 'This is my contact page', |
||||
}) |
||||
->status_is( 302 ) |
||||
->header_is( location => "/dashboard/blog/$blog_id/pages" ); |
||||
|
||||
# See if we have the blog post entry on disk, then try to read the post we created and confirm it's correct. |
||||
ok -f $t->app->jekyll( 'blog.example.com' )->root . '/blog.example.com/contact.markdown', |
||||
'The new blog page was written to disk.'; |
||||
|
||||
# Remove the page |
||||
$t->post_ok( "/dashboard/blog/$blog_id/page/remove", form => { |
||||
file => '/contact.markdown', |
||||
}) |
||||
->status_is( 302 ) |
||||
->header_is( location => "/dashboard/blog/$blog_id/pages" ); |
||||
|
||||
ok ! -f $t->app->jekyll( 'blog.example.com' )->root . '/blog.example.com/contact.markdown', |
||||
'The new blog page was removed from disk.'; |
||||
|
||||
#== |
||||
# Remove Jekyll blog repos that were created as a part of this test. |
||||
#== |
||||
$t->clear_tempdir; |
||||
|
||||
done_testing; |
||||
Loading…
Reference in new issue