-
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.
fix: solve issue when updating an existing component with a code list (…
…#894) * feat: solve issue when saving Component with a code list * feat: create reusable See button * fix: solve typescript issue * fix: remove onClick props
- Loading branch information
1 parent
486a5b4
commit 61f13ee
Showing
34 changed files
with
304 additions
and
154 deletions.
There are no files selected for viewing
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,40 @@ | ||
import { render, screen, fireEvent } from '@testing-library/react'; | ||
import { SeeButton } from './see'; // Chemin d'accès au fichier du composant | ||
|
||
describe('SeeButton', () => { | ||
it('renders the button with the correct attributes and icon', () => { | ||
render(<SeeButton onClick={jest.fn()} />); | ||
|
||
const button = screen.getByRole('button'); | ||
|
||
expect(button).not.toBeNull(); | ||
expect(button.classList.contains('btn')).toBeTruthy(); | ||
expect(button.classList.contains('btn-default')).toBeTruthy(); | ||
|
||
expect(button.getAttribute('aria-label')).toBe('See'); | ||
expect(button.getAttribute('title')).toBe('See'); | ||
expect(button.getAttribute('type')).toBe('button'); | ||
|
||
const icon = button.querySelector('span')!; | ||
expect(icon.classList.contains('glyphicon')).toBeTruthy(); | ||
expect(icon.classList.contains('glyphicon-eye-open')).toBeTruthy(); | ||
}); | ||
|
||
it('calls the onClick handler when clicked', () => { | ||
const handleClick = jest.fn(); | ||
render(<SeeButton onClick={handleClick} />); | ||
|
||
const button = screen.getByRole('button'); | ||
fireEvent.click(button); | ||
|
||
expect(handleClick).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
it('passes additional props to the button element', () => { | ||
render(<SeeButton onClick={jest.fn()} data-test="see-button" />); | ||
|
||
const button = screen.getByRole('button'); | ||
|
||
expect(button.dataset.test).toEqual('see-button'); | ||
}); | ||
}); |
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,25 @@ | ||
import { createAllDictionary } from '../../utils/dictionnary'; | ||
|
||
const { D } = createAllDictionary({ | ||
see: { | ||
fr: 'Voir', | ||
en: 'See', | ||
}, | ||
}); | ||
|
||
type SeeButtonTypes = { | ||
onClick: (e: any) => void; | ||
}; | ||
export const SeeButton = ({ onClick, ...props }: Readonly<SeeButtonTypes>) => { | ||
return ( | ||
<button | ||
{...props} | ||
type="button" | ||
className="btn btn-default" | ||
aria-label={D.see} | ||
title={D.see} | ||
> | ||
<span className="glyphicon glyphicon-eye-open"></span> | ||
</button> | ||
); | ||
}; |
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
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
12 changes: 4 additions & 8 deletions
12
src/packages/modules-datasets/datasets/edit/tabs/statistical-information.js
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
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
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
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
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 |
---|---|---|
@@ -1,2 +1 @@ | ||
export { default as StructureAPI } from './structure-api'; | ||
export { getCodeList, getFormattedCodeList } from './code-list'; |
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.