-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: new scope tree - Ref gestion-de-projet#2027
* refactor: start creating new ScopeTree component - Ref gestion-de-projet#2027 * refactor: starting creation of new caresite selection flow - Ref gestion-de-projet#2027 * refactor: display care sites table, display care site search result - Ref gestion-de-projet#2027 * refactor: display care sites table, display care site search result (2) - Ref gestion-de-projet#2027 * refactor: display care sites table, display care site search result (3) - Ref gestion-de-projet#2027 * refactor: set scope tree tabs (3) - Ref gestion-de-projet#2027 * refactor: set scope tree tabs (4) - Ref gestion-de-projet#2027 * refactor: rename files - Ref gestion-de-projet#2027 * refactor: set scope tree search tab - Ref gestion-de-projet#2027 * refactor: chipset, multiselection - Ref gestion-de-projet#2027 * refactor: requests optimization - Ref gestion-de-projet#2027 * feat: multiselection loading progress - Ref gestion-de-projet#2027 * feat: multiselection rename components - Ref gestion-de-projet#2027 * test: unit tests for getParents, getAllParentsIds and getHeadCells - Ref gestion-de-projet#2027 * test: integration tests for ScopeTreeExploration and ScopeTreeChipsets - Ref gestion-de-projet#2027 * test: integration tests for ScopeTreeExploration (2) - Ref gestion-de-projet#2027 * test: integration tests for ScopeTreeSearch - Ref gestion-de-projet#2027 * refactor: display ScopeTreeTableRow - Ref gestion-de-projet#2027 * refactor: display ScopeTreeTableRow - Ref gestion-de-projet#2027 * feat: remove rights on executive units filter - Ref gestion-de-projet#2307 * refactor: update scopeTree feature - Ref gestion-de-projet#2027 * refactor: apply improvement of indeterminate icons - Ref gestion-de-projet#2027 * refactor: remove executive units rights filter (1) - Ref gestion-de-projet#2027 * fix: change files names and fixes some undefined objet - Ref gestion-de-projet#2027 * fix: change files names and fixes some undefined objet - Ref gestion-de-projet#2027 * fix: change files names and fixes some undefined objet - Ref gestion-de-projet#2027 * fix: fix cohortCreation select source population - Ref gestion-de-projet#2027 * fix: fix retrive scope for pop source of executivUnit - Ref gestion-de-projet#2027 * fix: split scope store into perimeters and executive units - Ref gestion-de-projet#2027 * fix: fix unselect a child failed - Ref gestion-de-projet#2027 * fix: fix type error boolean for isExecutiveUnit - Ref gestion-de-projet#2027 * fix: perimeters ids containing spaces - Ref gestion-de-projet#2027 * fix: optimize and fix scopeTree * fix: perimeters ids containing spaces - Ref gestion-de-projet#2027 * fix: fix lint error * fix: fix typescript error --------- Co-authored-by: Salah-BOUYAHIA <salah.bouyahia-ext@aphp.fr> Co-authored-by: mourads <mourad.sellam@open-groupe.com>
- Loading branch information
1 parent
6509909
commit 152d7e6
Showing
45 changed files
with
3,467 additions
and
980 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
46 changes: 46 additions & 0 deletions
46
src/__tests__/integrationTests/ScopeTree/ScopeTreeChipsets.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,46 @@ | ||
import { fireEvent, render } from '@testing-library/react' | ||
import { vi } from 'vitest' | ||
import ScopeTreeChipsets from 'components/ScopeTree/ScopeTreeChipsets' | ||
import { ScopeTreeRow } from 'types' | ||
|
||
describe('ScopeTreeChipsets', () => { | ||
test('renders selected items', () => { | ||
const selectedItems: ScopeTreeRow[] = [ | ||
{ | ||
id: '1', | ||
name: 'Item 1', | ||
quantity: 1, | ||
subItems: [] | ||
}, | ||
{ | ||
id: '2', | ||
name: 'Item 2', | ||
quantity: 2, | ||
subItems: [] | ||
} | ||
] | ||
const onDelete = vi.fn() | ||
const { getByText } = render(<ScopeTreeChipsets selectedItems={selectedItems} onDelete={onDelete} />) | ||
expect(getByText('Item 1')).toBeInTheDocument() | ||
expect(getByText('Item 2')).toBeInTheDocument() | ||
}) | ||
|
||
it('should call onDelete when a chip is deleted', () => { | ||
const selectedItems: ScopeTreeRow[] = [ | ||
{ | ||
id: '1', | ||
name: 'Item 1', | ||
quantity: 1, | ||
subItems: [] | ||
} | ||
] | ||
|
||
const onDelete = vi.fn() | ||
|
||
const { getByTestId } = render(<ScopeTreeChipsets selectedItems={selectedItems} onDelete={onDelete} />) | ||
|
||
fireEvent.click(getByTestId('CancelIcon')) | ||
|
||
expect(onDelete).toHaveBeenCalledWith(selectedItems[0]) | ||
}) | ||
}) |
197 changes: 197 additions & 0 deletions
197
src/__tests__/integrationTests/ScopeTree/ScopeTreeExploration.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,197 @@ | ||
import { Reducer, configureStore } from '@reduxjs/toolkit' | ||
import '@testing-library/jest-dom/extend-expect' | ||
import { render } from '@testing-library/react' | ||
import { Provider } from 'react-redux' | ||
import { combineReducers } from 'redux' | ||
import thunk from 'redux-thunk' | ||
import { describe, test, vi } from 'vitest' | ||
import ScopeTreeExploration from '../../../components/ScopeTree/ScopeTreeExploration' | ||
import scope from '../../../state/scope' | ||
import { ScopeTreeRow, ScopeType } from '../../../types' | ||
|
||
describe('ScopeTreeExploration', () => { | ||
test('renders table for scope tree exploration with header and given data', () => { | ||
const rootRows: ScopeTreeRow[] = [ | ||
{ | ||
id: '1', | ||
name: 'Item 1', | ||
quantity: 1, | ||
subItems: [] | ||
}, | ||
{ | ||
id: '2', | ||
name: 'Item 2', | ||
quantity: 2, | ||
subItems: [] | ||
} | ||
] | ||
const initialState = { | ||
scope: { | ||
scopesList: rootRows | ||
} | ||
} | ||
const rootReducer: Reducer = combineReducers({ scope }) | ||
const mockStore = configureStore({ | ||
reducer: rootReducer, | ||
preloadedState: initialState, | ||
middleware: [thunk] | ||
}) | ||
const selectedItems: ScopeTreeRow[] = [] | ||
const setSelectedItems = vi.fn() | ||
const searchSavedRootRows: ScopeTreeRow[] = [] | ||
const executiveUnitType: ScopeType | undefined = undefined | ||
const isSelectionLoading = false | ||
const openPopulation: number[] = [] | ||
const setOpenPopulations = vi.fn() | ||
const setIsSelectionLoading = vi.fn() | ||
const setSearchSavedRootRows = vi.fn() | ||
|
||
const { container } = render( | ||
<Provider store={mockStore}> | ||
<ScopeTreeExploration | ||
selectedItems={selectedItems} | ||
setSelectedItems={setSelectedItems} | ||
searchSavedRootRows={searchSavedRootRows} | ||
executiveUnitType={executiveUnitType} | ||
isSelectionLoading={isSelectionLoading} | ||
setIsSelectionLoading={setIsSelectionLoading} | ||
openPopulation={openPopulation} | ||
setOpenPopulations={setOpenPopulations} | ||
setSearchSavedRootRows={setSearchSavedRootRows} | ||
/> | ||
</Provider> | ||
) | ||
expect(container).toBeInTheDocument() | ||
const xpaths = [ | ||
'//span[normalize-space()="Nom"]', | ||
'//span[normalize-space()="Nombre de patients"]', | ||
'//span[normalize-space()="Accès"]', | ||
'//p[normalize-space()="Item 1"]', | ||
'//p[normalize-space()="Item 2"]' | ||
] | ||
xpaths.forEach((xpath) => { | ||
const result = document.evaluate(xpath, container, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null) | ||
const span = result.singleNodeValue | ||
expect(span).to.exist | ||
}) | ||
}) | ||
|
||
test('renders table for scope tree exploration of an executive units', () => { | ||
const rootRows: ScopeTreeRow[] = [ | ||
{ | ||
id: '1', | ||
name: 'Item 1', | ||
quantity: 1, | ||
subItems: [] | ||
}, | ||
{ | ||
id: '2', | ||
name: 'Item 2', | ||
quantity: 2, | ||
subItems: [] | ||
} | ||
] | ||
const initialState = { | ||
scope: { | ||
scopesList: rootRows | ||
} | ||
} | ||
const rootReducer: Reducer = combineReducers({ scope }) | ||
const mockStore = configureStore({ | ||
reducer: rootReducer, | ||
preloadedState: initialState, | ||
middleware: [thunk] | ||
}) | ||
const selectedItems: ScopeTreeRow[] = [] | ||
const setSelectedItems = vi.fn() | ||
const searchSavedRootRows: ScopeTreeRow[] = [] | ||
const executiveUnitType: ScopeType | undefined = 'AP-HP' | ||
const isSelectionLoading = false | ||
const openPopulation: number[] = [] | ||
const setOpenPopulations = vi.fn() | ||
const setIsSelectionLoading = vi.fn() | ||
const setSearchSavedRootRows = vi.fn() | ||
|
||
const { container } = render( | ||
<Provider store={mockStore}> | ||
<ScopeTreeExploration | ||
selectedItems={selectedItems} | ||
setSelectedItems={setSelectedItems} | ||
searchSavedRootRows={searchSavedRootRows} | ||
executiveUnitType={executiveUnitType} | ||
isSelectionLoading={isSelectionLoading} | ||
setIsSelectionLoading={setIsSelectionLoading} | ||
openPopulation={openPopulation} | ||
setOpenPopulations={setOpenPopulations} | ||
setSearchSavedRootRows={setSearchSavedRootRows} | ||
/> | ||
</Provider> | ||
) | ||
expect(container).toBeInTheDocument() | ||
const xpaths = [ | ||
'//span[normalize-space()="Nom"]', | ||
'//span[normalize-space()="Nombre de patients"]', | ||
'//span[normalize-space()="Type"]' | ||
] | ||
xpaths.forEach((xpath) => { | ||
const result = document.evaluate(xpath, container, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null) | ||
const span = result.singleNodeValue | ||
expect(span).to.exist | ||
}) | ||
}) | ||
|
||
test('displays a linear progress loading when isSelectionLoading is true', () => { | ||
const rootRows: ScopeTreeRow[] = [ | ||
{ | ||
id: '1', | ||
name: 'Item 1', | ||
quantity: 1, | ||
subItems: [] | ||
}, | ||
{ | ||
id: '2', | ||
name: 'Item 2', | ||
quantity: 2, | ||
subItems: [] | ||
} | ||
] | ||
const initialState = { | ||
scope: { | ||
scopesList: rootRows | ||
} | ||
} | ||
const rootReducer: Reducer = combineReducers({ scope }) | ||
const mockStore = configureStore({ | ||
reducer: rootReducer, | ||
preloadedState: initialState, | ||
middleware: [thunk] | ||
}) | ||
const selectedItems: ScopeTreeRow[] = [] | ||
const setSelectedItems = vi.fn() | ||
const searchSavedRootRows: ScopeTreeRow[] = [] | ||
const executiveUnitType: ScopeType = 'AP-HP' | ||
const isSelectionLoading = true | ||
const openPopulation: number[] = [] | ||
const setOpenPopulations = vi.fn() | ||
const setIsSelectionLoading = vi.fn() | ||
const setSearchSavedRootRows = vi.fn() | ||
|
||
const { container } = render( | ||
<Provider store={mockStore}> | ||
<ScopeTreeExploration | ||
selectedItems={selectedItems} | ||
setSelectedItems={setSelectedItems} | ||
searchSavedRootRows={searchSavedRootRows} | ||
executiveUnitType={executiveUnitType} | ||
isSelectionLoading={isSelectionLoading} | ||
setIsSelectionLoading={setIsSelectionLoading} | ||
openPopulation={openPopulation} | ||
setOpenPopulations={setOpenPopulations} | ||
setSearchSavedRootRows={setSearchSavedRootRows} | ||
/> | ||
</Provider> | ||
) | ||
const linearProgress = document.querySelector('.MuiLinearProgress-root') | ||
expect(linearProgress).to.exist | ||
}) | ||
}) |
Oops, something went wrong.