Skip to content

Commit

Permalink
Add a few pagination tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed May 14, 2024
1 parent 6c31637 commit 303600a
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
49 changes: 49 additions & 0 deletions t/api.t
Original file line number Diff line number Diff line change
Expand Up @@ -270,4 +270,53 @@ subtest 'Remove request (but keep packages that are still part of a product)' =>
is $pkgs->find($ids[4])->{state}, 'new', 'right state';
};

subtest 'Pagination' => sub {
subtest 'Search' => sub {
$t->get_ok('/pagination/search/perl-Mojolicious')->json_is('/start', 1)->json_is('/end', 1)->json_is('/total', 1)
->json_is('/page/0/package', 'perl-Mojolicious')->json_is('/page/0/id', 1)->json_is('/page/0/state', 'obsolete')
->json_has('/page/0/checksum')->json_has('/page/0/comment')->json_has('/page/0/user')
->json_has('/page/0/created_epoch')->json_has('/page/0/imported_epoch')->json_has('/page/0/indexed_epoch')
->json_has('/page/0/unpacked_epoch')->json_hasnt('/page/1');
$t->get_ok('/pagination/search/perl-Mojolicious?notObsolete=true')->json_is('/start', 1)->json_is('/end', 0)
->json_is('/total', 0)->json_hasnt('/page/0');
$t->get_ok('/pagination/search/perl-Mojolicious?filter=Artistic')->json_is('/start', 1)->json_is('/end', 1)
->json_is('/total', 1)->json_is('/page/0/id', 1)->json_hasnt('/page/1');
$t->get_ok('/pagination/search/perl-Mojolicious?filter=MIT')->json_is('/start', 1)->json_is('/end', 0)
->json_is('/total', 0)->json_hasnt('/page/0');
};

subtest 'Products' => sub {
$t->get_ok('/pagination/products/known')->json_is('/start', 1)->json_is('/end', 3)->json_is('/total', 3)
->json_is('/page/0/id', 3)->json_is('/page/0/name', 'openSUSE:Test')->json_is('/page/0/new_packages', 3)
->json_is('/page/0/reviewed_packages', 0)->json_is('/page/0/unacceptable_packages', 0)->json_hasnt('/page/3');
$t->get_ok('/pagination/products/known?filter=Factory')->json_is('/start', 1)->json_is('/end', 1)
->json_is('/total', 1)->json_is('/page/0/id', 1)->json_hasnt('/page/1');

$t->get_ok('/pagination/products/openSUSE:Test')->json_is('/start', 1)->json_is('/end', 3)->json_is('/total', 3)
->json_is('/page/0/id', 6)->json_is('/page/0/state', 'new')->json_is('/page/0/name', 'test-package-5')
->json_has('/page/0/checksum')->json_has('/page/0/imported_epoch')->json_has('/page/0/indexed_epoch')
->json_has('/page/0/unpacked_epoch');
$t->get_ok('/pagination/products/openSUSE:Test?filter=package-3')->json_is('/start', 1)->json_is('/end', 1)
->json_is('/total', 1)->json_is('/page/0/id', 4)->json_hasnt('/page/1');
};

subtest 'Licenses' => sub {
$t->get_ok('/pagination/licenses/known')->json_is('/start', 1)->json_is('/end', 4)->json_is('/total', 4)
->json_is('/page/0/license', '')->json_is('/page/0/spdx', '')->json_is('/page/1/license', 'Apache-2.0')
->json_is('/page/1/spdx', '')->json_hasnt('/page/4');
$t->get_ok('/pagination/licenses/known?filter=Artistic')->json_is('/start', 1)->json_is('/end', 1)
->json_is('/total', 1)->json_is('/page/0/license', 'Artistic-2.0')->json_hasnt('/page/1');
};

subtest 'Reviews' => sub {
$t->get_ok('/pagination/reviews/open')->json_is('/start', 1)->json_is('/end', 3)->json_is('/total', 3)
->json_is('/page/0/id', 2)->json_is('/page/0/state', 'new')->json_is('/page/0/priority', 5)
->json_is('/page/0/name', 'test-package-1')->json_has('/page/0/checksum')->json_has('/page/0/external_link')
->json_has('/page/0/created_epoch')->json_has('/page/0/imported_epoch')->json_has('/page/0/indexed_epoch')
->json_has('/page/0/unpacked_epoch')->json_hasnt('/page/3');
$t->get_ok('/pagination/reviews/open?filter=package-3')->json_is('/start', 1)->json_is('/end', 1)
->json_is('/total', 1)->json_is('/page/0/id', 4)->json_hasnt('/page/1');
};
};

done_testing;
7 changes: 7 additions & 0 deletions t/manual_review.t
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ subtest 'Manual review' => sub {
$t->element_exists('#emails')->text_like('#emails tr td', qr!coolo\@suse\.com!)->element_exists('#urls')
->text_like('#urls tr td', qr!http://mojolicious.org!);

$t->get_ok('/pagination/reviews/recent')->json_is('/start', 1)->json_is('/end', 1)->json_is('/total', 1)
->json_is('/page/0/id', 1)->json_like('/page/0/checksum', qr/Artistic/)->json_is('/page/0/external_link', 'mojo#1')
->json_is('/page/0/login', 'tester')->json_is('/page/0/name', 'perl-Mojolicious')->json_is('/page/0/priority', 5)
->json_is('/page/0/result', 'Test review')->json_is('/page/0/state', 'acceptable')
->json_has('/page/0/created_epoch')->json_has('/page/0/imported_epoch')->json_has('/page/0/indexed_epoch')
->json_has('/page/0/unpacked_epoch')->json_hasnt('/page/1');

$t->get_ok('/logout')->status_is(302)->header_is(Location => '/');
};

Expand Down

0 comments on commit 303600a

Please sign in to comment.