From d54b1b9afc2b3aa85e04d7cc68bc3160f9af3242 Mon Sep 17 00:00:00 2001 From: suryxks <123004250@sastra.ac.in> Date: Mon, 4 Dec 2023 09:18:05 +0530 Subject: [PATCH 1/3] feat: display tasks assigned to archived users --- __tests__/Unit/Components/Tabs/Tab.test.tsx | 10 ++++- .../Components/Tasks/FilterModal.test.tsx | 44 +++++++++++++++++++ __tests__/Unit/utils/getActiveTab.test.ts | 1 + __tests__/Utils/taskQueryParams.test.ts | 14 +++++- src/app/services/tasksApi.ts | 9 +++- src/components/Header/index.tsx | 12 ++++- src/components/Tabs/index.tsx | 4 +- .../tasks/TaskSearch/FilterModal.tsx | 4 +- src/components/tasks/TasksContent.tsx | 13 +++++- src/constants/constants.ts | 1 + src/constants/header-categories.ts | 5 +++ src/constants/tasks.ts | 1 + src/interfaces/task.type.ts | 3 ++ src/utils/getActiveTab.ts | 2 + src/utils/taskQueryParams.ts | 13 +++++- 15 files changed, 125 insertions(+), 11 deletions(-) diff --git a/__tests__/Unit/Components/Tabs/Tab.test.tsx b/__tests__/Unit/Components/Tabs/Tab.test.tsx index de94895cc..3cf4a7cb2 100644 --- a/__tests__/Unit/Components/Tabs/Tab.test.tsx +++ b/__tests__/Unit/Components/Tabs/Tab.test.tsx @@ -32,7 +32,10 @@ describe('Tabs Component', () => { const presentTabs = screen.queryAllByRole('button'); expect(presentTabs.length).toBe( TABS.filter( - (tab) => tab != 'BLOCKED' && !newTaskStatus.includes(tab) + (tab) => + tab != Tab.BLOCKED && + tab != Tab.ASSIGNEE_ARCHIVED && + !newTaskStatus.includes(tab) ).length ); }); @@ -118,7 +121,10 @@ describe('Tabs Component', () => { ); const presentTabs = screen.getAllByRole('button'); const OLDTABS = TABS.filter( - (tab) => tab != 'BLOCKED' && !newTaskStatus.includes(tab) + (tab) => + tab != Tab.BLOCKED && + tab != Tab.ASSIGNEE_ARCHIVED && + !newTaskStatus.includes(tab) ); for (let i = 0; i < presentTabs.length; i++) { expect(presentTabs[i].textContent).toBe(changeName(OLDTABS[i])); diff --git a/__tests__/Unit/Components/Tasks/FilterModal.test.tsx b/__tests__/Unit/Components/Tasks/FilterModal.test.tsx index 1a9084795..9a6ca23b0 100644 --- a/__tests__/Unit/Components/Tasks/FilterModal.test.tsx +++ b/__tests__/Unit/Components/Tasks/FilterModal.test.tsx @@ -196,4 +196,48 @@ describe('FilterModal', () => { const doneButton = screen.getByText(/done/i); expect(doneButton).not.toHaveClass('status-button-active'); }); + test('Assignee Archived Modal should be visibel in tasks page when dev=true', () => { + render( + + ); + + const assignee_archivedButton = screen.getByText(/assignee archived/i); + expect(assignee_archivedButton).toBeInTheDocument(); + }); + test('Assignee Archived should not be visible when dev!=true', () => { + render( + + ); + + expect( + screen.queryByText(/assignee archived/i) + ).not.toBeInTheDocument(); + }); + test('Clicking on Assignee Archived from filter modal should call hte onSelect function with the right props', () => { + render( + + ); + + const assignee_archivedButton = screen.getByText(/assignee archived/i); + fireEvent.click(assignee_archivedButton); + expect(mockOnSelect).toBeCalledWith(Tab.ASSIGNEE_ARCHIVED); + }); }); diff --git a/__tests__/Unit/utils/getActiveTab.test.ts b/__tests__/Unit/utils/getActiveTab.test.ts index c0bd43f21..76e0b8a18 100644 --- a/__tests__/Unit/utils/getActiveTab.test.ts +++ b/__tests__/Unit/utils/getActiveTab.test.ts @@ -13,6 +13,7 @@ describe('Unit | Util | Get Active Tab', () => { expect(getActiveTab('merged')).toEqual(Tab.MERGED); expect(getActiveTab('completed')).toEqual(Tab.COMPLETED); expect(getActiveTab('in-progress')).toEqual(Tab.IN_PROGRESS); + expect(getActiveTab('archived')).toEqual(Tab.ASSIGNEE_ARCHIVED); expect(getActiveTab('someRandomSection')).toEqual(Tab.ALL); }); diff --git a/__tests__/Utils/taskQueryParams.test.ts b/__tests__/Utils/taskQueryParams.test.ts index 28952149c..72d68a807 100644 --- a/__tests__/Utils/taskQueryParams.test.ts +++ b/__tests__/Utils/taskQueryParams.test.ts @@ -17,7 +17,14 @@ describe('extractQueryParams', () => { expect(result.assignees).toEqual(['sunny-s']); expect(result.title).toBe('Develop feature'); }); - + it('should extract assignee-role and title assignee role from query param', () => { + const queryParam = + 'assignee-role:archived assignee:sunny-s Develop feature'; + const result = extractQueryParams(queryParam); + expect(result.assignees).toEqual(['sunny-s']); + expect(result.title).toBe('Develop feature'); + expect(result.assigneeRole).toBe('archived'); + }); it('should extract status, multiple assignees, and title from query param', () => { const queryParam = 'status:in-progress assignee:sunny-s assignee:ajoy-kumar Develop feature'; @@ -42,6 +49,11 @@ describe('getQueryParamTab', () => { const result = getQueryParamTab(tab); expect(result).toBe('status:in-progress'); }); + it('should generate a query param for assignee archived tab', () => { + const tab = Tab.ASSIGNEE_ARCHIVED; + const result = getQueryParamTab(tab); + expect(result).toBe('assignee-role:archived'); + }); }); describe('getAPIQueryParamAssignee', () => { diff --git a/src/app/services/tasksApi.ts b/src/app/services/tasksApi.ts index 654a0c28a..6be24438f 100644 --- a/src/app/services/tasksApi.ts +++ b/src/app/services/tasksApi.ts @@ -20,11 +20,14 @@ export const tasksApi = api.injectEndpoints({ prevTasks, assignee, title, + assigneeRole, }) => { const baseQuery = `/tasks?size=${size}&dev=true`; let url = - !status || status === 'ALL' + !status || + status === 'ALL' || + status === 'ASSIGNEE_ARCHIVED' ? baseQuery : `${baseQuery}&status=${status}`; @@ -43,7 +46,9 @@ export const tasksApi = api.injectEndpoints({ if (prevTasks) { url = prevTasks; } - + if (assigneeRole || status === 'ASSIGNEE_ARCHIVED') { + url += `&assignee-role=${assigneeRole}`; + } return { url }; }, providesTags: ['Tasks'], diff --git a/src/components/Header/index.tsx b/src/components/Header/index.tsx index a86861ab8..6b7fae046 100644 --- a/src/components/Header/index.tsx +++ b/src/components/Header/index.tsx @@ -35,7 +35,12 @@ export const Header = () => { key={index} title={title} link={refURL} - isActive={router.pathname === pathName} + isActive={ + router.pathname === pathName && + (router.pathname === '/tasks' && dev + ? !router?.asPath?.includes('assignee-role%3A') + : true) + } /> ))} @@ -50,6 +55,11 @@ export const Header = () => { router.pathname === pathName && (router.pathname === '/pull-requests' ? queryState === state + : true) && + (router.pathname === '/tasks' + ? router?.asPath?.includes( + 'assignee-role%3A' + ) : true) } /> diff --git a/src/components/Tabs/index.tsx b/src/components/Tabs/index.tsx index 46e1fb567..520b73250 100644 --- a/src/components/Tabs/index.tsx +++ b/src/components/Tabs/index.tsx @@ -19,7 +19,9 @@ const Tabs = ({ dev, tabs, onSelect, activeTab }: TabsProps) => ( .filter((tab: Tab) => dev ? !depreciatedTaskStatus.includes(tab) - : tab != 'BLOCKED' && !newTaskStatus.includes(tab) + : tab != Tab.BLOCKED && + tab != Tab.ASSIGNEE_ARCHIVED && + !newTaskStatus.includes(tab) ) .map((tab: Tab) => ( - ))} + <> + {dev && ( +
+ )} +
+
+ Filter + + × + +
+
+ {tabs + .filter((tab: Tab) => + dev + ? !depreciatedTaskStatus.includes(tab) + : tab != Tab.BLOCKED && + tab != Tab.ASSIGNEE_ARCHIVED && + !newTaskStatus.includes(tab) + ) + .map((tab) => ( + + ))} +
- + ); }; diff --git a/src/constants/header-categories.ts b/src/constants/header-categories.ts index 942567295..b80f612e0 100644 --- a/src/constants/header-categories.ts +++ b/src/constants/header-categories.ts @@ -16,13 +16,15 @@ export const headerCategories = [ }, { title: 'Open PRs', - refURL: '/openPRs', - pathName: '/openPRs', + refURL: '/pull-requests?state=open', + pathName: '/pull-requests', + state: 'open', }, { title: 'Stale PRs', - refURL: '/stale-pr', - pathName: '/stale-pr', + refURL: '/pull-requests?state=stale', + pathName: '/pull-requests', + state: 'stale', }, { title: 'Idle Users', @@ -34,26 +36,14 @@ export const headerCategories = [ export const devHeaderCategories = [ { title: 'Standup', - refURL: '/standup/?dev=true', + refURL: '/standup?dev=true', pathName: '/standup', }, { title: 'Availability Panel', - refURL: '/availability-panel', + refURL: '/availability-panel?dev=true', pathName: '/availability-panel', }, - { - title: 'Open PRs(dev)', - refURL: '/pull-requests?state=open&dev=true', - pathName: '/pull-requests', - state: 'open', - }, - { - title: 'Stale PRs(dev)', - refURL: '/pull-requests?state=stale&dev=true', - pathName: '/pull-requests', - state: 'stale', - }, { title: 'Tasks Assigned to Archived users', refURL: '/tasks?q=assignee-role%3Aarchived&dev=true', From 4d9559eb01918a19089ecfbf69556e235c289154 Mon Sep 17 00:00:00 2001 From: suryxks <123004250@sastra.ac.in> Date: Sat, 9 Dec 2023 16:26:33 +0530 Subject: [PATCH 3/3] fix: merge conflict --- src/app/services/tasksApi.ts | 7 +++---- src/components/tasks/TasksContent.tsx | 10 ++++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/app/services/tasksApi.ts b/src/app/services/tasksApi.ts index 6be24438f..059e727f6 100644 --- a/src/app/services/tasksApi.ts +++ b/src/app/services/tasksApi.ts @@ -30,7 +30,9 @@ export const tasksApi = api.injectEndpoints({ status === 'ASSIGNEE_ARCHIVED' ? baseQuery : `${baseQuery}&status=${status}`; - + if (assigneeRole || status === 'ASSIGNEE_ARCHIVED') { + url += `&assignee-role=${assigneeRole}`; + } if (assignee) { url += `&assignee=${assignee}`; } @@ -46,9 +48,6 @@ export const tasksApi = api.injectEndpoints({ if (prevTasks) { url = prevTasks; } - if (assigneeRole || status === 'ASSIGNEE_ARCHIVED') { - url += `&assignee-role=${assigneeRole}`; - } return { url }; }, providesTags: ['Tasks'], diff --git a/src/components/tasks/TasksContent.tsx b/src/components/tasks/TasksContent.tsx index cd11fe0a5..e0f625eb8 100644 --- a/src/components/tasks/TasksContent.tsx +++ b/src/components/tasks/TasksContent.tsx @@ -84,10 +84,12 @@ export const TasksContent = ({ dev }: { dev?: boolean }) => { setInputValue(value); }; - const searchButtonHandler = () => { - const { status, assignees, title, assigneeRole } = - extractQueryParams(inputValue); - if (inputValue) { + const searchButtonHandler = (searchString?: string) => { + console.log(searchString, inputValue); + const { status, assignees, title, assigneeRole } = extractQueryParams( + searchString || inputValue + ); + if (searchString || inputValue) { if (assigneeRole) { searchNewTasks(Tab.ASSIGNEE_ARCHIVED, assignees, title); } else {