2023-08-13 20:39:36 -04:00
|
|
|
|
use Mojo::Base -strict;
|
|
|
|
|
use Test::More;
|
|
|
|
|
use Test::Mojo;
|
|
|
|
|
|
|
|
|
|
my $t = Test::Mojo->new('PostText');
|
|
|
|
|
|
2023-11-10 13:23:18 -05:00
|
|
|
|
# For CAPTCHA
|
|
|
|
|
my %good_captcha = (answer => 1, number => 'Ⅰ');
|
|
|
|
|
my $bump_thread_url =
|
|
|
|
|
'/captcha/H4sIAImTzmQAA8soKSmw0tfPyU9OzMnILy6xMjYwMNDPKM1NzNMvyShKTUzRTyrNLdA3BAD5ek7T%0AKQAAAA==%0A';
|
|
|
|
|
|
2023-08-13 22:09:44 -04:00
|
|
|
|
my %preview_thread = (
|
|
|
|
|
author => 'Anonymous',
|
|
|
|
|
title => 'hi',
|
|
|
|
|
body => 'ayy... lmao',
|
|
|
|
|
preview => 1
|
|
|
|
|
);
|
|
|
|
|
|
2023-08-13 20:39:36 -04:00
|
|
|
|
my %preview_remark = (
|
|
|
|
|
author => 'Anonymous',
|
|
|
|
|
body => 'ayy... lmao',
|
|
|
|
|
preview => 1
|
|
|
|
|
);
|
|
|
|
|
|
2023-11-10 13:23:18 -05:00
|
|
|
|
# Do CAPTCHA
|
|
|
|
|
$t->post_ok($bump_thread_url, form => \%good_captcha)
|
|
|
|
|
->status_is(302)
|
|
|
|
|
->header_like(Location => qr{human/thread/bump/1});
|
|
|
|
|
|
2023-08-13 20:39:36 -04:00
|
|
|
|
subtest 'Check the form + button', sub {
|
2023-11-10 13:23:18 -05:00
|
|
|
|
$t->get_ok('/human/remark/post/1')->status_is(200)
|
2023-08-13 20:39:36 -04:00
|
|
|
|
->element_exists('input[id="preview"]');
|
|
|
|
|
|
2023-11-10 13:23:18 -05:00
|
|
|
|
$t->get_ok('/human/thread/post')->status_is(200)
|
2023-08-13 22:09:44 -04:00
|
|
|
|
->element_exists('input[id="preview"]');
|
2023-08-13 20:39:36 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
subtest 'Submit input', sub {
|
2023-11-10 13:23:18 -05:00
|
|
|
|
$t->post_ok('/human/remark/post/1', form => \%preview_remark)
|
2023-08-13 20:39:36 -04:00
|
|
|
|
->status_is(200)
|
|
|
|
|
->text_like(p => qr/ayy\.\.\. lmao/);
|
|
|
|
|
|
2023-11-10 13:23:18 -05:00
|
|
|
|
$t->post_ok('/human/thread/post', form => \%preview_thread)
|
2023-08-13 22:09:44 -04:00
|
|
|
|
->status_is(200)
|
|
|
|
|
->text_like(p => qr/ayy\.\.\. lmao/);
|
2023-08-13 20:39:36 -04:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
done_testing;
|