mirror of
https://github.com/strapi/strapi.git
synced 2025-11-13 08:38:09 +00:00
Add tests for the permissions accordions
This commit is contained in:
parent
0c2fc63ccc
commit
65736dff2f
@ -1,5 +1,5 @@
|
|||||||
import React, { memo, useCallback, useReducer } from 'react';
|
import React, { memo, useCallback, useReducer } from 'react';
|
||||||
import { Accordion, AccordionToggle, AccordionContent, Box } from '@strapi/parts';
|
import { Accordion, AccordionToggle, AccordionContent } from '@strapi/parts';
|
||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
import { useUsersPermissions } from '../../contexts/UsersPermissionsContext';
|
import { useUsersPermissions } from '../../contexts/UsersPermissionsContext';
|
||||||
import formatPluginName from '../../utils/formatPluginName';
|
import formatPluginName from '../../utils/formatPluginName';
|
||||||
@ -36,7 +36,7 @@ const Permissions = () => {
|
|||||||
id: 'users-permissions.Plugin.permissions.plugins.description',
|
id: 'users-permissions.Plugin.permissions.plugins.description',
|
||||||
defaultMessage: 'Define all allowed actions for the {name} plugin.',
|
defaultMessage: 'Define all allowed actions for the {name} plugin.',
|
||||||
},
|
},
|
||||||
{ name: formatPluginName(collapse.name) }
|
{ name: collapse.name }
|
||||||
)}
|
)}
|
||||||
variant={index % 2 ? 'primary' : 'secondary'}
|
variant={index % 2 ? 'primary' : 'secondary'}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -966,4 +966,18 @@ describe('Admin | containers | RoleEditPage', () => {
|
|||||||
const errorMessages = await getAllByText(/invalid value/i);
|
const errorMessages = await getAllByText(/invalid value/i);
|
||||||
errorMessages.forEach(errorMessage => expect(errorMessage).toBeInTheDocument());
|
errorMessages.forEach(errorMessage => expect(errorMessage).toBeInTheDocument());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('can toggle the permissions accordions', async () => {
|
||||||
|
// Create app and wait for loading
|
||||||
|
const { getByLabelText, queryByText, getByTestId, getByText } = makeAndRenderApp();
|
||||||
|
const loader = getByTestId('loader');
|
||||||
|
await waitForElementToBeRemoved(loader).catch(e => console.error(e));
|
||||||
|
|
||||||
|
// Open then close the collapse
|
||||||
|
const collapse = getByText(/define all allowed actions for the application plugin/i);
|
||||||
|
await userEvent.click(collapse);
|
||||||
|
expect(getByLabelText(/select all/i)).toBeInTheDocument();
|
||||||
|
await userEvent.click(collapse);
|
||||||
|
expect(queryByText(/select all/i)).not.toBeInTheDocument();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user