Skip to content

Commit 4cca4cd

Browse files
cbrandtbuffalosunnavy
authored andcommitted
Update to new Dashboard and SavedSearch methods and names
1 parent 61feace commit 4cca4cd

1 file changed

Lines changed: 26 additions & 42 deletions

File tree

t/web/custom_frontpage.t

Lines changed: 26 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,11 @@ $user_obj->SetName('customer');
1313
$user_obj->SetPrivileged(1);
1414
($ret, $msg) = $user_obj->SetPassword('customer');
1515
$user_obj->PrincipalObj->GrantRight(Right => 'LoadSavedSearch');
16-
$user_obj->PrincipalObj->GrantRight(Right => 'EditSavedSearches');
17-
$user_obj->PrincipalObj->GrantRight(Right => 'CreateSavedSearch');
16+
$user_obj->PrincipalObj->GrantRight(Right => 'AdminSavedSearch');
1817
$user_obj->PrincipalObj->GrantRight(Right => 'ModifySelf');
1918
$user_obj->PrincipalObj->GrantRight(Right => 'SeeDashboard');
2019
$user_obj->PrincipalObj->GrantRight(Right => 'SeeOwnDashboard');
21-
$user_obj->PrincipalObj->GrantRight(Right => 'CreateOwnDashboard');
22-
$user_obj->PrincipalObj->GrantRight(Right => 'ModifyOwnDashboard');
20+
$user_obj->PrincipalObj->GrantRight(Right => 'AdminOwnDashboard');
2321

2422
ok $m->login( customer => 'customer' ), "logged in";
2523

@@ -28,8 +26,9 @@ $m->get ( $url."Search/Build.html");
2826
#create a saved search
2927
$m->form_name ('BuildQuery');
3028

31-
$m->field ( "ValueOfAttachment" => 'stupid');
32-
$m->field ( "SavedSearchDescription" => 'stupid tickets');
29+
$m->field ( "ValueOfAttachment" => 'awesome');
30+
$m->field ( "SavedSearchName" => 'awesome tickets');
31+
$m->field ( "SavedSearchDescription" => 'awesome tickets');
3332
$m->click_button (name => 'SavedSearchSave');
3433

3534
$m->get_ok( $url . "Dashboards/Modify.html?Create=1" );
@@ -38,7 +37,7 @@ $m->field( Name => 'My RTIR homepage' );
3837
$m->click_button( value => 'Create' );
3938

4039
$m->follow_link_ok( { text => 'Content' } );
41-
$m->content_contains('stupid tickets', 'saved search listed in rt at a glance items');
40+
$m->content_contains('awesome tickets', 'saved search listed in rt at a glance items');
4241

4342
# Grant rights for RTIR Constituency to get around warnings on create page
4443
my $constituency_cf = RT::CustomField->new(RT->SystemUser);
@@ -70,18 +69,13 @@ $m->click_button( value => 'Create' );
7069
my ($id) = ( $m->uri =~ /id=(\d+)/ );
7170
ok( $id, "got a dashboard ID, $id" );
7271

72+
# remove all portlets from the body pane except 'newest unowned tickets'
7373
my $args = {
74-
UpdateSearches => "Save",
75-
body => [],
76-
sidebar => [],
74+
Update => "Save Changes",
75+
Content => "[{\"Layout\":\"col-md-6\",\"Elements\":[[{\"id\":2,\"portlet_type\":\"search\",\"description\":\"Ticket: Unowned Tickets\"}],[]]}]",
7776
};
7877

7978
$m->follow_link_ok( { text => 'Content' } );
80-
# remove all portlets from the body pane except 'newest unowned tickets'
81-
push(
82-
@{$args->{body}},
83-
"saved-" . $m->dom->find('[data-description="Unowned Tickets"]')->first->attr('data-name'),
84-
);
8579

