-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add useListWorkflowsBasic hook that uses useMergedInfiniteQueries to fetch data from both ListOpen and ListClosed Add DomainWorkflowsBasicTable to display basic visibility table listing Add util getDateDaysBeforeToday that gets a new Date "n" days before present Preload dates in DomainWorkflowsBasicFilters since ListOpen/ListClosed need a date string (also add unit tests)
- Loading branch information
1 parent
8943728
commit ce67a14
Showing
18 changed files
with
839 additions
and
3 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
src/utils/datetime/__tests__/get-date-days-before-today.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import getDateDaysBeforeToday from '../get-date-days-before-today'; | ||
|
||
jest.useFakeTimers().setSystemTime(new Date('2023-05-25')); | ||
|
||
describe(getDateDaysBeforeToday.name, () => { | ||
it('should return date 30 days before today', () => { | ||
expect(getDateDaysBeforeToday(30)).toEqual( | ||
new Date('2023-04-25T00:00:00.000Z') | ||
); | ||
}); | ||
|
||
it('should return date 0 days before today', () => { | ||
expect(getDateDaysBeforeToday(0)).toEqual( | ||
new Date('2023-05-25T00:00:00.000Z') | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export default function getDateDaysBeforeToday(n: number) { | ||
const today = new Date(); | ||
if (n === 0) return today; | ||
return new Date(today.setDate(today.getDate() - n)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/views/domain-workflows-basic/config/domain-workflows-basic-page-size.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const DOMAIN_WORKFLOWS_BASIC_PAGE_SIZE = 10; | ||
|
||
export default DOMAIN_WORKFLOWS_BASIC_PAGE_SIZE; |
59 changes: 59 additions & 0 deletions
59
src/views/domain-workflows-basic/config/domain-workflows-basic-table.config.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { createElement } from 'react'; | ||
|
||
import FormattedDate from '@/components/formatted-date/formatted-date'; | ||
import Link from '@/components/link/link'; | ||
import { type DomainWorkflow } from '@/views/domain-page/domain-page.types'; | ||
import WorkflowStatusTag from '@/views/shared/workflow-status-tag/workflow-status-tag'; | ||
|
||
import { type DomainWorkflowsBasicTableConfig } from '../domain-workflows-basic-table/domain-workflows-basic-table.types'; | ||
|
||
const domainWorkflowsBasicTableConfig = [ | ||
{ | ||
name: 'Workflow ID', | ||
id: 'WorkflowID', | ||
renderCell: (row: DomainWorkflow) => row.workflowID, | ||
width: '25.5%', | ||
}, | ||
{ | ||
name: 'Status', | ||
id: 'CloseStatus', | ||
renderCell: (row: DomainWorkflow) => | ||
createElement(WorkflowStatusTag, { status: row.status }), | ||
width: '7.5%', | ||
}, | ||
{ | ||
name: 'Run ID', | ||
id: 'RunID', | ||
renderCell: (row: DomainWorkflow) => | ||
createElement( | ||
Link, | ||
{ | ||
href: `workflows/${encodeURIComponent(row.workflowID)}/${encodeURIComponent(row.runID)}`, | ||
}, | ||
row.runID | ||
), | ||
width: '22%', | ||
}, | ||
{ | ||
name: 'Workflow type', | ||
id: 'WorkflowType', | ||
renderCell: (row: DomainWorkflow) => row.workflowName, | ||
width: '20%', | ||
}, | ||
{ | ||
name: 'Started', | ||
id: 'StartTime', | ||
renderCell: (row: DomainWorkflow) => | ||
createElement(FormattedDate, { timestampMs: row.startTime }), | ||
width: '12.5%', | ||
}, | ||
{ | ||
name: 'Ended', | ||
id: 'CloseTime', | ||
renderCell: (row: DomainWorkflow) => | ||
createElement(FormattedDate, { timestampMs: row.closeTime }), | ||
width: '12.5%', | ||
}, | ||
] as const satisfies DomainWorkflowsBasicTableConfig; | ||
|
||
export default domainWorkflowsBasicTableConfig; |
66 changes: 66 additions & 0 deletions
66
...ws-basic/domain-workflows-basic-filters/__tests__/domain-workflows-basic-filters.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { render, screen, userEvent } from '@/test-utils/rtl'; | ||
|
||
import { type Props as PageFiltersToggleProps } from '@/components/page-filters/page-filters-toggle/page-filters-toggle.types'; | ||
import { mockDomainWorkflowsQueryParamsValues } from '@/views/domain-workflows/__fixtures__/domain-workflows-query-params'; | ||
|
||
import DomainWorkflowsBasicFilters from '../domain-workflows-basic-filters'; | ||
|
||
jest.mock( | ||
'@/components/page-filters/page-filters-search/page-filters-search', | ||
() => | ||
jest.fn(({ searchPlaceholder }) => ( | ||
<div>Filter search: {searchPlaceholder}</div> | ||
)) | ||
); | ||
|
||
jest.mock( | ||
'@/components/page-filters/page-filters-fields/page-filters-fields', | ||
() => jest.fn(() => <div>Filter fields</div>) | ||
); | ||
|
||
jest.mock( | ||
'@/components/page-filters/page-filters-toggle/page-filters-toggle', | ||
() => | ||
jest.fn((props: PageFiltersToggleProps) => ( | ||
<button onClick={props.onClick}>Filter toggle</button> | ||
)) | ||
); | ||
|
||
const mockSetQueryParams = jest.fn(); | ||
const mockResetAllFilters = jest.fn(); | ||
const mockActiveFiltersCount = 2; | ||
jest.mock('@/components/page-filters/hooks/use-page-filters', () => | ||
jest.fn(() => ({ | ||
resetAllFilters: mockResetAllFilters, | ||
activeFiltersCount: mockActiveFiltersCount, | ||
queryParams: mockDomainWorkflowsQueryParamsValues, | ||
setQueryParams: mockSetQueryParams, | ||
})) | ||
); | ||
|
||
describe(DomainWorkflowsBasicFilters.name, () => { | ||
it('renders page search and filters', async () => { | ||
render(<DomainWorkflowsBasicFilters />); | ||
|
||
expect( | ||
await screen.findByText('Filter search: Workflow ID') | ||
).toBeInTheDocument(); | ||
expect( | ||
await screen.findByText('Filter search: Workflow Type') | ||
).toBeInTheDocument(); | ||
|
||
expect(await screen.findByText('Filter fields')).toBeInTheDocument(); | ||
}); | ||
|
||
it('hides page filters when filter toggle is clicked', async () => { | ||
const user = userEvent.setup(); | ||
render(<DomainWorkflowsBasicFilters />); | ||
|
||
expect(await screen.findByText('Filter fields')).toBeInTheDocument(); | ||
|
||
const filterToggle = await screen.findByText('Filter toggle'); | ||
await user.click(filterToggle); | ||
|
||
expect(screen.queryByText('Filter fields')).toBeNull(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.