From a3cc34fc2535e35cf0285ef7cd988321ceb4baf8 Mon Sep 17 00:00:00 2001 From: ChetanKarwa Date: Sat, 27 Jan 2024 01:30:17 +0530 Subject: [PATCH 1/5] Bounty List: Fix loaded state when using filters of languages --- src/pages/tickets/Tickets.tsx | 3 ++- src/pages/tickets/org/OrgTickets.tsx | 2 ++ src/people/utils/NoResults.tsx | 6 +++--- src/people/widgetViews/WidgetSwitchViewer.tsx | 5 ++--- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/pages/tickets/Tickets.tsx b/src/pages/tickets/Tickets.tsx index 50e83b0c..07d57f90 100644 --- a/src/pages/tickets/Tickets.tsx +++ b/src/pages/tickets/Tickets.tsx @@ -170,6 +170,7 @@ function BodyComponent() { setCurrentItems={setCurrentItems} page={page} setPage={setPage} + languageString={languageString} /> @@ -194,7 +195,6 @@ function BodyComponent() { minHeight: '32px' }} /> - diff --git a/src/pages/tickets/org/OrgTickets.tsx b/src/pages/tickets/org/OrgTickets.tsx index 9f566de3..736a08ee 100644 --- a/src/pages/tickets/org/OrgTickets.tsx +++ b/src/pages/tickets/org/OrgTickets.tsx @@ -139,6 +139,7 @@ function OrgBodyComponent() { fromBountyPage={true} selectedWidget={selectedWidget} loading={loading} + languageString={languageString} /> @@ -194,6 +195,7 @@ function OrgBodyComponent() { selectedWidget={selectedWidget} loading={loading} org_uuid={uuid} + languageString={languageString} /> diff --git a/src/people/utils/NoResults.tsx b/src/people/utils/NoResults.tsx index 10b6c1cb..b546d507 100644 --- a/src/people/utils/NoResults.tsx +++ b/src/people/utils/NoResults.tsx @@ -25,11 +25,11 @@ const H = styled.div` letter-spacing: 0px; color: rgb(60, 63, 65); `; -function NoResults() { +function NoResults({loaded = false}: {loaded?: boolean}) { const { ui } = useStores(); const { searchText } = ui || {}; - - if (searchText) { + console.log({searchText}) + if (searchText || loaded) { return (
({}); const closeModal = () => setShowDeleteModal(false); const showModal = () => setShowDeleteModal(true); - const { currentItems, setCurrentItems, totalBounties, page: propsPage, setPage } = props; + const { currentItems, setCurrentItems, totalBounties, page: propsPage, setPage, languageString } = props; const items = currentItems ?? 0; const bountiesTotal = totalBounties ?? 0; @@ -236,14 +236,13 @@ function WidgetSwitchViewer(props: any) { ); }) ) : ( - + ); const showLoadMore = bountiesTotal > items && activeList.length >= queryLimit; return ( <> {listItems} - {showDeleteModal && ( )} From 1d664c2906e5391d0473cf6260b5e94d097e28b6 Mon Sep 17 00:00:00 2001 From: ChetanKarwa Date: Sat, 27 Jan 2024 12:40:11 +0530 Subject: [PATCH 2/5] fix prettier --- src/people/utils/NoResults.tsx | 4 ++-- src/people/widgetViews/WidgetSwitchViewer.tsx | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/people/utils/NoResults.tsx b/src/people/utils/NoResults.tsx index b546d507..98156dd7 100644 --- a/src/people/utils/NoResults.tsx +++ b/src/people/utils/NoResults.tsx @@ -25,10 +25,10 @@ const H = styled.div` letter-spacing: 0px; color: rgb(60, 63, 65); `; -function NoResults({loaded = false}: {loaded?: boolean}) { +function NoResults({ loaded = false }: { loaded?: boolean }) { const { ui } = useStores(); const { searchText } = ui || {}; - console.log({searchText}) + console.log({ searchText }); if (searchText || loaded) { return (
({}); const closeModal = () => setShowDeleteModal(false); const showModal = () => setShowDeleteModal(true); - const { currentItems, setCurrentItems, totalBounties, page: propsPage, setPage, languageString } = props; + const { + currentItems, + setCurrentItems, + totalBounties, + page: propsPage, + setPage, + languageString + } = props; const items = currentItems ?? 0; const bountiesTotal = totalBounties ?? 0; From 0d900c04a2185b3e965d8cda3a24665ed265f7fa Mon Sep 17 00:00:00 2001 From: ChetanKarwa Date: Sun, 28 Jan 2024 12:35:22 +0530 Subject: [PATCH 3/5] add No results test --- .../__tests__/WidgetSwitchViewer.spec.tsx | 42 +++++++++++++++---- 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/src/people/widgetViews/__tests__/WidgetSwitchViewer.spec.tsx b/src/people/widgetViews/__tests__/WidgetSwitchViewer.spec.tsx index 72e4ef24..86662125 100644 --- a/src/people/widgetViews/__tests__/WidgetSwitchViewer.spec.tsx +++ b/src/people/widgetViews/__tests__/WidgetSwitchViewer.spec.tsx @@ -1,14 +1,38 @@ -import WidgetViewer from '../WidgetSwitchViewer'; -import { uiStore } from '../../../store/ui'; -// import crypto from 'crypto'; -// import moment from 'moment'; +import React from 'react'; +import { render, screen } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import { useStores } from 'store'; +import WidgetSwitchViewer from '../WidgetSwitchViewer'; -beforeAll(() => {}); +jest.mock('hooks', () => ({ + useIsMobile: jest.fn() +})); -afterAll(() => {}); +jest.mock('store', () => ({ + useStores: jest.fn() +})); -describe('testing helpers', () => { - test('test', () => { - expect(true).toBe(true); +describe('WidgetSwitchViewer Component', () => { + beforeEach(() => { + jest.clearAllMocks(); }); + + test('should display No results when there are no active list items with filter of languages', () => { + // Mock return value for the store hook + (useStores as jest.Mock).mockReturnValue({ + main: { + peopleBounties: [], + peopleOffers: [], + peoplePosts: [] + } + }); + + // Render the component with a selected widget and empty lists + render(); + + // Assert that is present in the document + expect(screen.getByText(/No results/i)).toBeInTheDocument(); + }); + + // Additional tests for different conditions can be added here }); From 8b402ad77a7621293a7fe6c86c822bd568982629 Mon Sep 17 00:00:00 2001 From: ChetanKarwa Date: Sun, 28 Jan 2024 12:36:03 +0530 Subject: [PATCH 4/5] prettier fix --- .../widgetViews/__tests__/WidgetSwitchViewer.spec.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/people/widgetViews/__tests__/WidgetSwitchViewer.spec.tsx b/src/people/widgetViews/__tests__/WidgetSwitchViewer.spec.tsx index 86662125..98b0ef99 100644 --- a/src/people/widgetViews/__tests__/WidgetSwitchViewer.spec.tsx +++ b/src/people/widgetViews/__tests__/WidgetSwitchViewer.spec.tsx @@ -28,7 +28,14 @@ describe('WidgetSwitchViewer Component', () => { }); // Render the component with a selected widget and empty lists - render(); + render( + + ); // Assert that is present in the document expect(screen.getByText(/No results/i)).toBeInTheDocument(); From 143b82a7e1331b7cacae381991c9f11451f2df60 Mon Sep 17 00:00:00 2001 From: ChetanKarwa Date: Mon, 29 Jan 2024 05:03:56 +0530 Subject: [PATCH 5/5] remove unnecessary console --- src/people/utils/NoResults.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/people/utils/NoResults.tsx b/src/people/utils/NoResults.tsx index 98156dd7..34c0d48d 100644 --- a/src/people/utils/NoResults.tsx +++ b/src/people/utils/NoResults.tsx @@ -28,7 +28,6 @@ const H = styled.div` function NoResults({ loaded = false }: { loaded?: boolean }) { const { ui } = useStores(); const { searchText } = ui || {}; - console.log({ searchText }); if (searchText || loaded) { return (