From 6047eb61721abdd91183047bbf78618fe5590fa0 Mon Sep 17 00:00:00 2001 From: Jake McDermott Date: Wed, 31 Mar 2021 12:27:01 -0400 Subject: [PATCH] Fix rounding error in output pagination controls --- .../src/screens/Job/JobOutput/shared/jobOutputUtils.js | 2 +- .../screens/Job/JobOutput/shared/jobOutputUtils.test.jsx | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/awx/ui_next/src/screens/Job/JobOutput/shared/jobOutputUtils.js b/awx/ui_next/src/screens/Job/JobOutput/shared/jobOutputUtils.js index cb3e7fb309..e61afeca32 100644 --- a/awx/ui_next/src/screens/Job/JobOutput/shared/jobOutputUtils.js +++ b/awx/ui_next/src/screens/Job/JobOutput/shared/jobOutputUtils.js @@ -6,7 +6,7 @@ export default function getRowRangePageSize(startIndex, stopIndex) { page = startIndex + 1; pageSize = 1; } else if (stopIndex >= startIndex + 50) { - page = Math.ceil(startIndex / 50); + page = Math.floor(startIndex / 50) + 1; pageSize = 50; } else { for (let i = stopIndex - startIndex + 1; i <= 50; i++) { diff --git a/awx/ui_next/src/screens/Job/JobOutput/shared/jobOutputUtils.test.jsx b/awx/ui_next/src/screens/Job/JobOutput/shared/jobOutputUtils.test.jsx index 2c06e347ba..ba4a0e9844 100644 --- a/awx/ui_next/src/screens/Job/JobOutput/shared/jobOutputUtils.test.jsx +++ b/awx/ui_next/src/screens/Job/JobOutput/shared/jobOutputUtils.test.jsx @@ -29,4 +29,11 @@ describe('getRowRangePageSize', () => { firstIndex: 5, }); }); + test('handles range with 0 startIndex', () => { + expect(getRowRangePageSize(0, 50)).toEqual({ + page: 1, + pageSize: 50, + firstIndex: 0, + }); + }); });