Skip to content

Commit 1e5cabf

Browse files
Add tests for config history pagination
1 parent 05cad49 commit 1e5cabf

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

t/web/admin_tools_editconfig.t

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,49 @@ foreach my $change (@{$tests}) {
8686
check_history_page_item($tx_items->[$i++], $change );
8787
}
8888

89+
# Test pagination with PerPage=2 (5 items total = 3 pages)
90+
diag "Test pagination";
91+
92+
$m->get_ok( $url . '/Admin/Tools/ConfigHistory.html?PerPage=2', 'Get history with PerPage=2' );
93+
my $dom = $m->dom;
94+
my $paging = $dom->at('div.paging');
95+
ok( $paging, 'Pagination div exists' );
96+
my $pagination_ul = $paging->at('ul.pagination');
97+
ok( $pagination_ul, 'Pagination list exists' );
98+
99+
# Page 1 should be active
100+
my $active_item = $pagination_ul->at('li.page-item.active');
101+
ok( $active_item, 'Active page item exists' );
102+
is( $active_item->at('a')->text, '1', 'Page 1 is active' );
103+
104+
# Should have links to pages 2 and 3
105+
ok( $m->find_link( url_regex => qr/Page=2/ ), 'Link to page 2 exists' );
106+
ok( $m->find_link( url_regex => qr/Page=3/ ), 'Link to page 3 exists' );
107+
108+
# Count history items on page 1 - should be 2
109+
my @history_items = $dom->find('div.history-container div.transaction')->each;
110+
is( scalar @history_items, 2, 'Page 1 shows 2 history items' );
111+
112+
# Go to page 2 by clicking the pagination link
113+
$m->follow_link_ok( { text => '2', url_regex => qr/Page=2/ }, 'Click page 2 link' );
114+
$dom = $m->dom;
115+
$active_item = $dom->at('div.paging ul.pagination li.page-item.active');
116+
ok( $active_item, 'Active page item exists on page 2' );
117+
is( $active_item->at('a')->text, '2', 'Page 2 is active' );
118+
119+
@history_items = $dom->find('div.history-container div.transaction')->each;
120+
is( scalar @history_items, 2, 'Page 2 shows 2 history items' );
121+
122+
# Go to page 3 by clicking the pagination link
123+
$m->follow_link_ok( { text => '3', url_regex => qr/Page=3/ }, 'Click page 3 link' );
124+
$dom = $m->dom;
125+
$active_item = $dom->at('div.paging ul.pagination li.page-item.active');
126+
ok( $active_item, 'Active page item exists on page 3' );
127+
is( $active_item->at('a')->text, '3', 'Page 3 is active' );
128+
129+
@history_items = $dom->find('div.history-container div.transaction')->each;
130+
is( scalar @history_items, 1, 'Page 3 shows 1 history item (last page)' );
131+
89132
sub run_test {
90133
my %args = @_;
91134

0 commit comments

Comments
 (0)