[Rt-commit] rt branch, 5.0/lifecycle-ui-mappings-handle-dashes, created. rt-5.0.0-116-ga8e2ae3f4c
Craig Kaiser
craig at bestpractical.com
Mon Nov 16 18:38:30 EST 2020
The branch, 5.0/lifecycle-ui-mappings-handle-dashes has been created
at a8e2ae3f4ccc0bd011956077fab147eb65c8be0e (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 93a6b498e0e68b27baa6cafdf54d7374f426cc29
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/lifecycles/utils.pl b/t/lifecycles/utils.pl
index cd167d668e..0bfe800827 100644
--- a/t/lifecycles/utils.pl
+++ b/t/lifecycles/utils.pl
@@ -66,6 +66,12 @@ Set(\%Lifecycles,
active => ['on-your-mark', 'get-set', 'go'],
inactive => ['first', 'second', 'third', 'no-place'],
},
+ foo => {
+ type => 'ticket',
+ initial => ['initial'],
+ active => ['active'],
+ inactive => ['inactive'],
+ }
);
END
}
diff --git a/t/web/lifecycle_mappings.t b/t/web/lifecycle_mappings.t
new file mode 100644
index 0000000000..f98dd122bb
--- /dev/null
+++ b/t/web/lifecycle_mappings.t
@@ -0,0 +1,132 @@
+use strict;
+use warnings;
+
+BEGIN {require './t/lifecycles/utils.pl'};
+
+my ( $url, $m ) = RT::Test->started_ok;
+
+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();
+ my ($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 a8593061a525ced1ee3db3dae609c991dbb4124d
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 a8e2ae3f4ccc0bd011956077fab147eb65c8be0e
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/lifecycles/types.t b/t/lifecycles/types.t
index 84cfd86277..bf6e4069b6 100644
--- a/t/lifecycles/types.t
+++ b/t/lifecycles/types.t
@@ -3,13 +3,13 @@ use warnings;
BEGIN {require './t/lifecycles/utils.pl'};
-is_deeply( [ RT::Lifecycle->ListAll ], [qw/ approvals default delivery /],
+is_deeply( [ RT::Lifecycle->ListAll ], [qw/ approvals default delivery foo sales sales-engineering/],
"Get the list of all lifecycles (implicitly for for tickets)");
-is_deeply( [ RT::Lifecycle->ListAll('ticket') ], [qw/ approvals default delivery /],
+is_deeply( [ RT::Lifecycle->ListAll('ticket') ], [qw/ approvals default delivery foo sales sales-engineering/],
"Get the list of all lifecycles for tickets");
-is_deeply( [ RT::Lifecycle->List], [qw/ default delivery /],
+is_deeply( [ RT::Lifecycle->List], [qw/ default delivery foo sales sales-engineering /],
"Get the list of lifecycles without approvals (implicitly for for tickets)");
-is_deeply( [ RT::Lifecycle->List('ticket') ], [qw/ default delivery /],
+is_deeply( [ RT::Lifecycle->List('ticket') ], [qw/ default delivery foo sales sales-engineering/],
"Get the list of lifecycles without approvals for tickets");
is_deeply( [ RT::Lifecycle->List('racecar') ], [qw/ racing /],
"Get the list of lifecycles for other types");
@@ -19,7 +19,7 @@ ok($tickets, "Got a generalized lifecycle for tickets");
isa_ok( $tickets, "RT::Lifecycle::Ticket", "Is the right subclass" );
is_deeply( [ sort $tickets->Valid ],
[ sort qw(new open stalled resolved rejected deleted ordered),
- 'on way', 'delayed', 'delivered' ],
+ 'on way', 'delayed', 'delivered', 'sales', 'engineering', 'initial', 'active', 'inactive'],
"Only gets ticket statuses" );
diff --git a/t/lifecycles/utils.pl b/t/lifecycles/utils.pl
index 0bfe800827..f71a894e43 100644
--- a/t/lifecycles/utils.pl
+++ b/t/lifecycles/utils.pl
@@ -71,6 +71,42 @@ Set(\%Lifecycles,
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" => "open",
+ "rejected" => "rejected",
+ "resolved" => "resolved",
+ "stalled" => "stalled"
+ },
}
);
END
diff --git a/t/web/lifecycle_mappings.t b/t/web/lifecycle_mappings.t
index f98dd122bb..f558d8b449 100644
--- a/t/web/lifecycle_mappings.t
+++ b/t/web/lifecycle_mappings.t
@@ -14,17 +14,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'
);
@@ -69,17 +69,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'
);
@@ -117,8 +117,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" );
@@ -129,4 +129,46 @@ diag "Confirm the web UI correctly displays mappings";
}
}
+diag "Test updating sales-engineering mappings";
+{
+ ok( $m->login( 'root', 'password' ), 'logged in' );
+
+ $m->get_ok( $url . '/Admin/Lifecycles/Mappings.html?Type=ticket&Name=sales-engineering' );
+
+ my $form = $m->form_name('ModifyMappings');
+ $m->submit_form(
+ fields => {
+ "map-sales-engineering--sales--default" => "new",
+ "map-sales-engineering--engineering--default" => "new", # Mapping we are changing
+ "map-sales-engineering--rejected--default" => "rejected",
+ "map-sales-engineering--resolved--default" => "resolved",
+ "map-sales-engineering--stalled--default" => "stalled",
+ "Name" => "sales-engineering",
+ "Type" => "ticket",
+ },
+ button => 'Update'
+ );
+ $m->content_contains( 'Lifecycle mappings updated' );
+ $form = $m->form_name('ModifyMappings');
+
+ my $from = {
+ sales => "new",
+ engineering => "new", # Changed mapping
+ stalled => "stalled",
+ rejected => "rejected",
+ resolved => "resolved",
+ deleted => "deleted",
+ };
+
+ # Ensure that the UI correctly reflects the changes we made
+ my @inputs = $form->inputs;
+ foreach my $input ( @inputs ) {
+ my ($sales_engineering, $status, $to) = $input->name =~ /^map-(sales-engineering)--(.*)--(default)$/;
+ next unless $from && $status && $to;
+ is ($input->value, $from->{$status}, "Mapping set correctly for sales-engineering -> default for status: $status" );
+ delete $from->{$status};
+ }
+ ok scalar keys %{$from} eq 0, "Checked all sales-engineering -> default mappings.";
+}
+
done_testing;
-----------------------------------------------------------------------
More information about the rt-commit
mailing list