From 918f5b19a62aab447a7df14d2e97d0720d5b61fd Mon Sep 17 00:00:00 2001 From: Manager Bot Date: Tue, 29 Nov 2022 19:42:39 +0000 Subject: [PATCH] More tests done. --- Web/lib/Test/Mojo/MJB.pm | 16 +++++++ .../01_endpoints/04_dashboard/16_blog_media.t | 44 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 Web/t/01_endpoints/04_dashboard/16_blog_media.t diff --git a/Web/lib/Test/Mojo/MJB.pm b/Web/lib/Test/Mojo/MJB.pm index 8e27009..7692cb3 100644 --- a/Web/lib/Test/Mojo/MJB.pm +++ b/Web/lib/Test/Mojo/MJB.pm @@ -96,6 +96,22 @@ sub dump_stash { return $t; } +sub dump_stash_keys { + my ( $t ) = @_; + + warn Dumper grep { + $_ ne 'controller' && + $_ ne 'action' && + $_ ne 'cb' && + $_ ne 'template' && + $_ ne 'person' && + $_ !~ m|^mojo\.|; + + } keys %{$t->stash}; + + return $t; +} + sub stash_has { my ( $t, $expect, $desc ) = @_; diff --git a/Web/t/01_endpoints/04_dashboard/16_blog_media.t b/Web/t/01_endpoints/04_dashboard/16_blog_media.t new file mode 100644 index 0000000..72c857a --- /dev/null +++ b/Web/t/01_endpoints/04_dashboard/16_blog_media.t @@ -0,0 +1,44 @@ +#!/usr/bin/env perl +use MJB::Web::Test; + +#== +# This test ensures that the media panel for the blog can be viewed. +# +# 1. Create user and login. +# 2. Make a new blog. +# 3. Go to the settings -> advanced config panel +# 4. Confirm the stash has the media_files arrayref. +#== + +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/media" ) + ->code_block(sub { + my $self = shift; + ok exists $self->stash->{media_files}, 'We have media files in the stash.'; + is ref $self->stash->{media_files}, 'ARRAY', 'We have media files in the stash as an arrayref.'; + }) + ->status_is( 200 ); + +#== +# Remove Jekyll blog repos that were created as a part of this test. +#== +$t->clear_tempdir; + +done_testing;