mirror of
https://github.com/strapi/strapi.git
synced 2025-09-20 05:52:08 +00:00
Fix tests
This commit is contained in:
parent
0871074d23
commit
c68d40b9e4
@ -117,6 +117,7 @@ export const MediaLibrary = () => {
|
|||||||
<ActionLayout
|
<ActionLayout
|
||||||
startActions={
|
startActions={
|
||||||
<>
|
<>
|
||||||
|
{canUpdate && (
|
||||||
<BoxWithHeight
|
<BoxWithHeight
|
||||||
paddingLeft={2}
|
paddingLeft={2}
|
||||||
paddingRight={2}
|
paddingRight={2}
|
||||||
@ -133,8 +134,9 @@ export const MediaLibrary = () => {
|
|||||||
onChange={selectAllAssets}
|
onChange={selectAllAssets}
|
||||||
/>
|
/>
|
||||||
</BoxWithHeight>
|
</BoxWithHeight>
|
||||||
<SortPicker />
|
)}
|
||||||
<Filters />
|
{canRead && <SortPicker />}
|
||||||
|
{canRead && <Filters />}
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
endActions={
|
endActions={
|
||||||
|
@ -98,6 +98,75 @@ describe('Media library homepage', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('general actions', () => {
|
describe('general actions', () => {
|
||||||
|
describe('filters', () => {
|
||||||
|
it('shows the filters dropdown when the user is allowed to read', () => {
|
||||||
|
renderML();
|
||||||
|
|
||||||
|
expect(screen.getByText('app.utils.filters')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('hides the filters dropdown when the user is not allowed to read', () => {
|
||||||
|
useRBAC.mockReturnValue({
|
||||||
|
isLoading: false,
|
||||||
|
allowedActions: {
|
||||||
|
canRead: false,
|
||||||
|
canCreate: true,
|
||||||
|
canUpdate: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
renderML();
|
||||||
|
|
||||||
|
expect(screen.queryByText('app.utils.filters')).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('sort by', () => {
|
||||||
|
it('shows the sort by dropdown when the user is allowed to read', () => {
|
||||||
|
renderML();
|
||||||
|
|
||||||
|
expect(screen.getByText('Sort by')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('hides the sort by dropdown when the user is not allowed to read', () => {
|
||||||
|
useRBAC.mockReturnValue({
|
||||||
|
isLoading: false,
|
||||||
|
allowedActions: {
|
||||||
|
canRead: false,
|
||||||
|
canCreate: true,
|
||||||
|
canUpdate: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
renderML();
|
||||||
|
|
||||||
|
expect(screen.queryByText('Sort by')).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('select all', () => {
|
||||||
|
it('shows the select all button when the user is allowed to update', () => {
|
||||||
|
renderML();
|
||||||
|
|
||||||
|
expect(screen.getByLabelText('Select all assets')).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('hides the select all button when the user is not allowed to update', () => {
|
||||||
|
useRBAC.mockReturnValue({
|
||||||
|
isLoading: false,
|
||||||
|
allowedActions: {
|
||||||
|
canRead: true,
|
||||||
|
canCreate: true,
|
||||||
|
canUpdate: false,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
renderML();
|
||||||
|
|
||||||
|
expect(screen.queryByLabelText('Select all assets')).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('create asset', () => {
|
describe('create asset', () => {
|
||||||
it('hides the "Upload new asset" button when the user does not have the permissions to', async () => {
|
it('hides the "Upload new asset" button when the user does not have the permissions to', async () => {
|
||||||
useRBAC.mockReturnValue({
|
useRBAC.mockReturnValue({
|
||||||
|
Loading…
x
Reference in New Issue
Block a user