diff --git a/src/pages-and-resources/discussions/app-config-form/apps/legacy/LegacyConfigForm.jsx b/src/pages-and-resources/discussions/app-config-form/apps/legacy/LegacyConfigForm.jsx index c7aa7bc58..71335f774 100644 --- a/src/pages-and-resources/discussions/app-config-form/apps/legacy/LegacyConfigForm.jsx +++ b/src/pages-and-resources/discussions/app-config-form/apps/legacy/LegacyConfigForm.jsx @@ -22,7 +22,6 @@ setupYupExtensions(); function LegacyConfigForm({ onSubmit, formRef, intl }) { const { discussionTopicIds, divideDiscussionIds, selectedAppId } = useSelector((state) => state.discussions); const appConfigObj = useModel('appConfigs', selectedAppId); - const app = useModel('apps', selectedAppId); const discussionTopicsModel = useModels('discussionTopics', discussionTopicIds); const appConfig = { ...appConfigObj, discussionTopics: discussionTopicsModel, divideDiscussionIds }; const LegacyAppConfig = { @@ -101,7 +100,7 @@ function LegacyConfigForm({ onSubmit, formRef, intl }) {
-

{intl.formatMessage(messages[`appName-${app?.id}`])}

+

{intl.formatMessage(messages[`appName-${selectedAppId}`])}

{ const updateTopicName = async (topicId, topicName) => { const topicCard = queryByTestId(container, topicId); - userEvent.click(queryByLabelText(topicCard, 'Expand')); + await act(async () => { userEvent.click(queryByLabelText(topicCard, 'Expand')); }); const topicInput = topicCard.querySelector('input'); topicInput.focus(); await act(async () => { fireEvent.change(topicInput, { target: { value: topicName } }); }); @@ -234,7 +234,7 @@ describe('LegacyConfigForm', () => { test('check field is not collapsible in case of error', async () => { await mockStore(legacyApiResponse); - createComponent(defaultAppConfig); + createComponent(); const topicCard = await updateTopicName('13f106c6-6735-4e84-b097-0456cff55960', ''); const collapseButton = queryByLabelText(topicCard, 'Collapse'); @@ -263,31 +263,36 @@ describe('LegacyConfigForm', () => { test('check duplicate error is removed on fields when name is fixed', async () => { const duplicateTopicInput = duplicateTopicCard.querySelector('input'); - duplicateTopicInput.focus(); - userEvent.type(duplicateTopicInput, 'valid'); + await act(async () => { userEvent.type(duplicateTopicInput, 'valid'); }); duplicateTopicInput.blur(); await waitForElementToBeRemoved( - queryByText(duplicateTopicCard, messages.discussionTopicNameAlreadyExist.defaultMessage), + queryAllByText(topicCard, messages.discussionTopicNameAlreadyExist.defaultMessage), ); - await assertDuplicateTopicNameValidation(duplicateTopicCard, false, false); - await assertDuplicateTopicNameValidation(topicCard, false, false); + + await assertDuplicateTopicNameValidation(duplicateTopicCard, false); + await assertDuplicateTopicNameValidation(topicCard, false); assertHasErrorValidation(false); }); test('check duplicate error is removed on deleting duplicate topic', async () => { - userEvent.click( - queryByLabelText(duplicateTopicCard, messages.deleteAltText.defaultMessage, { selector: 'button' }), - ); - userEvent.click( - queryByRole(container, 'button', { name: messages.deleteButton.defaultMessage }), - ); + await act(async () => { + userEvent.click( + queryByLabelText(duplicateTopicCard, messages.deleteAltText.defaultMessage, { selector: 'button' }), + ); + }); + + await act(async () => { + userEvent.click( + queryByRole(container, 'button', { name: messages.deleteButton.defaultMessage }), + ); + }); await waitForElementToBeRemoved(queryByText(topicCard, messages.discussionTopicNameAlreadyExist.defaultMessage)); expect(duplicateTopicCard).not.toBeInTheDocument(); - await assertDuplicateTopicNameValidation(topicCard, false, false); + await assertDuplicateTopicNameValidation(topicCard, false); assertHasErrorValidation(false); }); });