* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-import { differenceWith, map, uniqBy } from 'lodash';
+
+import {
+ ButtonSecondary,
+ CardWithPrimaryBackground,
+ FlagMessage,
+ HeadingDark,
+ HelperHintIcon,
+ LightPrimary,
+ Link,
+ SubHeading,
+ SubnavigationFlowSeparator,
+ Title,
+} from 'design-system';
+import { differenceWith, map, times, uniqBy } from 'lodash';
import * as React from 'react';
import { FormattedMessage } from 'react-intl';
import withAvailableFeatures, {
WithAvailableFeaturesProps,
} from '../../../app/components/available-features/withAvailableFeatures';
import withMetricsContext from '../../../app/components/metrics/withMetricsContext';
-import DocLink from '../../../components/common/DocLink';
import DocumentationTooltip from '../../../components/common/DocumentationTooltip';
import ModalButton, { ModalProps } from '../../../components/controls/ModalButton';
-import { Button } from '../../../components/controls/buttons';
-import { Alert } from '../../../components/ui/Alert';
+import { useDocUrl } from '../../../helpers/docs';
import { getLocalizedMetricName, translate } from '../../../helpers/l10n';
import { Feature } from '../../../types/features';
import { MetricKey } from '../../../types/metrics';
QualityGate,
} from '../../../types/types';
import { groupAndSortByPriorityConditions } from '../utils';
+import CaycConditionsListItem from './CaycConditionsListItem';
import ConditionModal from './ConditionModal';
import CaycReviewUpdateConditionsModal from './ConditionReviewAndUpdateModal';
import ConditionsTable from './ConditionsTable';
+export const CAYC_CONDITIONS_LIST_ITEMS = 6;
+
interface Props extends WithAvailableFeaturesProps {
metrics: Dict<Metric>;
onAddCondition: (condition: ConditionType) => void;
updatedConditionId?: string;
}
-interface State {
- unlockEditing: boolean;
-}
-
const FORBIDDEN_METRIC_TYPES = ['DATA', 'DISTRIB', 'STRING', 'BOOL'];
const FORBIDDEN_METRICS: string[] = [
MetricKey.alert_status,
MetricKey.new_security_hotspots,
];
-export class Conditions extends React.PureComponent<Props, State> {
- constructor(props: Props) {
- super(props);
- this.state = {
- unlockEditing: props.qualityGate.caycStatus === CaycStatus.NonCompliant,
- };
- }
+export function Conditions({
+ qualityGate,
+ metrics,
+ onRemoveCondition,
+ onSaveCondition,
+ onAddCondition,
+ hasFeature,
+ updatedConditionId,
+}: Props) {
+ const [editing, setEditing] = React.useState<boolean>(
+ qualityGate.caycStatus === CaycStatus.NonCompliant
+ );
+ const canEdit = Boolean(qualityGate.actions?.manageConditions);
+ const { conditions = [] } = qualityGate;
+ const existingConditions = conditions.filter((condition) => metrics[condition.metric]);
+ const { overallCodeConditions, newCodeConditions } = groupAndSortByPriorityConditions(
+ existingConditions,
+ metrics
+ );
- componentDidUpdate(prevProps: Readonly<Props>): void {
- const { qualityGate } = this.props;
- if (prevProps.qualityGate.name !== qualityGate.name) {
- this.setState({ unlockEditing: qualityGate.caycStatus === CaycStatus.NonCompliant });
+ const duplicates: ConditionType[] = [];
+ const savedConditions = existingConditions.filter((condition) => condition.id != null);
+ savedConditions.forEach((condition) => {
+ const sameCount = savedConditions.filter((sample) => sample.metric === condition.metric).length;
+ if (sameCount > 1) {
+ duplicates.push(condition);
}
- }
-
- unlockEditing = () => {
- this.setState({ unlockEditing: true });
- };
+ });
- lockEditing = () => {
- this.setState({ unlockEditing: false });
- };
+ const uniqDuplicates = uniqBy(duplicates, (d) => d.metric).map((condition) => ({
+ ...condition,
+ metric: metrics[condition.metric],
+ }));
- renderConditionModal = ({ onClose }: ModalProps) => {
- const { metrics, qualityGate } = this.props;
- const { conditions = [] } = qualityGate;
- const availableMetrics = differenceWith(
- map(metrics, (metric) => metric).filter(
- (metric) =>
- !metric.hidden &&
- !FORBIDDEN_METRIC_TYPES.includes(metric.type) &&
- !FORBIDDEN_METRICS.includes(metric.key),
- ),
- conditions,
- (metric, condition) => metric.key === condition.metric,
- );
- return (
- <ConditionModal
- header={translate('quality_gates.add_condition')}
- metrics={availableMetrics}
- onAddCondition={this.props.onAddCondition}
- onClose={onClose}
- qualityGate={qualityGate}
- />
- );
- };
+ const getDocUrl = useDocUrl();
- renderCaycModal = ({ onClose }: ModalProps) => {
- const { qualityGate, metrics } = this.props;
- const { conditions = [] } = qualityGate;
- const canEdit = Boolean(qualityGate.actions?.manageConditions);
- return (
- <CaycReviewUpdateConditionsModal
- qualityGate={qualityGate}
- metrics={metrics}
- canEdit={canEdit}
- onRemoveCondition={this.props.onRemoveCondition}
- onSaveCondition={this.props.onSaveCondition}
- onAddCondition={this.props.onAddCondition}
- lockEditing={this.lockEditing}
- updatedConditionId={this.props.updatedConditionId}
- conditions={conditions}
- scope="new-cayc"
- onClose={onClose}
- />
- );
- };
+ React.useEffect(() => {
+ setEditing(qualityGate.caycStatus === CaycStatus.NonCompliant);
+ }, [qualityGate]);
- render() {
- const { qualityGate, metrics, onRemoveCondition, onSaveCondition, updatedConditionId } =
- this.props;
- const canEdit = Boolean(qualityGate.actions?.manageConditions);
- const { unlockEditing } = this.state;
- const { conditions = [] } = qualityGate;
- const existingConditions = conditions.filter((condition) => metrics[condition.metric]);
- const { overallCodeConditions, newCodeConditions } = groupAndSortByPriorityConditions(
- existingConditions,
- metrics,
- );
+ const renderConditionModal = React.useCallback(
+ ({ onClose }: ModalProps) => {
+ const { conditions = [] } = qualityGate;
+ const availableMetrics = differenceWith(
+ map(metrics, (metric) => metric).filter(
+ (metric) =>
+ !metric.hidden &&
+ !FORBIDDEN_METRIC_TYPES.includes(metric.type) &&
+ !FORBIDDEN_METRICS.includes(metric.key)
+ ),
+ conditions,
+ (metric, condition) => metric.key === condition.metric
+ );
+ return (
+ <ConditionModal
+ header={translate('quality_gates.add_condition')}
+ metrics={availableMetrics}
+ onAddCondition={onAddCondition}
+ onClose={onClose}
+ qualityGate={qualityGate}
+ />
+ );
+ },
+ [metrics, qualityGate, onAddCondition]
+ );
- const duplicates: ConditionType[] = [];
- const savedConditions = existingConditions.filter((condition) => condition.id != null);
- savedConditions.forEach((condition) => {
- const sameCount = savedConditions.filter(
- (sample) => sample.metric === condition.metric,
- ).length;
- if (sameCount > 1) {
- duplicates.push(condition);
- }
- });
+ const renderCaycModal = React.useCallback(
+ ({ onClose }: ModalProps) => {
+ const { conditions = [] } = qualityGate;
+ const canEdit = Boolean(qualityGate.actions?.manageConditions);
+ return (
+ <CaycReviewUpdateConditionsModal
+ qualityGate={qualityGate}
+ metrics={metrics}
+ canEdit={canEdit}
+ onRemoveCondition={onRemoveCondition}
+ onSaveCondition={onSaveCondition}
+ onAddCondition={onAddCondition}
+ lockEditing={() => setEditing(false)}
+ updatedConditionId={updatedConditionId}
+ conditions={conditions}
+ scope="new-cayc"
+ onClose={onClose}
+ />
+ );
+ },
+ [qualityGate, metrics, updatedConditionId, onAddCondition, onRemoveCondition, onSaveCondition]
+ );
- const uniqDuplicates = uniqBy(duplicates, (d) => d.metric).map((condition) => ({
- ...condition,
- metric: metrics[condition.metric],
- }));
-
- return (
- <div className="quality-gate-section">
- {qualityGate.caycStatus !== CaycStatus.NonCompliant && (
- <Alert className="big-spacer-top big-spacer-bottom cayc-success-banner" variant="success">
- <h4 className="spacer-bottom cayc-success-header">
- {translate('quality_gates.cayc.banner.title')}
- </h4>
- <div className="cayc-warning-description">
- <FormattedMessage
- id="quality_gates.cayc.banner.description1"
- defaultMessage={translate('quality_gates.cayc.banner.description1')}
- values={{
- cayc_link: (
- <DocLink to="/user-guide/clean-as-you-code/">
- {translate('quality_gates.cayc')}
- </DocLink>
- ),
- }}
- />
- <br />
- {translate('quality_gates.cayc.banner.description2')}
- </div>
- <ul className="big-spacer-top big-spacer-left spacer-bottom cayc-warning-description">
- <li>{translate('quality_gates.cayc.banner.list_item1')}</li>
- <li>{translate('quality_gates.cayc.banner.list_item2')}</li>
- <li>{translate('quality_gates.cayc.banner.list_item3')}</li>
- <li>{translate('quality_gates.cayc.banner.list_item4')}</li>
- <li>{translate('quality_gates.cayc.banner.list_item5')}</li>
- <li>{translate('quality_gates.cayc.banner.list_item6')}</li>
- </ul>
- </Alert>
- )}
-
- {qualityGate.caycStatus === CaycStatus.NonCompliant && canEdit && (
- <Alert className="big-spacer-top big-spacer-bottom" variant="warning" role="alert">
- <h4 className="spacer-bottom cayc-warning-header">
- {translate('quality_gates.cayc_missing.banner.title')}
- </h4>
- <div className="cayc-warning-description spacer-bottom">
- <FormattedMessage
- id="quality_gates.cayc_missing.banner.description"
- defaultMessage={translate('quality_gates.cayc_missing.banner.description')}
- values={{
- cayc_link: (
- <DocLink to="/user-guide/clean-as-you-code/">
- {translate('quality_gates.cayc')}
- </DocLink>
- ),
- }}
+ return (
+ <div>
+ {qualityGate.caycStatus !== CaycStatus.NonCompliant && (
+ <CardWithPrimaryBackground className="sw-mb-9 sw-p-8">
+ <Title as="h2" className="sw-mb-2 sw-heading-md">
+ {translate('quality_gates.cayc.banner.title')}
+ </Title>
+ <SubHeading className="sw-body-sm sw-mb-4">
+ <FormattedMessage
+ id="quality_gates.cayc.banner.description1"
+ defaultMessage={translate('quality_gates.cayc.banner.description1')}
+ values={{
+ cayc_link: (
+ <Link to={getDocUrl('/user-guide/clean-as-you-code/')}>
+ {translate('quality_gates.cayc')}
+ </Link>
+ ),
+ }}
+ />
+ {translate('quality_gates.cayc.banner.description2')}
+ </SubHeading>
+ <ul className="sw-body-sm">
+ {times(CAYC_CONDITIONS_LIST_ITEMS, (i) => (
+ <CaycConditionsListItem
+ index={i}
+ key={i}
+ last={i === CAYC_CONDITIONS_LIST_ITEMS - 1}
/>
- </div>
- {canEdit && (
- <ModalButton modal={this.renderCaycModal}>
- {({ onClick }) => (
- <Button className="big-spacer-top spacer-bottom" onClick={onClick}>
- {translate('quality_gates.cayc_condition.review_update')}
- </Button>
- )}
- </ModalButton>
- )}
- </Alert>
- )}
+ ))}
+ </ul>
+ </CardWithPrimaryBackground>
+ )}
- {(qualityGate.caycStatus === CaycStatus.NonCompliant || unlockEditing) && canEdit && (
- <div className="pull-right">
- <ModalButton modal={this.renderConditionModal}>
+ {qualityGate.caycStatus === CaycStatus.NonCompliant && canEdit && (
+ <CardWithPrimaryBackground className="sw-mb-9 sw-p-8">
+ <Title as="h2" className="sw-mb-2 sw-heading-md">
+ {translate('quality_gates.cayc_missing.banner.title')}
+ </Title>
+ <SubHeading className="sw-body-sm sw-mb-4">
+ <FormattedMessage
+ id="quality_gates.cayc_missing.banner.description"
+ defaultMessage={translate('quality_gates.cayc_missing.banner.description')}
+ values={{
+ cayc_link: (
+ <Link to={getDocUrl('/user-guide/clean-as-you-code/')}>
+ {translate('quality_gates.cayc')}
+ </Link>
+ ),
+ }}
+ />
+ </SubHeading>
+ <SubnavigationFlowSeparator className="sw-m-0" />
+ {canEdit && (
+ <ModalButton modal={renderCaycModal}>
{({ onClick }) => (
- <Button data-test="quality-gates__add-condition" onClick={onClick}>
- {translate('quality_gates.add_condition')}
- </Button>
+ <ButtonSecondary className="sw-mt-4" onClick={onClick}>
+ {translate('quality_gates.cayc_condition.review_update')}
+ </ButtonSecondary>
)}
</ModalButton>
- </div>
- )}
+ )}
+ </CardWithPrimaryBackground>
+ )}
- <header className="display-flex-center">
- <h2 className="big">{translate('quality_gates.conditions')}</h2>
+ <header className="sw-flex sw-items-center sw-mb-4 sw-justify-between">
+ <div className="sw-flex">
+ <HeadingDark className="sw-body-md-highlight sw-m-0">
+ {translate('quality_gates.conditions')}
+ </HeadingDark>
<DocumentationTooltip
- className="spacer-left"
+ className="sw-ml-2"
content={translate('quality_gates.conditions.help')}
links={[
{
label: translate('quality_gates.conditions.help.link'),
},
]}
- />
- </header>
+ >
+ <HelperHintIcon />
+ </DocumentationTooltip>
+ </div>
+ <div>
+ {(qualityGate.caycStatus === CaycStatus.NonCompliant || editing) && canEdit && (
+ <ModalButton modal={renderConditionModal}>
+ {({ onClick }) => (
+ <ButtonSecondary data-test="quality-gates__add-condition" onClick={onClick}>
+ {translate('quality_gates.add_condition')}
+ </ButtonSecondary>
+ )}
+ </ModalButton>
+ )}
+ </div>
+ </header>
- {uniqDuplicates.length > 0 && (
- <Alert variant="warning">
+ {uniqDuplicates.length > 0 && (
+ <FlagMessage variant="warning" className="sw-flex sw-mb-4">
+ <p>
<p>{translate('quality_gates.duplicated_conditions')}</p>
- <ul className="list-styled spacer-top">
+ <ul className="sw-my-2 sw-list-disc sw-pl-10">
{uniqDuplicates.map((d) => (
<li key={d.metric.key}>{getLocalizedMetricName(d.metric)}</li>
))}
</ul>
- </Alert>
- )}
+ </p>
+ </FlagMessage>
+ )}
- {newCodeConditions.length > 0 && (
- <div className="big-spacer-top">
- <h3 className="medium text-normal">
- {translate('quality_gates.conditions.new_code', 'long')}
- </h3>
- {this.props.hasFeature(Feature.BranchSupport) && (
- <p className="spacer-top spacer-bottom">
- {translate('quality_gates.conditions.new_code', 'description')}
- </p>
- )}
- <ConditionsTable
- qualityGate={qualityGate}
- metrics={metrics}
- canEdit={canEdit}
- onRemoveCondition={onRemoveCondition}
- onSaveCondition={onSaveCondition}
- updatedConditionId={updatedConditionId}
- conditions={newCodeConditions}
- showEdit={this.state.unlockEditing}
- scope="new"
- />
- </div>
- )}
+ {newCodeConditions.length > 0 && (
+ <div>
+ <HeadingDark as="h3" className="sw-mb-2">
+ {translate('quality_gates.conditions.new_code', 'long')}
+ </HeadingDark>
+ {hasFeature(Feature.BranchSupport) && (
+ <SubHeading as="p" className="sw-mb-2 sw-body-sm">
+ {translate('quality_gates.conditions.new_code', 'description')}
+ </SubHeading>
+ )}
+ <ConditionsTable
+ qualityGate={qualityGate}
+ metrics={metrics}
+ canEdit={canEdit}
+ onRemoveCondition={onRemoveCondition}
+ onSaveCondition={onSaveCondition}
+ updatedConditionId={updatedConditionId}
+ conditions={newCodeConditions}
+ showEdit={editing}
+ scope="new"
+ />
+ </div>
+ )}
- {overallCodeConditions.length > 0 && (
- <div className="big-spacer-top">
- <h3 className="medium text-normal">
- {translate('quality_gates.conditions.overall_code', 'long')}
- </h3>
+ {overallCodeConditions.length > 0 && (
+ <div className="sw-mt-5">
+ <HeadingDark as="h3" className="sw-mb-2">
+ {translate('quality_gates.conditions.overall_code', 'long')}
+ </HeadingDark>
- {this.props.hasFeature(Feature.BranchSupport) && (
- <p className="spacer-top spacer-bottom">
- {translate('quality_gates.conditions.overall_code', 'description')}
- </p>
- )}
+ {hasFeature(Feature.BranchSupport) && (
+ <SubHeading as="p" className="sw-mb-2 sw-body-sm">
+ {translate('quality_gates.conditions.overall_code', 'description')}
+ </SubHeading>
+ )}
- <ConditionsTable
- qualityGate={qualityGate}
- metrics={metrics}
- canEdit={canEdit}
- onRemoveCondition={onRemoveCondition}
- onSaveCondition={onSaveCondition}
- updatedConditionId={updatedConditionId}
- conditions={overallCodeConditions}
- scope="overall"
- />
- </div>
- )}
+ <ConditionsTable
+ qualityGate={qualityGate}
+ metrics={metrics}
+ canEdit={canEdit}
+ onRemoveCondition={onRemoveCondition}
+ onSaveCondition={onSaveCondition}
+ updatedConditionId={updatedConditionId}
+ conditions={overallCodeConditions}
+ scope="overall"
+ />
+ </div>
+ )}
- {qualityGate.caycStatus !== CaycStatus.NonCompliant && !unlockEditing && canEdit && (
- <div className="big-spacer-top big-spacer-bottom cayc-warning-description it__qg-unfollow-cayc">
- <p>
- <FormattedMessage
- id="quality_gates.cayc_unfollow.description"
- defaultMessage={translate('quality_gates.cayc_unfollow.description')}
- values={{
- cayc_link: (
- <DocLink to="/user-guide/clean-as-you-code/">
- {translate('quality_gates.cayc')}
- </DocLink>
- ),
- }}
- />
- </p>
- <Button className="big-spacer-top spacer-bottom" onClick={this.unlockEditing}>
- {translate('quality_gates.cayc.unlock_edit')}
- </Button>
- </div>
- )}
+ {qualityGate.caycStatus !== CaycStatus.NonCompliant && !editing && canEdit && (
+ <div className="sw-mt-4 sw-mb-10 it__qg-unfollow-cayc">
+ <SubHeading as="p" className="sw-mb-2 sw-body-sm">
+ <FormattedMessage
+ id="quality_gates.cayc_unfollow.description"
+ defaultMessage={translate('quality_gates.cayc_unfollow.description')}
+ values={{
+ cayc_link: (
+ <Link to={getDocUrl('/user-guide/clean-as-you-code/')}>
+ {translate('quality_gates.cayc')}
+ </Link>
+ ),
+ }}
+ />
+ </SubHeading>
+ <ButtonSecondary className="sw-mt-2" onClick={() => setEditing(true)}>
+ {translate('quality_gates.cayc.unlock_edit')}
+ </ButtonSecondary>
+ </div>
+ )}
- {existingConditions.length === 0 && (
- <div className="big-spacer-top">{translate('quality_gates.no_conditions')}</div>
- )}
- </div>
- );
- }
+ {existingConditions.length === 0 && (
+ <div className="sw-mt-4 sw-body-sm">
+ <LightPrimary as="p">{translate('quality_gates.no_conditions')}</LightPrimary>
+ </div>
+ )}
+ </div>
+ );
}
export default withMetricsContext(withAvailableFeatures(Conditions));
await screen.findByRole('link', {
current: 'page',
name: `${defaultQualityGate.name} default`,
- }),
+ })
).toBeInTheDocument();
});
expect(
await screen.findByRole('link', {
name: `${handler.getDefaultQualityGate().name} default`,
- }),
+ })
).toBeInTheDocument();
expect(
screen.getByRole('link', {
name: `${handler.getBuiltInQualityGate().name} quality_gates.built_in`,
- }),
+ })
).toBeInTheDocument();
});
await user.click(dialog.getByRole('button', { name: 'quality_gates.add_condition' }));
expect(
- await overallConditions.findByRole('cell', { name: 'Maintainability Rating' }),
+ await overallConditions.findByRole('cell', { name: 'Maintainability Rating' })
).toBeInTheDocument();
expect(await overallConditions.findByRole('cell', { name: 'B' })).toBeInTheDocument();
});
const newConditions = within(await screen.findByTestId('quality-gates__conditions-new'));
await user.click(
- newConditions.getByLabelText('quality_gates.condition.edit.Coverage on New Code'),
+ newConditions.getByLabelText('quality_gates.condition.edit.Coverage on New Code')
);
const dialog = within(screen.getByRole('dialog'));
await user.click(dialog.getByRole('textbox', { name: 'quality_gates.conditions.value' }));
await user.click(
// make it a regexp to ignore badges:
- await screen.findByRole('link', { name: new RegExp(handler.getCorruptedQualityGateName()) }),
+ await screen.findByRole('link', { name: new RegExp(handler.getCorruptedQualityGateName()) })
);
expect(await screen.findByText('quality_gates.duplicated_conditions')).toBeInTheDocument();
expect(
- await screen.findByRole('cell', { name: 'Complexity / Function deprecated' }),
+ await screen.findByRole('cell', { name: 'Complexity / Function deprecated' })
).toBeInTheDocument();
});
const newConditions = within(await screen.findByTestId('quality-gates__conditions-new'));
await user.click(
- newConditions.getByLabelText('quality_gates.condition.delete.Coverage on New Code'),
+ newConditions.getByLabelText('quality_gates.condition.delete.Coverage on New Code')
);
const dialog = within(screen.getByRole('dialog'));
renderQualityGateApp({ featureList: [Feature.BranchSupport] });
expect(
- await screen.findByText('quality_gates.conditions.new_code.description'),
+ await screen.findByText('quality_gates.conditions.new_code.description')
).toBeInTheDocument();
expect(
- await screen.findByText('quality_gates.conditions.overall_code.description'),
+ await screen.findByText('quality_gates.conditions.overall_code.description')
).toBeInTheDocument();
});
expect(screen.getByText('quality_gates.cayc_missing.banner.title')).toBeInTheDocument();
expect(screen.getByText('quality_gates.cayc_missing.banner.description')).toBeInTheDocument();
expect(
- screen.getByRole('button', { name: 'quality_gates.cayc_condition.review_update' }),
+ screen.getByRole('button', { name: 'quality_gates.cayc_condition.review_update' })
).toBeInTheDocument();
await user.click(
- screen.getByRole('button', { name: 'quality_gates.cayc_condition.review_update' }),
+ screen.getByRole('button', { name: 'quality_gates.cayc_condition.review_update' })
);
expect(
screen.getByRole('dialog', {
name: 'quality_gates.cayc.review_update_modal.header.SonarSource way - CFamily',
- }),
+ })
).toBeInTheDocument();
expect(
- screen.getByText('quality_gates.cayc.review_update_modal.description1'),
+ screen.getByText('quality_gates.cayc.review_update_modal.description1')
).toBeInTheDocument();
expect(
- screen.getByText('quality_gates.cayc.review_update_modal.description2'),
+ screen.getByText('quality_gates.cayc.review_update_modal.description2')
).toBeInTheDocument();
expect(
- screen.getByRole('button', { name: 'quality_gates.cayc.review_update_modal.confirm_text' }),
+ screen.getByRole('button', { name: 'quality_gates.cayc.review_update_modal.confirm_text' })
).toBeInTheDocument();
await user.click(
- screen.getByRole('button', { name: 'quality_gates.cayc.review_update_modal.confirm_text' }),
+ screen.getByRole('button', { name: 'quality_gates.cayc.review_update_modal.confirm_text' })
);
const conditionsWrapper = within(await screen.findByTestId('quality-gates__conditions-new'));
expect(conditionsWrapper.getByText('Duplicated Lines (%)')).toBeInTheDocument();
const overallConditionsWrapper = within(
- await screen.findByTestId('quality-gates__conditions-overall'),
+ await screen.findByTestId('quality-gates__conditions-overall')
);
expect(overallConditionsWrapper.getByText('Complexity / Function')).toBeInTheDocument();
});
await user.click(nonCompliantQualityGate);
- expect(await screen.findByRole('alert')).toHaveTextContent(
- /quality_gates.cayc_missing.banner.title/,
- );
+ expect(await screen.findByText(/quality_gates.cayc_missing.banner.title/)).toBeInTheDocument();
expect(screen.getAllByText('quality_gates.cayc.tooltip.message').length).toBeGreaterThan(0);
});
expect(screen.getByText('quality_gates.cayc.banner.title')).toBeInTheDocument();
expect(
- screen.getByText('quality_gates.cayc.banner.description1', { exact: false }),
+ screen.getByText('quality_gates.cayc.banner.description1', { exact: false })
).toBeInTheDocument();
expect(
- screen.queryByText('quality_gates.cayc_condition.missing_warning.title'),
+ screen.queryByText('quality_gates.cayc_condition.missing_warning.title')
).not.toBeInTheDocument();
expect(
- screen.queryByRole('button', { name: 'quality_gates.cayc_condition.review_update' }),
+ screen.queryByRole('button', { name: 'quality_gates.cayc_condition.review_update' })
).not.toBeInTheDocument();
const conditionsWrapper = within(await screen.findByTestId('quality-gates__conditions-new'));
expect(
screen.queryByRole('button', {
name: 'quality_gates.condition.edit.Security Rating on New Code',
- }),
+ })
).not.toBeInTheDocument();
expect(
screen.queryByRole('button', {
name: 'quality_gates.condition.delete.Security Rating on New Code',
- }),
+ })
).not.toBeInTheDocument();
await user.click(screen.getByText('quality_gates.cayc.unlock_edit'));
expect(
screen.getByRole('button', {
name: 'quality_gates.condition.edit.Security Rating on New Code',
- }),
+ })
).toBeInTheDocument();
expect(
screen.getByRole('button', {
name: 'quality_gates.condition.delete.Security Rating on New Code',
- }),
+ })
).toBeInTheDocument();
});
expect(
await screen.findByRole('link', {
name: `${handler.getDefaultQualityGate().name} default`,
- }),
+ })
).toBeInTheDocument();
expect(screen.queryByText('quality_gates.permissions')).not.toBeInTheDocument();