rulesUpdatedAt?: string;
lastUsed?: string;
userUpdatedAt?: string;
- organization: string;
isBuiltIn?: boolean;
projectCount?: number;
}
export interface SearchQualityProfilesParameters {
defaults?: boolean;
language?: string;
- organization?: string;
project?: string;
qualityProfile?: string;
}
export function getProfileInheritance({
language,
- name: qualityProfile,
- organization
+ name: qualityProfile
}: Profile): Promise<{
ancestors: T.ProfileInheritanceDetails[];
children: T.ProfileInheritanceDetails[];
}> {
return getJSON('/api/qualityprofiles/inheritance', {
language,
- qualityProfile,
- organization
+ qualityProfile
}).catch(throwGlobalError);
}
-export function setDefaultProfile({ language, name: qualityProfile, organization }: Profile) {
+export function setDefaultProfile({ language, name: qualityProfile }: Profile) {
return post('/api/qualityprofiles/set_default', {
language,
- qualityProfile,
- organization
+ qualityProfile
});
}
return postJSON('/api/qualityprofiles/copy', { fromKey, toName }).catch(throwGlobalError);
}
-export function deleteProfile({ language, name: qualityProfile, organization }: Profile) {
- return post('/api/qualityprofiles/delete', { language, qualityProfile, organization }).catch(
- throwGlobalError
- );
+export function deleteProfile({ language, name: qualityProfile }: Profile) {
+ return post('/api/qualityprofiles/delete', { language, qualityProfile }).catch(throwGlobalError);
}
export function changeProfileParent(
- { language, name: qualityProfile, organization }: Profile,
+ { language, name: qualityProfile }: Profile,
parentProfile?: Profile
) {
return post('/api/qualityprofiles/change_parent', {
language,
qualityProfile,
- organization,
parentQualityProfile: parentProfile ? parentProfile.name : undefined
}).catch(throwGlobalError);
}
-export function getQualityProfileBackupUrl({
- language,
- name: qualityProfile,
- organization
-}: Profile) {
- const queryParams = Object.entries({ language, qualityProfile, organization })
+export function getQualityProfileBackupUrl({ language, name: qualityProfile }: Profile) {
+ const queryParams = Object.entries({ language, qualityProfile })
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
.join('&');
return `/api/qualityprofiles/backup?${queryParams}`;
export function getQualityProfileExporterUrl(
{ key: exporterKey }: Exporter,
- { language, name: qualityProfile, organization }: Profile
+ { language, name: qualityProfile }: Profile
) {
- const queryParams = Object.entries({ exporterKey, language, qualityProfile, organization })
+ const queryParams = Object.entries({ exporterKey, language, qualityProfile })
.map(([key, value]) => `${key}=${encodeURIComponent(value)}`)
.join('&');
return `/api/qualityprofiles/export?${queryParams}`;
export function getProfileChangelog(
since: any,
to: any,
- { language, name: qualityProfile, organization }: Profile,
+ { language, name: qualityProfile }: Profile,
page?: number
): Promise<{
events: ProfileChangelogEvent[];
to,
language,
qualityProfile,
- organization,
p: page
});
}
return getJSON('/api/qualityprofiles/compare', { leftKey, rightKey });
}
-export function associateProject(
- { language, name: qualityProfile, organization }: Profile,
- project: string
-) {
+export function associateProject({ language, name: qualityProfile }: Profile, project: string) {
return post('/api/qualityprofiles/add_project', {
language,
qualityProfile,
- organization,
project
}).catch(throwGlobalError);
}
-export function dissociateProject(
- { language, name: qualityProfile, organization }: Profile,
- project: string
-) {
+export function dissociateProject({ language, name: qualityProfile }: Profile, project: string) {
return post('/api/qualityprofiles/remove_project', {
language,
qualityProfile,
- organization,
project
}).catch(throwGlobalError);
}
export interface AddRemoveUserParameters {
language: string;
login: string;
- organization?: string;
qualityProfile: string;
}
fetchQualityProfiles = () => {
const { currentUser, organization, userOrganizations } = this.props;
if (hasPrivateAccess(currentUser, organization, userOrganizations)) {
- return searchQualityProfiles({ organization: organization && organization.key });
+ return searchQualityProfiles();
}
return { profiles: [] };
};
"language": "js",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
},
}
"language": "js",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
},
}
"language": "js",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
},
]
"language": "css",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
},
],
"language": "html",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
},
],
"language": "js",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
},
],
"language": "js",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
},
]
"language": "js",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
}
}
interface Props {
events: ProfileChangelogEvent[];
- organization: string | null;
}
export default function Changelog(props: Props) {
import ChangelogSearch from './ChangelogSearch';
interface Props extends Pick<WithRouterProps, 'router' | 'location'> {
- organization: string | null;
profile: Profile;
}
{this.state.events != null && this.state.events.length === 0 && <ChangelogEmpty />}
{this.state.events != null && this.state.events.length > 0 && (
- <Changelog events={this.state.events} organization={this.props.organization} />
+ <Changelog events={this.state.events} />
)}
{shouldDisplayFooter && (
it('should render events', () => {
const events = [createEvent(), createEvent()];
- const changelog = shallow(<Changelog events={events} organization={null} />);
+ const changelog = shallow(<Changelog events={events} />);
expect(changelog.find('tbody').find('tr').length).toBe(2);
});
it('should render event date', () => {
const events = [createEvent()];
- const changelog = shallow(<Changelog events={events} organization={null} />);
+ const changelog = shallow(<Changelog events={events} />);
expect(changelog.find('DateTimeFormatter')).toHaveLength(1);
});
it('should render author', () => {
const events = [createEvent()];
- const changelog = shallow(<Changelog events={events} organization={null} />);
+ const changelog = shallow(<Changelog events={events} />);
expect(changelog.text()).toContain('John');
});
it('should render system author', () => {
const events = [createEvent({ authorName: undefined })];
- const changelog = shallow(<Changelog events={events} organization={null} />);
+ const changelog = shallow(<Changelog events={events} />);
expect(changelog.text()).toContain('System');
});
it('should render action', () => {
const events = [createEvent()];
- const changelog = shallow(<Changelog events={events} organization={null} />);
+ const changelog = shallow(<Changelog events={events} />);
expect(changelog.text()).toContain('ACTIVATED');
});
it('should render rule', () => {
const events = [createEvent()];
- const changelog = shallow(<Changelog events={events} organization={null} />);
+ const changelog = shallow(<Changelog events={events} />);
expect(changelog.find('Link').prop('to')).toHaveProperty('query', { rule_key: 'squid1234' });
});
it('should render ChangesList', () => {
const params = { severity: 'BLOCKER' };
const events = [createEvent({ params })];
- const changelog = shallow(<Changelog events={events} organization={null} />);
+ const changelog = shallow(<Changelog events={events} />);
const changesList = changelog.find(ChangesList);
expect(changesList.length).toBe(1);
expect(changesList.prop('changes')).toBe(params);
createEvent({ date: '2019-02-07T14:03:14', action: 'ACTIVATED' }),
createEvent({ date: '2019-02-07T14:03:07', action: 'ACTIVATED' })
];
- const changelog = shallow(<Changelog events={events} organization={null} />);
+ const changelog = shallow(<Changelog events={events} />);
const rows = changelog.find('tbody').find('tr');
const getAction = (index: number) =>
return shallow<ChangelogContainer>(
<ChangelogContainer
location={mockLocation()}
- organization="TEST"
profile={mockQualityProfile()}
router={mockRouter()}
/>
},
]
}
- organization="TEST"
/>
<footer
className="text-center spacer-top small"
import ComparisonResults from './ComparisonResults';
interface Props extends WithRouterProps {
- organization?: string;
profile: Profile;
profiles: Profile[];
}
left={this.state.left}
leftProfile={profile}
modified={this.state.modified}
- organization={this.props.organization}
refresh={this.loadResults}
right={this.state.right}
rightProfile={profiles.find(p => p.key === withKey)}
interface Props {
onDone: () => Promise<void>;
- organization?: string;
profile: Profile;
ruleKey: string;
}
handleButtonClick = () => {
this.setState({ state: 'opening' });
- getRuleDetails({ key: this.props.ruleKey, organization: this.props.organization }).then(
+ getRuleDetails({ key: this.props.ruleKey }).then(
({ rule }) => {
if (this.mounted) {
this.setState({ rule, state: 'open' });
type Params = T.Dict<string>;
interface Props extends CompareResponse {
- organization?: string;
leftProfile: Profile;
refresh: () => Promise<void>;
rightProfile?: Profile;
<ComparisonResultActivation
key={rule.key}
onDone={this.props.refresh}
- organization={this.props.organization || undefined}
profile={this.props.rightProfile}
ruleKey={rule.key}>
<ChevronRightIcon />
<ComparisonResultActivation
key={rule.key}
onDone={this.props.refresh}
- organization={this.props.organization || undefined}
profile={this.props.leftProfile}
ruleKey={rule.key}>
<ChevronLeftIcon />
interface Props {
children: React.ReactElement<any>;
languages: T.Languages;
- organization: { name: string; key: string } | undefined;
}
interface State {
}
fetchProfiles() {
- const { organization } = this.props;
- const data = organization ? { organization: organization.key } : {};
- return searchQualityProfiles(data);
+ return searchQualityProfiles();
}
loadData() {
if (this.state.loading) {
return <i className="spinner" />;
}
- const { organization } = this.props;
const finalLanguages = Object.values(this.props.languages);
return React.cloneElement(this.props.children, {
profiles: this.state.profiles || [],
languages: finalLanguages,
exporters: this.state.exporters,
- updateProfiles: this.updateProfiles,
- organization: organization ? organization.key : null
+ updateProfiles: this.updateProfiles
});
}
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
import { connect } from 'react-redux';
-import { getLanguages, getOrganizationByKey, Store } from '../../../store/rootReducer';
+import { getLanguages, Store } from '../../../store/rootReducer';
import App from './App';
-const mapStateToProps = (state: Store, ownProps: any) => ({
- languages: getLanguages(state),
- organization: ownProps.params.organizationKey
- ? getOrganizationByKey(state, ownProps.params.organizationKey)
- : undefined
+const mapStateToProps = (state: Store) => ({
+ languages: getLanguages(state)
});
export default connect(mapStateToProps)(App);
interface Props {
onClose: () => void;
onExtend: (name: string) => void;
- organization: string | null;
profile: Profile;
}
handleFormSubmit = async (event: React.SyntheticEvent<HTMLFormElement>) => {
event.preventDefault();
if (this.canSubmit(this.state)) {
- const { organization, profile: parentProfile } = this.props;
+ const { profile: parentProfile } = this.props;
const { name } = this.state;
const data = new FormData();
data.append('language', parentProfile.language);
data.append('name', name);
- if (organization) {
- data.append('organization', organization);
- }
-
this.setState({ loading: true });
try {
interface Props {
className?: string;
fromList?: boolean;
- organization: string | null;
profile: Profile;
router: Pick<Router, 'push' | 'replace'>;
updateProfiles: () => Promise<void>;
<ExtendProfileForm
onClose={this.closeExtendForm}
onExtend={this.handleProfileExtend}
- organization={this.props.organization}
profile={profile}
/>
)}
interface Props {
children: React.ReactElement<any>;
- location: {
- pathname: string;
- query: { key?: string; language: string; name: string };
- };
- organization: string | null;
profiles: Profile[];
updateProfiles: () => Promise<void>;
}
}
render() {
- const { organization, profiles, location, ...other } = this.props;
+ const { profiles, location, ...other } = this.props;
const { key, language, name } = location.query;
if (key) {
}
const child = React.cloneElement(this.props.children, {
- organization,
profile,
profiles,
...other
return (
<div id="quality-profile">
<Helmet defer={false} title={profile.name} />
- <ProfileHeader
- organization={organization}
- profile={profile}
- updateProfiles={this.props.updateProfiles}
- />
+ <ProfileHeader profile={profile} updateProfiles={this.props.updateProfiles} />
{child}
</div>
);
function shallowRender(props: Partial<App['props']> = {}) {
return shallow<App>(
- <App languages={{}} organization={undefined} {...props}>
+ <App languages={{}} {...props}>
<div />
</App>
);
it('should correctly create a new profile and extend the existing one', async () => {
const profile = mockQualityProfile();
- const organization = 'org';
const name = 'New name';
- const wrapper = shallowRender({ organization, profile });
+ const wrapper = shallowRender({ profile });
expect(wrapper.find('SubmitButton').props().disabled).toBe(true);
const data = new FormData();
data.append('language', profile.language);
data.append('name', name);
- data.append('organization', organization);
expect(createQualityProfile).toHaveBeenCalledWith(data);
expect(changeProfileParent).toHaveBeenCalledWith({ key: 'new-profile' }, profile);
});
<ExtendProfileForm
onClose={jest.fn()}
onExtend={jest.fn()}
- organization="foo"
profile={mockQualityProfile()}
{...props}
/>
function shallowRender(props: Partial<ProfileActions['props']> = {}) {
const router = mockRouter();
return shallow<ProfileActions>(
- <ProfileActions
- organization="org"
- profile={PROFILE}
- router={router}
- updateProfiles={jest.fn()}
- {...props}
- />
+ <ProfileActions profile={PROFILE} router={router} updateProfiles={jest.fn()} {...props} />
);
}
import * as React from 'react';
import { Helmet } from 'react-helmet-async';
import { WithRouterProps } from 'react-router';
-import { mockQualityProfile } from '../../../../helpers/testMocks';
+import { mockLocation, mockQualityProfile, mockRouter } from '../../../../helpers/testMocks';
import ProfileHeader from '../../details/ProfileHeader';
import ProfileContainer from '../ProfileContainer';
import ProfileNotFound from '../ProfileNotFound';
-const routerProps = { router: {} } as WithRouterProps;
-
it('should render ProfileHeader', () => {
const targetProfile = mockQualityProfile({ name: 'fake' });
const profiles = [targetProfile, mockQualityProfile({ name: 'another' })];
const updateProfiles = jest.fn();
- const output = shallow(
- <ProfileContainer
- location={{ pathname: '', query: { language: 'js', name: 'fake' } }}
- organization={null}
- profiles={profiles}
- updateProfiles={updateProfiles}
- {...routerProps}>
- <div />
- </ProfileContainer>
- );
+ const location = mockLocation({ pathname: '', query: { language: 'js', name: 'fake' } });
+
+ const output = shallowRender({ profiles, updateProfiles, location });
+
const header = output.find(ProfileHeader);
expect(header.length).toBe(1);
expect(header.prop('profile')).toBe(targetProfile);
it('should render ProfileNotFound', () => {
const profiles = [mockQualityProfile({ name: 'fake' }), mockQualityProfile({ name: 'another' })];
- const output = shallow(
- <ProfileContainer
- location={{ pathname: '', query: { language: 'js', name: 'random' } }}
- organization={null}
- profiles={profiles}
- updateProfiles={jest.fn()}
- {...routerProps}>
- <div />
- </ProfileContainer>
- );
+ const location = mockLocation({ pathname: '', query: { language: 'js', name: 'random' } });
+
+ const output = shallowRender({ profiles, location });
+
expect(output.is(ProfileNotFound)).toBe(true);
});
const name = 'First Profile';
const profiles = [mockQualityProfile({ name })];
const updateProfiles = jest.fn();
- const output = shallow(
- <ProfileContainer
- location={{ pathname: '', query: { language: 'js', name } }}
- organization={null}
- profiles={profiles}
- updateProfiles={updateProfiles}
- {...routerProps}>
- <div />
- </ProfileContainer>
- );
+ const location = mockLocation({ pathname: '', query: { language: 'js', name } });
+
+ const output = shallowRender({ profiles, updateProfiles, location });
+
const helmet = output.find(Helmet);
expect(helmet.length).toBe(1);
expect(helmet.prop('title')).toContain(name);
});
+
+function shallowRender(overrides: Partial<ProfileContainer['props']> = {}) {
+ const routerProps = { router: mockRouter(), ...overrides } as WithRouterProps;
+
+ return shallow(
+ <ProfileContainer profiles={[]} updateProfiles={jest.fn()} {...routerProps} {...overrides}>
+ <div />
+ </ProfileContainer>
+ );
+}
</ActionsDropdownItem>
<ActionsDropdownItem
download="key.xml"
- to="/api/qualityprofiles/backup?language=js&qualityProfile=name&organization=foo"
+ to="/api/qualityprofiles/backup?language=js&qualityProfile=name"
>
<span
data-test="quality-profiles__backup"
<ActionsDropdown>
<ActionsDropdownItem
download="key.xml"
- to="/api/qualityprofiles/backup?language=js&qualityProfile=name&organization=foo"
+ to="/api/qualityprofiles/backup?language=js&qualityProfile=name"
>
<span
data-test="quality-profiles__backup"
</ActionsDropdownItem>
<ActionsDropdownItem
download="key.xml"
- to="/api/qualityprofiles/backup?language=js&qualityProfile=name&organization=foo"
+ to="/api/qualityprofiles/backup?language=js&qualityProfile=name"
>
<span
data-test="quality-profiles__backup"
interface Props {
onClose: () => void;
- organization: string | null;
profile: Profile;
}
fetchProjects = (searchParams: SelectListSearchParams) =>
getProfileProjects({
key: this.props.profile.key,
- organization: this.props.organization,
p: searchParams.page,
ps: searchParams.pageSize,
q: searchParams.query !== '' ? searchParams.query : undefined,
interface Props {
exporters: Exporter[];
- organization: string | null;
profile: Profile;
profiles: Profile[];
updateProfiles: () => Promise<void>;
}
export default function ProfileDetails(props: Props) {
- const { organization, profile } = props;
+ const { profile } = props;
return (
<div>
<div className="quality-profile-grid">
<div className="quality-profile-grid-left">
- <ProfileRules organization={organization} profile={profile} />
- <ProfileExporters
- exporters={props.exporters}
- organization={organization}
- profile={profile}
- />
+ <ProfileRules profile={profile} />
+ <ProfileExporters exporters={props.exporters} profile={profile} />
{profile.actions && profile.actions.edit && !profile.isBuiltIn && (
- <ProfilePermissions organization={organization || undefined} profile={profile} />
+ <ProfilePermissions profile={profile} />
)}
</div>
<div className="quality-profile-grid-right">
<ProfileInheritance
- organization={organization}
profile={profile}
profiles={props.profiles}
updateProfiles={props.updateProfiles}
/>
- <ProfileProjects organization={organization} profile={profile} />
+ <ProfileProjects profile={profile} />
</div>
</div>
</div>
interface Props {
exporters: Exporter[];
- organization: string | null;
profile: Profile;
}
interface Props {
profile: Profile;
- organization: string | null;
updateProfiles: () => Promise<void>;
}
export default class ProfileHeader extends React.PureComponent<Props> {
render() {
- const { organization, profile } = this.props;
+ const { profile } = this.props;
return (
<header className="page-header quality-profile-header">
<li>
<ProfileActions
className="pull-left"
- organization={organization}
profile={profile}
updateProfiles={this.props.updateProfiles}
/>
import ProfileInheritanceBox from './ProfileInheritanceBox';
interface Props {
- organization: string | null;
profile: Profile;
profiles: Profile[];
updateProfiles: () => Promise<void>;
depth={index}
key={ancestor.key}
language={profile.language}
- organization={this.props.organization}
profile={ancestor}
type="ancestor"
/>
displayLink={false}
extendsBuiltIn={extendsBuiltIn}
language={profile.language}
- organization={this.props.organization}
profile={this.state.profile}
/>
)}
depth={ancestors ? ancestors.length + 1 : 0}
key={child.key}
language={profile.language}
- organization={this.props.organization}
profile={child}
type="child"
/>
displayLink?: boolean;
extendsBuiltIn?: boolean;
language: string;
- organization: string | null;
profile: T.ProfileInheritanceDetails;
type?: string;
}
}
interface Props {
- organization?: string;
profile: Pick<Profile, 'key' | 'language' | 'name'>;
}
}
componentDidUpdate(prevProps: Props) {
- if (
- prevProps.organization !== this.props.organization ||
- prevProps.profile.key !== this.props.profile.key
- ) {
+ if (prevProps.profile.key !== this.props.profile.key) {
this.fetchUsersAndGroups();
}
}
fetchUsersAndGroups() {
this.setState({ loading: true });
- const { organization, profile } = this.props;
+ const { profile } = this.props;
const parameters: SearchUsersGroupsParameters = {
language: profile.language,
- organization,
qualityProfile: profile.name,
selected: 'selected'
};
<ProfilePermissionsUser
key={user.login}
onDelete={this.handleUserDelete}
- organization={this.props.organization}
profile={this.props.profile}
user={user}
/>
group={group}
key={group.name}
onDelete={this.handleGroupDelete}
- organization={this.props.organization}
profile={this.props.profile}
/>
))}
onClose={this.handleAddUserFormClose}
onGroupAdd={this.handleGroupAdd}
onUserAdd={this.handleUserAdd}
- organization={this.props.organization}
profile={this.props.profile}
/>
)}
onClose: () => void;
onGroupAdd: (group: Group) => void;
onUserAdd: (user: T.UserSelected) => void;
- organization?: string;
profile: { language: string; name: string };
}
handleUserAdd = (user: T.UserSelected) => {
const {
- profile: { language, name },
- organization
+ profile: { language, name }
} = this.props;
addUser({
language,
login: user.login,
- organization,
qualityProfile: name
}).then(() => this.props.onUserAdd(user), this.stopSubmitting);
};
handleGroupAdd = (group: Group) => {
const {
- profile: { language, name },
- organization
+ profile: { language, name }
} = this.props;
addGroup({
group: group.name,
language,
- organization,
qualityProfile: name
}).then(() => this.props.onGroupAdd(group), this.stopSubmitting);
};
};
handleSearch = (q: string) => {
- const { organization, profile } = this.props;
+ const { profile } = this.props;
const parameters: SearchUsersGroupsParameters = {
language: profile.language,
- organization,
q,
qualityProfile: profile.name,
selected: 'deselected'
interface Props {
group: Group;
onDelete: (group: Group) => void;
- organization?: string;
profile: { language: string; name: string };
}
};
handleDelete = () => {
- const { group, organization, profile } = this.props;
+ const { group, profile } = this.props;
return removeGroup({
group: group.name,
language: profile.language,
- organization,
qualityProfile: profile.name
}).then(() => {
this.handleDeleteModalClose();
interface Props {
onDelete: (user: T.UserSelected) => void;
- organization?: string;
profile: { language: string; name: string };
user: T.UserSelected;
}
};
handleDelete = () => {
- const { organization, profile, user } = this.props;
+ const { profile, user } = this.props;
return removeUser({
language: profile.language,
login: user.login,
- organization,
qualityProfile: profile.name
}).then(() => {
this.handleDeleteModalClose();
import ChangeProjectsForm from './ChangeProjectsForm';
interface Props {
- organization: string | null;
profile: Profile;
}
{profile.isDefault ? this.renderDefault() : this.renderProjects()}
</div>
- {this.state.formOpen && (
- <ChangeProjectsForm
- onClose={this.closeForm}
- organization={this.props.organization}
- profile={profile}
- />
- )}
+ {this.state.formOpen && <ChangeProjectsForm onClose={this.closeForm} profile={profile} />}
</div>
);
}
const TYPES = ['BUG', 'VULNERABILITY', 'CODE_SMELL', 'SECURITY_HOTSPOT'];
interface Props {
- organization: string | null;
profile: Profile;
}
return searchRules({
languages: this.props.profile.language,
facets: 'types',
- organization: this.props.organization || undefined,
ps: 1
});
}
return searchRules({
activation: 'true',
facets: 'types',
- organization: this.props.organization || undefined,
ps: 1,
qprofile: this.props.profile.key
});
}
loadRules() {
- Promise.all([this.loadAllRules(), this.loadActivatedRules(), this.loadProfile()]).then(
+ return Promise.all([this.loadAllRules(), this.loadActivatedRules(), this.loadProfile()]).then(
responses => {
if (this.mounted) {
const [allRules, activatedRules, showProfile] = responses;
}
render() {
- const { organization, profile } = this.props;
+ const { profile } = this.props;
const { compareToSonarWay } = this.state;
const activateMoreUrl = getRulesUrl({ qprofile: profile.key, activation: 'false' });
const { actions = {} } = profile;
<tbody>
<ProfileRulesRowTotal
count={this.state.activatedTotal}
- organization={organization}
qprofile={profile.key}
total={this.state.total}
/>
<ProfileRulesRowOfType
count={this.getRulesCountForType(type)}
key={type}
- organization={organization}
qprofile={profile.key}
total={this.getRulesTotalForType(type)}
type={type}
</div>
)}
- {/* if a user is allowed to `copy` a profile if they are a global or organization admin */}
+ {/* if a user is allowed to `copy` a profile if they are a global admin */}
{/* this user could potentially active more rules if the profile was not built-in */}
{/* in such cases it's better to show the button but disable it with a tooltip */}
{actions.copy && profile.isBuiltIn && (
{profile.activeDeprecatedRuleCount > 0 && (
<ProfileRulesDeprecatedWarning
activeDeprecatedRules={profile.activeDeprecatedRuleCount}
- organization={organization}
profile={profile.key}
/>
)}
{compareToSonarWay != null && compareToSonarWay.missingRuleCount > 0 && (
<ProfileRulesSonarWayComparison
language={profile.language}
- organization={organization}
profile={profile.key}
sonarWayMissingRules={compareToSonarWay.missingRuleCount}
sonarway={compareToSonarWay.profile}
interface Props {
activeDeprecatedRules: number;
- organization: string | null;
profile: string;
}
interface Props {
count: number | null;
- organization: string | null;
qprofile: string;
total: number | null;
type: string;
interface Props {
count: number | null;
- organization: string | null;
qprofile: string;
total: number | null;
}
interface Props {
language: string;
- organization: string | null;
profile: string;
sonarway: string;
sonarWayMissingRules: number;
import ChangeProjectsForm from '../ChangeProjectsForm';
const profile: any = { key: 'profFile_key' };
-const organization = 'TEST';
jest.mock('../../../../api/quality-profiles', () => ({
getProfileProjects: jest.fn().mockResolvedValue({
expect(getProfileProjects).toHaveBeenCalledWith(
expect.objectContaining({
key: profile.key,
- organization,
p: 1,
ps: 100,
q: undefined,
function shallowRender(props: Partial<ChangeProjectsForm['props']> = {}) {
return shallow<ChangeProjectsForm>(
- <ChangeProjectsForm
- onClose={jest.fn()}
- organization={organization}
- profile={profile}
- {...props}
- />
+ <ChangeProjectsForm onClose={jest.fn()} profile={profile} {...props} />
);
}
shallow(
<ProfileDetails
exporters={[]}
- organization="org"
profile={{} as Profile}
profiles={[]}
updateProfiles={jest.fn()}
shallow(
<ProfileDetails
exporters={[]}
- organization="org"
profile={{ actions: { edit: true } } as Profile}
profiles={[]}
updateProfiles={jest.fn()}
return shallow<ProfileExporters>(
<ProfileExporters
exporters={[mockQualityProfileExporter({ languages: [profile.language] })]}
- organization="test-org"
profile={profile}
{...props}
/>
function shallowRender(props: Partial<ProfileHeader['props']> = {}) {
return shallow(
- <ProfileHeader
- organization="foo"
- profile={mockQualityProfile()}
- updateProfiles={jest.fn()}
- {...props}
- />
+ <ProfileHeader profile={mockQualityProfile()} updateProfiles={jest.fn()} {...props} />
);
}
function shallowRender(props: Partial<ProfileInheritance['props']> = {}) {
return shallow<ProfileInheritance>(
<ProfileInheritance
- organization={null}
profile={mockQualityProfile()}
profiles={[mockQualityProfile()]}
updateProfiles={jest.fn()}
<ProfileInheritanceBox
depth={1}
language="foo"
- organization={null}
profile={mockQualityProfileInheritance()}
{...props}
/>
import { mount, shallow } from 'enzyme';
import * as React from 'react';
import { click, waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
+import { searchGroups, searchUsers } from '../../../../api/quality-profiles';
import ProfilePermissions from '../ProfilePermissions';
jest.mock('../../../../api/quality-profiles', () => ({
searchGroups: jest.fn(() => Promise.resolve([]))
}));
-const searchUsers = require('../../../../api/quality-profiles').searchUsers as jest.Mock<any>;
-const searchGroups = require('../../../../api/quality-profiles').searchGroups as jest.Mock<any>;
-
-const profile = { key: 'sonar-way', name: 'Sonar way', language: 'js' };
-
beforeEach(() => {
- searchUsers.mockClear();
- searchGroups.mockClear();
+ jest.clearAllMocks();
});
it('renders', () => {
- const wrapper = shallow(<ProfilePermissions profile={profile} />);
+ const wrapper = shallowRender();
expect(wrapper).toMatchSnapshot();
wrapper.setState({
groups: [{ name: 'Lambda' }],
loading: false,
- users: [{ login: 'luke', name: 'Luke Skywalker' }]
+ users: [{ login: 'luke', name: 'Luke Skywalker', selected: false }]
});
expect(wrapper).toMatchSnapshot();
});
+it('should update correctly', () => {
+ const wrapper = shallowRender();
+
+ wrapper.setProps({ profile: { key: 'otherKey', name: 'new profile', language: 'js' } });
+
+ expect(searchGroups).toBeCalledTimes(2);
+ expect(searchUsers).toBeCalledTimes(2);
+});
+
it('opens add users form', async () => {
- searchUsers.mockImplementationOnce(() =>
+ (searchUsers as jest.Mock).mockImplementationOnce(() =>
Promise.resolve({ users: [{ login: 'luke', name: 'Luke Skywalker' }] })
);
- const wrapper = shallow(<ProfilePermissions profile={profile} />);
+ const wrapper = shallowRender();
expect(searchUsers).toHaveBeenCalled();
await waitAndUpdate(wrapper);
expect(wrapper.find('ProfilePermissionsForm').exists()).toBe(false);
});
it('removes user', () => {
- const wrapper = shallow(<ProfilePermissions profile={profile} />);
+ const wrapper = shallowRender();
(wrapper.instance() as ProfilePermissions).mounted = true;
- const joda = { login: 'joda', name: 'Joda' };
- wrapper.setState({ loading: false, users: [{ login: 'luke', name: 'Luke Skywalker' }, joda] });
+ const joda = { login: 'joda', name: 'Joda', selected: false };
+ wrapper.setState({
+ loading: false,
+ users: [{ login: 'luke', name: 'Luke Skywalker', selected: false }, joda]
+ });
expect(wrapper.find('ProfilePermissionsUser')).toHaveLength(2);
wrapper
});
it('removes group', () => {
- const wrapper = shallow(<ProfilePermissions profile={profile} />);
+ const wrapper = shallowRender();
(wrapper.instance() as ProfilePermissions).mounted = true;
const lambda = { name: 'Lambda' };
});
it('fetches users and groups on mount', () => {
- mount(<ProfilePermissions organization="org" profile={profile} />);
+ mount(<ProfilePermissions profile={{ key: 'sonar-way', name: 'Sonar way', language: 'js' }} />);
expect(searchUsers).toBeCalledWith({
language: 'js',
- organization: 'org',
qualityProfile: 'Sonar way',
selected: 'selected'
});
expect(searchGroups).toBeCalledWith({
language: 'js',
- organization: 'org',
qualityProfile: 'Sonar way',
selected: 'selected'
});
});
+
+function shallowRender(overrides: Partial<{ key: string; name: string; language: string }> = {}) {
+ const profile = { key: 'sonar-way', name: 'Sonar way', language: 'js', ...overrides };
+ return shallow<ProfilePermissions>(<ProfilePermissions profile={profile} />);
+}
it('removes user', async () => {
const onDelete = jest.fn();
const wrapper = shallow(
- <ProfilePermissionsGroup
- group={group}
- onDelete={onDelete}
- organization="org"
- profile={profile}
- />
+ <ProfilePermissionsGroup group={group} onDelete={onDelete} profile={profile} />
);
(wrapper.instance() as ProfilePermissionsGroup).mounted = true;
expect(wrapper.find('SimpleModal').exists()).toBe(false);
expect(removeGroup).toBeCalledWith({
group: 'lambda',
language: 'js',
- organization: 'org',
qualityProfile: 'Sonar way'
});
it('removes user', async () => {
const onDelete = jest.fn();
const wrapper = shallow(
- <ProfilePermissionsUser onDelete={onDelete} organization="org" profile={profile} user={user} />
+ <ProfilePermissionsUser onDelete={onDelete} profile={profile} user={user} />
);
(wrapper.instance() as ProfilePermissionsUser).mounted = true;
expect(wrapper.find('SimpleModal').exists()).toBe(false);
expect(removeUser).toBeCalledWith({
language: 'js',
login: 'luke',
- organization: 'org',
qualityProfile: 'Sonar way'
});
import * as React from 'react';
import { waitAndUpdate } from 'sonar-ui-common/helpers/testUtils';
import { mockQualityProfile } from '../../../../helpers/testMocks';
+import ChangeProjectsForm from '../ChangeProjectsForm';
import ProfileProjects from '../ProfileProjects';
jest.mock('../../../../api/quality-profiles', () => ({
expect(wrapper).toMatchSnapshot();
});
+it('should open and close the form', async () => {
+ const wrapper = shallowRender();
+ await waitAndUpdate(wrapper);
+
+ wrapper.instance().handleChangeClick();
+ expect(wrapper.find(ChangeProjectsForm).exists()).toBe(true);
+
+ wrapper.instance().closeForm();
+ expect(wrapper.find(ChangeProjectsForm).exists()).toBe(false);
+});
+
function shallowRender(props: Partial<ProfileProjects['props']> = {}) {
- return shallow(
+ return shallow<ProfileProjects>(
<ProfileProjects
- organization="foo"
profile={mockQualityProfile({ actions: { associateProjects: true } })}
{...props}
/>
activeDeprecatedRuleCount: 0,
depth: 0,
language: 'js',
- organization: 'org',
rulesUpdatedAt: '2017-06-28T12:58:44+0000'
});
});
it('should render the quality profiles rules with sonarway comparison', async () => {
- const wrapper = shallow(<ProfileRules organization="foo" profile={PROFILE} />);
+ const wrapper = shallow(<ProfileRules profile={PROFILE} />);
const instance = wrapper.instance() as any;
instance.mounted = true;
instance.loadRules();
});
it('should show a button to activate more rules for admins', () => {
- const wrapper = shallow(<ProfileRules organization="foo" profile={EDITABLE_PROFILE} />);
+ const wrapper = shallow(<ProfileRules profile={EDITABLE_PROFILE} />);
expect(wrapper.find('.js-activate-rules')).toMatchSnapshot();
});
it('should show a disabled button to activate more rules for built-in profiles', () => {
const wrapper = shallow(
- <ProfileRules
- organization={null}
- profile={{ ...EDITABLE_PROFILE, actions: { copy: true }, isBuiltIn: true }}
- />
+ <ProfileRules profile={{ ...EDITABLE_PROFILE, actions: { copy: true }, isBuiltIn: true }} />
);
expect(wrapper.find('.js-activate-rules')).toMatchSnapshot();
});
it('should show a deprecated rules warning message', () => {
const wrapper = shallow(
- <ProfileRules
- organization="foo"
- profile={{ ...EDITABLE_PROFILE, activeDeprecatedRuleCount: 8 }}
- />
+ <ProfileRules profile={{ ...EDITABLE_PROFILE, activeDeprecatedRuleCount: 8 }} />
);
expect(wrapper.find('ProfileRulesDeprecatedWarning')).toMatchSnapshot();
});
it('should not show a button to activate more rules on built in profiles', () => {
- const wrapper = shallow(
- <ProfileRules organization={null} profile={{ ...EDITABLE_PROFILE, isBuiltIn: true }} />
- );
+ const wrapper = shallow(<ProfileRules profile={{ ...EDITABLE_PROFILE, isBuiltIn: true }} />);
expect(wrapper.find('.js-activate-rules').exists()).toBe(false);
});
it('should not show sonarway comparison for built in profiles', async () => {
(apiQP as any).getQualityProfile = jest.fn(() => Promise.resolve());
- const wrapper = shallow(
- <ProfileRules organization={null} profile={{ ...PROFILE, isBuiltIn: true }} />
- );
+ const wrapper = shallow(<ProfileRules profile={{ ...PROFILE, isBuiltIn: true }} />);
await new Promise(setImmediate);
wrapper.update();
expect(apiQP.getQualityProfile).toHaveBeenCalledTimes(0);
}
})
);
- const wrapper = shallow(<ProfileRules organization={null} profile={PROFILE} />);
+ const wrapper = shallow(<ProfileRules profile={PROFILE} />);
await waitAndUpdate(wrapper);
expect(apiQP.getQualityProfile).toHaveBeenCalledTimes(1);
expect(wrapper.find('ProfileRulesSonarWayComparison')).toHaveLength(0);
it('should render correctly', () => {
expect(
- shallow(
- <ProfileRulesDeprecatedWarning activeDeprecatedRules={18} organization="foo" profile="bar" />
- )
+ shallow(<ProfileRulesDeprecatedWarning activeDeprecatedRules={18} profile="bar" />)
).toMatchSnapshot();
});
it('should render correctly', () => {
expect(
- shallow(
- <ProfileRulesRowOfType count={3} organization="foo" qprofile="bar" total={10} type="BUG" />
- )
+ shallow(<ProfileRulesRowOfType count={3} qprofile="bar" total={10} type="BUG" />)
).toMatchSnapshot();
});
it('should render correctly if there is 0 rules', () => {
expect(
- shallow(
- <ProfileRulesRowOfType
- count={0}
- organization={null}
- qprofile="bar"
- total={0}
- type="VULNERABILITY"
- />
- )
+ shallow(<ProfileRulesRowOfType count={0} qprofile="bar" total={0} type="VULNERABILITY" />)
).toMatchSnapshot();
});
it('should render correctly if there is missing data', () => {
expect(
- shallow(
- <ProfileRulesRowOfType
- count={5}
- organization={null}
- qprofile="bar"
- total={null}
- type="VULNERABILITY"
- />
- )
+ shallow(<ProfileRulesRowOfType count={5} qprofile="bar" total={null} type="VULNERABILITY" />)
).toMatchSnapshot();
expect(
- shallow(
- <ProfileRulesRowOfType
- count={null}
- organization={null}
- qprofile="foo"
- total={10}
- type="VULNERABILITY"
- />
- )
+ shallow(<ProfileRulesRowOfType count={null} qprofile="foo" total={10} type="VULNERABILITY" />)
).toMatchSnapshot();
});
import ProfileRulesRowTotal from '../ProfileRulesRowTotal';
it('should render correctly', () => {
- expect(
- shallow(<ProfileRulesRowTotal count={3} organization="foo" qprofile="bar" total={10} />)
- ).toMatchSnapshot();
+ expect(shallow(<ProfileRulesRowTotal count={3} qprofile="bar" total={10} />)).toMatchSnapshot();
});
it('should render correctly if there is 0 rules', () => {
- expect(
- shallow(<ProfileRulesRowTotal count={0} organization={null} qprofile="bar" total={0} />)
- ).toMatchSnapshot();
+ expect(shallow(<ProfileRulesRowTotal count={0} qprofile="bar" total={0} />)).toMatchSnapshot();
});
it('should render correctly if there is missing data', () => {
+ expect(shallow(<ProfileRulesRowTotal count={5} qprofile="bar" total={null} />)).toMatchSnapshot();
expect(
- shallow(<ProfileRulesRowTotal count={5} organization={null} qprofile="bar" total={null} />)
- ).toMatchSnapshot();
- expect(
- shallow(<ProfileRulesRowTotal count={null} organization={null} qprofile="foo" total={10} />)
+ shallow(<ProfileRulesRowTotal count={null} qprofile="foo" total={10} />)
).toMatchSnapshot();
});
shallow(
<ProfileRulesSonarWayComparison
language="Java"
- organization="foo"
profile="bar"
sonarWayMissingRules={158}
sonarway="baz"
className="quality-profile-grid-left"
>
<ProfileRules
- organization="org"
profile={
Object {
"actions": Object {
/>
<ProfileExporters
exporters={Array []}
- organization="org"
profile={
Object {
"actions": Object {
}
/>
<ProfilePermissions
- organization="org"
profile={
Object {
"actions": Object {
className="quality-profile-grid-right"
>
<ProfileInheritance
- organization="org"
profile={
Object {
"actions": Object {
updateProfiles={[MockFunction]}
/>
<ProfileProjects
- organization="org"
profile={
Object {
"actions": Object {
className="quality-profile-grid-left"
>
<ProfileRules
- organization="org"
profile={Object {}}
/>
<ProfileExporters
exporters={Array []}
- organization="org"
profile={Object {}}
/>
</div>
className="quality-profile-grid-right"
>
<ProfileInheritance
- organization="org"
profile={Object {}}
profiles={Array []}
updateProfiles={[MockFunction]}
/>
<ProfileProjects
- organization="org"
profile={Object {}}
/>
</div>
key="exporter-key"
>
<a
- href="/api/qualityprofiles/export?exporterKey=exporter-key&language=js&qualityProfile=name&organization=foo"
+ href="/api/qualityprofiles/export?exporterKey=exporter-key&language=js&qualityProfile=name"
rel="noopener noreferrer"
target="_blank"
>
<li>
<withRouter(ProfileActions)
className="pull-left"
- organization="foo"
profile={
Object {
"activeDeprecatedRuleCount": 2,
"language": "js",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
}
}
depth={0}
key="foo"
language="js"
- organization={null}
profile={
Object {
"activeRuleCount": 4,
depth={2}
key="foo"
language="js"
- organization={null}
profile={
Object {
"activeRuleCount": 4,
depth={0}
key="foo"
language="js"
- organization={null}
profile={
Object {
"activeRuleCount": 4,
depth={2}
key="foo"
language="js"
- organization={null}
profile={
Object {
"activeRuleCount": 4,
"language": "js",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
}
}
"language": "js",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
},
]
Object {
"login": "luke",
"name": "Luke Skywalker",
+ "selected": false,
}
}
/>
<tbody>
<ProfileRulesRowTotal
count={68}
- organization="foo"
qprofile="key"
total={253}
/>
<ProfileRulesRowOfType
count={68}
key="BUG"
- organization="foo"
qprofile="key"
total={68}
type="BUG"
<ProfileRulesRowOfType
count={0}
key="VULNERABILITY"
- organization="foo"
qprofile="key"
total={7}
type="VULNERABILITY"
<ProfileRulesRowOfType
count={0}
key="CODE_SMELL"
- organization="foo"
qprofile="key"
total={168}
type="CODE_SMELL"
<ProfileRulesRowOfType
count={0}
key="SECURITY_HOTSPOT"
- organization="foo"
qprofile="key"
total={10}
type="SECURITY_HOTSPOT"
</div>
<ProfileRulesSonarWayComparison
language="js"
- organization="foo"
profile="key"
sonarWayMissingRules={4}
sonarway="sonarway"
exports[`should show a deprecated rules warning message 1`] = `
<ProfileRulesDeprecatedWarning
activeDeprecatedRules={8}
- organization="foo"
profile="key"
/>
`;
location: Location;
onClose: () => void;
onCreate: Function;
- organization: string | null;
profiles: Profile[];
}
this.setState({ loading: true });
const data = new FormData(event.currentTarget);
- if (this.props.organization) {
- data.append('organization', this.props.organization);
- }
try {
const { profile } = await createQualityProfile(data);
import EvolutionRules from './EvolutionRules';
import EvolutionStagnant from './EvolutionStagnant';
-interface Props {
- organization: string | null;
+export interface EvolutionProps {
profiles: Profile[];
}
-export default function Evolution({ organization, profiles }: Props) {
+export default function Evolution({ profiles }: EvolutionProps) {
return (
<div className="quality-profiles-evolution">
- <EvolutionDeprecated organization={organization} profiles={profiles} />
- <EvolutionStagnant organization={organization} profiles={profiles} />
- <EvolutionRules organization={organization} />
+ <EvolutionDeprecated profiles={profiles} />
+ <EvolutionStagnant profiles={profiles} />
+ <EvolutionRules />
</div>
);
}
import { Profile } from '../types';
interface Props {
- organization: string | null;
profiles: Profile[];
}
});
}
-interface Props {
- organization: string | null;
-}
-
interface ExtendedRule extends T.Rule {
activations: number;
}
latestRulesTotal?: number;
}
-export default class EvolutionRules extends React.PureComponent<Props, State> {
+export default class EvolutionRules extends React.PureComponent<{}, State> {
periodStartDate: string;
mounted = false;
- constructor(props: Props) {
+ constructor(props: {}) {
super(props);
this.state = {};
const startDate = new Date();
asc: false,
available_since: this.periodStartDate,
f: 'name,langName,actives',
- organization: this.props.organization || undefined,
ps: RULES_LIMIT,
s: 'createdAt'
};
});
}
},
- () => {}
+ () => {
+ /*noop*/
+ }
);
}
import { isStagnant } from '../utils';
interface Props {
- organization: string | null;
profiles: Profile[];
}
actions: Actions;
languages: Array<{ key: string; name: string }>;
location: Location;
- organization: string | null;
profiles: Profile[];
updateProfiles: () => Promise<void>;
}
actions: Actions;
languages: Array<{ key: string; name: string }>;
location: Location;
- organization: string | null;
profiles: Profile[];
router: Pick<Router, 'push'>;
updateProfiles: () => Promise<void>;
};
render() {
- const { actions, languages, location, organization, profiles } = this.props;
+ const { actions, languages, location, profiles } = this.props;
return (
<header className="page-header">
<h1 className="page-title">{translate('quality_profiles.page')}</h1>
<RestoreProfileForm
onClose={this.closeRestoreForm}
onRestore={this.props.updateProfiles}
- organization={organization}
/>
)}
location={location}
onClose={this.closeCreateForm}
onCreate={this.handleCreate}
- organization={organization}
profiles={profiles}
/>
)}
interface Props {
languages: T.Language[];
location: Pick<Location, 'query'>;
- organization: string | null;
profiles: Profile[];
updateProfiles: () => Promise<void>;
}
return profiles.map(profile => (
<ProfilesListRow
key={profile.key}
- organization={this.props.organization}
profile={profile}
updateProfiles={this.props.updateProfiles}
/>
import { Profile } from '../types';
export interface ProfilesListRowProps {
- organization: string | null;
profile: Profile;
updateProfiles: () => Promise<void>;
}
export function ProfilesListRow(props: ProfilesListRowProps) {
- const { organization, profile } = props;
+ const { profile } = props;
const offset = 25 * (profile.depth - 1);
const activeRulesUrl = getRulesUrl({
</td>
<td className="quality-profiles-table-actions thin nowrap text-middle text-right">
- <ProfileActions
- fromList={true}
- organization={organization}
- profile={profile}
- updateProfiles={props.updateProfiles}
- />
+ <ProfileActions fromList={true} profile={profile} updateProfiles={props.updateProfiles} />
</td>
</tr>
);
interface Props {
onClose: () => void;
onRestore: () => void;
- organization: string | null;
}
interface State {
this.setState({ loading: true });
const data = new FormData(event.currentTarget);
- if (this.props.organization) {
- data.append('organization', this.props.organization);
- }
restoreQualityProfile(data).then(
(response: any) => {
location={mockLocation()}
onClose={jest.fn()}
onCreate={jest.fn()}
- organization="org"
profiles={[mockQualityProfile(), mockQualityProfile({ language: 'css' })]}
{...props}
/>
--- /dev/null
+/*
+ * SonarQube
+ * Copyright (C) 2009-2020 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+import { shallow } from 'enzyme';
+import * as React from 'react';
+import Evolution, { EvolutionProps } from '../Evolution';
+
+it('should render correctly', () => {
+ expect(shallowRender()).toMatchSnapshot();
+});
+
+function shallowRender(props: Partial<EvolutionProps> = {}) {
+ return shallow(<Evolution profiles={[]} {...props} />);
+}
it('should render correctly', () => {
const wrapper = shallow(
<EvolutionDeprecated
- organization="foo"
profiles={[
mockQualityProfile({
key: 'qp-1',
actions={{ create: false }}
languages={[mockLanguage()]}
location={mockLocation()}
- organization="foo"
profiles={[mockQualityProfile()]}
router={mockRouter()}
updateProfiles={jest.fn()}
<ProfilesList
languages={[mockLanguage(), mockLanguage({ key: 'js', name: 'JS' })]}
location={mockLocation()}
- organization="foo"
profiles={[
mockQualityProfile(),
mockQualityProfile({ language: 'css', languageName: 'CSS' })
function shallowRender(props: Partial<ProfilesListRowProps> = {}) {
return shallow(
<ProfilesListRow
- organization={null}
profile={mockQualityProfile({ activeDeprecatedRuleCount: 0 })}
updateProfiles={jest.fn()}
{...props}
it('should render correctly', () => {
expect(
- shallow(<RestoreProfileForm onClose={jest.fn()} onRestore={jest.fn()} organization="org" />)
+ shallow(<RestoreProfileForm onClose={jest.fn()} onRestore={jest.fn()} />)
).toMatchSnapshot();
});
--- /dev/null
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`should render correctly 1`] = `
+<div
+ className="quality-profiles-evolution"
+>
+ <EvolutionDeprecated
+ profiles={Array []}
+ />
+ <EvolutionStagnant
+ profiles={Array []}
+ />
+ <EvolutionRules />
+</div>
+`;
}
onClose={[Function]}
onCreate={[Function]}
- organization="foo"
profiles={
Array [
Object {
"language": "js",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
},
]
<RestoreProfileForm
onClose={[Function]}
onRestore={[MockFunction]}
- organization="foo"
/>
</header>
`;
<tbody>
<Memo(ProfilesListRow)
key="key"
- organization="foo"
profile={
Object {
"activeDeprecatedRuleCount": 2,
"language": "css",
"languageName": "CSS",
"name": "name",
- "organization": "foo",
"projectCount": 3,
}
}
<tbody>
<Memo(ProfilesListRow)
key="key"
- organization="foo"
profile={
Object {
"activeDeprecatedRuleCount": 2,
"language": "js",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
}
}
<tbody>
<Memo(ProfilesListRow)
key="key"
- organization="foo"
profile={
Object {
"activeDeprecatedRuleCount": 2,
"language": "css",
"languageName": "CSS",
"name": "name",
- "organization": "foo",
"projectCount": 3,
}
}
>
<withRouter(ProfileActions)
fromList={true}
- organization={null}
profile={
Object {
"activeDeprecatedRuleCount": 2,
"language": "js",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
}
}
>
<withRouter(ProfileActions)
fromList={true}
- organization={null}
profile={
Object {
"activeDeprecatedRuleCount": 0,
"language": "js",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
}
}
>
<withRouter(ProfileActions)
fromList={true}
- organization={null}
profile={
Object {
"activeDeprecatedRuleCount": 2,
"language": "js",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
}
}
>
<withRouter(ProfileActions)
fromList={true}
- organization={null}
profile={
Object {
"activeDeprecatedRuleCount": 10,
"language": "js",
"languageName": "JavaScript",
"name": "name",
- "organization": "foo",
"projectCount": 3,
}
}
languageName: 'JavaScript',
name: 'name',
projectCount: 3,
- organization: 'foo',
...overrides
};
}