From 059326f1c35acc96849a7002090091974fb416b9 Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Fri, 16 Jun 2023 17:26:44 +0200 Subject: [PATCH] SONAR-19345 Add test to verify new filter link --- .../components/issue/__tests__/Issue-it.tsx | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/server/sonar-web/src/main/js/components/issue/__tests__/Issue-it.tsx b/server/sonar-web/src/main/js/components/issue/__tests__/Issue-it.tsx index 9c116a3ac7b..5a7e5135acf 100644 --- a/server/sonar-web/src/main/js/components/issue/__tests__/Issue-it.tsx +++ b/server/sonar-web/src/main/js/components/issue/__tests__/Issue-it.tsx @@ -22,10 +22,11 @@ import { act, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { omit, pick } from 'lodash'; import * as React from 'react'; +import { Route } from 'react-router-dom'; import IssuesServiceMock from '../../../api/mocks/IssuesServiceMock'; import { KeyboardKeys } from '../../../helpers/keycodes'; import { mockIssue, mockLoggedInUser, mockRawIssue } from '../../../helpers/testMocks'; -import { findTooltipWithContent, renderApp } from '../../../helpers/testReactTestingUtils'; +import { findTooltipWithContent, renderAppRoutes } from '../../../helpers/testReactTestingUtils'; import { byLabelText, byRole, byText } from '../../../helpers/testSelector'; import { IssueActions, @@ -55,6 +56,11 @@ describe('rendering', () => { renderIssue({ issue, onSelect: onClick }); expect(ui.effort('2 days').get()).toBeInTheDocument(); + expect(ui.issueMessageLink.get()).toHaveAttribute( + 'href', + '/project/issues?scopes=MAIN&severities=MINOR&types=VULNERABILITY&open=AVsae-CQS-9G3txfbFN2&id=myproject' + ); + await ui.clickIssueMessage(); expect(onClick).toHaveBeenCalledWith(issue.key); }); @@ -154,7 +160,6 @@ describe('updating', () => { expect(ui.updateAssigneeBtn('luke').get()).toBeInTheDocument(); }); - // eslint-disable-next-line jest/no-commented-out-tests it('should allow updating the tags', async () => { const { ui } = getPageObject(); const issue = mockRawIssue(false, { @@ -222,11 +227,10 @@ function getPageObject() { ruleStatusBadge: (status: RuleStatus) => byText(`issue.resolution.badge.${status}`), locationsBadge: (count: number) => byText(count), lineInfo: (line: number) => byText(`L${line}`), - permalink: byRole('link', { name: 'permalink' }), effort: (effort: string) => byText(`issue.x_effort.${effort}`), whyLink: byRole('link', { name: 'issue.why_this_issue.long' }), checkbox: byRole('checkbox'), - issueMessageBtn: byRole('link', { name: 'This is an issue' }), + issueMessageLink: byRole('link', { name: 'This is an issue' }), variants: (n: number) => byText(`issue.x_code_variants.${n}`), // Changelog @@ -366,7 +370,7 @@ function getPageObject() { await user.click(selectors.checkbox.get()); }, async clickIssueMessage() { - await user.click(selectors.issueMessageBtn.get()); + await user.click(selectors.issueMessageLink.get()); }, async pressDismissShortcut() { await act(async () => { @@ -432,9 +436,14 @@ function renderIssue(props: Partial, + return renderAppRoutes( + 'issues?scopes=MAIN&severities=MINOR&types=VULNERABILITY', + () => ( + } + /> + ), { currentUser: mockLoggedInUser({ login: 'leia', name: 'Organa' }), } -- 2.39.5