re-work installation to use a bse.cfg style file
[bse.git] / t / 070-user / 010-edit.t
1 #!perl -w
2 use strict;
3 use Test::More tests => 22;
4 use BSE::Test qw(base_url make_ua check_form post_ok
5                  check_content follow_ok);
6 use URI::QueryParam;
7 #use WWW::Mechanize;
8 ++$|;
9 my $baseurl = base_url;
10 my $ua = make_ua;
11
12 ok($ua->get("$baseurl/cgi-bin/admin/add.pl?parentid=-1"), "edit page");
13   check_content($ua->{content}, 'edit page',
14               qr!No\s+parent\s+-\s+this\s+is\s+a\s+section
15               .*
16               common/default.tmpl
17               .*
18               Add\s+New\s+Page\s+Lev1
19               !xs);
20 check_form($ua->{content},
21            "edit form",
22            parentid=>[ -1, 'select' ],
23            id => [ '', 'hidden' ],
24            template=> [ 'common/default.tmpl', 'select' ],
25            body => [ '', 'textarea' ],
26            listed => [ 1, 'select' ],
27           );
28 $ua->field(title=>'Test Article');
29 $ua->field(body=>'This is a test body');
30 ok($ua->click('save'), 'submit modified edit form');
31 # should redirect to admin mode page
32 check_content($ua->{content}, "admin mode", 
33            qr!
34            <title>.*Test\ Article.*</title>
35            .*
36            This\ is\ a\ test\ body
37            !xsm);
38 my $uri = $ua->uri;
39 my $id = $uri->query_param("id");
40 # manage sections
41 ok($ua->get("$baseurl/cgi-bin/admin/add.pl?id=-1"), "sections page");
42 follow_ok($ua, "clean up",
43           {
44            text => "Delete",
45            url_regex => qr/id=$id/
46           }, qr/Article deleted/);