Browse Source

SONAR-21692 Remove test warnings from QualityGate, CaycGuide, GitHub

tags/10.5.0.89998
Viktor Vorona 2 months ago
parent
commit
5d53328777

+ 1
- 1
server/sonar-web/src/main/js/api/mocks/QualityGatesServiceMock.ts View File

@@ -140,7 +140,7 @@ export class QualityGatesServiceMock {
isCaycCondition: true,
},
{ id: 'AXJMbIUHPAOIsUIE3eNs', metric: 'new_security_rating', op: 'GT', error: '1' },
{ id: 'AXJMbIUHPAOIsUIE3eNs', metric: 'new_security_rating', op: 'GT', error: '0' },
{ id: 'AXJMbIUHPAOIsUIE3eNy', metric: 'new_security_rating', op: 'GT', error: '0' },
{ id: 'deprecated', metric: 'function_complexity', op: 'LT', error: '1' },
],
isDefault: false,

+ 9
- 6
server/sonar-web/src/main/js/apps/create/project/__tests__/GitHub-it.tsx View File

@@ -67,6 +67,7 @@ const ui = {
name: 'onboarding.create_project.new_code_definition.create_x_projects2',
}),
globalSettingRadio: byRole('radio', { name: 'new_code_definition.global_setting' }),
createErrorMessage: byText('onboarding.create_project.github.warning.message'),
};

