Skip to content

Commit

Permalink
Test sorting/limiting axis labels of search charts
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnavy committed Mar 28, 2024
1 parent 0c8ef9f commit 7798108
Showing 1 changed file with 49 additions and 13 deletions.
62 changes: 49 additions & 13 deletions t/charts/basics.t
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ my @tickets = add_tix_from_data(
{ Subject => 'n', Status => 'new' },
{ Subject => 'o', Status => 'open' },
{ Subject => 'o', Status => 'open' },
{ Subject => 'r', Status => 'resolved' },
{ Subject => 'o', Status => 'open' },
{ Subject => 'r', Status => 'resolved' },
{ Subject => 'r', Status => 'resolved' },
);
Expand All @@ -28,6 +28,19 @@ use_ok 'RT::Report::Tickets';
);
$report->SortEntries;

my $new_cell = [
{ 'value' => 'new', 'type' => 'label' },
{ 'query' => '(Status = \'new\')', 'value' => '1', 'type' => 'value' },
];
my $open_cell = [
{ 'value' => 'open', 'type' => 'label' },
{ 'query' => '(Status = \'open\')', 'value' => '3', 'type' => 'value' }
];
my $resolved_cell = [
{ 'value' => 'resolved', 'type' => 'label' },
{ 'query' => '(Status = \'resolved\')', 'value' => '2', 'type' => 'value' }
];

my @colors = RT->Config->Get("ChartColors");
my $expected = {
'thead' => [ {
Expand All @@ -45,31 +58,54 @@ use_ok 'RT::Report::Tickets';
} ],
'tbody' => [
{
'cells' => [
{ 'value' => 'new', 'type' => 'label' },
{ 'query' => '(Status = \'new\')', 'value' => '1', 'type' => 'value' },
],
'cells' => $new_cell,
'even' => 1
},
{
'cells' => [
{ 'value' => 'open', 'type' => 'label' },
{ 'query' => '(Status = \'open\')', 'value' => '2', 'type' => 'value' }
],
'cells' => $open_cell,
'even' => 0
},
{
'cells' => [
{ 'value' => 'resolved', 'type' => 'label' },
{ 'query' => '(Status = \'resolved\')', 'value' => '3', 'type' => 'value' }
],
'cells' => $resolved_cell,
'even' => 1
},
]
};

my %table = $report->FormatTable( %columns );
is_deeply( \%table, $expected, "basic table" );

$report->SortEntries( ChartOrderBy => 'label', ChartOrder => 'ASC' );
%table = $report->FormatTable( %columns );
is_deeply( \%table, $expected, "basic table sorted by label ASC" );

$report->SortEntries( ChartOrderBy => 'label', ChartOrder => 'DESC' );
%table = $report->FormatTable( %columns );
@{$expected->{'tbody'}} = reverse @{$expected->{'tbody'}};
is_deeply( \%table, $expected, "basic table sorted by label DESC" );

$report->SortEntries( ChartOrderBy => 'value', ChartOrder => 'ASC' );
%table = $report->FormatTable( %columns );
$expected->{'tbody'} = [
{
'cells' => $new_cell,
'even' => 1
},
{
'cells' => $resolved_cell,
'even' => 0,
},
{
'cells' => $open_cell,
'even' => 1
},
];
is_deeply( \%table, $expected, "basic table sorted by value ASC" );

$report->SortEntries( ChartOrderBy => 'value', ChartOrder => 'DESC' );
%table = $report->FormatTable( %columns );
@{$expected->{'tbody'}} = reverse @{$expected->{'tbody'}};
is_deeply( \%table, $expected, "basic table sorted by value DESC" );
}

done_testing;
Expand Down

0 comments on commit 7798108

Please sign in to comment.