[Rt-commit] rt 04/10: Update tests for the migration of "RT at a glance" => dashboard

sunnavy sunnavy at bestpractical.com
Fri Jul 9 16:30:24 EDT 2021


This is an automated email from the git hooks/post-receive script.

sunnavy pushed a commit to branch 5.0/use-dashboard-for-homepage-select-ui
in repository rt.

commit 949506b791a20db20ca9be7e43c236125f4eb18f
Author: sunnavy <sunnavy at bestpractical.com>
AuthorDate: Fri May 14 06:13:19 2021 +0800

    Update tests for the migration of "RT at a glance" => dashboard
---
 t/api/initialdata-roundtrip.t |  6 ++---
 t/web/custom_frontpage.t      | 56 +++++++++++++++++++++++++++++++++----------
 t/web/download_user_info.t    |  6 ++---
 3 files changed, 50 insertions(+), 18 deletions(-)

diff --git a/t/api/initialdata-roundtrip.t b/t/api/initialdata-roundtrip.t
index fbd349507d..e55223acc7 100644
--- a/t/api/initialdata-roundtrip.t
+++ b/t/api/initialdata-roundtrip.t
@@ -1026,10 +1026,10 @@ my @tests = (
         present => sub {
             # Provided in core initialdata
             my $homepage = RT::Attribute->new(RT->SystemUser);
-            $homepage->LoadByNameAndObject(Name => 'HomepageSettings', Object => RT->System);
+            $homepage->LoadByNameAndObject(Name => 'Dashboard', Description => 'Homepage', Object => RT->System);
             ok($homepage->Id, 'Loaded homepage attribute');
-            is($homepage->Name, 'HomepageSettings', 'Name is HomepageSettings');
-            is($homepage->Description, 'HomepageSettings', 'Description is HomepageSettings');
+            is($homepage->Name, 'Dashboard', 'Name is Dashboard');
+            is($homepage->Description, 'Homepage', 'Description is Homepage');
             is($homepage->ContentType, 'storable', 'ContentType is storable');
 
             my $root = RT::User->new(RT->SystemUser);
diff --git a/t/web/custom_frontpage.t b/t/web/custom_frontpage.t
index cbfcde0c55..9196c57683 100644
--- a/t/web/custom_frontpage.t
+++ b/t/web/custom_frontpage.t
@@ -16,6 +16,10 @@ $user_obj->PrincipalObj->GrantRight(Right => 'LoadSavedSearch');
 $user_obj->PrincipalObj->GrantRight(Right => 'EditSavedSearches');
 $user_obj->PrincipalObj->GrantRight(Right => 'CreateSavedSearch');
 $user_obj->PrincipalObj->GrantRight(Right => 'ModifySelf');
+$user_obj->PrincipalObj->GrantRight(Right => 'SeeDashboard');
+$user_obj->PrincipalObj->GrantRight(Right => 'SeeOwnDashboard');
+$user_obj->PrincipalObj->GrantRight(Right => 'CreateOwnDashboard');
+$user_obj->PrincipalObj->GrantRight(Right => 'ModifyOwnDashboard');
 
 ok $m->login( customer => 'customer' ), "logged in";
 
@@ -28,11 +32,24 @@ $m->field ( "ValueOfAttachment" => 'stupid');
 $m->field ( "SavedSearchDescription" => 'stupid tickets');
 $m->click_button (name => 'SavedSearchSave');
 
-$m->get ( $url.'Prefs/MyRT.html' );
+$m->get_ok( $url . "Dashboards/Modify.html?Create=1" );
+$m->form_name('ModifyDashboard');
+$m->field( Name => 'My homepage' );
+$m->click_button( value => 'Create' );
+
+$m->follow_link_ok( { text => 'Content' } );
 $m->content_contains('stupid tickets', 'saved search listed in rt at a glance items');
 
 ok $m->login('root', 'password', logout => 1), 'we did log in as root';
 
+$m->get_ok( $url . "Dashboards/Modify.html?Create=1" );
+$m->form_name('ModifyDashboard');
+$m->field( Name => 'My homepage' );
+$m->click_button( value => 'Create' );
+
+my ($id) = ( $m->uri =~ /id=(\d+)/ );
+ok( $id, "got a dashboard ID, $id" );
+
 my $args = {
     UpdateSearches => "Save",
     dashboard_id   => "MyRT",
@@ -41,18 +58,28 @@ my $args = {
 };
 
 # remove all portlets from the body pane except 'newest unowned tickets'
+$m->follow_link_ok( { text => 'Content' } );
 push(
     @{$args->{body}},
-    ( "system-Unowned Tickets", )
+    "saved-" . $m->dom->find('[data-description="Unowned Tickets"]')->first->attr('data-name'),
 );
 
 my $res = $m->post(
-    $url . 'Prefs/MyRT.html',
+    $url . "Dashboards/Queries.html?id=$id",
     $args,
 );
 
 is( $res->code, 200, "remove all portlets from body except 'newest unowned tickets'" );
 like( $m->uri, qr/results=[A-Za-z0-9]{32}/, 'URL redirected for results' );
+$m->content_contains( 'Dashboard updated' );
+
+$m->get_ok( $url . 'Prefs/MyRT.html' );
+$m->submit_form_ok(
+    {   form_name => 'UpdateDefaultDashboard',
+        button    => "DefaultDashboard-$id",
+    },
+);
+
 $m->content_contains( 'Preferences saved' );
 
 $m->get( $url );
@@ -61,10 +88,14 @@ $m->content_lacks( 'highest priority tickets', "'highest priority tickets' is no
 $m->content_lacks( 'Bookmarked Tickets<span class="results-count">', "'Bookmarked Tickets' is not present" );  # 'Bookmarked Tickets' also shows up in the nav, so we need to be more specific
 $m->content_lacks( 'Quick ticket creation', "'Quick ticket creation' is not present" );
 
+$m->get_ok( $url . "Dashboards/Queries.html?id=$id" );
+
 # add back the previously removed portlets
 push(
     @{$args->{body}},
-    ( "system-My Tickets", "system-Bookmarked Tickets", "component-QuickCreate" )
+    "saved-" . $m->dom->find('[data-description="My Tickets"]')->first->attr('data-name'),
+    "saved-" . $m->dom->find('[data-description="Bookmarked Tickets"]')->first->attr('data-name'),
+    "component-QuickCreate",
 );
 
 push(
@@ -73,13 +104,13 @@ push(
 );
 
 $res = $m->post(
-    $url . 'Prefs/MyRT.html',
+    $url . "Dashboards/Queries.html?id=$id",
     $args,
 );
 
 is( $res->code, 200, 'add back previously removed portlets' );
 like( $m->uri, qr/results=[A-Za-z0-9]{32}/, 'URL redirected for results' );
-$m->content_contains( 'Preferences saved' );
+$m->content_contains( 'Dashboard updated' );
 
 $m->get( $url );
 $m->content_contains( 'newest unowned tickets', "'newest unowned tickets' is present" );
@@ -95,7 +126,8 @@ $m->field( "SavedSearchDescription" => 'special chars [test] [_1] ~[_1~]' );
 $m->click_button( name => 'SavedSearchSave' );
 my ($name) = $m->content =~ /value="(RT::User-\d+-SavedSearch-\d+)"/;
 ok( $name, 'saved search name' );
-$m->get( $url . 'Prefs/MyRT.html' );
+
+$m->get_ok( $url . "Dashboards/Queries.html?id=$id" );
 $m->content_contains( 'special chars [test] [_1] ~[_1~]',
     'saved search listed in rt at a glance items' );
 
@@ -106,13 +138,13 @@ push(
 );
 
 $res = $m->post(
-    $url . 'Prefs/MyRT.html',
+    $url . "Dashboards/Queries.html?id=$id",
     $args,
 );
 
 is( $res->code, 200, 'add saved search to body' );
 like( $m->uri, qr/results=[A-Za-z0-9]{32}/, 'URL redirected for results' );
-$m->content_contains( 'Preferences saved' );
+$m->content_contains( 'Dashboard updated' );
 
 $m->get($url);
 $m->content_like( qr/special chars \[test\] \d+ \[_1\]/,
@@ -161,7 +193,7 @@ $m->submit_form(
 # We don't show saved message on page :/
 $m->content_contains("Save as New", 'saved first txn search' );
 
-$m->get_ok( $url . 'Prefs/MyRT.html' );
+$m->get_ok( $url . "Dashboards/Queries.html?id=$id" );
 push(
     @{$args->{body}},
     "saved-" . $m->dom->find('[data-description="first chart"]')->first->attr('data-name'),
@@ -169,12 +201,12 @@ push(
 );
 
 $res = $m->post(
-    $url . 'Prefs/MyRT.html',
+    $url . "Dashboards/Queries.html?id=$id",
     $args,
 );
 
 is( $res->code, 200, 'add system saved searches to body' );
-$m->text_contains( 'Preferences saved' );
+$m->content_contains( 'Dashboard updated' );
 
 $m->get_ok($url);
 $m->text_contains('first chart');
diff --git a/t/web/download_user_info.t b/t/web/download_user_info.t
index 06ade8e624..79e381cbc3 100644
--- a/t/web/download_user_info.t
+++ b/t/web/download_user_info.t
@@ -62,9 +62,9 @@ EOF
 
     my $transaction_info_tsv = <<EOF;
 Ticket Id\tid\tCreated\tDescription\tOldValue\tNewValue\tContent
-1\t30\t$date_created\tTicket created\t\t\tThis transaction appears to have no content
-1\t32\t$date_commented\tComments added\t\t\tTest - Comment
-1\t33\t$date_correspondence\tCorrespondence added\t\t\tTest - Reply
+1\t32\t$date_created\tTicket created\t\t\tThis transaction appears to have no content
+1\t34\t$date_commented\tComments added\t\t\tTest - Comment
+1\t35\t$date_correspondence\tCorrespondence added\t\t\tTest - Reply
 EOF
 
     is $agent->content, $transaction_info_tsv,

-- 
To stop receiving notification emails like this one, please contact
sysadmin at bestpractical.com.


More information about the rt-commit mailing list