beforeAll(() => {
@@ -109,7 +110,9 @@ it('should not redirect to github when url is malformated', async () => {
expect(screen.getByText('alm.configuration.selector.placeholder')).toBeInTheDocument();
expect(ui.instanceSelector.get()).toBeInTheDocument();

await selectEvent.select(ui.instanceSelector.get(), [/conf-github-3/]);
await waitFor(() => selectEvent.select(ui.instanceSelector.get(), [/conf-github-3/]));

expect(await ui.createErrorMessage.find()).toBeInTheDocument();

expect(window.location.replace).not.toHaveBeenCalled();
});
@@ -121,7 +124,7 @@ it('should show import project feature when the authentication is successfull',

expect(await ui.instanceSelector.find()).toBeInTheDocument();

await selectEvent.select(ui.organizationSelector.get(), [/org-1/]);
await waitFor(() => selectEvent.select(ui.organizationSelector.get(), [/org-1/]));

expect(await ui.project1.find()).toBeInTheDocument();
expect(ui.project2.get()).toBeInTheDocument();
@@ -173,7 +176,7 @@ it('should import several projects', async () => {

expect(await ui.instanceSelector.find()).toBeInTheDocument();

await selectEvent.select(ui.organizationSelector.get(), [/org-1/]);
await waitFor(() => selectEvent.select(ui.organizationSelector.get(), [/org-1/]));

expect(await ui.project1.find()).toBeInTheDocument();
expect(ui.project1Checkbox.get()).not.toBeChecked();
@@ -238,7 +241,7 @@ it('should show search filter when the authentication is successful', async () =

expect(await ui.instanceSelector.find()).toBeInTheDocument();

await selectEvent.select(ui.organizationSelector.get(), [/org-1/]);
await waitFor(() => selectEvent.select(ui.organizationSelector.get(), [/org-1/]));

const inputSearch = screen.getByRole('searchbox');
await user.click(inputSearch);
@@ -261,7 +264,7 @@ it('should have load more', async () => {

expect(await ui.instanceSelector.find()).toBeInTheDocument();

await selectEvent.select(ui.organizationSelector.get(), [/org-1/]);
await waitFor(() => selectEvent.select(ui.organizationSelector.get(), [/org-1/]));

const loadMore = await screen.findByRole('button', { name: 'show_more' });
expect(loadMore).toBeInTheDocument();
@@ -289,7 +292,7 @@ it('should show no result message when there are no projects', async () => {

expect(await ui.instanceSelector.find()).toBeInTheDocument();

await selectEvent.select(ui.organizationSelector.get(), [/org-1/]);
await waitFor(() => selectEvent.select(ui.organizationSelector.get(), [/org-1/]));

expect(screen.getByText('no_results')).toBeInTheDocument();
});

+ 0
- 1
server/sonar-web/src/main/js/apps/quality-gates/components/CaYCConditionsSimplificationGuide.tsx View File

@@ -88,7 +88,6 @@ export default function CaYCConditionsSimplificationGuide({ qualityGate }: Props

return (
<SpotlightTour
debug
continuous
run={shouldRun}
closeLabel={translate('dismiss')}

+ 15
- 33
server/sonar-web/src/main/js/apps/quality-gates/components/__tests__/QualityGate-it.tsx View File

@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { act, screen, waitFor, within } from '@testing-library/react';
import { screen, waitFor, within } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import selectEvent from 'react-select-event';
import { QualityGatesServiceMock } from '../../../../api/mocks/QualityGatesServiceMock';
@@ -79,9 +79,7 @@ it('should render the built-in quality gate properly', async () => {

const builtInQualityGate = await screen.findByText('Sonar way');

await act(async () => {
await user.click(builtInQualityGate);
});
await user.click(builtInQualityGate);

expect(await screen.findByText(/quality_gates.is_built_in.cayc.description/)).toBeInTheDocument();
expect(await screen.findByText(/quality_gates.is_built_in.description/)).toBeInTheDocument();
@@ -95,11 +93,9 @@ it('should be able to create a quality gate then delete it', async () => {

// Using keyboard
await user.click(createButton);
await act(async () => {
await user.click(screen.getByRole('textbox', { name: /name.*/ }));
await user.keyboard('testone');
await user.click(screen.getByRole('button', { name: 'quality_gate.create' }));
});
await user.click(screen.getByRole('textbox', { name: /name.*/ }));
await user.keyboard('testone');
await user.click(screen.getByRole('button', { name: 'quality_gate.create' }));
expect(await screen.findByRole('button', { name: 'testone' })).toBeInTheDocument();

// Using modal button
@@ -109,11 +105,9 @@ it('should be able to create a quality gate then delete it', async () => {

expect(saveButton).toBeDisabled();
const nameInput = screen.getByRole('textbox', { name: /name.*/ });
await act(async () => {
await user.click(nameInput);
await user.keyboard('testtwo');
await user.click(saveButton);
});
await user.click(nameInput);
await user.keyboard('testtwo');
await user.click(saveButton);

const newQG = await screen.findByRole('button', { name: 'testtwo' });

@@ -147,10 +141,8 @@ it('should be able to copy a quality gate which is CaYC compliant', async () =>
await user.click(copyButton);
const nameInput = screen.getByRole('textbox', { name: /name.*/ });
expect(nameInput).toBeInTheDocument();
await act(async () => {
await user.click(nameInput);
await user.keyboard(' bis{Enter}');
});
await user.click(nameInput);
await user.keyboard(' bis{Enter}');
expect(await screen.findByRole('button', { name: /.* bis/ })).toBeInTheDocument();
});

@@ -498,9 +490,7 @@ it('should display CaYC condition simplification tour for users who didnt dismis

const qualityGate = await screen.findByText('Sonar way');

await act(async () => {
await user.click(qualityGate);
});
await user.click(qualityGate);

expect(await byRole('alertdialog').find()).toBeInTheDocument();

@@ -510,9 +500,7 @@ it('should display CaYC condition simplification tour for users who didnt dismis
.get(),
).toBeInTheDocument();

await act(async () => {
await user.click(byRole('alertdialog').byRole('button', { name: 'next' }).get());
});
await user.click(byRole('alertdialog').byRole('button', { name: 'next' }).get());

expect(
byRole('alertdialog')
@@ -520,9 +508,7 @@ it('should display CaYC condition simplification tour for users who didnt dismis
.get(),
).toBeInTheDocument();

await act(async () => {
await user.click(byRole('alertdialog').byRole('button', { name: 'next' }).get());
});
await user.click(byRole('alertdialog').byRole('button', { name: 'next' }).get());

expect(
byRole('alertdialog')
@@ -530,9 +516,7 @@ it('should display CaYC condition simplification tour for users who didnt dismis
.get(),
).toBeInTheDocument();

await act(async () => {
await user.click(byRole('alertdialog').byRole('button', { name: 'dismiss' }).get());
});
await user.click(byRole('alertdialog').byRole('button', { name: 'dismiss' }).get());

expect(byRole('alertdialog').query()).not.toBeInTheDocument();
expect(dismissNotice).toHaveBeenLastCalledWith(NoticeType.QG_CAYC_CONDITIONS_SIMPLIFICATION);
@@ -549,9 +533,7 @@ it('should not display CaYC condition simplification tour for users who dismisse

const qualityGate = await screen.findByText('Sonar way');

await act(async () => {
await user.click(qualityGate);
});
await user.click(qualityGate);

expect(byRole('alertdialog').query()).not.toBeInTheDocument();
});

Loading…
Cancel
Save