mirror of
https://github.com/strapi/strapi.git
synced 2025-08-10 17:58:07 +00:00
add read button test
This commit is contained in:
parent
df6504fafc
commit
714233a0ce
@ -15,9 +15,7 @@ jest.mock('@strapi/helper-plugin', () => ({
|
|||||||
...jest.requireActual('@strapi/helper-plugin'),
|
...jest.requireActual('@strapi/helper-plugin'),
|
||||||
useNotification: jest.fn(),
|
useNotification: jest.fn(),
|
||||||
useFocusWhenNavigate: jest.fn(),
|
useFocusWhenNavigate: jest.fn(),
|
||||||
useRBAC: jest.fn(() => ({
|
useRBAC: jest.fn(),
|
||||||
allowedActions: { canCreate: true, canDelete: true, canRead: true, canUpdate: true },
|
|
||||||
})),
|
|
||||||
useGuidedTour: jest.fn(() => ({
|
useGuidedTour: jest.fn(() => ({
|
||||||
startSection: jest.fn(),
|
startSection: jest.fn(),
|
||||||
})),
|
})),
|
||||||
@ -73,6 +71,9 @@ describe('ADMIN | Pages | API TOKENS | ListPage', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should show a list of api tokens', async () => {
|
it('should show a list of api tokens', async () => {
|
||||||
|
useRBAC.mockImplementation(() => ({
|
||||||
|
allowedActions: { canCreate: true, canDelete: true, canRead: true, canUpdate: true },
|
||||||
|
}));
|
||||||
const history = createMemoryHistory();
|
const history = createMemoryHistory();
|
||||||
history.push('/settings/api-tokens');
|
history.push('/settings/api-tokens');
|
||||||
const app = makeApp(history);
|
const app = makeApp(history);
|
||||||
@ -989,7 +990,7 @@ describe('ADMIN | Pages | API TOKENS | ListPage', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should not show the create button when the user does not have the rights to create', async () => {
|
it('should not show the create button when the user does not have the rights to create', async () => {
|
||||||
useRBAC.mockImplementationOnce(() => ({
|
useRBAC.mockImplementation(() => ({
|
||||||
allowedActions: { canCreate: false, canDelete: true, canRead: true, canUpdate: true },
|
allowedActions: { canCreate: false, canDelete: true, canRead: true, canUpdate: true },
|
||||||
}));
|
}));
|
||||||
|
|
||||||
@ -1002,6 +1003,9 @@ describe('ADMIN | Pages | API TOKENS | ListPage', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should show the delete button when the user have the rights to delete', async () => {
|
it('should show the delete button when the user have the rights to delete', async () => {
|
||||||
|
useRBAC.mockImplementation(() => ({
|
||||||
|
allowedActions: { canCreate: false, canDelete: true, canRead: true, canUpdate: false },
|
||||||
|
}));
|
||||||
const history = createMemoryHistory();
|
const history = createMemoryHistory();
|
||||||
history.push('/settings/api-tokens');
|
history.push('/settings/api-tokens');
|
||||||
const app = makeApp(history);
|
const app = makeApp(history);
|
||||||
@ -1014,8 +1018,8 @@ describe('ADMIN | Pages | API TOKENS | ListPage', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('should show the read button when the user have the rights to read and not to update', async () => {
|
it('should show the read button when the user have the rights to read and not to update', async () => {
|
||||||
useRBAC.mockImplementationOnce(() => ({
|
useRBAC.mockImplementation(() => ({
|
||||||
allowedActions: { canCreate: false, canDelete: false, canRead: true, canUpdate: false },
|
allowedActions: { canCreate: false, canDelete: true, canRead: true, canUpdate: false },
|
||||||
}));
|
}));
|
||||||
const history = createMemoryHistory();
|
const history = createMemoryHistory();
|
||||||
history.push('/settings/api-tokens');
|
history.push('/settings/api-tokens');
|
||||||
@ -1024,7 +1028,7 @@ describe('ADMIN | Pages | API TOKENS | ListPage', () => {
|
|||||||
const { container } = render(app);
|
const { container } = render(app);
|
||||||
|
|
||||||
await waitFor(() => {
|
await waitFor(() => {
|
||||||
expect(container.querySelector('a[title*="Edit"]')).toBeInTheDocument();
|
expect(container.querySelector('a[title*="Read"]')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user