-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Northumberland] Send updates to assigned user to Alloy
- Loading branch information
1 parent
e790de9
commit 8346eb9
Showing
3 changed files
with
79 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -150,15 +150,29 @@ $integration->mock('api_call', sub { | |
$content = path(__FILE__)->sibling("json/alloyv2/northumberland/fixmystreet_users_query_response.json")->slurp; | ||
|
||
# Only get the IDs that are provided in the body | ||
my $id_type = $body->{aqs}{children}[0]{children}[0]{type}; | ||
my @body_ids | ||
= @{ | ||
$body->{aqs}{children}[0]{children}[1]{properties}{value} | ||
}; | ||
|
||
my @matching_items; | ||
for my $item ( @{ decode_json($content)->{results} } ) { | ||
for (@body_ids) { | ||
push @matching_items, $item if $item->{itemId} == $_; | ||
if ( $id_type eq 'ItemProperty' ) { | ||
# Searching for multiple users | ||
for my $item ( @{ decode_json($content)->{results} } ) { | ||
for (@body_ids) { | ||
push @matching_items, $item if $item->{itemId} eq $_; | ||
} | ||
} | ||
} elsif ( $id_type eq 'Attribute' ) { | ||
# Searching for a single user via email | ||
for my $item ( @{ decode_json($content)->{results} } ) { | ||
for ( @{ $item->{attributes} } ) { | ||
push @matching_items, $item | ||
if $_->{attributeCode} eq | ||
'attributes_fixMyStreetUsersEmail_6532518cac7139477485ec38' | ||
&& $_->{value} eq $body_ids[0]; | ||
} | ||
} | ||
} | ||
|
||
|
@@ -449,10 +463,11 @@ HERE | |
service_code => 'Damaged_/_Missing_/_Facing_Wrong_Way', | ||
description => 'update', | ||
status => 'FIXED', | ||
extra_details => $extra_details, | ||
service_request_id => '642062376be3a0036bbbb64b', | ||
update_id => '1', | ||
updated_datetime => '2023-05-15T14:55:55+00:00', | ||
'attribute[extra_details]' => $extra_details, | ||
'attribute[assigned_to_user_email]' => '[email protected]', | ||
); | ||
ok $res->is_success, 'valid request' | ||
or diag $res->content; | ||
|
@@ -467,13 +482,22 @@ HERE | |
my $expected_extra_details_attribute_code = 'attributes_customerRequestFMSExtraDetails_646e07533726d8036a7a4022'; | ||
my $expected_extra_details_attribute_value = $extra_details; | ||
|
||
my $expected_assigned_user_attribute_code = | ||
'attributes_customerRequestAssignedTo_653664b0557119eef53a97e1'; | ||
my $expected_assigned_user_attribute_value = '123'; | ||
|
||
foreach (@{ $attributes }) { | ||
if ($_->{attributeCode} eq $expected_status_attribute_code) { | ||
ok ref($_->{value}) eq 'ARRAY' && $_->{value}[0] eq $expected_status_attribute_value, "value sent in status attribute update is correct"; | ||
is_deeply $_->{value}, [$expected_status_attribute_value], | ||
"value sent in status attribute update is correct"; | ||
} | ||
if ($_->{attributeCode} eq $expected_extra_details_attribute_code) { | ||
ok $_->{value} eq $expected_extra_details_attribute_value, "value sent in extra_details attribute update is correct"; | ||
} | ||
if ( $_->{attributeCode} eq $expected_assigned_user_attribute_code ) { | ||
is_deeply $_->{value}, [$expected_assigned_user_attribute_value], | ||
"value sent in assigned_to_user attribute update is correct"; | ||
} | ||
} | ||
}; | ||
|
||
|