"@emotion/babel-plugin-jsx-pragmatic": "0.2.1",
"@sonarsource/echoes-react": "0.6.0",
"@testing-library/dom": "10.2.0",
- "@testing-library/jest-dom": "6.4.6",
- "@testing-library/react": "16.0.0",
+ "@testing-library/jest-dom": "6.5.0",
+ "@testing-library/react": "16.0.1",
"@testing-library/user-event": "14.5.2",
"@types/d3-array": "3.2.1",
"@types/d3-hierarchy": "~3.1.7",
const { label, isSelected } = props;
const { Icon } = props.data as { Icon: JSX.Element };
+ // For tests and a11y
+ props.innerProps.role = 'option';
+ props.innerProps['aria-selected'] = isSelected;
+
return (
<components.Option {...props}>
- <div aria-selected={isSelected} className="sw-flex sw-items-center sw-gap-1" role="option">
+ <div className="sw-flex sw-items-center sw-gap-1">
{Icon}
<SearchHighlighter>{label}</SearchHighlighter>
</div>
"@jupyterlab/nbformat": "4.2.4",
"@swc/core": "1.6.6",
"@swc/jest": "0.2.36",
- "@testing-library/dom": "9.3.4",
- "@testing-library/jest-dom": "6.4.6",
- "@testing-library/react": "14.2.1",
+ "@testing-library/dom": "10.2.0",
+ "@testing-library/jest-dom": "6.5.0",
+ "@testing-library/react": "16.0.1",
"@testing-library/user-event": "14.5.2",
"@types/cheerio": "0.22.35",
"@types/classnames": "2.3.1",
"postcss-custom-properties": "12.1.11",
"prettier": "3.3.2",
"prettier-plugin-organize-imports": "3.2.4",
- "react-select-event": "5.5.1",
"tailwindcss": "3.4.4",
"turbo": "1.11.3",
"typescript": "5.5.3",
"dep-check": "node scripts/validate-package-json.js"
},
"engines": {
- "node": ">=14"
+ "node": ">=18.20"
},
"browser": {
"path": "path-browserify"
import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup';
import React from 'react';
import { Outlet, Route } from 'react-router-dom';
-import selectEvent from 'react-select-event';
import { byRole, byText } from '~sonar-aligned/helpers/testSelector';
import { getMyProjects, getScannableProjects } from '../../../api/components';
import NotificationsMock from '../../../api/mocks/NotificationsMock';
// eslint-disable-next-line jest/no-conditional-in-test
if (tokenTypeOption === TokenType.Project) {
- await selectEvent.select(screen.getByRole('combobox', { name: 'users.tokens.type' }), [
- tokenTypeLabel,
- ]);
+ await user.click(ui.tokenTypeSelect.get());
+ await user.click(byRole('option', { name: tokenTypeLabel }).get());
+
// eslint-disable-next-line jest/no-conditional-expect
expect(generateButton).toBeDisabled();
// eslint-disable-next-line jest/no-conditional-expect
expect(screen.getByRole('textbox', { name: 'users.tokens.name' })).toBeInTheDocument();
// eslint-disable-next-line jest/no-conditional-expect
expect(screen.getAllByRole('combobox')).toHaveLength(3);
- await selectEvent.select(screen.getByRole('combobox', { name: 'users.tokens.project' }), [
- 'Project Name 1',
- ]);
+
+ await user.click(ui.projectSelect.get());
+ await user.click(byRole('option', { name: 'Project Name 1' }).get());
// eslint-disable-next-line jest/no-conditional-expect
expect(generateButton).toBeEnabled();
} else {
- await selectEvent.select(screen.getByRole('combobox', { name: 'users.tokens.type' }), [
- tokenTypeLabel,
- ]);
+ await user.click(ui.tokenTypeSelect.get());
+ await user.click(byRole('option', { name: tokenTypeLabel }).get());
// eslint-disable-next-line jest/no-conditional-expect
expect(generateButton).toBeEnabled();
}
});
it("should not suggest creating a Project token if the user doesn't have at least one scannable Projects", async () => {
+ const user = userEvent.setup();
jest.mocked(getScannableProjects).mockResolvedValueOnce({
projects: [],
});
expect(await screen.findByText('users.tokens.generate')).toBeInTheDocument();
- await selectEvent.openMenu(screen.getByRole('combobox', { name: 'users.tokens.type' }));
+ await user.click(ui.tokenTypeSelect.get());
expect(screen.queryByText(`users.tokens.${TokenType.Project}`)).not.toBeInTheDocument();
});
});
it('should preselect the only project the user has access to if they select project token', async () => {
+ const user = userEvent.setup();
jest.mocked(getScannableProjects).mockResolvedValueOnce({
projects: [
{
securityPagePath,
);
expect(await screen.findByText('users.tokens.generate')).toBeInTheDocument();
- await selectEvent.select(screen.getByRole('combobox', { name: 'users.tokens.type' }), [
- `users.tokens.${TokenType.Project}`,
- ]);
+
+ await user.click(ui.tokenTypeSelect.get());
+ await user.click(byRole('option', { name: `users.tokens.${TokenType.Project}` }).get());
expect(screen.getByText('Project Name 1')).toBeInTheDocument();
});
{ currentUser, navigateTo },
);
}
+
+const ui = {
+ tokenTypeSelect: byRole('combobox', { name: 'users.tokens.type' }),
+ projectSelect: byRole('combobox', { name: 'users.tokens.project' }),
+};
*/
import { screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
-import selectEvent from 'react-select-event';
import {
byLabelText,
byPlaceholderText,
},
async changeTaskFilter(fieldLabel: string, value: string) {
- await selectEvent.select(screen.getByRole('combobox', { name: fieldLabel }), [value]);
+ await user.click(byRole('combobox', { name: fieldLabel }).get());
+ await user.click(byRole('option', { name: value }).get());
+
expect(await screen.findByRole('button', { name: 'reload' })).toBeEnabled();
},
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { fireEvent, screen, within } from '@testing-library/react';
-import selectEvent from 'react-select-event';
import CodingRulesServiceMock, { RULE_TAGS_MOCK } from '../../../api/mocks/CodingRulesServiceMock';
import SettingsServiceMock from '../../../api/mocks/SettingsServiceMock';
import { QP_2, RULE_1, RULE_10, RULE_9 } from '../../../api/mocks/data/ids';
import { CLEAN_CODE_CATEGORIES, SOFTWARE_QUALITIES } from '../../../helpers/constants';
import { mockCurrentUser, mockLoggedInUser } from '../../../helpers/testMocks';
+import { byRole } from '../../../sonar-aligned/helpers/testSelector';
import {
CleanCodeAttribute,
CleanCodeAttributeCategory,
const monthSelector = within(ui.dateInputMonthSelect.get()).getByRole('combobox');
await user.click(monthSelector);
- await selectEvent.select(ui.dateInputMonthSelect.byRole('combobox').get(), 'Nov');
+ await user.click(ui.dateInputMonthSelect.byRole('combobox').get());
+ await user.click(byRole('option', { name: 'Nov' }).get());
const yearSelector = within(ui.dateInputYearSelect.get()).getByRole('combobox');
await user.click(yearSelector);
- await selectEvent.select(ui.dateInputYearSelect.byRole('combobox').get(), '2022');
+ await user.click(ui.dateInputYearSelect.byRole('combobox').get());
+ await user.click(byRole('option', { name: '2022' }).get());
+
await user.click(await screen.findByText('1', { selector: 'button' }));
expect(ui.getAllRuleListItems()).toHaveLength(1);
await user.click(ui.activateButton.getAll()[0]);
expect(ui.selectValue.get(ui.activateQPDialog.get())).toHaveTextContent('severity.MAJOR');
expect(ui.prioritizedSwitch.get(ui.activateQPDialog.get())).not.toBeChecked();
- await selectEvent.select(ui.oldSeveritySelect.get(), 'severity.MINOR');
+ await user.click(ui.oldSeveritySelect.get());
+ await user.click(byRole('option', { name: 'severity.MINOR' }).get());
+
await user.click(ui.prioritizedSwitch.get(ui.activateQPDialog.get()));
await user.click(ui.activateButton.get(ui.activateQPDialog.get()));
await user.click(ui.changeButton('QP Bar').get());
expect(ui.selectValue.get(ui.changeQPDialog.get())).toHaveTextContent('severity.MINOR');
expect(ui.prioritizedSwitch.get(ui.changeQPDialog.get())).toBeChecked();
- await selectEvent.select(ui.oldSeveritySelect.get(), 'severity.BLOCKER');
+ await user.click(ui.oldSeveritySelect.get());
+ await user.click(byRole('option', { name: 'severity.BLOCKER' }).get());
await user.click(ui.prioritizedSwitch.get(ui.changeQPDialog.get()));
await user.click(ui.saveButton.get(ui.changeQPDialog.get()));
// Activate rule in quality profile
expect(ui.prioritizedRuleCell.query()).not.toBeInTheDocument();
await user.click(ui.activateButton.get());
- await selectEvent.select(ui.qualityProfileSelect.get(), 'QP FooBar');
+
await user.click(ui.prioritizedSwitch.get());
await user.click(ui.activateButton.get(ui.activateQPDialog.get()));
expect(ui.qpLink('QP FooBar').get()).toBeInTheDocument();
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import selectEvent from 'react-select-event';
-import { byText } from '~sonar-aligned/helpers/testSelector';
+import { byRole, byText } from '~sonar-aligned/helpers/testSelector';
import CodingRulesServiceMock from '../../../api/mocks/CodingRulesServiceMock';
import SettingsServiceMock from '../../../api/mocks/SettingsServiceMock';
import { mockLoggedInUser } from '../../../helpers/testMocks';
await user.clear(ui.keyTextbox.get());
await user.type(ui.keyTextbox.get(), 'new_custom_rule');
- await selectEvent.select(
- ui.cleanCodeCategorySelect.get(),
- 'rule.clean_code_attribute_category.CONSISTENT',
- );
- await selectEvent.select(
- ui.cleanCodeAttributeSelect.get(),
- 'rule.clean_code_attribute.IDENTIFIABLE',
+ await user.click(ui.cleanCodeCategorySelect.get());
+ await user.click(
+ byRole('option', { name: 'rule.clean_code_attribute_category.CONSISTENT' }).get(),
);
- await selectEvent.select(
- ui.cleanCodeCategorySelect.get(),
- 'rule.clean_code_attribute_category.INTENTIONAL',
+ await user.click(ui.cleanCodeAttributeSelect.get());
+ await user.click(byRole('option', { name: 'rule.clean_code_attribute.IDENTIFIABLE' }).get());
+
+ await user.click(ui.cleanCodeCategorySelect.get());
+ await user.click(
+ byRole('option', { name: 'rule.clean_code_attribute_category.INTENTIONAL' }).get(),
);
+
// Setting default clean code category of a template should set corresponding attribute
expect(
ui.createCustomRuleDialog.byText('rule.clean_code_attribute.CLEAR').get(),
).toBeInTheDocument();
await user.click(ui.cleanCodeQualityCheckbox(SoftwareQuality.Reliability).get());
- await selectEvent.select(
- ui.cleanCodeSeveritySelect(SoftwareQuality.Reliability).get(),
- 'severity.MEDIUM',
- );
+
+ await user.click(ui.cleanCodeSeveritySelect(SoftwareQuality.Reliability).get());
+ await user.click(byRole('option', { name: 'severity.MEDIUM severity.MEDIUM' }).get());
+
expect(ui.createCustomRuleDialog.byText('severity.MEDIUM').get()).toBeInTheDocument();
- await selectEvent.select(ui.statusSelect.get(), 'rules.status.BETA');
+ await user.click(ui.statusSelect.get());
+ await user.click(byRole('option', { name: 'rules.status.BETA' }).get());
await user.type(ui.descriptionTextbox.get(), 'Some description for custom rule');
await user.type(ui.paramInput('1').get(), 'Default value');
}
function Option(props: Readonly<OptionProps<LabelValueSelectOption<IssueSeverity>, false>>) {
+ // For tests and a11y
+ props.innerProps.role = 'option';
+ props.innerProps['aria-selected'] = props.isSelected;
+
return (
<components.Option {...props}>
<SeverityHelper className="sw-flex sw-items-center" severity={props.data.value} />
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { screen, waitFor } from '@testing-library/react';
-
import userEvent from '@testing-library/user-event';
import * as React from 'react';
-import selectEvent from 'react-select-event';
import { byLabelText, byRole, byText } from '~sonar-aligned/helpers/testSelector';
import { searchAzureRepositories } from '../../../../api/alm-integrations';
import AlmIntegrationsServiceMock from '../../../../api/mocks/AlmIntegrationsServiceMock';
expect(await screen.findByText('onboarding.create_project.azure.title')).toBeInTheDocument();
expect(screen.getByText('alm.configuration.selector.label.alm.azure.long')).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-azure-1/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-azure-1/ }).get());
expect(await screen.findByText('onboarding.create_project.enter_pat')).toBeInTheDocument();
expect(screen.getByText('onboarding.create_project.pat_form.title')).toBeInTheDocument();
renderCreateProject();
expect(await screen.findByText('onboarding.create_project.azure.title')).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-azure-2/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-azure-2/ }).get());
expect(await screen.findByText('Azure project')).toBeInTheDocument();
expect(screen.getByText('Azure project 2')).toBeInTheDocument();
renderCreateProject();
expect(await screen.findByText('onboarding.create_project.azure.title')).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-azure-2/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-azure-2/ }).get());
// Should search with positive results
const inputSearch = await screen.findByPlaceholderText(
});
it('should load every repositories from every projects in monorepo setup mode', async () => {
+ const user = userEvent.setup();
renderCreateProject({ isMonorepo: true });
- await selectEvent.select(await ui.monorepoDopSettingDropdown.find(), [/conf-azure-2/]);
- selectEvent.openMenu(await ui.repositorySelector.find());
+ await user.click(await ui.monorepoDopSettingDropdown.find());
+ await user.click(byRole('option', { name: /conf-azure-2/ }).get());
+
+ await user.click(ui.repositorySelector.get());
expect(screen.getByText('Azure repo 1')).toBeInTheDocument();
expect(screen.getByText('Azure repo 2')).toBeInTheDocument();
import userEvent from '@testing-library/user-event';
import * as React from 'react';
-import selectEvent from 'react-select-event';
import { byLabelText, byRole, byText } from '~sonar-aligned/helpers/testSelector';
import { searchForBitbucketServerRepositories } from '../../../../api/alm-integrations';
import AlmIntegrationsServiceMock from '../../../../api/mocks/AlmIntegrationsServiceMock';
expect(screen.getByText('onboarding.create_project.bitbucket.title')).toBeInTheDocument();
expect(await ui.instanceSelector.find()).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-bitbucketserver-1/]);
+
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-bitbucketserver-1/ }).get());
expect(await screen.findByText('onboarding.create_project.pat_form.title')).toBeInTheDocument();
expect(screen.getByText('onboarding.create_project.bitbucket.title')).toBeInTheDocument();
expect(await ui.instanceSelector.find()).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-bitbucketserver-2/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-bitbucketserver-2/ }).get());
expect(await screen.findByText('Bitbucket Project 1')).toBeInTheDocument();
expect(screen.getByText('onboarding.create_project.bitbucket.title')).toBeInTheDocument();
expect(await ui.instanceSelector.find()).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-bitbucketserver-2/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-bitbucketserver-2/ }).get());
const inputSearch = await screen.findByRole('searchbox', {
name: 'onboarding.create_project.search_repositories_by_name',
});
it('should show no result message when there are no projects', async () => {
+ const user = userEvent.setup();
almIntegrationHandler.setBitbucketServerProjects([]);
renderCreateProject();
expect(screen.getByText('onboarding.create_project.bitbucket.title')).toBeInTheDocument();
expect(await ui.instanceSelector.find()).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-bitbucketserver-2/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-bitbucketserver-2/ }).get());
expect(await screen.findByText('onboarding.create_project.no_bbs_projects')).toBeInTheDocument();
});
import userEvent from '@testing-library/user-event';
import * as React from 'react';
-import selectEvent from 'react-select-event';
import { byLabelText, byRole, byText } from '~sonar-aligned/helpers/testSelector';
import { searchForBitbucketCloudRepositories } from '../../../../api/alm-integrations';
import AlmIntegrationsServiceMock from '../../../../api/mocks/AlmIntegrationsServiceMock';
expect(screen.getByText('onboarding.create_project.bitbucketcloud.title')).toBeInTheDocument();
expect(await ui.instanceSelector.find()).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-bitbucketcloud-1/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-bitbucketcloud-1/ }).get());
expect(
await screen.findByText('onboarding.create_project.bitbucket_cloud.enter_password'),
expect(screen.getByText('onboarding.create_project.bitbucketcloud.title')).toBeInTheDocument();
expect(await ui.instanceSelector.find()).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-bitbucketcloud-2/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-bitbucketcloud-2/ }).get());
expect(await screen.findByText('BitbucketCloud Repo 1')).toBeInTheDocument();
expect(screen.getByText('BitbucketCloud Repo 2')).toBeInTheDocument();
expect(screen.getByText('onboarding.create_project.bitbucketcloud.title')).toBeInTheDocument();
expect(await ui.instanceSelector.find()).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-bitbucketcloud-2/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-bitbucketcloud-2/ }).get());
await waitFor(() =>
expect(searchForBitbucketCloudRepositories).toHaveBeenLastCalledWith(
});
it('should show no result message when there are no projects', async () => {
+ const user = userEvent.setup();
almIntegrationHandler.setBitbucketCloudRepositories([]);
renderCreateProject();
expect(screen.getByText('onboarding.create_project.bitbucketcloud.title')).toBeInTheDocument();
expect(await ui.instanceSelector.find()).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-bitbucketcloud-2/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-bitbucketcloud-2/ }).get());
expect(
await screen.findByText('onboarding.create_project.bitbucketcloud.no_projects'),
expect(screen.getByText('onboarding.create_project.bitbucketcloud.title')).toBeInTheDocument();
expect(await ui.instanceSelector.find()).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-bitbucketcloud-2/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-bitbucketcloud-2/ }).get());
expect(await screen.findByRole('button', { name: 'show_more' })).toBeInTheDocument();
import userEvent from '@testing-library/user-event';
import * as React from 'react';
-import selectEvent from 'react-select-event';
import { byLabelText, byRole, byText } from '~sonar-aligned/helpers/testSelector';
import { getGithubRepositories } from '../../../../api/alm-integrations';
import AlmIntegrationsServiceMock from '../../../../api/mocks/AlmIntegrationsServiceMock';
});
it('should redirect to github authorization page when not already authorized', async () => {
+ const user = userEvent.setup();
renderCreateProject('project/create?mode=github');
expect(await screen.findByText('onboarding.create_project.github.title')).toBeInTheDocument();
expect(screen.getByText('alm.configuration.selector.placeholder')).toBeInTheDocument();
expect(ui.instanceSelector.get()).toBeInTheDocument();
- await selectEvent.select(await ui.instanceSelector.find(), [/conf-github-1/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-github-1/ }).get());
expect(window.location.replace).toHaveBeenCalled();
});
it('should not redirect to github when url is malformated', async () => {
+ const user = userEvent.setup();
renderCreateProject('project/create?mode=github');
expect(await screen.findByText('onboarding.create_project.github.title')).toBeInTheDocument();
expect(screen.getByText('alm.configuration.selector.placeholder')).toBeInTheDocument();
expect(ui.instanceSelector.get()).toBeInTheDocument();
- await waitFor(() => selectEvent.select(ui.instanceSelector.get(), [/conf-github-3/]));
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-github-3/ }).get());
expect(await ui.createErrorMessage.find()).toBeInTheDocument();
expect(await ui.instanceSelector.find()).toBeInTheDocument();
- await waitFor(() => selectEvent.select(ui.organizationSelector.get(), [/org-1/]));
+ await user.click(ui.organizationSelector.get());
+ await user.click(byRole('option', { name: /org-1/ }).get());
expect(await ui.project1.find()).toBeInTheDocument();
expect(ui.project2.get()).toBeInTheDocument();
expect(await ui.instanceSelector.find()).toBeInTheDocument();
- await waitFor(() => selectEvent.select(ui.organizationSelector.get(), [/org-1/]));
+ await user.click(ui.organizationSelector.get());
+ await user.click(byRole('option', { name: /org-1/ }).get());
expect(await ui.project1.find()).toBeInTheDocument();
expect(ui.project1Checkbox.get()).not.toBeChecked();
expect(await ui.instanceSelector.find()).toBeInTheDocument();
- await waitFor(() => selectEvent.select(ui.organizationSelector.get(), [/org-1/]));
+ await user.click(ui.organizationSelector.get());
+ await user.click(byRole('option', { name: /org-1/ }).get());
const inputSearch = screen.getByRole('searchbox');
await user.click(inputSearch);
expect(await ui.instanceSelector.find()).toBeInTheDocument();
- await waitFor(() => selectEvent.select(ui.organizationSelector.get(), [/org-1/]));
+ await user.click(ui.organizationSelector.get());
+ await user.click(byRole('option', { name: /org-1/ }).get());
const loadMore = await screen.findByRole('button', { name: 'show_more' });
expect(loadMore).toBeInTheDocument();
});
it('should show no result message when there are no projects', async () => {
+ const user = userEvent.setup();
almIntegrationHandler.setGithubRepositories([]);
renderCreateProject('project/create?mode=github&dopSetting=conf-github-2&code=213321213');
expect(await ui.instanceSelector.find()).toBeInTheDocument();
- await waitFor(() => selectEvent.select(ui.organizationSelector.get(), [/org-1/]));
+ await user.click(ui.organizationSelector.get());
+ await user.click(byRole('option', { name: /org-1/ }).get());
expect(screen.getByText('no_results')).toBeInTheDocument();
});
import { screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import * as React from 'react';
-import selectEvent from 'react-select-event';
import { byLabelText, byRole, byText } from '~sonar-aligned/helpers/testSelector';
import { getGitlabProjects } from '../../../../api/alm-integrations';
import AlmIntegrationsServiceMock from '../../../../api/mocks/AlmIntegrationsServiceMock';
expect(await ui.importProjectsTitle.find()).toBeInTheDocument();
expect(ui.instanceSelector.get()).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-final-1/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-final-1/ }).get());
expect(await screen.findByText('onboarding.create_project.enter_pat')).toBeInTheDocument();
expect(ui.patHelpInstructions.get()).toBeInTheDocument();
});
it('should show import project feature when PAT is already set', async () => {
+ const user = userEvent.setup();
renderCreateProject();
expect(await ui.importProjectsTitle.find()).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-final-2/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-final-2/ }).get());
expect(await ui.project1.find()).toBeInTheDocument();
expect(ui.project1Link.get()).toHaveAttribute('href', '/dashboard?id=key');
expect(await ui.importProjectsTitle.find()).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-final-2/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-final-2/ }).get());
const inputSearch = await screen.findByRole('searchbox');
await user.click(inputSearch);
renderCreateProject();
expect(await ui.importProjectsTitle.find()).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-final-2/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-final-2/ }).get());
expect(await ui.project1.find()).toBeInTheDocument();
expect(ui.project1Checkbox.get()).not.toBeChecked();
almIntegrationHandler.createRandomGitlabProjectsWithLoadMore(50, 75);
renderCreateProject();
- await selectEvent.select(await ui.instanceSelector.find(), [/conf-final-2/]);
+ await user.click(await ui.instanceSelector.find());
+ await user.click(byRole('option', { name: /conf-final-2/ }).get());
+
const loadMore = await screen.findByRole('button', { name: 'show_more' });
expect(loadMore).toBeInTheDocument();
});
it('should show no result message when there are no projects', async () => {
+ const user = userEvent.setup();
almIntegrationHandler.setGitlabProjects([]);
renderCreateProject();
expect(await ui.importProjectsTitle.find()).toBeInTheDocument();
- await selectEvent.select(ui.instanceSelector.get(), [/conf-final-2/]);
+ await user.click(ui.instanceSelector.get());
+ await user.click(byRole('option', { name: /conf-final-2/ }).get());
expect(await screen.findByText('no_results')).toBeInTheDocument();
});
import { waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import React from 'react';
-import selectEvent from 'react-select-event';
import { byRole, byText } from '~sonar-aligned/helpers/testSelector';
import AlmIntegrationsServiceMock from '../../../../api/mocks/AlmIntegrationsServiceMock';
import AlmSettingsServiceMock from '../../../../api/mocks/AlmSettingsServiceMock';
});
it('should display that selected repository is not bound to any existing project', async () => {
+ const user = userEvent.setup();
renderCreateProject({ code: '123', dopSetting: 'dop-setting-test-id', isMonorepo: true });
expect(await ui.monorepoTitle.find()).toBeInTheDocument();
expect(await ui.dopSettingSelector.find()).toBeInTheDocument();
expect(ui.monorepoProjectTitle.query()).not.toBeInTheDocument();
- await waitFor(async () => {
- await selectEvent.select(await ui.organizationSelector.find(), 'org-1');
- });
+ await user.click(ui.organizationSelector.get());
+ await user.click(byRole('option', { name: 'org-1' }).get());
+
expect(ui.monorepoProjectTitle.query()).not.toBeInTheDocument();
- await selectEvent.select(await ui.repositorySelector.find(), 'Github repo 1');
+ await user.click(ui.repositorySelector.get());
+ await user.click(byRole('option', { name: 'Github repo 1' }).get());
expect(await ui.notBoundRepositoryMessage.find()).toBeInTheDocument();
});
it('should display that selected repository is already bound to an existing project', async () => {
+ const user = userEvent.setup();
projectManagementHandler.setProjects([
mockProject({
key: 'key123',
expect(await ui.dopSettingSelector.find()).toBeInTheDocument();
expect(ui.monorepoProjectTitle.query()).not.toBeInTheDocument();
- await waitFor(async () => {
- await selectEvent.select(await ui.organizationSelector.find(), 'org-1');
- });
+ await user.click(ui.organizationSelector.get());
+ await user.click(byRole('option', { name: 'org-1' }).get());
+
expect(ui.monorepoProjectTitle.query()).not.toBeInTheDocument();
- await selectEvent.select(await ui.repositorySelector.find(), 'Github repo 1');
+ await user.click(ui.repositorySelector.get());
+ await user.click(byRole('option', { name: 'Github repo 1' }).get());
expect(await ui.alreadyBoundRepositoryMessage.find()).toBeInTheDocument();
expect(byRole('link', { name: 'Project GitHub 1' }).get()).toBeInTheDocument();
expect(await ui.dopSettingSelector.find()).toBeInTheDocument();
expect(ui.monorepoProjectTitle.query()).not.toBeInTheDocument();
- await waitFor(async () => {
- await selectEvent.select(await ui.organizationSelector.find(), 'org-1');
- });
+ await user.click(ui.organizationSelector.get());
+ await user.click(byRole('option', { name: 'org-1' }).get());
+
expect(ui.monorepoProjectTitle.query()).not.toBeInTheDocument();
- await selectEvent.select(await ui.repositorySelector.find(), 'Github repo 1');
+ await user.click(ui.repositorySelector.get());
+ await user.click(byRole('option', { name: 'Github repo 1' }).get());
+
expect(await ui.monorepoProjectTitle.find()).toBeInTheDocument();
let projects = byRole('textbox', {
name: /onboarding.create_project.project_key/,
const MIN_SIZE_INSTANCES = 2;
function optionRenderer(props: OptionProps<LabelValueSelectOption<DopSetting>, false>) {
+ // For tests and a11y
+ props.innerProps.role = 'option';
+ props.innerProps['aria-selected'] = props.isSelected;
+
return <components.Option {...props}>{customOptions(props.data.value)}</components.Option>;
}
*/
import { waitFor } from '@testing-library/react';
import { UserEvent } from '@testing-library/user-event/dist/types/setup/setup';
-import selectEvent from 'react-select-event';
import { byRole, byText } from '~sonar-aligned/helpers/testSelector';
import { Visibility } from '~sonar-aligned/types/component';
import { Permissions } from '../../types/permissions';
await user.click(ui.closeModalBtn.get());
},
async chooseTemplate(name: string) {
- await selectEvent.select(ui.templateSelect.get(), [name]);
+ await user.click(ui.templateSelect.get());
+ await user.click(byRole('option', { name }).get());
+
await user.click(ui.confirmApplyTemplateBtn.get());
},
async toggleFilterByPermission(permission: Permissions) {
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { fireEvent, screen, waitFor } from '@testing-library/react';
+import { screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import * as React from 'react';
-import selectEvent from 'react-select-event';
import { ComponentQualifier } from '~sonar-aligned/types/component';
import { MetricKey } from '~sonar-aligned/types/metrics';
import { getProjectBadgesToken } from '../../../../api/project-badges';
import { mockComponent } from '../../../../helpers/mocks/component';
import { renderComponent } from '../../../../helpers/testReactTestingUtils';
import { Location } from '../../../../helpers/urls';
+import { byRole } from '../../../../sonar-aligned/helpers/testSelector';
import ProjectBadges, { ProjectBadgesProps } from '../ProjectBadges';
import { BadgeType } from '../utils';
});
it('should update params', async () => {
+ const user = userEvent.setup();
renderProjectBadges();
await appLoaded();
),
).toBeInTheDocument();
- await selectEvent.select(
- screen.getByLabelText('overview.badges.format'),
- 'overview.badges.options.formats.url',
- );
+ await user.click(byRole('radio', { name: 'overview.badges.options.formats.url' }).get());
expect(
screen.getByText(
),
).toBeInTheDocument();
- await selectEvent.openMenu(screen.getByLabelText('overview.badges.metric'));
- fireEvent.click(screen.getByText(`metric.${MetricKey.coverage}.name`));
+ await user.click(screen.getByLabelText('overview.badges.metric'));
+ await user.click(screen.getByText(`metric.${MetricKey.coverage}.name`));
expect(
screen.getByText(
),
).toBeInTheDocument();
- fireEvent.click(
+ await user.click(
screen.getByRole('button', {
name: `overview.badges.${BadgeType.qualityGate}.alt overview.badges.${BadgeType.qualityGate}.description.${ComponentQualifier.Project}`,
}),
),
).toBeInTheDocument();
- fireEvent.click(
+ await user.click(
screen.getByRole('button', {
name: `overview.badges.${BadgeType.measure}.alt overview.badges.${BadgeType.measure}.description.${ComponentQualifier.Project}`,
}),
});
it('should warn about deprecated metrics', async () => {
+ const user = userEvent.setup();
renderProjectBadges();
await appLoaded();
- await selectEvent.openMenu(screen.getByLabelText('overview.badges.metric'));
- fireEvent.click(screen.getByText(`metric.${MetricKey.bugs}.name (deprecated)`));
+ await user.click(screen.getByLabelText('overview.badges.metric'));
+ await user.click(screen.getByText(`metric.${MetricKey.bugs}.name (deprecated)`));
expect(
screen.getByText(
function renderBranchOption(props: OptionProps<BranchOption, false>) {
const { data: option } = props;
+ // For tests and a11y
+ props.innerProps.role = 'option';
+ props.innerProps['aria-selected'] = props.isSelected;
+
return (
<components.Option {...props}>
{option.isInvalid ? (
*/
import userEvent from '@testing-library/user-event';
import { last } from 'lodash';
-import selectEvent from 'react-select-event';
import { byLabelText, byRole, byText } from '~sonar-aligned/helpers/testSelector';
import { MessageTypes } from '../../../../api/messages';
import BranchesServiceMock from '../../../../api/mocks/BranchesServiceMock';
async function setReferenceBranchSetting(branch: string) {
await user.click(ui.specificSettingRadio.get());
await user.click(ui.referenceBranchRadio.get());
- await selectEvent.select(ui.chooseBranchSelect.get(), branch);
+
+ await user.click(ui.chooseBranchSelect.get());
+ await user.click(byRole('option', { name: new RegExp(branch) }).get());
}
async function setBranchReferenceToBranchSetting(branch: string, branchRef: string) {
await openBranchSettingModal(branch);
await user.click(last(ui.referenceBranchRadio.getAll()) as HTMLElement);
- await selectEvent.select(ui.chooseBranchSelect.get(), branchRef);
+
+ await user.click(ui.chooseBranchSelect.get());
+ await user.click(byRole('option', { name: new RegExp(branchRef) }).get());
+
await user.click(last(ui.saveButton.getAll()) as HTMLElement);
}
import { waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { addGlobalErrorMessage, addGlobalSuccessMessage } from 'design-system';
-import selectEvent from 'react-select-event';
import { byRole, byText } from '~sonar-aligned/helpers/testSelector';
import { QualityGatesServiceMock } from '../../../api/mocks/QualityGatesServiceMock';
import handleRequiredAuthorization from '../../../app/utils/handleRequiredAuthorization';
});
it('should be able to select and save specific Quality Gate', async () => {
+ const user = userEvent.setup();
renderProjectQualityGateApp();
expect(await ui.qualityGateHeading.find()).toBeInTheDocument();
expect(ui.defaultRadioQualityGate.get()).toBeChecked();
- await userEvent.click(ui.specificRadioQualityGate.get());
+ await user.click(ui.specificRadioQualityGate.get());
expect(ui.qualityGatesSelect.get()).toBeEnabled();
- await selectEvent.select(ui.qualityGatesSelect.get(), 'Sonar way');
- await userEvent.click(ui.saveButton.get());
+ await user.click(ui.qualityGatesSelect.get());
+ await user.click(byText('Sonar way').get());
+
+ await user.click(ui.saveButton.get());
expect(addGlobalSuccessMessage).toHaveBeenCalledWith('project_quality_gate.successfully_updated');
// Set back default QG
- await userEvent.click(ui.defaultRadioQualityGate.get());
+ await user.click(ui.defaultRadioQualityGate.get());
expect(ui.qualityGatesSelect.get()).toBeDisabled();
expect(ui.defaultRadioQualityGate.get()).toBeChecked();
- await userEvent.click(ui.saveButton.get());
+ await user.click(ui.saveButton.get());
expect(addGlobalSuccessMessage).toHaveBeenCalledWith('project_quality_gate.successfully_updated');
});
it('shows warning for quality gate that doesnt have conditions on new code', async () => {
+ const user = userEvent.setup();
handler.setGetGateForProjectName('Sonar way');
renderProjectQualityGateApp();
- await userEvent.click(await ui.specificRadioQualityGate.find());
- await selectEvent.select(ui.qualityGatesSelect.get(), 'QG without conditions');
+ await user.click(await ui.specificRadioQualityGate.find());
+
+ await user.click(ui.qualityGatesSelect.get());
+ await user.click(byText('QG without conditions').get());
+
expect(ui.QGWithoutConditionsOptionLabel.query()).not.toBeInTheDocument();
- await selectEvent.select(ui.qualityGatesSelect.get(), 'QG without new code conditions');
+ await user.click(ui.qualityGatesSelect.get());
+ await user.click(byText('QG without new code conditions').get());
+
expect(ui.noConditionsNewCodeWarning.get()).toBeInTheDocument();
});
*/
import userEvent from '@testing-library/user-event';
import { addGlobalSuccessMessage } from 'design-system';
-import selectEvent from 'react-select-event';
import { byLabelText, byRole, byText } from '~sonar-aligned/helpers/testSelector';
import {
ProfileProject,
expect(ui.selectProfile.get()).toBeDisabled();
expect(ui.buttonSave.get()).toBeInTheDocument();
- await selectEvent.select(ui.selectLanguage.get(), 'HTML');
+ await user.click(ui.selectLanguage.get());
+ await user.click(byRole('option', { name: 'HTML' }).get());
+
expect(ui.selectProfile.get()).toBeEnabled();
- await selectEvent.select(ui.selectProfile.get(), 'html profile');
+
+ await user.click(ui.selectProfile.get());
+ await user.click(byRole('option', { name: 'html profile' }).get());
+
await user.click(ui.buttonSave.get());
expect(associateProject).toHaveBeenLastCalledWith(
expect.objectContaining({ key: 'html', name: 'html profile' }),
expect(ui.newAnalysisWarningMessage.get()).toBeInTheDocument();
expect(ui.selectUseSpecificProfile.get()).toBeInTheDocument();
- await selectEvent.select(ui.selectUseSpecificProfile.get(), 'html default profile');
+ await user.click(ui.selectUseSpecificProfile.get());
+ await user.click(byRole('option', { name: 'html default profile' }).get());
+
await user.click(ui.buttonSave.get());
expect(addGlobalSuccessMessage).toHaveBeenCalledWith(
[option.label, option.language],
);
+ // For tests and a11y
+ props.innerProps.role = 'option';
+ props.innerProps['aria-selected'] = props.isSelected;
+
return (
<components.Option {...props}>
<div>
handleVisibilityChange = ({ value }: LabelValueSelectOption) =>
this.props.onVisibilityChanged(value);
- optionRenderer = (props: OptionProps<LabelValueSelectOption, false>) => (
- <components.Option {...props}>{this.renderQualifierOption(props.data)}</components.Option>
- );
+ optionRenderer = (props: OptionProps<LabelValueSelectOption, false>) => {
+ // For tests and a11y
+ props.innerProps.role = 'option';
+ props.innerProps['aria-selected'] = props.isSelected;
+
+ return (
+ <components.Option {...props}>{this.renderQualifierOption(props.data)}</components.Option>
+ );
+ };
singleValueRenderer = (props: SingleValueProps<LabelValueSelectOption, false>) => (
<components.SingleValue {...props}>
*/
import { screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
-import selectEvent from 'react-select-event';
import { byPlaceholderText, byRole, byText } from '~sonar-aligned/helpers/testSelector';
import { ComponentQualifier } from '~sonar-aligned/types/component';
import DopTranslationServiceMock from '../../../api/mocks/DopTranslationServiceMock';
}));
const ui = {
+ pageDescription: byText('projects_management.page.description'),
row: byRole('row'),
firstProjectActions: byRole('button', {
name: 'projects_management.show_actions_for_x.Project 1',
const user = userEvent.setup();
renderProjectManagementApp();
await waitFor(() => expect(ui.row.getAll()).toHaveLength(5));
- // Should return Promise: (and same for all similar cases below)
- // await waitFor(() => selectEvent.select(ui.visibilityFilter.get(), ‘visibility.public’));
- // Can be fixed by migrating ProjectManagementApp to functional component
- await waitFor(() => {
- selectEvent.select(ui.visibilityFilter.get(), 'visibility.public');
- });
+
+ await user.click(ui.visibilityFilter.get());
+ await user.click(byRole('option', { name: 'visibility.public' }).get());
+
await waitFor(() => expect(ui.row.getAll()).toHaveLength(4));
await user.click(ui.analysisDateFilter.get());
await user.click(await screen.findByRole('gridcell', { name: '5' }));
await user.click(ui.provisionedFilter.get());
expect(ui.row.getAll()).toHaveLength(2);
expect(ui.row.getAll()[1]).toHaveTextContent('Project 4');
- await waitFor(() => {
- selectEvent.select(ui.qualifierFilter.get(), 'qualifiers.VW');
- });
+
+ await user.click(ui.qualifierFilter.get());
+ await user.click(byRole('option', { name: 'qualifiers.VW' }).get());
+
await waitFor(() => expect(ui.provisionedFilter.query()).not.toBeInTheDocument());
expect(ui.row.getAll()).toHaveLength(2);
await waitFor(() => expect(ui.row.getAll()[1]).toHaveTextContent('Portfolio 1'));
- await waitFor(() => {
- selectEvent.select(ui.qualifierFilter.get(), 'qualifiers.APP');
- });
+
+ await user.click(ui.qualifierFilter.get());
+ await user.click(byRole('option', { name: 'qualifiers.APP' }).get());
+
expect(ui.provisionedFilter.query()).not.toBeInTheDocument();
expect(ui.row.getAll()).toHaveLength(2);
await waitFor(() => expect(ui.row.getAll()[1]).toHaveTextContent('Application 1'));
await waitFor(() => expect(ui.row.getAll()).toHaveLength(5));
await user.type(ui.searchFilter.get(), 'provision');
expect(ui.row.getAll()).toHaveLength(2);
- await waitFor(() => {
- selectEvent.select(ui.qualifierFilter.get(), 'qualifiers.VW');
- });
+
+ await user.click(ui.qualifierFilter.get());
+ await user.click(byRole('option', { name: 'qualifiers.VW' }).get());
+
await waitFor(() => expect(ui.row.getAll()).toHaveLength(4));
expect(ui.searchFilter.get()).toHaveValue('');
await user.type(ui.searchFilter.get(), 'Portfolio 2');
expect(ui.row.getAll()).toHaveLength(2);
- await waitFor(() => {
- selectEvent.select(ui.qualifierFilter.get(), 'qualifiers.APP');
- });
+
+ await user.click(ui.qualifierFilter.get());
+ await user.click(byRole('option', { name: 'qualifiers.APP' }).get());
+
await waitFor(() => expect(ui.row.getAll()).toHaveLength(4));
expect(ui.searchFilter.get()).toHaveValue('');
await user.type(ui.searchFilter.get(), 'Application 3');
expect(ui.row.getAll()).toHaveLength(2);
});
-it('should hide quilifier filter', () => {
+it('should hide qualifier filter', async () => {
renderProjectManagementApp({ qualifiers: [ComponentQualifier.Project] });
+ // pretext to wait for loading
+ expect(await ui.pageDescription.find()).toBeInTheDocument();
expect(ui.qualifierFilter.query()).not.toBeInTheDocument();
});
-it('should hide create Project button', () => {
+it('should hide create Project button', async () => {
renderProjectManagementApp();
+ // pretext to wait for loading
+ expect(await ui.pageDescription.find()).toBeInTheDocument();
expect(ui.createProject.query()).not.toBeInTheDocument();
});
.byText('permission_templates.bulk_apply_permission_template.apply_to_selected.2')
.get(),
).toBeInTheDocument();
- await selectEvent.select(
- ui.bulkApplyDialog.by(ui.selectTemplate('required')).get(),
- 'Permission Template 2',
- );
+
+ await user.click(ui.bulkApplyDialog.by(ui.selectTemplate('required')).get());
+ await user.click(byRole('option', { name: 'Permission Template 2' }).get());
+
await user.click(ui.bulkApplyDialog.by(ui.apply).get());
expect(
expect(projectRows[1]).toHaveTextContent('Project 0');
expect(projectRows[60]).toHaveTextContent('Project 59');
- await waitFor(() => {
- selectEvent.select(ui.qualifierFilter.get(), 'qualifiers.VW');
- });
+ await user.click(ui.qualifierFilter.get());
+ await user.click(byRole('option', { name: 'qualifiers.VW' }).get());
+
await waitFor(() => expect(projectRows[1]).not.toBeInTheDocument());
const portfolioRows = ui.row.getAll();
expect(portfolioRows).toHaveLength(51);
await user.click(ui.applyPermissionTemplate.get());
expect(ui.applyTemplateDialog.get()).toBeInTheDocument();
- await selectEvent.select(
- ui.applyTemplateDialog.by(ui.selectTemplate('required')).get(),
- 'Permission Template 2',
- );
+
+ await user.click(ui.applyTemplateDialog.by(ui.selectTemplate('required')).get());
+ await user.click(byRole('option', { name: 'Permission Template 2' }).get());
+
await user.click(ui.applyTemplateDialog.by(ui.apply).get());
expect(
});
it('should not show local badge for applications and portfolios', async () => {
+ const user = userEvent.setup();
dopTranslationHandler.gitHubConfigurations.push(
mockGitHubConfiguration({ provisioningType: ProvisioningType.auto }),
);
renderProjectManagementApp({}, {}, { featureList: [Feature.GithubProvisioning] });
await waitFor(() => expect(screen.getAllByText('local')).toHaveLength(3));
- await selectEvent.select(ui.qualifierFilter.get(), 'qualifiers.VW');
+ await user.click(ui.qualifierFilter.get());
+ await user.click(byRole('option', { name: 'qualifiers.VW' }).get());
+
await waitFor(() => expect(screen.queryByText('local')).not.toBeInTheDocument());
- await selectEvent.select(ui.qualifierFilter.get(), 'qualifiers.APP');
+ await user.click(ui.qualifierFilter.get());
+ await user.click(byRole('option', { name: 'qualifiers.APP' }).get());
+
expect(screen.queryByText('local')).not.toBeInTheDocument();
});
*/
import { screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
-import selectEvent from 'react-select-event';
import { byLabelText, byRole, byTestId } from '~sonar-aligned/helpers/testSelector';
import { QualityGatesServiceMock } from '../../../../api/mocks/QualityGatesServiceMock';
import UsersServiceMock from '../../../../api/mocks/UsersServiceMock';
const dialog = byRole('dialog');
await user.click(dialog.byRole('radio', { name: 'quality_gates.conditions.overall_code' }).get());
- await selectEvent.openMenu(dialog.byRole('combobox').get());
+ await user.click(dialog.byRole('combobox').get());
expect(
byRole('option', { name: 'Issues from prioritized rules' }).query(),
).not.toBeInTheDocument();
*/
import { screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
-import selectEvent from 'react-select-event';
import { byRole, byText } from '~sonar-aligned/helpers/testSelector';
import QualityProfilesServiceMock from '../../../api/mocks/QualityProfilesServiceMock';
import { renderAppRoutes } from '../../../helpers/testReactTestingUtils';
// Add user
await user.click(ui.grantPermissionButton.get());
expect(ui.dialog.get()).toBeInTheDocument();
- await selectEvent.select(ui.selectUserOrGroup.get(), 'Buzz');
+
+ await user.click(ui.selectUserOrGroup.get());
+ await user.click(byRole('option', { name: /^Buzz/ }).get());
+
await user.click(ui.addButton.get());
expect(ui.permissionSection.byText('Buzz').get()).toBeInTheDocument();
// Add Group
await user.click(ui.grantPermissionButton.get());
expect(ui.dialog.get()).toBeInTheDocument();
- await selectEvent.select(ui.selectUserOrGroup.get(), 'ACDC');
+
+ await user.click(ui.selectUserOrGroup.get());
+ await user.click(byRole('option', { name: /^ACDC/ }).get());
+
await user.click(ui.addButton.get());
expect(ui.permissionSection.byText('ACDC').get()).toBeInTheDocument();
await user.click(ui.changeParentButton.get());
expect(await ui.dialog.find()).toBeInTheDocument();
expect(ui.changeButton.get()).toBeDisabled();
- await selectEvent.select(ui.selectField.get(), 'PHP Sonar way 2');
+
+ await user.click(ui.selectField.get());
+ await user.click(byRole('option', { name: 'PHP Sonar way 2' }).get());
+
await user.click(ui.changeButton.get());
expect(ui.dialog.query()).not.toBeInTheDocument();
*/
import { screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
-import selectEvent from 'react-select-event';
import { byRole, byText } from '~sonar-aligned/helpers/testSelector';
import QualityProfilesServiceMock from '../../../api/mocks/QualityProfilesServiceMock';
import SettingsServiceMock from '../../../api/mocks/SettingsServiceMock';
expect(await ui.listLinkCQualityProfile.find()).toBeInTheDocument();
expect(ui.listLinkJavaQualityProfile.get()).toBeInTheDocument();
- await selectEvent.select(ui.filterByLang.get(), 'C');
+ await user.click(ui.filterByLang.get());
+ await user.click(byRole('option', { name: 'C' }).get());
expect(ui.listLinkJavaQualityProfile.query()).not.toBeInTheDocument();
expect(ui.profileActions('java quality profile', 'Java').query()).not.toBeInTheDocument();
expect(ui.changelogLink.query()).not.toBeInTheDocument();
- await selectEvent.select(ui.compareDropdown.get(), 'java quality profile #2');
+ await user.click(ui.compareDropdown.get());
+ await user.click(byRole('option', { name: 'java quality profile #2' }).get());
+
expect(await ui.comparisonDiffTableHeading(1, 'java quality profile').find()).toBeInTheDocument();
expect(ui.comparisonDiffTableHeading(1, 'java quality profile #2').get()).toBeInTheDocument();
expect(ui.comparisonModifiedTableHeading(1).get()).toBeInTheDocument();
await user.click(await ui.listProfileActions('java quality profile #2', 'Java').find());
await user.click(ui.compareButton.get());
- await selectEvent.select(ui.compareDropdown.get(), 'java quality profile');
+
+ await user.click(ui.compareDropdown.get());
+ await user.click(byRole('option', { name: 'java quality profile' }).get());
expect(await ui.summaryFewerRules(1).find()).toBeInTheDocument();
expect(ui.summaryAdditionalRules(1).get()).toBeInTheDocument();
const { isDefault, label } = props.data;
const intl = useIntl();
+ // For tests and a11y
+ props.innerProps.role = 'option';
+ props.innerProps['aria-selected'] = props.isSelected;
+
return (
<components.Option {...props}>
<span>{label}</span>
import userEvent from '@testing-library/user-event';
import React from 'react';
import { Route } from 'react-router-dom';
-import selectEvent from 'react-select-event';
-import { byRole } from '~sonar-aligned/helpers/testSelector';
+import { byRole, byText } from '~sonar-aligned/helpers/testSelector';
import SettingsServiceMock from '../../../../api/mocks/SettingsServiceMock';
import { KeyboardKeys } from '../../../../helpers/keycodes';
import { mockComponent } from '../../../../helpers/mocks/component';
await user.click(await ui.categoryLink('property.category.languages').find());
expect(await ui.languagesHeading.find()).toBeInTheDocument();
- await selectEvent.select(ui.languagesSelect.get(), 'property.category.javascript');
+ await user.click(ui.languagesSelect.get());
+ await user.click(byText('property.category.javascript').get());
+
expect(await ui.jsGeneralSubCategoryHeading.find()).toBeInTheDocument();
});
*/
import userEvent from '@testing-library/user-event';
import React from 'react';
-import selectEvent from 'react-select-event';
import { byRole, byText } from '~sonar-aligned/helpers/testSelector';
import AlmSettingsServiceMock from '../../../../../api/mocks/AlmSettingsServiceMock';
import CurrentUserContextProvider from '../../../../../app/components/current-user/CurrentUserContextProvider';
const { rerender } = renderPRDecorationBinding();
expect(await ui.mainTitle.find()).toBeInTheDocument();
- // Set form data
- await selectEvent.select(ui.input('name', 'combobox').get(), (content) =>
- content.includes(key),
- );
+ await user.click(ui.input('name', 'combobox').get());
+ await user.click(byRole('option', { name: new RegExp(key) }).get());
const list = inputsList[alm];
for (const [inputId, value] of Object.entries(list)) {
import { screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import * as React from 'react';
-import selectEvent from 'react-select-event';
import { byLabelText, byRole, byText } from '~sonar-aligned/helpers/testSelector';
import ComponentsServiceMock from '../../../api/mocks/ComponentsServiceMock';
import DopTranslationServiceMock from '../../../api/mocks/DopTranslationServiceMock';
await user.click(await ui.localFilter.find());
await waitFor(() => expect(ui.activityFilter.get()).toBeEnabled());
- await selectEvent.select(
- ui.activityFilter.get(),
- 'users.activity_filter.active_sonarlint_users',
+ await user.click(ui.activityFilter.get());
+ await user.click(
+ byRole('option', { name: 'users.activity_filter.active_sonarlint_users' }).get(),
);
expect(await ui.userRows.findAll()).toHaveLength(1);
await user.click(await ui.managedByScimFilter.find());
await waitFor(() => expect(ui.activityFilter.get()).toBeEnabled());
- await selectEvent.select(
- ui.activityFilter.get(),
- 'users.activity_filter.active_sonarqube_users',
+ await user.click(ui.activityFilter.get());
+ await user.click(
+ byRole('option', { name: 'users.activity_filter.active_sonarqube_users' }).get(),
);
expect(await ui.userRows.findAll()).toHaveLength(1);
await user.click(await ui.localAndManagedFilter.find());
await waitFor(() => expect(ui.activityFilter.get()).toBeEnabled());
- await selectEvent.select(ui.activityFilter.get(), 'users.activity_filter.inactive_users');
+ await user.click(ui.activityFilter.get());
+ await user.click(byRole('option', { name: 'users.activity_filter.inactive_users' }).get());
expect(await ui.userRows.findAll()).toHaveLength(2);
expect(ui.evaRow.get()).toBeInTheDocument();
expect(getTokensList()).toHaveLength(2); // header + "No tokens"
expect(await screen.findByText('users.no_tokens')).toBeInTheDocument();
- await selectEvent.select(ui.expiresInSelector.get(), 'users.tokens.expiration.0');
+ await user.click(ui.expiresInSelector.get());
+ await user.click(byRole('option', { name: 'users.tokens.expiration.0' }).get());
+
await user.click(ui.generateButton.get());
expect(getTokensList()).toHaveLength(2); // header + "test" token
expect(screen.queryByText('users.no_tokens')).not.toBeInTheDocument();
import { AlmInstanceBase } from '../../types/alm-settings';
function optionRenderer(props: OptionProps<LabelValueSelectOption<AlmInstanceBase>, false>) {
+ // For tests and a11y
+ props.innerProps.role = 'option';
+ props.innerProps['aria-selected'] = props.isSelected;
+
return <components.Option {...props}>{customOptions(props.data.value)}</components.Option>;
}
*/
import userEvent from '@testing-library/user-event';
import React from 'react';
-import selectEvent from 'react-select-event';
import AlmSettingsServiceMock from '../../../../api/mocks/AlmSettingsServiceMock';
import UserTokensMock from '../../../../api/mocks/UserTokensMock';
import { mockAlmSettingsInstance } from '../../../../helpers/mocks/alm-settings';
import { mockComponent } from '../../../../helpers/mocks/component';
import { mockLanguage, mockLoggedInUser } from '../../../../helpers/testMocks';
import { RenderContext, renderApp } from '../../../../helpers/testReactTestingUtils';
+import { byRole } from '../../../../sonar-aligned/helpers/testSelector';
import { AlmKeys } from '../../../../types/alm-settings';
import { Feature } from '../../../../types/features';
import {
// Revoke current token and create new one
await user.click(ui.deleteTokenButton.get());
await user.type(ui.tokenNameInput.get(), 'newtoken');
- await selectEvent.select(ui.expiresInSelect.get(), 'users.tokens.expiration.365');
+
+ await user.click(ui.expiresInSelect.get());
+ await user.click(byRole('option', { name: 'users.tokens.expiration.365' }).get());
+
await user.click(ui.generateTokenButton.get());
expect(ui.tokenValue.get()).toBeInTheDocument();
await user.click(ui.continueButton.getAll()[0]);
*/
import userEvent from '@testing-library/user-event';
import React from 'react';
-import selectEvent from 'react-select-event';
import AlmSettingsServiceMock from '../../../../api/mocks/AlmSettingsServiceMock';
import UserTokensMock from '../../../../api/mocks/UserTokensMock';
import { mockAlmSettingsInstance } from '../../../../helpers/mocks/alm-settings';
import { mockComponent } from '../../../../helpers/mocks/component';
import { mockLanguage, mockLoggedInUser } from '../../../../helpers/testMocks';
import { RenderContext, renderApp } from '../../../../helpers/testReactTestingUtils';
+import { byRole } from '../../../../sonar-aligned/helpers/testSelector';
import { AlmKeys } from '../../../../types/alm-settings';
import { Feature } from '../../../../types/features';
import {
// Revoke current token and create new one
await user.click(ui.deleteTokenButton.get());
await user.type(ui.tokenNameInput.get(), 'newtoken');
- await selectEvent.select(ui.expiresInSelect.get(), 'users.tokens.expiration.365');
+
+ await user.click(ui.expiresInSelect.get());
+ await user.click(byRole('option', { name: 'users.tokens.expiration.365' }).get());
+
await user.click(ui.generateTokenButton.get());
expect(ui.tokenValue.get()).toBeInTheDocument();
await user.click(ui.continueButton.getAll()[0]);
*/
import userEvent from '@testing-library/user-event';
import React from 'react';
-import selectEvent from 'react-select-event';
import UserTokensMock from '../../../../api/mocks/UserTokensMock';
import { mockComponent } from '../../../../helpers/mocks/component';
import { mockLanguage, mockLoggedInUser } from '../../../../helpers/testMocks';
import { RenderContext, renderApp } from '../../../../helpers/testReactTestingUtils';
+import { byRole } from '../../../../sonar-aligned/helpers/testSelector';
import {
getCommonNodes,
getCopyToClipboardValue,
// Revoke current token and create new one
await user.click(ui.deleteTokenButton.get());
await user.type(ui.tokenNameInput.get(), 'newtoken');
- await selectEvent.select(ui.expiresInSelect.get(), 'users.tokens.expiration.365');
+ await user.click(ui.expiresInSelect.get());
+ await user.click(byRole('option', { name: 'users.tokens.expiration.365' }).get());
+
await user.click(ui.generateTokenButton.get());
expect(ui.tokenValue.get()).toBeInTheDocument();
await user.click(ui.continueButton.getAll()[0]);
*/
import userEvent from '@testing-library/user-event';
import React from 'react';
-import selectEvent from 'react-select-event';
import { byRole, byText } from '~sonar-aligned/helpers/testSelector';
import UserTokensMock from '../../../../api/mocks/UserTokensMock';
import { mockComponent } from '../../../../helpers/mocks/component';
// Generating token
await user.type(ui.tokenNameInput.get(), 'Testing token');
- await selectEvent.select(ui.expiresInSelect.get(), 'users.tokens.expiration.365');
+ await user.click(ui.expiresInSelect.get());
+ await user.click(byRole('option', { name: 'users.tokens.expiration.365' }).get());
+
await user.click(ui.generateTokenButton.get());
expect(ui.continueButton.get()).toBeEnabled();
languageName: node
linkType: hard
-"@babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.16.3, @babel/runtime@npm:^7.9.2":
+"@babel/runtime@npm:^7.12.5, @babel/runtime@npm:^7.16.3":
version: 7.16.7
resolution: "@babel/runtime@npm:7.16.7"
dependencies:
languageName: node
linkType: hard
-"@testing-library/dom@npm:9.3.4, @testing-library/dom@npm:>=7, @testing-library/dom@npm:^9.0.0":
- version: 9.3.4
- resolution: "@testing-library/dom@npm:9.3.4"
- dependencies:
- "@babel/code-frame": "npm:^7.10.4"
- "@babel/runtime": "npm:^7.12.5"
- "@types/aria-query": "npm:^5.0.1"
- aria-query: "npm:5.1.3"
- chalk: "npm:^4.1.0"
- dom-accessibility-api: "npm:^0.5.9"
- lz-string: "npm:^1.5.0"
- pretty-format: "npm:^27.0.2"
- checksum: 10/510da752ea76f4a10a0a4e3a77917b0302cf03effe576cd3534cab7e796533ee2b0e9fb6fb11b911a1ebd7c70a0bb6f235bf4f816c9b82b95b8fe0cddfd10975
- languageName: node
- linkType: hard
-
-"@testing-library/jest-dom@npm:6.4.6":
- version: 6.4.6
- resolution: "@testing-library/jest-dom@npm:6.4.6"
+"@testing-library/jest-dom@npm:6.5.0":
+ version: 6.5.0
+ resolution: "@testing-library/jest-dom@npm:6.5.0"
dependencies:
"@adobe/css-tools": "npm:^4.4.0"
- "@babel/runtime": "npm:^7.9.2"
aria-query: "npm:^5.0.0"
chalk: "npm:^3.0.0"
css.escape: "npm:^1.5.1"
dom-accessibility-api: "npm:^0.6.3"
lodash: "npm:^4.17.21"
redent: "npm:^3.0.0"
- peerDependencies:
- "@jest/globals": ">= 28"
- "@types/bun": "*"
- "@types/jest": ">= 28"
- jest: ">= 28"
- vitest: ">= 0.32"
- peerDependenciesMeta:
- "@jest/globals":
- optional: true
- "@types/bun":
- optional: true
- "@types/jest":
- optional: true
- jest:
- optional: true
- vitest:
- optional: true
- checksum: 10/94fad29d740ff2c34967c644e2481a472aa8eeb1f11cdec5d4f81f14b2576660387551264c0fa718c15bfc61dd342f7621d888fe3e4ba1b7f830fe65bdd37bc8
- languageName: node
- linkType: hard
-
-"@testing-library/react@npm:14.2.1":
- version: 14.2.1
- resolution: "@testing-library/react@npm:14.2.1"
- dependencies:
- "@babel/runtime": "npm:^7.12.5"
- "@testing-library/dom": "npm:^9.0.0"
- "@types/react-dom": "npm:^18.0.0"
- peerDependencies:
- react: ^18.0.0
- react-dom: ^18.0.0
- checksum: 10/e02b2f32ae79665a79fc4d8ee053fd3832bfcd4753aa1dba05cdece1a9f59c72a0fae91e0a9387597dcb686d631a722729f2878e38dc95e6f23b291ad8d09b6c
+ checksum: 10/3d2080888af5fd7306f57448beb5a23f55d965e265b5e53394fffc112dfb0678d616a5274ff0200c46c7618f293520f86fc8562eecd8bdbc0dbb3294d63ec431
languageName: node
linkType: hard
-"@testing-library/react@npm:16.0.0":
- version: 16.0.0
- resolution: "@testing-library/react@npm:16.0.0"
+"@testing-library/react@npm:16.0.1":
+ version: 16.0.1
+ resolution: "@testing-library/react@npm:16.0.1"
dependencies:
"@babel/runtime": "npm:^7.12.5"
peerDependencies:
optional: true
"@types/react-dom":
optional: true
- checksum: 10/b32894be94e31276138decfa6bcea69dfebc0c37cf91499ff6c878f41eb1154a43a7df6eb1e72e7bede78468af6cb67ca59e4acd3206b41f3ecdae2c6efdf67e
+ checksum: 10/904b48881cf5bd208e25899e168f5c99c78ed6d77389544838d9d861a038d2c5c5385863ee9a367436770cbf7d21c5e05a991b9e24a33806e9ac985df2448185
languageName: node
linkType: hard
languageName: node
linkType: hard
-"@types/react-dom@npm:^18.0.0":
- version: 18.2.17
- resolution: "@types/react-dom@npm:18.2.17"
- dependencies:
- "@types/react": "npm:*"
- checksum: 10/fe0dbb3224b48515da8fe25559e3777d756a27c3f22903f0b1b020de8d68bd57eb1f0af62b52ee65d9632637950afed8cbad24d158c4f3d910d083d49bd73fba
- languageName: node
- linkType: hard
-
"@types/react-helmet@npm:6.1.11":
version: 6.1.11
resolution: "@types/react-helmet@npm:6.1.11"
"@swc/core": "npm:1.6.6"
"@swc/jest": "npm:0.2.36"
"@tanstack/react-query": "npm:5.18.1"
- "@testing-library/dom": "npm:9.3.4"
- "@testing-library/jest-dom": "npm:6.4.6"
- "@testing-library/react": "npm:14.2.1"
+ "@testing-library/dom": "npm:10.2.0"
+ "@testing-library/jest-dom": "npm:6.5.0"
+ "@testing-library/react": "npm:16.0.1"
"@testing-library/user-event": "npm:14.5.2"
"@types/cheerio": "npm:0.22.35"
"@types/classnames": "npm:2.3.1"
react-modal: "npm:3.16.1"
react-router-dom: "npm:6.24.0"
react-select: "npm:5.7.7"
- react-select-event: "npm:5.5.1"
react-virtualized: "npm:9.22.5"
regenerator-runtime: "npm:0.14.1"
shared-store-hook: "npm:0.0.4"
languageName: node
linkType: hard
-"aria-query@npm:5.1.3, aria-query@npm:~5.1.3":
- version: 5.1.3
- resolution: "aria-query@npm:5.1.3"
- dependencies:
- deep-equal: "npm:^2.0.5"
- checksum: 10/e5da608a7c4954bfece2d879342b6c218b6b207e2d9e5af270b5e38ef8418f02d122afdc948b68e32649b849a38377785252059090d66fa8081da95d1609c0d2
- languageName: node
- linkType: hard
-
"aria-query@npm:5.3.0":
version: 5.3.0
resolution: "aria-query@npm:5.3.0"
languageName: node
linkType: hard
+"aria-query@npm:~5.1.3":
+ version: 5.1.3
+ resolution: "aria-query@npm:5.1.3"
+ dependencies:
+ deep-equal: "npm:^2.0.5"
+ checksum: 10/e5da608a7c4954bfece2d879342b6c218b6b207e2d9e5af270b5e38ef8418f02d122afdc948b68e32649b849a38377785252059090d66fa8081da95d1609c0d2
+ languageName: node
+ linkType: hard
+
"array-buffer-byte-length@npm:^1.0.0":
version: 1.0.0
resolution: "array-buffer-byte-length@npm:1.0.0"
"@emotion/babel-plugin-jsx-pragmatic": "npm:0.2.1"
"@sonarsource/echoes-react": "npm:0.6.0"
"@testing-library/dom": "npm:10.2.0"
- "@testing-library/jest-dom": "npm:6.4.6"
- "@testing-library/react": "npm:16.0.0"
+ "@testing-library/jest-dom": "npm:6.5.0"
+ "@testing-library/react": "npm:16.0.1"
"@testing-library/user-event": "npm:14.5.2"
"@types/d3-array": "npm:3.2.1"
"@types/d3-hierarchy": "npm:~3.1.7"
languageName: node
linkType: hard
-"react-select-event@npm:5.5.1":
- version: 5.5.1
- resolution: "react-select-event@npm:5.5.1"
- dependencies:
- "@testing-library/dom": "npm:>=7"
- checksum: 10/b0917707ff9aa6eb887178107879403e483aeaacb14f2d74fef25a805538299be88adfc87709decc1b9f9280679a5ddf0d2c6f92178b7bbd416ea7c7a9149757
- languageName: node
- linkType: hard
-
"react-select@npm:5.7.7":
version: 5.7.7
resolution: "react-select@npm:5.7.7"