Skip to content

Commit 2d28312

Browse files
Add basic tests for new CF column width config
1 parent 7f78c8e commit 2d28312

2 files changed

Lines changed: 69 additions & 0 deletions

File tree

t/playwright/ticket_inline_edit.t

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,32 @@ diag "Testing inline edit on list page";
553553
);
554554
}
555555

556+
diag "Testing CF widget ColumnWidth configuration";
557+
{
558+
# The test config uses legacy string format 'CustomFieldCustomGroupings'
559+
# Verify default rendering has no cf-columns class
560+
$p->goto_ticket($ticket_id);
561+
my $dom = $p->dom;
562+
my $show_cf = $dom->at('.show-custom-fields');
563+
ok($show_cf, 'Found show-custom-fields element');
564+
unlike($show_cf->attr('class'), qr/cf-columns-/, 'Legacy string config has no cf-columns class');
565+
566+
# Navigate to page layout editor and verify Column Width dropdown exists
567+
$p->get_ok("$url/Admin/PageLayouts/Modify.html?Class=RT::Ticket&Page=Display&Name=Default");
568+
569+
$dom = $p->dom;
570+
my $cw_select = $dom->at('select[name=ColumnWidth]');
571+
ok($cw_select, 'Column Width select exists in CF widget modal');
572+
573+
my @options = $cw_select->find('option')->map(sub { { value => $_->attr('value'), text => $_->text } })->each;
574+
ok(scalar @options >= 5, 'Column Width has at least 5 options');
575+
ok((grep { $_->{value} eq 'xs' } @options), 'Has extra narrow option');
576+
ok((grep { $_->{value} eq 'sm' } @options), 'Has narrow option');
577+
ok((grep { $_->{value} eq '__empty_value__' } @options), 'Has default (medium) option');
578+
ok((grep { $_->{value} eq 'lg' } @options), 'Has wide option');
579+
ok((grep { $_->{value} eq 'xl' } @options), 'Has extra wide option');
580+
}
581+
556582
$p->logout;
557583

558584
done_testing;

t/web/page_layouts.t

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,47 @@ ok $m->login, 'logged in as root';
6060
$m->goto_ticket($ticket2->Id);
6161
}
6262

63+
diag "Testing CF widget ColumnWidth rendering";
64+
{
65+
# Default layout with no ColumnWidth — should have no cf-columns class
66+
my $ticket = RT::Test->create_ticket(
67+
Queue => $queue1->Name,
68+
Subject => 'Test CF column width',
69+
);
70+
$m->goto_ticket($ticket->Id);
71+
$m->content_like(qr/class="show-custom-fields"/, 'Default layout has show-custom-fields class');
72+
$m->content_unlike(qr/cf-columns-/, 'Default layout has no cf-columns class');
73+
74+
# Update PageLayouts to include ColumnWidth => 'sm'
75+
my ($ret2, $msg2) = HTML::Mason::Commands::UpdateConfig(
76+
Name => 'PageLayouts',
77+
Value => {
78+
'RT::Ticket' => {
79+
'Display' => {
80+
Default => [
81+
{
82+
Layout => 'col-md-6',
83+
Title => 'Ticket metadata',
84+
Elements => [
85+
[ 'Basics', {Name => 'CustomFieldCustomGroupings', ColumnWidth => 'sm'} ],
86+
[ 'Dates', 'Links' ],
87+
],
88+
},
89+
{
90+
Layout => 'col-12',
91+
Elements => ['History'],
92+
},
93+
],
94+
},
95+
},
96+
},
97+
CurrentUser => RT->SystemUser,
98+
);
99+
ok($ret2, "Updated PageLayouts with ColumnWidth");
100+
101+
$m->goto_ticket($ticket->Id);
102+
$m->content_like(qr/class="show-custom-fields cf-columns-sm"/, 'ColumnWidth sm renders cf-columns-sm class');
103+
$m->content_unlike(qr/class="show-custom-fields"[^>]*cf-columns-(?!sm)/, 'No other cf-columns classes present');
104+
}
105+
63106
done_testing;

0 commit comments

Comments
 (0)