diff options
author | Wouter Admiraal <wouter.admiraal@sonarsource.com> | 2019-08-23 15:45:40 +0200 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-08-27 20:21:04 +0200 |
commit | 4509ca82e5a066731a4b4625149b79248ad1e70b (patch) | |
tree | 7500d74df8c75959b8dfea4abe28cbdebf573805 /server | |
parent | 987abb5a686375f3689a2eccbf2026a300a3462e (diff) | |
download | sonarqube-4509ca82e5a066731a4b4625149b79248ad1e70b.tar.gz sonarqube-4509ca82e5a066731a4b4625149b79248ad1e70b.zip |
SONAR-12333 Write IT, improve existing ITs
Diffstat (limited to 'server')
5 files changed, 100 insertions, 63 deletions
diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx index c1a9b343552..29ba03a6321 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/ProfileActions.tsx @@ -155,60 +155,55 @@ export class ProfileActions extends React.PureComponent<Props, State> { <> <ActionsDropdown className={this.props.className}> {actions.edit && ( - <ActionsDropdownItem id="quality-profile-activate-more-rules" to={activateMoreUrl}> - {translate('quality_profiles.activate_more_rules')} + <ActionsDropdownItem to={activateMoreUrl}> + <span data-test="quality-profiles__activate-more-rules"> + {translate('quality_profiles.activate_more_rules')} + </span> </ActionsDropdownItem> )} {!profile.isBuiltIn && ( - <ActionsDropdownItem - download={`${profile.key}.xml`} - id="quality-profile-backup" - to={backupUrl}> - {translate('backup_verb')} + <ActionsDropdownItem download={`${profile.key}.xml`} to={backupUrl}> + <span data-test="quality-profiles__backup">{translate('backup_verb')}</span> </ActionsDropdownItem> )} <ActionsDropdownItem - id="quality-profile-compare" to={getProfileComparePath(profile.name, profile.language, this.props.organization)}> - {translate('compare')} + <span data-test="quality-profiles__compare">{translate('compare')}</span> </ActionsDropdownItem> {actions.copy && ( <> - <ActionsDropdownItem id="quality-profile-copy" onClick={this.handleCopyClick}> - {translate('copy')} + <ActionsDropdownItem onClick={this.handleCopyClick}> + <span data-test="quality-profiles__copy">{translate('copy')}</span> </ActionsDropdownItem> - <ActionsDropdownItem id="quality-profile-extend" onClick={this.handleExtendClick}> - {translate('extend')} + <ActionsDropdownItem onClick={this.handleExtendClick}> + <span data-test="quality-profiles__extend">{translate('extend')}</span> </ActionsDropdownItem> </> )} {actions.edit && ( - <ActionsDropdownItem id="quality-profile-rename" onClick={this.handleRenameClick}> - {translate('rename')} + <ActionsDropdownItem onClick={this.handleRenameClick}> + <span data-test="quality-profiles__rename">{translate('rename')}</span> </ActionsDropdownItem> )} {actions.setAsDefault && ( - <ActionsDropdownItem - id="quality-profile-set-as-default" - onClick={this.handleSetDefaultClick}> - {translate('set_as_default')} + <ActionsDropdownItem onClick={this.handleSetDefaultClick}> + <span data-test="quality-profiles__set-as-default"> + {translate('set_as_default')} + </span> </ActionsDropdownItem> )} {actions.delete && <ActionsDropdownDivider />} {actions.delete && ( - <ActionsDropdownItem - destructive={true} - id="quality-profile-delete" - onClick={this.handleDeleteClick}> - {translate('delete')} + <ActionsDropdownItem destructive={true} onClick={this.handleDeleteClick}> + <span data-test="quality-profiles__delete">{translate('delete')}</span> </ActionsDropdownItem> )} </ActionsDropdown> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileActions-test.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileActions-test.tsx index 5e037a560c5..0af06aa6a84 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileActions-test.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/ProfileActions-test.tsx @@ -67,7 +67,7 @@ it('should copy profile', async () => { updateProfiles }); - click(wrapper.find('[id="quality-profile-copy"]')); + click(wrapper.find('[data-test="quality-profiles__copy"]').parent()); expect(wrapper.find('CopyProfileForm').exists()).toBe(true); wrapper.find('CopyProfileForm').prop<Function>('onCopy')(name); @@ -91,7 +91,7 @@ it('should extend profile', async () => { updateProfiles }); - click(wrapper.find('[id="quality-profile-extend"]')); + click(wrapper.find('[data-test="quality-profiles__extend"]').parent()); expect(wrapper.find('ExtendProfileForm').exists()).toBe(true); wrapper.find('ExtendProfileForm').prop<Function>('onExtend')(name); diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/__snapshots__/ProfileActions-test.tsx.snap b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/__snapshots__/ProfileActions-test.tsx.snap index 0066c498c61..b7c5aff79f9 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/__snapshots__/ProfileActions-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/quality-profiles/components/__tests__/__snapshots__/ProfileActions-test.tsx.snap @@ -4,7 +4,6 @@ exports[`renders with all permissions 1`] = ` <Fragment> <ActionsDropdown> <ActionsDropdownItem - id="quality-profile-activate-more-rules" to={ Object { "pathname": "/organizations/org/rules", @@ -15,17 +14,23 @@ exports[`renders with all permissions 1`] = ` } } > - quality_profiles.activate_more_rules + <span + data-test="quality-profiles__activate-more-rules" + > + quality_profiles.activate_more_rules + </span> </ActionsDropdownItem> <ActionsDropdownItem download="key.xml" - id="quality-profile-backup" to="/api/qualityprofiles/backup?profileKey=key" > - backup_verb + <span + data-test="quality-profiles__backup" + > + backup_verb + </span> </ActionsDropdownItem> <ActionsDropdownItem - id="quality-profile-compare" to={ Object { "pathname": "/organizations/org/quality_profiles/compare", @@ -36,39 +41,58 @@ exports[`renders with all permissions 1`] = ` } } > - compare + <span + data-test="quality-profiles__compare" + > + compare + </span> </ActionsDropdownItem> <ActionsDropdownItem - id="quality-profile-copy" onClick={[Function]} > - copy + <span + data-test="quality-profiles__copy" + > + copy + </span> </ActionsDropdownItem> <ActionsDropdownItem - id="quality-profile-extend" onClick={[Function]} > - extend + <span + data-test="quality-profiles__extend" + > + extend + </span> </ActionsDropdownItem> <ActionsDropdownItem - id="quality-profile-rename" onClick={[Function]} > - rename + <span + data-test="quality-profiles__rename" + > + rename + </span> </ActionsDropdownItem> <ActionsDropdownItem - id="quality-profile-set-as-default" onClick={[Function]} > - set_as_default + <span + data-test="quality-profiles__set-as-default" + > + set_as_default + </span> </ActionsDropdownItem> <ActionsDropdownDivider /> <ActionsDropdownItem destructive={true} - id="quality-profile-delete" onClick={[Function]} > - delete + <span + data-test="quality-profiles__delete" + > + delete + </span> </ActionsDropdownItem> </ActionsDropdown> </Fragment> @@ -79,13 +103,15 @@ exports[`renders with no permissions 1`] = ` <ActionsDropdown> <ActionsDropdownItem download="key.xml" - id="quality-profile-backup" to="/api/qualityprofiles/backup?profileKey=key" > - backup_verb + <span + data-test="quality-profiles__backup" + > + backup_verb + </span> </ActionsDropdownItem> <ActionsDropdownItem - id="quality-profile-compare" to={ Object { "pathname": "/organizations/org/quality_profiles/compare", @@ -96,7 +122,11 @@ exports[`renders with no permissions 1`] = ` } } > - compare + <span + data-test="quality-profiles__compare" + > + compare + </span> </ActionsDropdownItem> </ActionsDropdown> </Fragment> @@ -106,7 +136,6 @@ exports[`renders with permission to edit only 1`] = ` <Fragment> <ActionsDropdown> <ActionsDropdownItem - id="quality-profile-activate-more-rules" to={ Object { "pathname": "/organizations/org/rules", @@ -117,17 +146,23 @@ exports[`renders with permission to edit only 1`] = ` } } > - quality_profiles.activate_more_rules + <span + data-test="quality-profiles__activate-more-rules" + > + quality_profiles.activate_more_rules + </span> </ActionsDropdownItem> <ActionsDropdownItem download="key.xml" - id="quality-profile-backup" to="/api/qualityprofiles/backup?profileKey=key" > - backup_verb + <span + data-test="quality-profiles__backup" + > + backup_verb + </span> </ActionsDropdownItem> <ActionsDropdownItem - id="quality-profile-compare" to={ Object { "pathname": "/organizations/org/quality_profiles/compare", @@ -138,13 +173,20 @@ exports[`renders with permission to edit only 1`] = ` } } > - compare + <span + data-test="quality-profiles__compare" + > + compare + </span> </ActionsDropdownItem> <ActionsDropdownItem - id="quality-profile-rename" onClick={[Function]} > - rename + <span + data-test="quality-profiles__rename" + > + rename + </span> </ActionsDropdownItem> </ActionsDropdown> </Fragment> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx index 40940d493e1..745583c979b 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritance.tsx @@ -122,10 +122,6 @@ export default class ProfileInheritance extends React.PureComponent<Props, State this.state.children != null && (ancestors.length > 0 || this.state.children.length > 0); - const currentClassName = classNames('js-inheritance-current', { - selected: highlightCurrent - }); - const extendsBuiltIn = ancestors != null && ancestors.some(profile => profile.isBuiltIn); return ( @@ -151,36 +147,39 @@ export default class ProfileInheritance extends React.PureComponent<Props, State {ancestors != null && ancestors.map((ancestor, index) => ( <ProfileInheritanceBox - className="js-inheritance-ancestor" depth={index} key={ancestor.key} language={profile.language} organization={this.props.organization} profile={ancestor} + type="ancestor" /> ))} {this.state.profile != null && ( <ProfileInheritanceBox - className={currentClassName} + className={classNames({ + selected: highlightCurrent + })} depth={ancestors ? ancestors.length : 0} displayLink={false} extendsBuiltIn={extendsBuiltIn} language={profile.language} organization={this.props.organization} profile={this.state.profile} + type="current" /> )} {this.state.children != null && this.state.children.map(child => ( <ProfileInheritanceBox - className="js-inheritance-child" depth={ancestors ? ancestors.length + 1 : 0} key={child.key} language={profile.language} organization={this.props.organization} profile={child} + type="child" /> ))} </tbody> diff --git a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx index a2d5db6cff1..29c8e6ccc3e 100644 --- a/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx +++ b/server/sonar-web/src/main/js/apps/quality-profiles/details/ProfileInheritanceBox.tsx @@ -38,14 +38,15 @@ interface Props { name: string; overridingRuleCount?: number; }; + type: string; } -export default function ProfileInheritanceBox({ displayLink = true, ...props }: Props) { +export default function ProfileInheritanceBox({ type, displayLink = true, ...props }: Props) { const { profile, className, extendsBuiltIn } = props; const offset = 25 * props.depth; return ( - <tr className={className}> + <tr className={className} data-test={`quality-profiles__inheritance-${type}`}> <td> <div style={{ paddingLeft: offset }}> {displayLink ? ( |