[Rt-commit] rt branch, 5.0/lifecycle-ui-mappings-fixes, created. rt-5.0.0-118-g5a71e1150b
Craig Kaiser
craig at bestpractical.com
Thu Nov 12 16:48:44 EST 2020
The branch, 5.0/lifecycle-ui-mappings-fixes has been created
at 5a71e1150ba43fe247f09c22df04bdbc617d9aee (commit)
- Log -----------------------------------------------------------------
commit 6e2f8685dd3b82fa13cbdd7bfbc593b0048e9059
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 df4ec62c0fc40a5dd9b32132ee95c75e7d20d7a0
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..d797a4d8a1
--- /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_to" );
+ }
+ }
+}
+
+done_testing;
commit 845a3c8ed54e6ba574e5c87cbbbd8950ac16ea75
Author: craig kaiser <craig at bestpractical.com>
Date: Tue Nov 3 16:43:01 2020 -0500
Add test for case variant statuses in mappings
diff --git a/t/web/lifecycle_mappings.t b/t/web/lifecycle_mappings.t
index d797a4d8a1..1c907676bd 100644
--- a/t/web/lifecycle_mappings.t
+++ b/t/web/lifecycle_mappings.t
@@ -13,7 +13,7 @@ my $new_lifecycle = {
foo => {
type => 'ticket',
initial => ['initial'],
- active => ['active'],
+ active => ['active', 'case-Variant-Status'],
inactive => ['inactive'],
}
};
@@ -42,7 +42,7 @@ diag "Test updating mappings";
"map-foo-inactive--default" => "resolved",
"map-default-deleted--foo" => "inactive",
"map-default-rejected--foo" => "inactive",
- "map-default-stalled--foo" => "active",
+ "map-default-stalled--foo" => "case-Variant-Status",
"Name" => "default",
"Type" => "ticket",
},
@@ -71,7 +71,7 @@ diag "Test updating mappings";
open => "active",
rejected => "inactive",
resolved => "inactive",
- stalled => "active"
+ stalled => "case-variant-status"
};
my $to = {
@@ -97,7 +97,7 @@ diag "Test updating mappings";
"map-foo-inactive--default" => "resolved",
"map-default-deleted--foo" => "inactive",
"map-default-rejected--foo" => "inactive",
- "map-default-stalled--foo" => "active",
+ "map-default-stalled--foo" => "case-variant-status",
"Name" => "default",
"Type" => "ticket",
},
@@ -126,7 +126,7 @@ diag "Confirm the web UI correctly displays mappings";
open => "active",
rejected => "inactive",
resolved => "inactive",
- stalled => "active"
+ stalled => "case-variant-status"
};
my $to = {
commit 4d90179ee5dbc02e3439132d2eb6955525f4f096
Author: craig kaiser <craig at bestpractical.com>
Date: Fri Oct 30 16:06:09 2020 -0400
Return lower case statuses from RT::Lifecycle->Valid
Per:
15857be24af0955e5eeb46e6bab96378704e1e09
Statuses are stored in lower-case, in order for the 'Valid' method to be
used to compare statuses with the results of other methods such as
RT::Lifecycle->MoveMap the values returned must also be lower-case.
diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index 7f39bd7d97..7a4f6ef31b 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -242,11 +242,11 @@ sub Valid {
my $self = shift;
my @types = @_;
unless ( @types ) {
- return @{ $self->{'data'}{''} || [] };
+ return map { lc $_ } @{ $self->{'data'}{''} || [] };
}
my @res;
- push @res, @{ $self->{'data'}{ $_ } || [] } foreach @types;
+ push @res, map { lc $_ } @{ $self->{'data'}{ $_ } || [] } foreach @types;
return @res;
}
commit 7adce3ad94bdd4101d380b9ea5e7b2f6f2b44f43
Author: craig kaiser <craig at bestpractical.com>
Date: Tue Nov 3 16:59:21 2020 -0500
Move code for parsing mappings form submissions to sub routine
diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index 7a4f6ef31b..b4515d0c21 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -953,6 +953,29 @@ sub UpdateMaps {
return (1, $CurrentUser->loc("Lifecycle mappings updated"));
}
+=head2 ParseMappingsInput
+
+Parse form submission from Mappings.html lifecycle UI page to fit the
+usual lifecycle __maps__ layout.
+
+=cut
+
+sub ParseMappingsInput {
+ my $args = shift;
+
+ my @lifecycle_names = grep { $_ ne 'approvals' } RT::Lifecycle->ListAll($args->{'Type'});
+
+ 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;
+ if ( my $to_status = $args->{$key} ) {
+ $maps{"$from_lifecycle -> $to_lifecycle"}{$from_status} = $to_status;
+ }
+ }
+ return %maps;
+}
+
=head2 ValidateLifecycle( CurrentUser => undef, Lifecycle => undef, Name => undef )
Validate passed Lifecycle data structure.
diff --git a/share/html/Admin/Lifecycles/Mappings.html b/share/html/Admin/Lifecycles/Mappings.html
index ce18f4cc8d..8d3fe8085a 100644
--- a/share/html/Admin/Lifecycles/Mappings.html
+++ b/share/html/Admin/Lifecycles/Mappings.html
@@ -125,14 +125,7 @@ MaybeRedirectForResults(
my @lifecycle_names = grep { $_ ne 'approvals' } RT::Lifecycle->ListAll($Type);
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;
- if (my $to_status = $ARGS{$key}) {
- $maps{"$from_lifecycle -> $to_lifecycle"}{$from_status} = $to_status;
- }
- }
+ my %maps = RT::Lifecycle::ParseMappingsInput( \%ARGS );
my ($ok, $msg) = RT::Lifecycle->UpdateMaps(
CurrentUser => $session{CurrentUser},
commit dd54d55914ef88b77c737d07db06eaf8d78e4013
Author: craig kaiser <craig at bestpractical.com>
Date: Tue Nov 3 17:55:20 2020 -0500
Add tests for RT::Lifecycle::ParseMappingsInput
diff --git a/t/web/lifecycle_mappings.t b/t/web/lifecycle_mappings.t
index 1c907676bd..e822d74665 100644
--- a/t/web/lifecycle_mappings.t
+++ b/t/web/lifecycle_mappings.t
@@ -144,7 +144,82 @@ diag "Confirm the web UI correctly displays mappings";
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_to" );
+ is ( $input->value, $to->{$foo_status}, "Mapping set correctly for foo -> default for status: $foo_status" );
+ }
+ }
+}
+
+diag "Test RT::Lifecycle::ParseMappingsInput method";
+{
+ my %args = (
+ "map-default-new--foo" => "initial",
+ "map-default-open--foo" => "active",
+ "map-default-stalled--foo" => "active",
+ "map-default-rejected--foo" => "inactive",
+ "map-default-resolved--foo" => "inactive",
+ "map-default-deleted--foo" => "inactive",
+
+ "map-foo-initial--default" => "new",
+ "map-foo-active--default" => "open",
+ "map-foo-inactive--default" => "resolved",
+ );
+ my %maps = RT::Lifecycle::ParseMappingsInput( \%args );
+
+ my %expected = (
+ 'default -> foo' => {
+ "new" => "initial",
+ "open" => "active",
+ "rejected" => "inactive",
+ "resolved" => "inactive",
+ "stalled" => "active",
+ "deleted" => "inactive",
+ },
+ 'foo -> default' => {
+ "initial" => "new",
+ "active" => "open",
+ "inactive" => "resolved",
+ }
+ );
+
+ is_deeply( \%expected, \%maps, "RT::Lifecycle::ParseMappingsInput method successfully parsed input." );
+
+ RT::Test->stop_server;
+ RT->Config->LoadConfigFromDatabase();
+ ( $url, $m ) = RT::Test->started_ok;
+ ok( $m->login( 'root', 'password' ), 'logged in' );
+ $lifecycles = RT->Config->Get('Lifecycles');
+
+ my %updated_maps = (%{$lifecycles->{'__maps__'}}, %maps);
+ $lifecycles->{'__maps__'} = \%updated_maps;
+
+ ($ret, $msg) = $lifecycleObj->_SaveLifecycles(
+ $lifecycles,
+ RT->SystemUser,
+ );
+ ok $ret, "Updated lifecycle successfully";
+
+ RT::Test->stop_server;
+ RT->Config->LoadConfigFromDatabase();
+ ( $url, $m ) = RT::Test->started_ok;
+ ok( $m->login( 'root', 'password' ), 'logged in' );
+ $lifecycles = RT->Config->Get('Lifecycles');
+
+ $m->get_ok( $url . '/Admin/Lifecycles/Mappings.html?Type=ticket&Name=foo' );
+ my $form = $m->form_name('ModifyMappings');
+
+ my $to = $expected{"default -> sales-engineering"};
+ my $from = $maps{"sales-engineering -> default"};
+
+ my @inputs = $form->inputs;
+ foreach my $input ( @inputs ) {
+ my ($default_from, $default_status, $default_to) = $input->name =~ /^map-(sales-engineering)-(.*)--(default)$/;
+ my ($sales_engineering_from, $sales_engineering_status, $sales_engineering_to) = $input->name =~ /^map-(default)-(.*)--(sales-engineering)$/;
+
+ if ( $default_from ) {
+ is ($input->value, $from->{$default_status}, "Mapping set correctly for default -> sales_engineering for status: $default_status" );
+ }
+ elsif ( $sales_engineering_from ) {
+ is ( $input->value, $to->{$sales_engineering_status}, "Mapping set correctly for sales_engineering -> default for status: $sales_engineering_to" );
}
}
}
commit d4fe5e7afc2aa637ec0ca4667c9b5db76ff642ed
Author: craig kaiser <craig at bestpractical.com>
Date: Tue Nov 3 17:57:51 2020 -0500
Update mapping form submission parsing to handle '-' in lifecycle name
diff --git a/lib/RT/Lifecycle.pm b/lib/RT/Lifecycle.pm
index b4515d0c21..2c34de60ed 100644
--- a/lib/RT/Lifecycle.pm
+++ b/lib/RT/Lifecycle.pm
@@ -968,7 +968,7 @@ sub ParseMappingsInput {
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;
}
diff --git a/share/html/Admin/Lifecycles/Mappings.html b/share/html/Admin/Lifecycles/Mappings.html
index 8d3fe8085a..943adad613 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>
% }
commit 4390158735bedae979eaa56db2f8ea873732cf5f
Author: craig kaiser <craig at bestpractical.com>
Date: Tue Nov 3 18:01:04 2020 -0500
Add test for when lifecycle status has '-' in name
diff --git a/t/web/lifecycle_mappings.t b/t/web/lifecycle_mappings.t
index e822d74665..8ca8570c71 100644
--- a/t/web/lifecycle_mappings.t
+++ b/t/web/lifecycle_mappings.t
@@ -15,6 +15,36 @@ my $new_lifecycle = {
initial => ['initial'],
active => ['active', 'case-Variant-Status'],
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"
+ },
}
};
@@ -224,4 +254,85 @@ diag "Test RT::Lifecycle::ParseMappingsInput method";
}
}
+diag "Test RT::Lifecycle::ParseMappingsInput method with lifecycle that has a '-' in the name";
+{
+ my %args = (
+ "map-default-new--sales-engineering" => "sales",
+ "map-default-open--sales-engineering" => "engineering",
+ "map-default-stalled--sales-engineering" => "stalled",
+ "map-default-rejected--sales-engineering" => "rejected",
+ "map-default-resolved--sales-engineering" => "resolved",
+ "map-default-deleted--sales-engineering" => "deleted",
+
+ "map-sales-engineering-sales--default" => "new",
+ "map-sales-engineering-engineering--default" => "open",
+ "map-sales-engineering-stalled--default" => "stalled",
+ "map-sales-engineering-rejected--default" => "rejected",
+ "map-sales-engineering-resolved--default" => "resolved",
+ "map-sales-engineering-deleted--default" => "deleted",
+ );
+ my %maps = RT::Lifecycle::ParseMappingsInput( \%args );
+
+ my %expected = (
+ 'default -> sales-engineering' => {
+ "new" => "sales",
+ "open" => "engineering",
+ "rejected" => "rejected",
+ "resolved" => "resolved",
+ "stalled" => "stalled",
+ "deleted" => "deleted",
+ },
+ 'sales-engineering -> default' => {
+ "sales" => "new",
+ "engineering" => "open",
+ "rejected" => "rejected",
+ "resolved" => "resolved",
+ "stalled" => "stalled",
+ "deleted" => "deleted",
+ }
+ );
+
+ is_deeply( \%expected, \%maps, "RT::Lifecycle::ParseMappingsInput method successfully parsed input." );
+
+ RT::Test->stop_server;
+ RT->Config->LoadConfigFromDatabase();
+ ( $url, $m ) = RT::Test->started_ok;
+ ok( $m->login( 'root', 'password' ), 'logged in' );
+ $lifecycles = RT->Config->Get('Lifecycles');
+
+ my %updated_maps = (%{$lifecycles->{'__maps__'}}, %maps);
+ $lifecycles->{'__maps__'} = \%updated_maps;
+
+ ($ret, $msg) = $lifecycleObj->_SaveLifecycles(
+ $lifecycles,
+ RT->SystemUser,
+ );
+ ok $ret, "Updated lifecycle successfully";
+
+ RT::Test->stop_server;
+ RT->Config->LoadConfigFromDatabase();
+ ( $url, $m ) = RT::Test->started_ok;
+ ok( $m->login( 'root', 'password' ), 'logged in' );
+ $lifecycles = RT->Config->Get('Lifecycles');
+
+ $m->get_ok( $url . '/Admin/Lifecycles/Mappings.html?Type=ticket&Name=foo' );
+ my $form = $m->form_name('ModifyMappings');
+
+ my $to = $expected{"default -> sales-engineering"};
+ my $from = $maps{"sales-engineering -> default"};
+
+ my @inputs = $form->inputs;
+ foreach my $input ( @inputs ) {
+ my ($default_from, $default_status, $default_to) = $input->name =~ /^map-(sales-engineering)-(.*)--(default)$/;
+ my ($sales_engineering_from, $sales_engineering_status, $sales_engineering_to) = $input->name =~ /^map-(default)-(.*)--(sales-engineering)$/;
+
+ if ( $default_from ) {
+ is ($input->value, $from->{$default_status}, "Mapping set correctly for default -> sales_engineering for status: $default_status" );
+ }
+ elsif ( $sales_engineering_from ) {
+ is ( $input->value, $to->{$sales_engineering_status}, "Mapping set correctly for sales_engineering -> default for status: $sales_engineering_to" );
+ }
+ }
+}
+
done_testing;
commit 5a71e1150ba43fe247f09c22df04bdbc617d9aee
Author: craig kaiser <craig at bestpractical.com>
Date: Thu Nov 12 16:40:51 2020 -0500
Update lifecycle mapping tests to pass form regex update
diff --git a/t/web/lifecycle_mappings.t b/t/web/lifecycle_mappings.t
index 8ca8570c71..c79bb6ee9b 100644
--- a/t/web/lifecycle_mappings.t
+++ b/t/web/lifecycle_mappings.t
@@ -64,17 +64,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" => "case-Variant-Status",
- "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" => "case-Variant-Status",
+ "Name" => "default",
+ "Type" => "ticket",
},
button => 'Update'
);
@@ -119,17 +119,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" => "case-variant-status",
- "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" => "case-variant-status",
+ "Name" => "default",
+ "Type" => "ticket",
},
button => 'Update'
);
@@ -167,8 +167,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" );
@@ -182,16 +182,16 @@ diag "Confirm the web UI correctly displays mappings";
diag "Test RT::Lifecycle::ParseMappingsInput method";
{
my %args = (
- "map-default-new--foo" => "initial",
- "map-default-open--foo" => "active",
- "map-default-stalled--foo" => "active",
- "map-default-rejected--foo" => "inactive",
- "map-default-resolved--foo" => "inactive",
- "map-default-deleted--foo" => "inactive",
-
- "map-foo-initial--default" => "new",
- "map-foo-active--default" => "open",
- "map-foo-inactive--default" => "resolved",
+ "map-default--new--foo" => "initial",
+ "map-default--open--foo" => "active",
+ "map-default--stalled--foo" => "active",
+ "map-default--rejected--foo" => "inactive",
+ "map-default--resolved--foo" => "inactive",
+ "map-default--deleted--foo" => "inactive",
+
+ "map-foo--initial--default" => "new",
+ "map-foo--active--default" => "open",
+ "map-foo--inactive--default" => "resolved",
);
my %maps = RT::Lifecycle::ParseMappingsInput( \%args );
@@ -242,8 +242,8 @@ diag "Test RT::Lifecycle::ParseMappingsInput method";
my @inputs = $form->inputs;
foreach my $input ( @inputs ) {
- my ($default_from, $default_status, $default_to) = $input->name =~ /^map-(sales-engineering)-(.*)--(default)$/;
- my ($sales_engineering_from, $sales_engineering_status, $sales_engineering_to) = $input->name =~ /^map-(default)-(.*)--(sales-engineering)$/;
+ my ($default_from, $default_status, $default_to) = $input->name =~ /^map-(sales-engineering)--(.*)--(default)$/;
+ my ($sales_engineering_from, $sales_engineering_status, $sales_engineering_to) = $input->name =~ /^map-(default)--(.*)--(sales-engineering)$/;
if ( $default_from ) {
is ($input->value, $from->{$default_status}, "Mapping set correctly for default -> sales_engineering for status: $default_status" );
@@ -257,19 +257,19 @@ diag "Test RT::Lifecycle::ParseMappingsInput method";
diag "Test RT::Lifecycle::ParseMappingsInput method with lifecycle that has a '-' in the name";
{
my %args = (
- "map-default-new--sales-engineering" => "sales",
- "map-default-open--sales-engineering" => "engineering",
- "map-default-stalled--sales-engineering" => "stalled",
- "map-default-rejected--sales-engineering" => "rejected",
- "map-default-resolved--sales-engineering" => "resolved",
- "map-default-deleted--sales-engineering" => "deleted",
-
- "map-sales-engineering-sales--default" => "new",
- "map-sales-engineering-engineering--default" => "open",
- "map-sales-engineering-stalled--default" => "stalled",
- "map-sales-engineering-rejected--default" => "rejected",
- "map-sales-engineering-resolved--default" => "resolved",
- "map-sales-engineering-deleted--default" => "deleted",
+ "map-default--new--sales-engineering" => "sales",
+ "map-default--open--sales-engineering" => "engineering",
+ "map-default--stalled--sales-engineering" => "stalled",
+ "map-default--rejected--sales-engineering" => "rejected",
+ "map-default--resolved--sales-engineering" => "resolved",
+ "map-default--deleted--sales-engineering" => "deleted",
+
+ "map-sales-engineering--sales--default" => "new",
+ "map-sales-engineering--engineering--default" => "open",
+ "map-sales-engineering--stalled--default" => "stalled",
+ "map-sales-engineering--rejected--default" => "rejected",
+ "map-sales-engineering--resolved--default" => "resolved",
+ "map-sales-engineering--deleted--default" => "deleted",
);
my %maps = RT::Lifecycle::ParseMappingsInput( \%args );
@@ -323,8 +323,8 @@ diag "Test RT::Lifecycle::ParseMappingsInput method with lifecycle that has a '-
my @inputs = $form->inputs;
foreach my $input ( @inputs ) {
- my ($default_from, $default_status, $default_to) = $input->name =~ /^map-(sales-engineering)-(.*)--(default)$/;
- my ($sales_engineering_from, $sales_engineering_status, $sales_engineering_to) = $input->name =~ /^map-(default)-(.*)--(sales-engineering)$/;
+ my ($default_from, $default_status, $default_to) = $input->name =~ /^map-(sales-engineering)--(.*)--(default)$/;
+ my ($sales_engineering_from, $sales_engineering_status, $sales_engineering_to) = $input->name =~ /^map-(default)--(.*)--(sales-engineering)$/;
if ( $default_from ) {
is ($input->value, $from->{$default_status}, "Mapping set correctly for default -> sales_engineering for status: $default_status" );
-----------------------------------------------------------------------
More information about the rt-commit
mailing list