Skip to content

Commit

Permalink
refactor: new scope tree - Ref gestion-de-projet#2027
Browse files Browse the repository at this point in the history
* 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
3 people authored Oct 28, 2023
1 parent 6509909 commit 152d7e6
Show file tree
Hide file tree
Showing 45 changed files with 3,467 additions and 980 deletions.
970 changes: 959 additions & 11 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"build": "vite build",
"serve": "vite preview",
"lint": "eslint --ext .jsx,.js,.ts,.tsx src/",
"test": "wdio wdio.conf.js --suite Generics --suite HomePage --suite MyPatients --suite Requests"
"test": "vitest"
},
"browserslist": {
"production": [
Expand All @@ -69,7 +69,7 @@
},
"devDependencies": {
"@testing-library/dom": "^8.20.0",
"@testing-library/jest-dom": "^5.16.4",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^14.4.3",
"@types/d3": "^7.4.0",
Expand Down Expand Up @@ -104,7 +104,8 @@
"typescript": "^4.9.5",
"vite": "^4.3.5",
"vite-plugin-svgr": "^3.2.0",
"vite-tsconfig-paths": "^4.2.0"
"vite-tsconfig-paths": "^4.2.0",
"vitest": "^0.34.4"
},
"jest": {
"clearMocks": true
Expand Down
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 src/__tests__/integrationTests/ScopeTree/ScopeTreeExploration.test.tsx
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
})
})
Loading

0 comments on commit 152d7e6

Please sign in to comment.