* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act, screen } from '@testing-library/react'; | |||||
import { screen } from '@testing-library/react'; | |||||
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import { formatISO, parseISO } from 'date-fns'; | import { formatISO, parseISO } from 'date-fns'; | ||||
import { byRole } from '../../../../../src/main/js/helpers/testSelector'; | import { byRole } from '../../../../../src/main/js/helpers/testSelector'; | ||||
onChange.mockClear(); | onChange.mockClear(); | ||||
act(() => { | |||||
jest.runAllTimers(); | |||||
}); | |||||
jest.runAllTimers(); | |||||
const previousButton = nav.byRole('button', { name: 'previous_month_x' }); | const previousButton = nav.byRole('button', { name: 'previous_month_x' }); | ||||
const nextButton = nav.byRole('button', { name: 'next_month_x' }); | const nextButton = nav.byRole('button', { name: 'next_month_x' }); |
* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act, screen } from '@testing-library/react'; | |||||
import { screen } from '@testing-library/react'; | |||||
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import { renderWithContext } from '../../../helpers/testUtils'; | import { renderWithContext } from '../../../helpers/testUtils'; | ||||
import { FCProps } from '../../../types/misc'; | import { FCProps } from '../../../types/misc'; | ||||
expect(screen.queryByText('different')).not.toBeInTheDocument(); | expect(screen.queryByText('different')).not.toBeInTheDocument(); | ||||
await user.keyboard('{Escape}'); | await user.keyboard('{Escape}'); | ||||
expect(await screen.findByText('different')).toBeInTheDocument(); | expect(await screen.findByText('different')).toBeInTheDocument(); | ||||
await act(async () => { | |||||
await user.keyboard('{Escape}'); | |||||
}); | |||||
await user.keyboard('{Escape}'); | |||||
expect(screen.queryByText('different')).not.toBeInTheDocument(); | expect(screen.queryByText('different')).not.toBeInTheDocument(); | ||||
await user.tab({ shift: true }); | await user.tab({ shift: true }); | ||||
await user.keyboard('{ArrowDown}'); | await user.keyboard('{ArrowDown}'); |
* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act, screen, waitFor } from '@testing-library/react'; | |||||
import { screen, waitFor } from '@testing-library/react'; | |||||
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import React, { useContext } from 'react'; | import React, { useContext } from 'react'; | ||||
import { Route } from 'react-router-dom'; | import { Route } from 'react-router-dom'; | ||||
}); | }); | ||||
await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(1)); | await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(1)); | ||||
act(() => jest.runOnlyPendingTimers()); | |||||
jest.runOnlyPendingTimers(); | |||||
// Second round, the queue is now empty, hence we assume the previous task | // Second round, the queue is now empty, hence we assume the previous task | ||||
// was done. We immediately load the component again. | // was done. We immediately load the component again. | ||||
expect(getTasksForComponent).toHaveBeenCalledTimes(3); | expect(getTasksForComponent).toHaveBeenCalledTimes(3); | ||||
// Make sure the timeout was cleared. It should not be called again. | // Make sure the timeout was cleared. It should not be called again. | ||||
act(() => jest.runAllTimers()); | |||||
jest.runAllTimers(); | |||||
// The number of calls haven't changed. | // The number of calls haven't changed. | ||||
await waitFor(() => { | await waitFor(() => { | ||||
}); | }); | ||||
await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(1)); | await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(1)); | ||||
act(() => jest.runOnlyPendingTimers()); | |||||
jest.runOnlyPendingTimers(); | |||||
// Second round, nothing in the queue, BUT a success task is current. This | // Second round, nothing in the queue, BUT a success task is current. This | ||||
// means the queue was processed too quick for us to see, and we didn't see | // means the queue was processed too quick for us to see, and we didn't see | ||||
// status endpoint. | // status endpoint. | ||||
await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(1)); | await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(1)); | ||||
act(() => jest.runOnlyPendingTimers()); | |||||
jest.runOnlyPendingTimers(); | |||||
// Second round, nothing in the queue, and a success task is current. This | // Second round, nothing in the queue, and a success task is current. This | ||||
// implies the current task was updated, and previously we displayed some information | // implies the current task was updated, and previously we displayed some information | ||||
await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(1)); | await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(1)); | ||||
act(() => jest.runOnlyPendingTimers()); | |||||
jest.runOnlyPendingTimers(); | |||||
expect(mockedReplace).not.toHaveBeenCalled(); | expect(mockedReplace).not.toHaveBeenCalled(); | ||||
await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(2)); | await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(2)); | ||||
await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(1)); | await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(1)); | ||||
act(() => jest.runOnlyPendingTimers()); | |||||
jest.runOnlyPendingTimers(); | |||||
expect(mockedReplace).not.toHaveBeenCalled(); | expect(mockedReplace).not.toHaveBeenCalled(); | ||||
await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(2)); | await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(2)); | ||||
await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(1)); | await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(1)); | ||||
act(() => jest.runOnlyPendingTimers()); | |||||
jest.runOnlyPendingTimers(); | |||||
expect(mockedReplace).not.toHaveBeenCalled(); | expect(mockedReplace).not.toHaveBeenCalled(); | ||||
await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(2)); | await waitFor(() => expect(getTasksForComponent).toHaveBeenCalledTimes(2)); |
* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act } from '@testing-library/react'; | |||||
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import React from 'react'; | import React from 'react'; | ||||
import { renderComponent } from '../../../helpers/testReactTestingUtils'; | import { renderComponent } from '../../../helpers/testReactTestingUtils'; | ||||
expect(ui.modalTitle.query()).not.toBeInTheDocument(); | expect(ui.modalTitle.query()).not.toBeInTheDocument(); | ||||
await act(() => user.keyboard('?')); | |||||
await user.keyboard('?'); | |||||
expect(ui.modalTitle.get()).toBeInTheDocument(); | expect(ui.modalTitle.get()).toBeInTheDocument(); | ||||
const user = userEvent.setup(); | const user = userEvent.setup(); | ||||
renderKeyboardShortcutsModal(); | renderKeyboardShortcutsModal(); | ||||
await act(() => user.keyboard('!')); | |||||
await user.keyboard('!'); | |||||
expect(ui.modalTitle.query()).not.toBeInTheDocument(); | expect(ui.modalTitle.query()).not.toBeInTheDocument(); | ||||
}); | }); | ||||
renderKeyboardShortcutsModal(); | renderKeyboardShortcutsModal(); | ||||
await user.click(ui.textInput.get()); | await user.click(ui.textInput.get()); | ||||
await act(() => user.keyboard('?')); | |||||
await user.keyboard('?'); | |||||
expect(ui.modalTitle.query()).not.toBeInTheDocument(); | expect(ui.modalTitle.query()).not.toBeInTheDocument(); | ||||
}); | }); |
* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act, screen } from '@testing-library/react'; | |||||
import { screen } from '@testing-library/react'; | |||||
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import { addGlobalErrorMessage, addGlobalSuccessMessage } from 'design-system'; | import { addGlobalErrorMessage, addGlobalSuccessMessage } from 'design-system'; | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
renderComponentIssueOpenInIdeButton(); | renderComponentIssueOpenInIdeButton(); | ||||
await act(async () => { | |||||
await user.click( | |||||
screen.getByRole('button', { | |||||
name: 'open_in_ide', | |||||
}), | |||||
); | |||||
}); | |||||
await user.click( | |||||
screen.getByRole('button', { | |||||
name: 'open_in_ide', | |||||
}), | |||||
); | |||||
expect(probeSonarLintServers).toHaveBeenCalledWith(); | expect(probeSonarLintServers).toHaveBeenCalledWith(); | ||||
renderComponentIssueOpenInIdeButton(); | renderComponentIssueOpenInIdeButton(); | ||||
await act(async () => { | |||||
await user.click( | |||||
screen.getByRole('button', { | |||||
name: 'open_in_ide', | |||||
}), | |||||
); | |||||
}); | |||||
await user.click( | |||||
screen.getByRole('button', { | |||||
name: 'open_in_ide', | |||||
}), | |||||
); | |||||
expect(probeSonarLintServers).toHaveBeenCalledWith(); | expect(probeSonarLintServers).toHaveBeenCalledWith(); | ||||
renderComponentIssueOpenInIdeButton(); | renderComponentIssueOpenInIdeButton(); | ||||
await act(async () => { | |||||
await user.click( | |||||
screen.getByRole('button', { | |||||
name: 'open_in_ide', | |||||
}), | |||||
); | |||||
}); | |||||
await user.click( | |||||
screen.getByRole('button', { | |||||
name: 'open_in_ide', | |||||
}), | |||||
); | |||||
expect(probeSonarLintServers).toHaveBeenCalledWith(); | expect(probeSonarLintServers).toHaveBeenCalledWith(); | ||||
expect(secondIde).toBeInTheDocument(); | expect(secondIde).toBeInTheDocument(); | ||||
await act(async () => { | |||||
await user.click(secondIde); | |||||
}); | |||||
await user.click(secondIde); | |||||
expect(openSonarLintIssue).toHaveBeenCalledWith({ | expect(openSonarLintIssue).toHaveBeenCalledWith({ | ||||
branchName: undefined, | branchName: undefined, |
* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act } from '@testing-library/react'; | |||||
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import React from 'react'; | import React from 'react'; | ||||
import IssuesServiceMock from '../../../../api/mocks/IssuesServiceMock'; | import IssuesServiceMock from '../../../../api/mocks/IssuesServiceMock'; | ||||
expect(await ui.guidePopup.find()).toBeInTheDocument(); | expect(await ui.guidePopup.find()).toBeInTheDocument(); | ||||
expect(ui.guidePopup.get()).toHaveTextContent('guiding.issue_accept.1.title'); | expect(ui.guidePopup.get()).toHaveTextContent('guiding.issue_accept.1.title'); | ||||
await act(async () => { | |||||
await user.click(ui.guidePopup.byRole('button', { name: 'next' }).get()); | |||||
}); | |||||
await user.click(ui.guidePopup.byRole('button', { name: 'next' }).get()); | |||||
expect(ui.guidePopup.get()).toHaveTextContent('guiding.issue_accept.2.title'); | expect(ui.guidePopup.get()).toHaveTextContent('guiding.issue_accept.2.title'); | ||||
await act(async () => { | |||||
await user.click(ui.guidePopup.byRole('button', { name: 'go_back' }).get()); | |||||
}); | |||||
await user.click(ui.guidePopup.byRole('button', { name: 'go_back' }).get()); | |||||
expect(ui.guidePopup.get()).toHaveTextContent('guiding.issue_accept.1.title'); | expect(ui.guidePopup.get()).toHaveTextContent('guiding.issue_accept.1.title'); | ||||
await act(async () => { | |||||
await user.click(ui.guidePopup.byRole('button', { name: 'next' }).get()); | |||||
}); | |||||
await act(async () => { | |||||
await user.click(ui.guidePopup.byRole('button', { name: 'next' }).get()); | |||||
}); | |||||
await user.click(ui.guidePopup.byRole('button', { name: 'next' }).get()); | |||||
await user.click(ui.guidePopup.byRole('button', { name: 'next' }).get()); | |||||
expect(ui.guidePopup.get()).toHaveTextContent('guiding.issue_accept.3.title'); | expect(ui.guidePopup.get()).toHaveTextContent('guiding.issue_accept.3.title'); | ||||
expect(ui.guidePopup.byRole('button', { name: 'Next' }).query()).not.toBeInTheDocument(); | expect(ui.guidePopup.byRole('button', { name: 'Next' }).query()).not.toBeInTheDocument(); | ||||
await act(async () => { | |||||
await user.click(ui.guidePopup.byRole('button', { name: 'close' }).get()); | |||||
}); | |||||
await user.click(ui.guidePopup.byRole('button', { name: 'close' }).get()); | |||||
expect(ui.guidePopup.query()).not.toBeInTheDocument(); | expect(ui.guidePopup.query()).not.toBeInTheDocument(); | ||||
}); | }); |
* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act, screen, waitFor } from '@testing-library/react'; | |||||
import { screen, waitFor } from '@testing-library/react'; | |||||
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import AlmSettingsServiceMock from '../../../../../api/mocks/AlmSettingsServiceMock'; | import AlmSettingsServiceMock from '../../../../../api/mocks/AlmSettingsServiceMock'; | ||||
import GithubProvisioningServiceMock from '../../../../../api/mocks/GithubProvisioningServiceMock'; | import GithubProvisioningServiceMock from '../../../../../api/mocks/GithubProvisioningServiceMock'; | ||||
expect( | expect( | ||||
ui.projectPermissionCheckbox('sonar-users', Permissions.Browse).query(), | ui.projectPermissionCheckbox('sonar-users', Permissions.Browse).query(), | ||||
).not.toBeInTheDocument(); | ).not.toBeInTheDocument(); | ||||
await act(async () => { | |||||
await ui.turnProjectPrivate(); | |||||
}); | |||||
await ui.turnProjectPrivate(); | |||||
expect(ui.visibilityRadio(Visibility.Private).get()).toBeChecked(); | expect(ui.visibilityRadio(Visibility.Private).get()).toBeChecked(); | ||||
expect( | expect( | ||||
ui.projectPermissionCheckbox('sonar-users', Permissions.Browse).get(), | ui.projectPermissionCheckbox('sonar-users', Permissions.Browse).get(), | ||||
await ui.turnProjectPublic(); | await ui.turnProjectPublic(); | ||||
expect(ui.makePublicDisclaimer.get()).toBeInTheDocument(); | expect(ui.makePublicDisclaimer.get()).toBeInTheDocument(); | ||||
await act(async () => { | |||||
await ui.confirmTurnProjectPublic(); | |||||
}); | |||||
await ui.confirmTurnProjectPublic(); | |||||
expect(ui.visibilityRadio(Visibility.Public).get()).toBeChecked(); | expect(ui.visibilityRadio(Visibility.Public).get()).toBeChecked(); | ||||
}); | }); | ||||
expect(ui.visibilityRadio(Visibility.Public).get()).toBeDisabled(); | expect(ui.visibilityRadio(Visibility.Public).get()).toBeDisabled(); | ||||
expect(ui.visibilityRadio(Visibility.Public).get()).toBeChecked(); | expect(ui.visibilityRadio(Visibility.Public).get()).toBeChecked(); | ||||
expect(ui.visibilityRadio(Visibility.Private).get()).toBeDisabled(); | expect(ui.visibilityRadio(Visibility.Private).get()).toBeDisabled(); | ||||
await act(async () => { | |||||
await ui.turnProjectPrivate(); | |||||
}); | |||||
await ui.turnProjectPrivate(); | |||||
expect(ui.visibilityRadio(Visibility.Private).get()).not.toBeChecked(); | expect(ui.visibilityRadio(Visibility.Private).get()).not.toBeChecked(); | ||||
}); | }); | ||||
expect(ui.visibilityRadio(Visibility.Public).get()).not.toHaveClass('disabled'); | expect(ui.visibilityRadio(Visibility.Public).get()).not.toHaveClass('disabled'); | ||||
expect(ui.visibilityRadio(Visibility.Public).get()).toBeChecked(); | expect(ui.visibilityRadio(Visibility.Public).get()).toBeChecked(); | ||||
expect(ui.visibilityRadio(Visibility.Private).get()).not.toHaveClass('disabled'); | expect(ui.visibilityRadio(Visibility.Private).get()).not.toHaveClass('disabled'); | ||||
await act(async () => { | |||||
await ui.turnProjectPrivate(); | |||||
}); | |||||
await ui.turnProjectPrivate(); | |||||
expect(ui.visibilityRadio(Visibility.Private).get()).toBeChecked(); | expect(ui.visibilityRadio(Visibility.Private).get()).toBeChecked(); | ||||
}); | }); | ||||
expect(ui.visibilityRadio(Visibility.Public).get()).not.toHaveClass('disabled'); | expect(ui.visibilityRadio(Visibility.Public).get()).not.toHaveClass('disabled'); | ||||
expect(ui.visibilityRadio(Visibility.Public).get()).toBeChecked(); | expect(ui.visibilityRadio(Visibility.Public).get()).toBeChecked(); | ||||
expect(ui.visibilityRadio(Visibility.Private).get()).not.toHaveClass('disabled'); | expect(ui.visibilityRadio(Visibility.Private).get()).not.toHaveClass('disabled'); | ||||
await act(async () => { | |||||
await ui.turnProjectPrivate(); | |||||
}); | |||||
await ui.turnProjectPrivate(); | |||||
expect(ui.visibilityRadio(Visibility.Private).get()).toBeChecked(); | expect(ui.visibilityRadio(Visibility.Private).get()).toBeChecked(); | ||||
}); | }); | ||||
expect(ui.confirmRemovePermissionDialog.get()).toHaveTextContent( | expect(ui.confirmRemovePermissionDialog.get()).toHaveTextContent( | ||||
`${Permissions.IssueAdmin}Alexa`, | `${Permissions.IssueAdmin}Alexa`, | ||||
); | ); | ||||
await act(() => | |||||
user.click(ui.confirmRemovePermissionDialog.byRole('button', { name: 'confirm' }).get()), | |||||
); | |||||
await user.click(ui.confirmRemovePermissionDialog.byRole('button', { name: 'confirm' }).get()); | |||||
expect(ui.projectPermissionCheckbox('Alexa', Permissions.IssueAdmin).get()).not.toBeChecked(); | expect(ui.projectPermissionCheckbox('Alexa', Permissions.IssueAdmin).get()).not.toBeChecked(); | ||||
expect(ui.projectPermissionCheckbox('sonar-users', Permissions.Browse).get()).toBeChecked(); | expect(ui.projectPermissionCheckbox('sonar-users', Permissions.Browse).get()).toBeChecked(); | ||||
expect(ui.confirmRemovePermissionDialog.get()).toHaveTextContent( | expect(ui.confirmRemovePermissionDialog.get()).toHaveTextContent( | ||||
`${Permissions.Browse}sonar-users`, | `${Permissions.Browse}sonar-users`, | ||||
); | ); | ||||
await act(() => | |||||
user.click(ui.confirmRemovePermissionDialog.byRole('button', { name: 'confirm' }).get()), | |||||
); | |||||
await user.click(ui.confirmRemovePermissionDialog.byRole('button', { name: 'confirm' }).get()); | |||||
expect(ui.projectPermissionCheckbox('sonar-users', Permissions.Browse).get()).not.toBeChecked(); | expect(ui.projectPermissionCheckbox('sonar-users', Permissions.Browse).get()).not.toBeChecked(); | ||||
expect(ui.projectPermissionCheckbox('sonar-admins', Permissions.Admin).get()).toBeChecked(); | expect(ui.projectPermissionCheckbox('sonar-admins', Permissions.Admin).get()).toBeChecked(); | ||||
expect(ui.projectPermissionCheckbox('sonar-admins', Permissions.Admin).get()).toHaveAttribute( | expect(ui.projectPermissionCheckbox('sonar-admins', Permissions.Admin).get()).toHaveAttribute( |
* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act, waitFor } from '@testing-library/react'; | |||||
import { waitFor } from '@testing-library/react'; | |||||
import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup'; | import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup'; | ||||
import selectEvent from 'react-select-event'; | import selectEvent from 'react-select-event'; | ||||
import { byRole, byText } from '../../helpers/testSelector'; | import { byRole, byText } from '../../helpers/testSelector'; | ||||
}); | }); | ||||
}, | }, | ||||
async toggleProjectPermission(target: string, permission: Permissions) { | async toggleProjectPermission(target: string, permission: Permissions) { | ||||
await act(() => user.click(ui.projectPermissionCheckbox(target, permission).get())); | |||||
await user.click(ui.projectPermissionCheckbox(target, permission).get()); | |||||
}, | }, | ||||
async toggleGlobalPermission(target: string, permission: Permissions) { | async toggleGlobalPermission(target: string, permission: Permissions) { | ||||
await user.click(ui.globalPermissionCheckbox(target, permission).get()); | await user.click(ui.globalPermissionCheckbox(target, permission).get()); |
* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act, screen } from '@testing-library/react'; | |||||
import { screen } from '@testing-library/react'; | |||||
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import { setApplicationTags, setProjectTags } from '../../../../../api/components'; | import { setApplicationTags, setProjectTags } from '../../../../../api/components'; | ||||
expect(await screen.findByText('foo, bar')).toBeInTheDocument(); | expect(await screen.findByText('foo, bar')).toBeInTheDocument(); | ||||
expect(screen.getByRole('button')).toBeInTheDocument(); | expect(screen.getByRole('button')).toBeInTheDocument(); | ||||
await act(() => user.click(screen.getByRole('button', { name: 'foo bar +' }))); | |||||
await user.click(screen.getByRole('button', { name: 'foo bar +' })); | |||||
expect(await screen.findByRole('checkbox', { name: 'best' })).toBeInTheDocument(); | expect(await screen.findByRole('checkbox', { name: 'best' })).toBeInTheDocument(); | ||||
}), | }), | ||||
}); | }); | ||||
await act(() => user.click(screen.getByRole('button', { name: 'no_tags +' }))); | |||||
await user.click(screen.getByRole('button', { name: 'no_tags +' })); | |||||
await user.click(await screen.findByRole('checkbox', { name: 'best' })); | await user.click(await screen.findByRole('checkbox', { name: 'best' })); | ||||
* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act, fireEvent, screen, waitFor } from '@testing-library/react'; | |||||
import { fireEvent, screen, waitFor } from '@testing-library/react'; | |||||
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import selectEvent from 'react-select-event'; | import selectEvent from 'react-select-event'; | ||||
), | ), | ||||
).toBeInTheDocument(); | ).toBeInTheDocument(); | ||||
await act(async () => { | |||||
await selectEvent.select( | |||||
screen.getByLabelText('overview.badges.format'), | |||||
'overview.badges.options.formats.url', | |||||
); | |||||
}); | |||||
await selectEvent.select( | |||||
screen.getByLabelText('overview.badges.format'), | |||||
'overview.badges.options.formats.url', | |||||
); | |||||
expect( | expect( | ||||
screen.getByText( | screen.getByText( | ||||
), | ), | ||||
).toBeInTheDocument(); | ).toBeInTheDocument(); | ||||
await act(async () => { | |||||
await selectEvent.openMenu(screen.getByLabelText('overview.badges.metric')); | |||||
}); | |||||
await selectEvent.openMenu(screen.getByLabelText('overview.badges.metric')); | |||||
fireEvent.click(screen.getByText(`metric.${MetricKey.coverage}.name`)); | fireEvent.click(screen.getByText(`metric.${MetricKey.coverage}.name`)); | ||||
expect( | expect( | ||||
renderProjectBadges(); | renderProjectBadges(); | ||||
await appLoaded(); | await appLoaded(); | ||||
await act(async () => { | |||||
await selectEvent.openMenu(screen.getByLabelText('overview.badges.metric')); | |||||
}); | |||||
await selectEvent.openMenu(screen.getByLabelText('overview.badges.metric')); | |||||
fireEvent.click(screen.getByText(`metric.${MetricKey.bugs}.name (deprecated)`)); | fireEvent.click(screen.getByText(`metric.${MetricKey.bugs}.name (deprecated)`)); | ||||
expect( | expect( |
* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act, screen } from '@testing-library/react'; | |||||
import { screen } from '@testing-library/react'; | |||||
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
import BranchesServiceMock from '../../../../api/mocks/BranchesServiceMock'; | import BranchesServiceMock from '../../../../api/mocks/BranchesServiceMock'; | ||||
expect(ui.moreInfo.get()).toBeInTheDocument(); | expect(ui.moreInfo.get()).toBeInTheDocument(); | ||||
expect(ui.branchSelect.get()).toBeInTheDocument(); | expect(ui.branchSelect.get()).toBeInTheDocument(); | ||||
await act(async () => { | |||||
await user.click(ui.branchSelect.get()); | |||||
await user.keyboard('[ArrowDown][Enter]'); | |||||
}); | |||||
await user.click(ui.branchSelect.get()); | |||||
await user.keyboard('[ArrowDown][Enter]'); | |||||
expect(ui.downloadButton.get()).toBeInTheDocument(); | expect(ui.downloadButton.get()).toBeInTheDocument(); | ||||
expect(screen.queryByText('regulatory_page.download_start.sentence')).not.toBeInTheDocument(); | expect(screen.queryByText('regulatory_page.download_start.sentence')).not.toBeInTheDocument(); | ||||
await act(async () => { | |||||
await user.click(ui.downloadButton.get()); | |||||
}); | |||||
await user.click(ui.downloadButton.get()); | |||||
expect(screen.getByText('regulatory_page.download_start.sentence')).toBeInTheDocument(); | expect(screen.getByText('regulatory_page.download_start.sentence')).toBeInTheDocument(); | ||||
}); | }); |
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import { last } from 'lodash'; | import { last } from 'lodash'; | ||||
import React from 'react'; | import React from 'react'; | ||||
import { act } from 'react-dom/test-utils'; | |||||
import { Route } from 'react-router-dom'; | import { Route } from 'react-router-dom'; | ||||
import ComponentsServiceMock from '../../../api/mocks/ComponentsServiceMock'; | import ComponentsServiceMock from '../../../api/mocks/ComponentsServiceMock'; | ||||
import { renderAppWithComponentContext } from '../../../helpers/testReactTestingUtils'; | import { renderAppWithComponentContext } from '../../../helpers/testReactTestingUtils'; | ||||
// Dialog should show old and new keys | // Dialog should show old and new keys | ||||
expect(within(ui.updateKeyDialog.get()).getByText(oldKey)).toBeInTheDocument(); | expect(within(ui.updateKeyDialog.get()).getByText(oldKey)).toBeInTheDocument(); | ||||
expect(within(ui.updateKeyDialog.get()).getByText(newKey)).toBeInTheDocument(); | expect(within(ui.updateKeyDialog.get()).getByText(newKey)).toBeInTheDocument(); | ||||
await act(async () => { | |||||
await user.click(last(ui.updateInputButton.getAll()) as HTMLElement); | |||||
}); | |||||
await user.click(last(ui.updateInputButton.getAll()) as HTMLElement); | |||||
expect(ui.updateInputButton.get()).toBeDisabled(); | expect(ui.updateInputButton.get()).toBeDisabled(); | ||||
expect(ui.newKeyInput.get()).toHaveValue(newKey); | expect(ui.newKeyInput.get()).toHaveValue(newKey); |
* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act } from '@testing-library/react'; | |||||
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import { last } from 'lodash'; | import { last } from 'lodash'; | ||||
import selectEvent from 'react-select-event'; | import selectEvent from 'react-select-event'; | ||||
expect(await ui.branchNCDsBanner.find()).toBeInTheDocument(); | expect(await ui.branchNCDsBanner.find()).toBeInTheDocument(); | ||||
const user = userEvent.setup(); | const user = userEvent.setup(); | ||||
await act(async () => { | |||||
await user.click(ui.dismissButton.get()); | |||||
}); | |||||
await user.click(ui.dismissButton.get()); | |||||
expect(ui.branchNCDsBanner.query()).not.toBeInTheDocument(); | expect(ui.branchNCDsBanner.query()).not.toBeInTheDocument(); | ||||
}); | }); |
* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act, screen, waitFor } from '@testing-library/react'; | |||||
import { screen, waitFor } from '@testing-library/react'; | |||||
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import React from 'react'; | import React from 'react'; | ||||
import { Route } from 'react-router-dom'; | import { Route } from 'react-router-dom'; | ||||
await user.click(await ui.activeAssignee.find()); | await user.click(await ui.activeAssignee.find()); | ||||
await user.click(ui.inputAssignee.get()); | await user.click(ui.inputAssignee.get()); | ||||
await act(async () => { | |||||
await user.keyboard('User'); | |||||
}); | |||||
await user.keyboard('User'); | |||||
expect(getUsers).toHaveBeenLastCalledWith({ q: 'User' }); | expect(getUsers).toHaveBeenLastCalledWith({ q: 'User' }); | ||||
await user.keyboard('{Enter}'); | await user.keyboard('{Enter}'); | ||||
await user.click(screen.getByRole('textbox', { name: 'hotspots.status.add_comment_optional' })); | await user.click(screen.getByRole('textbox', { name: 'hotspots.status.add_comment_optional' })); | ||||
await user.keyboard(comment); | await user.keyboard(comment); | ||||
await act(async () => { | |||||
await user.click(ui.changeStatus.get()); | |||||
}); | |||||
await user.click(ui.changeStatus.get()); | |||||
expect(ui.continueReviewingButton.get()).toBeInTheDocument(); | expect(ui.continueReviewingButton.get()).toBeInTheDocument(); | ||||
await user.click(ui.continueReviewingButton.get()); | await user.click(ui.continueReviewingButton.get()); | ||||
const user = userEvent.setup(); | const user = userEvent.setup(); | ||||
renderSecurityHotspotsApp(); | renderSecurityHotspotsApp(); | ||||
await act(() => user.keyboard('{ArrowLeft}')); | |||||
await user.keyboard('{ArrowLeft}'); | |||||
expect(ui.codeContent.get()).toBeInTheDocument(); | expect(ui.codeContent.get()).toBeInTheDocument(); | ||||
await act(() => user.keyboard('{ArrowRight}')); | |||||
await user.keyboard('{ArrowRight}'); | |||||
expect(ui.riskContent.get()).toBeInTheDocument(); | expect(ui.riskContent.get()).toBeInTheDocument(); | ||||
await act(() => user.keyboard('{ArrowRight}')); | |||||
await user.keyboard('{ArrowRight}'); | |||||
expect(ui.vulnerabilityContent.get()).toBeInTheDocument(); | expect(ui.vulnerabilityContent.get()).toBeInTheDocument(); | ||||
await act(() => user.keyboard('{ArrowRight}')); | |||||
await user.keyboard('{ArrowRight}'); | |||||
expect(ui.fixContent.get()).toBeInTheDocument(); | expect(ui.fixContent.get()).toBeInTheDocument(); | ||||
await act(() => user.keyboard('{ArrowRight}')); | |||||
await user.keyboard('{ArrowRight}'); | |||||
expect(ui.addCommentButton.get()).toBeInTheDocument(); | expect(ui.addCommentButton.get()).toBeInTheDocument(); | ||||
await act(() => user.keyboard('{ArrowRight}')); | |||||
await user.keyboard('{ArrowRight}'); | |||||
expect(ui.addCommentButton.get()).toBeInTheDocument(); | expect(ui.addCommentButton.get()).toBeInTheDocument(); | ||||
}); | }); | ||||
await user.click(await ui.reviewButton.find()); | await user.click(await ui.reviewButton.find()); | ||||
await user.click(ui.toReviewStatus.get()); | await user.click(ui.toReviewStatus.get()); | ||||
await act(async () => { | |||||
await user.click(ui.changeStatus.get()); | |||||
}); | |||||
await user.click(ui.changeStatus.get()); | |||||
await user.click(ui.dontShowSuccessDialogCheckbox.get()); | await user.click(ui.dontShowSuccessDialogCheckbox.get()); | ||||
expect(ui.dontShowSuccessDialogCheckbox.get()).toBeChecked(); | expect(ui.dontShowSuccessDialogCheckbox.get()).toBeChecked(); | ||||
await user.click(await ui.reviewButton.find()); | await user.click(await ui.reviewButton.find()); | ||||
await user.click(ui.toReviewStatus.get()); | await user.click(ui.toReviewStatus.get()); | ||||
await act(async () => { | |||||
await user.click(ui.changeStatus.get()); | |||||
}); | |||||
await user.click(ui.changeStatus.get()); | |||||
expect(ui.continueReviewingButton.query()).not.toBeInTheDocument(); | expect(ui.continueReviewingButton.query()).not.toBeInTheDocument(); | ||||
}); | }); |
* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act } from '@testing-library/react'; | |||||
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import React from 'react'; | import React from 'react'; | ||||
import selectEvent from 'react-select-event'; | import selectEvent from 'react-select-event'; | ||||
await ui.setInput(inputId, value); | await ui.setInput(inputId, value); | ||||
} | } | ||||
// Save form and check for errors | // Save form and check for errors | ||||
await act(() => user.click(ui.saveButton.get())); | |||||
await user.click(ui.saveButton.get()); | |||||
expect(await ui.validationMsg('cute error').find()).toBeInTheDocument(); | expect(await ui.validationMsg('cute error').find()).toBeInTheDocument(); | ||||
// Check validation with errors | // Check validation with errors | ||||
await act(() => user.click(ui.validateButton.get())); | |||||
await user.click(ui.validateButton.get()); | |||||
expect(ui.validationMsg('cute error').get()).toBeInTheDocument(); | expect(ui.validationMsg('cute error').get()).toBeInTheDocument(); | ||||
// Save form and check for errors | // Save form and check for errors | ||||
Object.keys(list).find((key) => key.endsWith('.repository')) as string, | Object.keys(list).find((key) => key.endsWith('.repository')) as string, | ||||
'Anything', | 'Anything', | ||||
); | ); | ||||
await act(() => user.click(ui.saveButton.get())); | |||||
await user.click(ui.saveButton.get()); | |||||
expect( | expect( | ||||
await ui.validationMsg('settings.pr_decoration.binding.check_configuration.success').find(), | await ui.validationMsg('settings.pr_decoration.binding.check_configuration.success').find(), | ||||
).toBeInTheDocument(); | ).toBeInTheDocument(); | ||||
await act(() => user.click(ui.validateButton.get())); | |||||
await user.click(ui.validateButton.get()); | |||||
expect( | expect( | ||||
ui.validationMsg('settings.pr_decoration.binding.check_configuration.success').get(), | ui.validationMsg('settings.pr_decoration.binding.check_configuration.success').get(), | ||||
).toBeInTheDocument(); | ).toBeInTheDocument(); | ||||
expect(ui.saveButton.query()).not.toBeInTheDocument(); | expect(ui.saveButton.query()).not.toBeInTheDocument(); | ||||
// Reset binding | // Reset binding | ||||
await act(() => user.click(ui.resetButton.get())); | |||||
await user.click(ui.resetButton.get()); | |||||
expect(ui.input('', 'textbox').query()).not.toBeInTheDocument(); | expect(ui.input('', 'textbox').query()).not.toBeInTheDocument(); | ||||
expect(ui.input('', 'switch').query()).not.toBeInTheDocument(); | expect(ui.input('', 'switch').query()).not.toBeInTheDocument(); | ||||
}, | }, |
* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act, render } from '@testing-library/react'; | |||||
import { act, fireEvent, render } from '@testing-library/react'; | |||||
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup'; | import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup'; | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
async function openToggler(user: UserEvent) { | async function openToggler(user: UserEvent) { | ||||
await user.click(ui.toggleButton.get()); | await user.click(ui.toggleButton.get()); | ||||
act(() => { | |||||
jest.runAllTimers(); | |||||
}); | |||||
jest.runAllTimers(); | |||||
expect(ui.overlayButton.get()).toBeInTheDocument(); | expect(ui.overlayButton.get()).toBeInTheDocument(); | ||||
} | } | ||||
function focusOut() { | function focusOut() { | ||||
act(() => { | |||||
ui.overlayButton.get().focus(); | |||||
ui.outButton.get().focus(); | |||||
}); | |||||
fireEvent.focus(ui.overlayButton.get()); | |||||
fireEvent.focus(ui.outButton.get()); | |||||
} | } | ||||
it('should handle key up/down', async () => { | it('should handle key up/down', async () => { | ||||
expect(await ui.overlayButton.find()).toBeInTheDocument(); | expect(await ui.overlayButton.find()).toBeInTheDocument(); | ||||
// Focus out should close | // Focus out should close | ||||
// I have no idea why only act + this 2 lines work, but fireEvent.focus does not | |||||
act(() => { | act(() => { | ||||
ui.overlayButton.get().focus(); | ui.overlayButton.get().focus(); | ||||
ui.outButton.get().focus(); | ui.outButton.get().focus(); |
* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act, screen } from '@testing-library/react'; | |||||
import { screen } from '@testing-library/react'; | |||||
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import { omit, pick } from 'lodash'; | import { omit, pick } from 'lodash'; | ||||
import * as React from 'react'; | import * as React from 'react'; | ||||
async addComment(content: string) { | async addComment(content: string) { | ||||
await user.click(selectors.commentAddBtn.get()); | await user.click(selectors.commentAddBtn.get()); | ||||
await user.type(selectors.commentTextInput.get(), content); | await user.type(selectors.commentTextInput.get(), content); | ||||
await act(async () => { | |||||
await user.click(selectors.commentSaveBtn.get()); | |||||
}); | |||||
await user.click(selectors.commentSaveBtn.get()); | |||||
}, | }, | ||||
async updateComment(content: string) { | async updateComment(content: string) { | ||||
await user.click(selectors.commentEditBtn.get()); | await user.click(selectors.commentEditBtn.get()); | ||||
await user.type(selectors.commentTextInput.get(), content); | await user.type(selectors.commentTextInput.get(), content); | ||||
await act(async () => { | |||||
await user.keyboard(`{Control>}{${KeyboardKeys.Enter}}{/Control}`); | |||||
}); | |||||
await user.keyboard(`{Control>}{${KeyboardKeys.Enter}}{/Control}`); | |||||
}, | }, | ||||
async deleteComment() { | async deleteComment() { | ||||
await user.click(selectors.commentDeleteBtn.get()); | await user.click(selectors.commentDeleteBtn.get()); | ||||
await act(async () => { | |||||
await user.click(selectors.commentConfirmDeleteBtn.get()); | |||||
}); | |||||
await user.click(selectors.commentConfirmDeleteBtn.get()); | |||||
}, | }, | ||||
async updateType(currentType: IssueType, newType: IssueType) { | async updateType(currentType: IssueType, newType: IssueType) { | ||||
await user.click(selectors.updateTypeBtn(currentType).get()); | await user.click(selectors.updateTypeBtn(currentType).get()); | ||||
await act(async () => { | |||||
await user.click(selectors.setTypeBtn(newType).get()); | |||||
}); | |||||
await user.click(selectors.setTypeBtn(newType).get()); | |||||
}, | }, | ||||
async updateSeverity(currentSeverity: IssueSeverity, newSeverity: IssueSeverity) { | async updateSeverity(currentSeverity: IssueSeverity, newSeverity: IssueSeverity) { | ||||
await user.click(selectors.updateSeverityBtn(currentSeverity).get()); | await user.click(selectors.updateSeverityBtn(currentSeverity).get()); | ||||
await act(async () => { | |||||
await user.click(selectors.setSeverityBtn(newSeverity).get()); | |||||
}); | |||||
await user.click(selectors.setSeverityBtn(newSeverity).get()); | |||||
}, | }, | ||||
async updateStatus(currentStatus: IssueStatus, transition: IssueTransition) { | async updateStatus(currentStatus: IssueStatus, transition: IssueTransition) { | ||||
await user.click(selectors.updateStatusBtn(currentStatus).get()); | await user.click(selectors.updateStatusBtn(currentStatus).get()); | ||||
await act(async () => { | |||||
await user.click(selectors.setStatusBtn(transition).get()); | |||||
}); | |||||
await user.click(selectors.setStatusBtn(transition).get()); | |||||
}, | }, | ||||
async updateAssignee(currentAssignee: string, newAssignee: string) { | async updateAssignee(currentAssignee: string, newAssignee: string) { | ||||
await user.click(selectors.updateAssigneeBtn(currentAssignee).get()); | await user.click(selectors.updateAssigneeBtn(currentAssignee).get()); | ||||
await act(async () => { | |||||
await user.type(selectors.assigneeSearchInput.get(), newAssignee); | |||||
}); | |||||
await act(async () => { | |||||
await user.click(selectors.setAssigneeBtn(new RegExp(newAssignee)).get()); | |||||
}); | |||||
await user.type(selectors.assigneeSearchInput.get(), newAssignee); | |||||
await user.click(selectors.setAssigneeBtn(new RegExp(newAssignee)).get()); | |||||
}, | }, | ||||
async addTag(tag: string, currentTagList?: string[]) { | async addTag(tag: string, currentTagList?: string[]) { | ||||
await user.click(selectors.updateTagsBtn(currentTagList).get()); | await user.click(selectors.updateTagsBtn(currentTagList).get()); | ||||
await act(async () => { | |||||
await user.click(selectors.toggleTagCheckbox(tag).get()); | |||||
}); | |||||
await act(async () => { | |||||
await user.keyboard('{Escape}'); | |||||
}); | |||||
await user.click(selectors.toggleTagCheckbox(tag).get()); | |||||
await user.keyboard('{Escape}'); | |||||
}, | }, | ||||
async showChangelog() { | async showChangelog() { | ||||
await user.click(selectors.toggleChangelogBtn.get()); | await user.click(selectors.toggleChangelogBtn.get()); | ||||
await user.click(selectors.issueMessageLink.get()); | await user.click(selectors.issueMessageLink.get()); | ||||
}, | }, | ||||
async pressDismissShortcut() { | async pressDismissShortcut() { | ||||
await act(async () => { | |||||
await user.keyboard(`{${KeyboardKeys.Escape}}`); | |||||
}); | |||||
await user.keyboard(`{${KeyboardKeys.Escape}}`); | |||||
}, | }, | ||||
async pressTransitionShortcut() { | async pressTransitionShortcut() { | ||||
await act(async () => { | |||||
await user.keyboard(`{${KeyboardKeys.KeyF}}`); | |||||
}); | |||||
await user.keyboard(`{${KeyboardKeys.KeyF}}`); | |||||
}, | }, | ||||
async pressAssignShortcut() { | async pressAssignShortcut() { | ||||
await act(async () => { | |||||
await user.keyboard(`{${KeyboardKeys.KeyA}}`); | |||||
}); | |||||
await user.keyboard(`{${KeyboardKeys.KeyA}}`); | |||||
}, | }, | ||||
async pressAssignToMeShortcut() { | async pressAssignToMeShortcut() { | ||||
await act(async () => { | |||||
await user.keyboard(`{${KeyboardKeys.KeyM}}`); | |||||
}); | |||||
await user.keyboard(`{${KeyboardKeys.KeyM}}`); | |||||
}, | }, | ||||
async pressSeverityShortcut() { | async pressSeverityShortcut() { | ||||
await act(async () => { | |||||
await user.keyboard(`{${KeyboardKeys.KeyI}}`); | |||||
}); | |||||
await user.keyboard(`{${KeyboardKeys.KeyI}}`); | |||||
}, | }, | ||||
async pressTagsShortcut() { | async pressTagsShortcut() { | ||||
await act(async () => { | |||||
await user.keyboard(`{${KeyboardKeys.KeyT}}`); | |||||
}); | |||||
await user.keyboard(`{${KeyboardKeys.KeyT}}`); | |||||
}, | }, | ||||
async pressCheckShortcut() { | async pressCheckShortcut() { | ||||
await act(async () => { | |||||
await user.keyboard(`{${KeyboardKeys.Space}}`); | |||||
}); | |||||
await user.keyboard(`{${KeyboardKeys.Space}}`); | |||||
}, | }, | ||||
}; | }; | ||||
* along with this program; if not, write to the Free Software Foundation, | * along with this program; if not, write to the Free Software Foundation, | ||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||||
*/ | */ | ||||
import { act } from '@testing-library/react'; | |||||
import userEvent from '@testing-library/user-event'; | import userEvent from '@testing-library/user-event'; | ||||
import React from 'react'; | import React from 'react'; | ||||
import { Route } from 'react-router-dom'; | import { Route } from 'react-router-dom'; | ||||
renderGlobalMessage(); | renderGlobalMessage(); | ||||
expect(await ui.globalBannerContent.find()).toBeVisible(); | expect(await ui.globalBannerContent.find()).toBeVisible(); | ||||
const user = userEvent.setup(); | const user = userEvent.setup(); | ||||
await act(async () => { | |||||
await user.click(ui.reviewLink.get()); | |||||
}); | |||||
await user.click(ui.reviewLink.get()); | |||||
expect(await ui.adminNcdMessage.find()).toBeVisible(); | expect(await ui.adminNcdMessage.find()).toBeVisible(); | ||||
}); | }); | ||||
}); | }); | ||||
renderProjectMessage(component); | renderProjectMessage(component); | ||||
expect(await ui.projectBannerContent.find()).toBeVisible(); | expect(await ui.projectBannerContent.find()).toBeVisible(); | ||||
const user = userEvent.setup(); | const user = userEvent.setup(); | ||||
await act(async () => { | |||||
await user.click(ui.reviewLink.get()); | |||||
}); | |||||
await user.click(ui.reviewLink.get()); | |||||
expect(await ui.projectNcdMessage.find()).toBeVisible(); | expect(await ui.projectNcdMessage.find()).toBeVisible(); | ||||
}); | }); | ||||
}); | }); |