Finish publish all modal

This commit is contained in:
Rémi de Juvigny 2023-04-28 12:09:04 +02:00
parent 7a53339f75
commit dc4c6a7877
3 changed files with 20 additions and 4 deletions

View File

@ -103,12 +103,14 @@ BulkActionsBar.defaultProps = {
showPublish: false,
showDelete: false,
onConfirmDeleteAll() {},
onConfirmPublishAll() {},
};
BulkActionsBar.propTypes = {
showPublish: PropTypes.bool,
showDelete: PropTypes.bool,
onConfirmDeleteAll: PropTypes.func,
onConfirmPublishAll: PropTypes.func,
selectedEntries: PropTypes.array.isRequired,
clearSelectedEntries: PropTypes.func.isRequired,
};

View File

@ -1,5 +1,5 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { act, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { ThemeProvider, lightTheme } from '@strapi/design-system';
import { IntlProvider } from 'react-intl';
@ -77,9 +77,23 @@ describe('BulkActionsBar', () => {
onConfirmDeleteAll: mockConfirmDeleteAll,
});
await user.click(screen.getByRole('button', { name: /\bDelete\b/ }));
await user.click(screen.getByRole('button', { name: /confirm/i }));
await act(async () => {
await user.click(screen.getByRole('button', { name: /\bDelete\b/ }));
await user.click(screen.getByRole('button', { name: /confirm/i }));
});
expect(mockConfirmDeleteAll).toHaveBeenCalledWith([]);
});
it('should show publish modal if publish button is clicked', async () => {
const onConfirmPublishAll = jest.fn();
setup({ showPublish: true, onConfirmPublishAll });
await act(async () => {
await user.click(screen.getByRole('button', { name: /\bpublish\b/i }));
await user.click(screen.getByTestId('confirm-publish'));
});
expect(onConfirmPublishAll).toHaveBeenCalledWith([]);
});
});

View File

@ -49,7 +49,7 @@ const ConfirmDialogPublishAll = ({ isConfirmButtonLoading, isOpen, onToggleDialo
onClick={onConfirm}
variant="secondary"
startIcon={<Check />}
id="confirm-publish"
data-testid="confirm-publish"
loading={isConfirmButtonLoading}
>
{formatMessage({