[Rt-commit] rt branch, 5.0/lifecycle-ui-mappings-handle-dashes, created. rt-5.0.0-116-gad800aac85
Craig Kaiser
craig at bestpractical.com
Mon Nov 16 14:49:42 EST 2020
The branch, 5.0/lifecycle-ui-mappings-handle-dashes has been created
at ad800aac85ecf1fc030a144973f0297c961e2f4e (commit)
- Log -----------------------------------------------------------------
commit 160f41a5e69a6e407945c1304cc681558e943b40
Author: craig kaiser <craig at bestpractical.com>
Date: Fri Oct 30 16:07:53 2020 -0400
Update instructions for lifecycle mapping page to mention assets
diff --git a/share/html/Admin/Lifecycles/Mappings.html b/share/html/Admin/Lifecycles/Mappings.html
index 0da577941b..ce18f4cc8d 100644
--- a/share/html/Admin/Lifecycles/Mappings.html
+++ b/share/html/Admin/Lifecycles/Mappings.html
@@ -50,7 +50,7 @@
<& /Elements/ListActions, actions => \@results &>
<div class="form-row">
<div class="col-12">
- <p><&|/l&>If a ticket is moved from one queue or catalog to another, these mappings define how statuses should be updated.</&></p>
+ <p><&|/l&>If a ticket or asset is moved from one queue or catalog to another, these mappings define how statuses should be updated.</&></p>
</div>
</div>
commit de643a6cf9b7b2ec2c15e31ffa17b4e1ca50e640
Author: craig kaiser <craig at bestpractical.com>
Date: Tue Nov 3 16:41:49 2020 -0500
Add general tests for the lifecycle Mappings.html page
diff --git a/t/web/lifecycle_mappings.t b/t/web/lifecycle_mappings.t
new file mode 100644
index 0000000000..f025bb4feb
--- /dev/null
+++ b/t/web/lifecycle_mappings.t
@@ -0,0 +1,152 @@
+use strict;
+use warnings;
+
+use RT::Test tests => undef;
+
+my ( $url, $m ) = RT::Test->started_ok;
+
+my $lifecycleObj = RT::Lifecycle->new();
+my $lifecycles = RT->Config->Get('Lifecycles');
+
+my $new_lifecycle = {
+ %{$lifecycles},
+ foo => {
+ type => 'ticket',
+ initial => ['initial'],
+ active => ['active'],
+ inactive => ['inactive'],
+ }
+};
+
+my ($ret, $msg) = $lifecycleObj->_SaveLifecycles(
+ $new_lifecycle,
+ RT->SystemUser,
+);
+ok $ret, "Updated lifecycle successfully";
+RT::Lifecycle->FillCache();
+
+diag "Test updating mappings";
+{
+ ok( $m->login( 'root', 'password' ), 'logged in' );
+
+ $m->get_ok( $url . '/Admin/Lifecycles/Mappings.html?Type=ticket&Name=default' );
+
+ my $form = $m->form_name('ModifyMappings');
+ $m->submit_form(
+ fields => {
+ "map-default-new--foo" => "initial",
+ "map-default-open--foo" => "active",
+ "map-default-resolved--foo" => "inactive",
+ "map-foo-initial--default" => "new",
+ "map-foo-active--default" => "open",
+ "map-foo-inactive--default" => "resolved",
+ "map-default-deleted--foo" => "inactive",
+ "map-default-rejected--foo" => "inactive",
+ "map-default-stalled--foo" => "active",
+ "Name" => "default",
+ "Type" => "ticket",
+ },
+ button => 'Update'
+ );
+ $m->content_contains( 'Lifecycle mappings updated' );
+
+ RT::Test->stop_server;
+ RT->Config->LoadConfigFromDatabase();
+ ( $url, $m ) = RT::Test->started_ok;
+ ok( $m->login( 'root', 'password' ), 'logged in' );
+
+ RT::Lifecycle->FillCache();
+
+ my $foo = RT::Lifecycle->new();
+ ($ret, $msg) = $foo->Load( Name => 'foo', Type => 'ticket' );
+ ok $ret, "Loaded lifecycle foo successfully";
+
+ my $default = RT::Lifecycle->new();
+ ($ret, $msg) = $default->Load( Name => 'default', Type => 'ticket' );
+ ok $ret, "Loaded lifecycle default successfully";
+
+ my $from = {
+ deleted => "inactive",
+ new => "initial",
+ open => "active",
+ rejected => "inactive",
+ resolved => "inactive",
+ stalled => "active"
+ };
+
+ my $to = {
+ active => "open",
+ inactive => "resolved",
+ initial => "new",
+ };
+
+ is_deeply( $from, $default->MoveMap( $foo ), "Move map from default -> foo set correctly" );
+ is_deeply( $to, $foo->MoveMap( $default ), "Move map from foo -> default set correctly" );
+
+ $from->{'new'} = 'active';
+
+ $m->get_ok( $url . '/Admin/Lifecycles/Mappings.html?Type=ticket&Name=default' );
+ $form = $m->form_name('ModifyMappings');
+ $m->submit_form(
+ fields => {
+ "map-default-new--foo" => "active",
+ "map-default-open--foo" => "active",
+ "map-default-resolved--foo" => "inactive",
+ "map-foo-initial--default" => "new",
+ "map-foo-active--default" => "open",
+ "map-foo-inactive--default" => "resolved",
+ "map-default-deleted--foo" => "inactive",
+ "map-default-rejected--foo" => "inactive",
+ "map-default-stalled--foo" => "active",
+ "Name" => "default",
+ "Type" => "ticket",
+ },
+ button => 'Update'
+ );
+ $m->content_contains( 'Lifecycle mappings updated' );
+
+ RT::Test->stop_server;
+ RT->Config->LoadConfigFromDatabase();
+ ( $url, $m ) = RT::Test->started_ok;
+ RT::Lifecycle->FillCache();
+
+ is_deeply( $from, $default->MoveMap( $foo ), "Move map from default -> foo updated correctly" );
+}
+
+diag "Confirm the web UI correctly displays mappings";
+{
+ ok( $m->login( 'root', 'password' ), 'logged in' );
+
+ $m->get_ok( $url . '/Admin/Lifecycles/Mappings.html?Type=ticket&Name=default' );
+ my $form = $m->form_name('ModifyMappings');
+
+ my $from = {
+ deleted => "inactive",
+ new => "active",
+ open => "active",
+ rejected => "inactive",
+ resolved => "inactive",
+ stalled => "active"
+ };
+
+ my $to = {
+ active => "open",
+ inactive => "resolved",
+ initial => "new",
+ };
+
+ my @inputs = $form->inputs;
+ foreach my $input ( @inputs ) {
+ my ($default_from, $default_status, $default_to) = $input->name =~ /^map-(default)-(.*)--(foo)$/;
+ my ($foo_from, $foo_status, $foo_to) = $input->name =~ /^map-(default)-(.*)--(foo)$/;
+
+ if ( $default_from ) {
+ is ($input->value, $from->{$default_status}, "Mapping set correctly for default -> foo for status: $default_status" );
+ }
+ elsif ( $foo_from ) {
+ is ( $input->value, $to->{$foo_status}, "Mapping set correctly for foo -> default for status: $foo_status" );
+ }
+ }
+}
+
+done_testing;
commit 12443d485a55116c73850474102be3249781010b
Author: craig kaiser <craig at bestpractical.com>
Date: Mon Nov 16 14:37:45 2020 -0500
Update mapping form submission parsing to handle '-' in lifecycle name
diff --git a/share/html/Admin/Lifecycles/Mappings.html b/share/html/Admin/Lifecycles/Mappings.html
index ce18f4cc8d..d487fedc3a 100644
--- a/share/html/Admin/Lifecycles/Mappings.html
+++ b/share/html/Admin/Lifecycles/Mappings.html
@@ -74,7 +74,7 @@
<% $OtherStatus %>:
</div>
<div class="col-8 value">
- <& /Elements/SelectStatus, Statuses => \@MyStatuses, Default => $FromMapping->{$OtherStatus}, Name => 'map-' . $Other->Name . '-' . $OtherStatus . '--' . $LifecycleObj->Name&>
+ <& /Elements/SelectStatus, Statuses => \@MyStatuses, Default => $FromMapping->{$OtherStatus}, Name => 'map-' . $Other->Name . '--' . $OtherStatus . '--' . $LifecycleObj->Name&>
</div>
</div>
% }
@@ -88,7 +88,7 @@
<% $MyStatus %>:
</div>
<div class="col-8 value">
- <& /Elements/SelectStatus, Statuses => \@OtherStatuses, Default => $ToMapping->{$MyStatus}, Name => 'map-' . $LifecycleObj->Name . '-' . $MyStatus . '--' . $Other->Name &>
+ <& /Elements/SelectStatus, Statuses => \@OtherStatuses, Default => $ToMapping->{$MyStatus}, Name => 'map-' . $LifecycleObj->Name . '--' . $MyStatus . '--' . $Other->Name &>
</div>
</div>
% }
@@ -128,7 +128,7 @@ if ($Update) {
my %maps;
my $lifecycle_re = join '|', map { quotemeta($_) } @lifecycle_names;
for my $key (keys %ARGS) {
- my ($from_lifecycle, $from_status, $to_lifecycle) = $key =~ /^map-($lifecycle_re)-(.*)--($lifecycle_re)$/ or next;
+ my ($from_lifecycle, $from_status, $to_lifecycle) = $key =~ /^map-($lifecycle_re)--(.*)--($lifecycle_re)$/ or next;
if (my $to_status = $ARGS{$key}) {
$maps{"$from_lifecycle -> $to_lifecycle"}{$from_status} = $to_status;
}
commit ad800aac85ecf1fc030a144973f0297c961e2f4e
Author: craig kaiser <craig at bestpractical.com>
Date: Tue Nov 3 18:01:04 2020 -0500
Add test for when lifecycle has '-' in name
When a lifecycle name has a dash in it the regex used to determine
mappings between lifecycles will break at the "-". Meaning if we have
one lifecycle named "sales" and one named "sales-engineering" the
Mappings.html submission will interpret mappings forthe "sales-engineering"
lifecycle as a submission for the "sales" lifecycle.
diff --git a/t/web/lifecycle_mappings.t b/t/web/lifecycle_mappings.t
index f025bb4feb..79cfe0897d 100644
--- a/t/web/lifecycle_mappings.t
+++ b/t/web/lifecycle_mappings.t
@@ -15,6 +15,42 @@ my $new_lifecycle = {
initial => ['initial'],
active => ['active'],
inactive => ['inactive'],
+ },
+ "sales" => {
+ type => 'ticket',
+ initial => ['initial'],
+ active => ['active'],
+ inactive => ['inactive'],
+ },
+ "sales-engineering" => {
+ "initial" => ["sales"],
+ "active" => [
+ "engineering",
+ "stalled"
+ ],
+ "inactive" => [
+ "resolved",
+ "rejected",
+ "deleted"
+ ],
+ },
+ "__maps__" => {
+ "default -> sales-engineering" => {
+ "deleted" => "deleted",
+ "new" => "sales",
+ "open" => "engineering",
+ "rejected" => "rejected",
+ "resolved" => "resolved",
+ "stalled" => "stalled"
+ },
+ "sales-engineering -> default" => {
+ "deleted" => "deleted",
+ "sales" => "new",
+ "engineering" => "new", # We want this to be different than the sales mapping
+ "rejected" => "rejected",
+ "resolved" => "resolved",
+ "stalled" => "stalled"
+ },
}
};
@@ -34,17 +70,17 @@ diag "Test updating mappings";
my $form = $m->form_name('ModifyMappings');
$m->submit_form(
fields => {
- "map-default-new--foo" => "initial",
- "map-default-open--foo" => "active",
- "map-default-resolved--foo" => "inactive",
- "map-foo-initial--default" => "new",
- "map-foo-active--default" => "open",
- "map-foo-inactive--default" => "resolved",
- "map-default-deleted--foo" => "inactive",
- "map-default-rejected--foo" => "inactive",
- "map-default-stalled--foo" => "active",
- "Name" => "default",
- "Type" => "ticket",
+ "map-default--new--foo" => "initial",
+ "map-default--open--foo" => "active",
+ "map-default--resolved--foo" => "inactive",
+ "map-foo--initial--default" => "new",
+ "map-foo--active--default" => "open",
+ "map-foo--inactive--default" => "resolved",
+ "map-default--deleted--foo" => "inactive",
+ "map-default--rejected--foo" => "inactive",
+ "map-default--stalled--foo" => "active",
+ "Name" => "default",
+ "Type" => "ticket",
},
button => 'Update'
);
@@ -89,17 +125,17 @@ diag "Test updating mappings";
$form = $m->form_name('ModifyMappings');
$m->submit_form(
fields => {
- "map-default-new--foo" => "active",
- "map-default-open--foo" => "active",
- "map-default-resolved--foo" => "inactive",
- "map-foo-initial--default" => "new",
- "map-foo-active--default" => "open",
- "map-foo-inactive--default" => "resolved",
- "map-default-deleted--foo" => "inactive",
- "map-default-rejected--foo" => "inactive",
- "map-default-stalled--foo" => "active",
- "Name" => "default",
- "Type" => "ticket",
+ "map-default--new--foo" => "active",
+ "map-default--open--foo" => "active",
+ "map-default--resolved--foo" => "inactive",
+ "map-foo--initial--default" => "new",
+ "map-foo--active--default" => "open",
+ "map-foo--inactive--default" => "resolved",
+ "map-default--deleted--foo" => "inactive",
+ "map-default--rejected--foo" => "inactive",
+ "map-default--stalled--foo" => "active",
+ "Name" => "default",
+ "Type" => "ticket",
},
button => 'Update'
);
@@ -137,8 +173,8 @@ diag "Confirm the web UI correctly displays mappings";
my @inputs = $form->inputs;
foreach my $input ( @inputs ) {
- my ($default_from, $default_status, $default_to) = $input->name =~ /^map-(default)-(.*)--(foo)$/;
- my ($foo_from, $foo_status, $foo_to) = $input->name =~ /^map-(default)-(.*)--(foo)$/;
+ my ($default_from, $default_status, $default_to) = $input->name =~ /^map-(default)--(.*)--(foo)$/;
+ my ($foo_from, $foo_status, $foo_to) = $input->name =~ /^map-(default)--(.*)--(foo)$/;
if ( $default_from ) {
is ($input->value, $from->{$default_status}, "Mapping set correctly for default -> foo for status: $default_status" );
-----------------------------------------------------------------------
More information about the rt-commit
mailing list