From 9cfab586637369dc3d4b338d187845f65f7f8cf4 Mon Sep 17 00:00:00 2001 From: alipov_d Date: Tue, 14 Nov 2023 16:35:19 +0200 Subject: [PATCH] fix: request error for empty user list responses --- src/containers/ListView/TableAction.jsx | 1 + src/containers/ListView/TableAction.test.jsx | 9 +++++++++ .../__snapshots__/TableAction.test.jsx.snap | 15 +++++++++++++++ src/data/redux/thunkActions/grading.js | 8 +++++--- src/data/redux/thunkActions/grading.test.js | 17 +++++++++++------ 5 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/containers/ListView/TableAction.jsx b/src/containers/ListView/TableAction.jsx index 44886d3f..40a800e1 100644 --- a/src/containers/ListView/TableAction.jsx +++ b/src/containers/ListView/TableAction.jsx @@ -11,6 +11,7 @@ export const TableAction = ({ tableInstance, handleClick }) => ( onClick={handleClick(tableInstance.rows)} variant="primary" className="view-all-responses-btn" + disabled={tableInstance.rows.length === 0} > diff --git a/src/containers/ListView/TableAction.test.jsx b/src/containers/ListView/TableAction.test.jsx index 4ecf9f22..5adef4cd 100644 --- a/src/containers/ListView/TableAction.test.jsx +++ b/src/containers/ListView/TableAction.test.jsx @@ -13,6 +13,15 @@ describe('TableAction component', () => { expect(el.snapshot).toMatchSnapshot(); }); + test('Inactive Button "View All Responses"', () => { + const emptyProps = { + tableInstance: { rows: [] }, + handleClick: jest.fn(), + }; + const el = shallow(); + expect(el.snapshot).toMatchSnapshot(); + }); + test('handleClick', () => { shallow(); expect(props.handleClick).toHaveBeenCalledWith(props.tableInstance.rows); diff --git a/src/containers/ListView/__snapshots__/TableAction.test.jsx.snap b/src/containers/ListView/__snapshots__/TableAction.test.jsx.snap index 5b314467..8867be0b 100644 --- a/src/containers/ListView/__snapshots__/TableAction.test.jsx.snap +++ b/src/containers/ListView/__snapshots__/TableAction.test.jsx.snap @@ -1,8 +1,23 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP +exports[`TableAction component Inactive Button "View All Responses" 1`] = ` + +`; + exports[`TableAction component snapshots 1`] = `