Skip to content

Commit

Permalink
Bugfix/2276/set not visible button (#2299)
Browse files Browse the repository at this point in the history
* Set not visible Edit button in cooperation

* Fixed tests
  • Loading branch information
YulichkaR authored Aug 6, 2024
1 parent 5585f0d commit a37630f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
} from '~/redux/features/cooperationsSlice'

import { styles } from '~/containers/cooperation-details/cooperetion-activities-view/CooperationActivitiesView.style'
import { CourseSection, UserRoleEnum } from '~/types'

interface CooperationActivitiesViewProps {
sections: CourseSection[]
Expand All @@ -28,20 +29,26 @@ const CooperationActivitiesView: FC<CooperationActivitiesViewProps> = ({
dispatch(setIsAddedClicked(false))
}

const { userRole } = useAppSelector((state) => state.appMain)
const isTutor = userRole === UserRoleEnum.Tutor

return (
<Box sx={styles.root}>
{sections.map((item) => (
<CooperationSectionView id={item._id} item={item} key={item._id} />
))}
<Box sx={styles.editContainer}>
<IconButton
data-testid='iconButton'
onClick={onEdit}
sx={styles.editButton}
>
<EditIcon />
</IconButton>
</Box>

{isTutor && (
<Box sx={styles.editContainer}>
<IconButton
data-testid='iconButton'
onClick={onEdit}
sx={styles.editButton}
>
<EditIcon />
</IconButton>
</Box>
)}
</Box>
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { render, screen, act, fireEvent } from '@testing-library/react'
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { UserRoleEnum } from '~/types'
import CooperationActivitiesView from '~/containers/cooperation-details/cooperetion-activities-view/CooperationActivitiesView.tsx'

vi.mock('~/components/cooperation-section-view/CooperationSectionView', () => ({
Expand All @@ -13,7 +14,8 @@ vi.mock('~/hooks/use-redux', () => ({
sections: [
{ _id: '1', title: 'Section1' },
{ _id: '2', title: 'Section2' }
]
],
userRole: UserRoleEnum.Tutor
}),
useAppDispatch: vi.fn().mockReturnValue(vi.fn())
}))
Expand Down

0 comments on commit a37630f

Please sign in to comment.