8680
my $res = $m->post(
8781
$url . "Dashboards/Queries.html?id=$id",
@@ -108,17 +102,8 @@ $m->content_lacks( 'Quick ticket creation', "'Quick ticket creation' is not pres
108102
$m->get_ok( $url . "Dashboards/Queries.html?id=$id" );
109103

110104
# add back the previously removed portlets
111-
push(
112-
@{$args->{body}},
113-
"saved-" . $m->dom->find('[data-description="My Tickets"]')->first->attr('data-name'),
114-
"saved-" . $m->dom->find('[data-description="Bookmarked Tickets"]')->first->attr('data-name'),
115-
"component-QuickCreate",
116-
);
117-
118-
push(
119-
@{$args->{sidebar}},
120-
( "component-MyReminders", "component-QueueList", "component-Dashboards", "component-RefreshHomepage", )
121-
);
105+
$args->{Content} =
106+
"[{\"Layout\":\"col-md-6\",\"Elements\":[[{\"id\":1,\"description\":\"Ticket: My Tickets\",\"portlet_type\":\"search\"},{\"portlet_type\":\"search\",\"description\":\"Ticket: Unowned Tickets\",\"id\":2},{\"description\":\"Ticket: Bookmarked Tickets\",\"portlet_type\":\"search\",\"id\":3},{\"component\":\"QuickCreate\",\"description\":\"QuickCreate\",\"portlet_type\":\"component\",\"path\":\"/Elements/QuickCreate\"}],[{\"path\":\"/Elements/MyReminders\",\"portlet_type\":\"component\",\"description\":\"MyReminders\",\"component\":\"MyReminders\"},{\"description\":\"QueueList\",\"portlet_type\":\"component\",\"path\":\"/Elements/QueueList\",\"component\":\"QueueList\"},{\"portlet_type\":\"component\",\"path\":\"/Elements/Dashboards\",\"description\":\"Dashboards\",\"component\":\"Dashboards\"}]]}]";
122107

123108
$res = $m->post(
124109
$url . "Dashboards/Queries.html?id=$id",
@@ -132,26 +117,25 @@ $m->content_contains( 'Dashboard updated' );
132117
$m->get( $url."RTIR/" );
133118
$m->content_contains( 'newest unowned tickets', "'newest unowned tickets' is present" );
134119
$m->content_contains( 'highest priority tickets', "'highest priority tickets' is present" );
135-
$m->content_contains( 'Bookmarked Tickets<span class="results-count">', "'Bookmarked Tickets' is present" );
120+
$m->content_contains( '>Bookmarked Tickets</a>', "'Bookmarked Tickets' is present" );
136121
$m->content_contains( 'Quick ticket creation', "'Quick ticket creation' is present" );
137122

138123
#create a saved search with special chars
139124
$m->get( $url . "Search/Build.html" );
140125
$m->form_name('BuildQuery');
141-
$m->field( "ValueOfAttachment" => 'stupid' );
126+
$m->field( "ValueOfAttachment" => 'awesome' );
127+
$m->field( "SavedSearchName" => 'special chars [test] [_1] ~[_1~]' );
142128
$m->field( "SavedSearchDescription" => 'special chars [test] [_1] ~[_1~]' );
143129
$m->click_button( name => 'SavedSearchSave' );
144-
my ($name) = $m->content =~ /value="(RT::User-\d+-SavedSearch-\d+)"/;
145-
ok( $name, 'saved search name' );
130+
my ($saved_search_id) = $m->content =~ /\<option value\="(\d+)"\>special chars \[test\]/;
131+
ok( $saved_search_id, "got saved search id $saved_search_id");
146132
$m->get_ok( $url . "Dashboards/Queries.html?id=$id" );
147133
$m->content_contains( 'special chars [test] [_1] ~[_1~]',
148134
'saved search listed in rt at a glance items' );
149135

150136
# add saved search to body
151-
push(
152-
@{$args->{body}},
153-
( "saved-" . $name )
154-
);
137+
$args->{Content} =
138+
"[{\"Layout\":\"col-md-6\",\"Elements\":[[{\"id\":1,\"description\":\"Ticket: My Tickets\",\"portlet_type\":\"search\"},{\"portlet_type\":\"search\",\"description\":\"Ticket: Unowned Tickets\",\"id\":2},{\"description\":\"Ticket: Bookmarked Tickets\",\"portlet_type\":\"search\",\"id\":3},{\"component\":\"QuickCreate\",\"description\":\"QuickCreate\",\"portlet_type\":\"component\",\"path\":\"/Elements/QuickCreate\"},{\"id\":5,\"description\":\"Ticket: special chars [test] [_1] ~[_1~]\",\"portlet_type\":\"search\"}],[{\"path\":\"/Elements/MyReminders\",\"portlet_type\":\"component\",\"description\":\"MyReminders\",\"component\":\"MyReminders\"},{\"description\":\"QueueList\",\"portlet_type\":\"component\",\"path\":\"/Elements/QueueList\",\"component\":\"QueueList\"},{\"portlet_type\":\"component\",\"path\":\"/Elements/Dashboards\",\"description\":\"Dashboards\",\"component\":\"Dashboards\"}]]}]";
155139

156140
$res = $m->post(
157141
$url . "Dashboards/Queries.html?id=$id",
@@ -168,19 +152,19 @@ $m->content_like( qr/special chars \[test\] \d+ \[_1\]/,
168152

169153
# Edit a system saved search to contain "[more]"
170154
{
171-
my $search = RT::Attribute->new( RT->SystemUser );
172-
$search->LoadByNameAndObject( Name => 'Search - My Tickets', Object => RT->System );
173-
my ($id, $desc) = ($search->id, RT->SystemUser->loc($search->Description, '&#34;N&#34;'));
174-
ok $id, 'loaded search attribute';
155+
my $search = RT::SavedSearch->new( RT->SystemUser );
156+
$search->LoadByCols( Name => 'My Tickets' );
157+
my ($id, $name) = ($search->id, RT->SystemUser->loc($search->Name, '&#34;N&#34;'));
158+
ok $id, "loaded search record $id";
175159

176160
$m->get( $url."RTIR/" );
177-
$m->follow_link_ok({ url_regex => qr"Prefs/Search\.html\?name=.+?Attribute-$id" }, 'Edit link');
178-
$m->content_contains($desc, "found description: $desc");
161+
$m->follow_link_ok({ url_regex => qr"Prefs/Search\.html\?id=$id" }, 'Edit link');
162+
$m->content_contains($name, "found search name: $name");
179163

180-
ok +($search->SetDescription( $search->Description . " [more]" ));
164+
ok +($search->SetName( $search->Name . " [more]" ));
181165

182166
$m->get_ok($m->uri); # "reload_ok"
183-
$m->content_contains($desc . " [more]", "found description: $desc");
167+
$m->content_contains($name . " [more]", "found search name: $name");
184168
}
185169

186170
done_testing;

0 commit comments

Comments
 (0)