diff options
author | sunnavy <sunnavy@bestpractical.com> | 2022-04-02 01:00:02 +0300 |
---|---|---|
committer | sunnavy <sunnavy@bestpractical.com> | 2022-04-29 23:13:05 +0300 |
commit | 3a6a0d3bdb0d4730e44d136dd2a9b4c511bc1d35 (patch) | |
tree | 3bb6d9f22d10bce3973cd51e8c54688ae6e8a24d | |
parent | 3dd61d4f3c3e92c74718603ab000cb82566305de (diff) |
Test validation of "unique values" custom fields on web UI4.4/validate-cf-unique-values-on-web-create
-rw-r--r-- | t/web/basic.t | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/t/web/basic.t b/t/web/basic.t index b72d8633ca..d795c2743f 100644 --- a/t/web/basic.t +++ b/t/web/basic.t @@ -95,4 +95,86 @@ is( $agent->title_is('Create a new ticket in foo&bar'); } +diag "test custom field unique values"; +{ + my $queue = RT::Test->load_or_create_queue( Name => 'General' ); + ok $queue && $queue->id, 'loaded or created queue'; + + my $cf = RT::Test->load_or_create_custom_field( + Name => 'External ID', + Queue => 'General', + Type => 'FreeformSingle', + UniqueValues => 1, + ); + my $cf_id = $cf->Id; + + $agent->goto_create_ticket($queue); + $agent->submit_form_ok( + { + form_name => 'TicketCreate', + fields => { Subject => 'Test unique values', "Object-RT::Ticket--CustomField-$cf_id-Value" => '123' }, + }, + 'Create ticket with cf value 123', + ); + + $agent->text_like(qr/Ticket \d+ created in queue/); + my $ticket = RT::Test->last_ticket; + is( $ticket->FirstCustomFieldValue($cf), 123, 'CF value is set' ); + + $agent->goto_create_ticket($queue); + $agent->submit_form_ok( + { + form_name => 'TicketCreate', + fields => { Subject => 'Test unique values', "Object-RT::Ticket--CustomField-$cf_id-Value" => '123' }, + }, + 'Create ticket with cf value 123', + ); + $agent->text_contains("'123' is not a unique value"); + $agent->text_unlike(qr/Ticket \d+ created in queue/); + + $agent->submit_form_ok( + { + form_name => 'TicketCreate', + fields => { Subject => 'Test unique values', "Object-RT::Ticket--CustomField-$cf_id-Value" => '456' }, + }, + 'Create ticket with cf value 456' + ); + $agent->text_like(qr/Ticket \d+ created in queue/); + $ticket = RT::Test->last_ticket; + is( $ticket->FirstCustomFieldValue($cf), 456, 'CF value is set' ); + my $ticket_id = $ticket->Id; + + $agent->follow_link_ok( { text => 'Basics' } ); + $agent->submit_form_ok( + { + form_name => 'TicketModify', + fields => { "Object-RT::Ticket-$ticket_id-CustomField-$cf_id-Value" => '123' }, + }, + 'Update ticket with cf value 123' + + ); + $agent->text_contains("'123' is not a unique value"); + $agent->text_lacks( 'External ID 456 changed to 123', 'Can not change to an existing value' ); + + $agent->submit_form_ok( + { + + form_name => 'TicketModify', + fields => { "Object-RT::Ticket-$ticket_id-CustomField-$cf_id-Value" => '789' }, + }, + 'Update ticket with cf value 789' + ); + $agent->text_contains( 'External ID 456 changed to 789', 'Changed cf to a new value' ); + + $agent->submit_form_ok( + { + + form_name => 'TicketModify', + fields => { "Object-RT::Ticket-$ticket_id-CustomField-$cf_id-Value" => '456' }, + }, + 'Update ticket with cf value 456' + ); + $agent->text_contains( 'External ID 789 changed to 456', 'Changed cf back to old value' ); +} + done_testing; |