Merge branch 'patch-5' of https://github.com/gjones2/Freeside (#13854 as this bug...
[freeside.git] / rt / t / web / admin_groups.t
1 #!/usr/bin/perl
2 use strict;
3 use warnings;
4
5 use RT::Test tests => 26;
6
7 my ( $url, $m ) = RT::Test->started_ok;
8 ok( $m->login(), 'logged in' );
9
10 {
11     diag "test creating a group" if $ENV{TEST_VERBOSE};
12     $m->get_ok( $url . '/Admin/Groups/Modify.html?Create=1' );
13     $m->content_contains('Create a new group', 'found title');
14     $m->submit_form_ok({
15         form_number => 3,
16         fields => { Name => 'test group' },
17     });
18     $m->content_contains('Group created', 'found results');
19     $m->content_contains('Modify the group test group', 'found title');
20 }
21
22 {
23     diag "test creating another group" if $ENV{TEST_VERBOSE};
24     $m->get_ok( $url . '/Admin/Groups/Modify.html?Create=1' );
25     $m->content_contains('Create a new group', 'found title');
26     $m->submit_form_ok({
27         form_number => 3,
28         fields => { Name => 'test group2' },
29     });
30     $m->content_contains('Group created', 'found results');
31     $m->content_contains('Modify the group test group2', 'found title');
32 }
33
34 {
35     diag "test creating an overlapping group" if $ENV{TEST_VERBOSE};
36     $m->get_ok( $url . '/Admin/Groups/Modify.html?Create=1' );
37     $m->content_contains('Create a new group', 'found title');
38     $m->submit_form_ok({
39         form_number => 3,
40         fields => { Name => 'test group' },
41     });
42     $m->content_contains('Group could not be created', 'found results');
43     $m->content_like(qr/Group name .+? is already in use/, 'found message');
44 }
45
46 {
47     diag "test updating a group name to overlap" if $ENV{TEST_VERBOSE};
48     $m->get_ok( $url . '/Admin/Groups/' );
49     $m->follow_link_ok({text => 'test group2'}, 'found title');
50     $m->content_contains('Modify the group test group2');
51     $m->submit_form_ok({
52         form_number => 3,
53         fields => { Name => 'test group' },
54     });
55     $m->content_lacks('Name changed', "name not changed");
56     $m->content_contains('Illegal value for Name', 'found error message');
57     $m->content_contains('test group', 'did not find new name');
58 }
59