Skip to content

Commit

Permalink
24.10 test ids (#4252)
Browse files Browse the repository at this point in the history
* add: set of test-ids

* added a lot more test-ids

* added the last test-ids

* removed not working test-ids

* fix test

---------

Co-authored-by: daniele-mng <[email protected]>
  • Loading branch information
christianpiske and daniele-mng authored Dec 17, 2024
1 parent 9bc5e5b commit 8d6368c
Show file tree
Hide file tree
Showing 153 changed files with 415 additions and 142 deletions.
2 changes: 1 addition & 1 deletion src/web/components/bar/compliancebar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const ComplianceBar = ({compliance, toolTip}) => {
const toolTipText = isDefined(toolTip) ? toolTip : title;

return (
<ProgressBar title={toolTipText} progress={100} background={background}>
<ProgressBar title={toolTipText} progress={100} background={background} data-testid="compliance-bar">
{title}
</ProgressBar>
);
Expand Down
1 change: 1 addition & 0 deletions src/web/components/bar/compliancestatusbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const ComplianceStatusBar = ({complianceStatus}) => {
progress={complianceStatus}
background={Theme.statusRunGreen}
boxBackground={boxBackground}
data-testid="compliance-status-bar"
>
{text}
</ProgressBar>
Expand Down
2 changes: 1 addition & 1 deletion src/web/components/bar/severitybar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const SeverityBar = ({severity, toolTip}) => {
const toolTipText = isDefined(toolTip) ? toolTip : title;

return (
<ProgressBar title={toolTipText} progress={fill} background={type}>
<ProgressBar title={toolTipText} progress={fill} background={type} data-testid="severitybar">
{text}
</ProgressBar>
);
Expand Down
4 changes: 2 additions & 2 deletions src/web/components/bar/statusbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ const StatusBar = ({status = 'Unknown', progress = '0'}) => {
: getTranslatableTaskStatus(status);

return (
<ProgressBar title={title} progress={progress} background={background}>
<Span>{text}</Span>
<ProgressBar title={title} progress={progress} background={background} data-testid={`progress-bar-${status.toLowerCase()}`}>
<Span data-testid="statusbar-text">{text}</Span>
</ProgressBar>
);
};
Expand Down
26 changes: 13 additions & 13 deletions src/web/components/certinfo/certinfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ import TableRow from 'web/components/table/row';
const CertInfo = ({info}) => {
const {activationTime, expirationTime, issuer, md5_fingerprint} = info;
return (
<InfoTable>
<InfoTable data-testid="cert-info-table">
<colgroup>
<Col width="10%" />
<Col width="90%" />
</colgroup>
<TableBody>
<TableRow>
<TableData>{_('Activation')}</TableData>
<TableData>
<TableRow data-testid="cert-info-activation-row">
<TableData data-testid="cert-info-activation-label">{_('Activation')}</TableData>
<TableData data-testid="cert-info-activation-data">
{isDefined(activationTime) ? (
<DateTime date={activationTime} />
) : (
Expand All @@ -41,9 +41,9 @@ const CertInfo = ({info}) => {
</TableData>
</TableRow>

<TableRow>
<TableData>{_('Expiration')}</TableData>
<TableData>
<TableRow data-testid="cert-info-expiration-row">
<TableData data-testid="cert-info-expiration-label">{_('Expiration')}</TableData>
<TableData data-testid="cert-info-expiration-data">
{isDefined(expirationTime) ? (
<DateTime date={expirationTime} />
) : (
Expand All @@ -52,14 +52,14 @@ const CertInfo = ({info}) => {
</TableData>
</TableRow>

<TableRow>
<TableData>{_('MD5 Fingerprint')}</TableData>
<TableData>{md5_fingerprint}</TableData>
<TableRow data-testid="cert-info-md5-row">
<TableData data-testid="cert-info-md5-label">{_('MD5 Fingerprint')}</TableData>
<TableData data-testid="cert-info-md5-data">{md5_fingerprint}</TableData>
</TableRow>

<TableRow>
<TableData>{_('Issuer')}</TableData>
<TableData>{issuer}</TableData>
<TableRow data-testid="cert-info-issuer-row">
<TableData data-testid="cert-info-issuer-label">{_('Issuer')}</TableData>
<TableData data-testid="cert-info-issuer-data">{issuer}</TableData>
</TableRow>
</TableBody>
</InfoTable>
Expand Down
2 changes: 1 addition & 1 deletion src/web/components/comment/comment.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const Comment = ({text, children}) => {
if (!isDefined(text)) {
return null;
}
return <div className="comment">{text}</div>;
return <div className="comment" data-testid="comment">{text}</div>;
};

Comment.propTypes = {
Expand Down
1 change: 1 addition & 0 deletions src/web/components/dashboard/controls.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export class DashboardControls extends React.Component {
: _('Dashboard limit reached')
}
onClick={canAdd ? this.handleNewClick : undefined}
data-testid="add-dashboard-display"
/>
<ResetIcon
title={_('Reset to Defaults')}
Expand Down
1 change: 1 addition & 0 deletions src/web/components/dialog/closebutton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ const CloseButton = ({title = _('Close'), size = 'medium', ...props}) => {
$lineHeight={height}
title={title}
{...props}
data-testid="close-button"
>
×{/* Javascript unicode: \u00D7 */}
</StyledCloseButton>
Expand Down
2 changes: 2 additions & 0 deletions src/web/components/dialog/composercontent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const ComposerContent = ({
onChange={onValueChange}
/>
<CheckBox
data-testid="include-overrides"
name="includeOverrides"
checked={includeOverrides}
checkedValue={YES_VALUE}
Expand All @@ -72,6 +73,7 @@ const ComposerContent = ({
onChange={onValueChange}
/>
<CheckBox
data-testid="include-tls-cert"
disabled={true}
name="includeTlsCertificates"
checked={true}
Expand Down
1 change: 1 addition & 0 deletions src/web/components/dialog/confirmationdialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const ConfirmationDialog = ({

return (
<Dialog
data-testid="confirmation-dialog"
width={width}
onClose={onClose}
title={title}
Expand Down
2 changes: 1 addition & 1 deletion src/web/components/dialog/error.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const DialogError = ({error, onCloseClick}) => {
>
{error}
</span>
<DialogCloseButton onClick={onCloseClick} title={_('Close')} />
<DialogCloseButton onClick={onCloseClick} title={_('Close')} data-testid="error-close-button"/>
</StyledLayout>
);
};
Expand Down
1 change: 1 addition & 0 deletions src/web/components/form/DatePicker.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const DatePickerComponent = (

return (
<DatePickerInput
data-testid="datepicker-input"
disabled={disabled}
locale={getLocale()}
value={value.toDate()}
Expand Down
1 change: 1 addition & 0 deletions src/web/components/form/button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ const Button = ({
});
return (
<OpenSightButton
data-testid="opensight-button"
{...other}
disabled={disabled}
name={name}
Expand Down
1 change: 1 addition & 0 deletions src/web/components/form/checkbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ const Checkbox = ({
);
return (
<OpenSightCheckbox
data-testid="opensight-checkbox"
{...props}
label={title}
title={toolTipTitle}
Expand Down
1 change: 1 addition & 0 deletions src/web/components/form/filefield.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const FileField = ({disabled, grow, name, title, onChange, ...props}) => {

return (
<FileInput
data-testid="file-input"
{...props}
styles={{root: {flexGrow: grow}}}
label={title}
Expand Down
2 changes: 2 additions & 0 deletions src/web/components/form/multiselect.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const MultiSelect = ({
if (isLoading) {
return (
<TextInput
data-testid="text-input"
styles={{root: {flexGrow: grow}}}
placeholder={_('Loading...')}
readOnly={true}
Expand All @@ -84,6 +85,7 @@ const MultiSelect = ({
}
return (
<StyledMultiSelect
data-testid="multi-select"
{...props}
styles={{root: {flexGrow: grow}}}
disabled={disabled || !items?.length}
Expand Down
1 change: 1 addition & 0 deletions src/web/components/form/numberfield.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const NumberField = forwardRef(

return (
<StyledNumberInput
data-testid="number-input"
{...props}
ref={ref}
allowDecimal={type === 'float'}
Expand Down
1 change: 1 addition & 0 deletions src/web/components/form/passwordfield.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const PasswordField = ({
const handleChange = useValueChange({onChange, name, disabled});
return (
<PasswordInput
data-testid="password-input"
{...props}
error={isDefined(errorContent) && `${errorContent}`}
styles={{root: {flexGrow: grow}}}
Expand Down
1 change: 1 addition & 0 deletions src/web/components/form/textfield.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const TextField = ({
const handleChange = useValueChange({onChange, disabled, name});
return (
<Input
data-testid="form-input"
{...props}
styles={{root: {flexGrow: grow}}}
autoComplete={autoComplete}
Expand Down
2 changes: 2 additions & 0 deletions src/web/components/form/yesnoradio.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const YesNoRadio = ({
convert={convert}
onChange={onChange}
disabled={disabled}
data-testid="radio-yes"
/>
<Radio
title={_('No')}
Expand All @@ -42,6 +43,7 @@ const YesNoRadio = ({
convert={convert}
onChange={onChange}
disabled={disabled}
data-testid="radio-no"
/>
</Row>
);
Expand Down
2 changes: 1 addition & 1 deletion src/web/components/icon/XIcon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {X as Icon} from 'lucide-react';
import IconWithStrokeWidth from 'web/components/icon/IconWithStrokeWidth';

const XIcon = withSvgIcon()(props => (
<IconWithStrokeWidth IconComponent={Icon} {...props} />
<IconWithStrokeWidth IconComponent={Icon} {...props} data-testid="X-icon"/>
));

export default XIcon;
6 changes: 5 additions & 1 deletion src/web/components/icon/addtoassetsicon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import withSvgIcon from './withSvgIcon';

import Icon from './svg/add_to_assets.svg';

const AddToAssetsIcon = withSvgIcon()(Icon);
const AddToAssetsIconComponent = withSvgIcon()(Icon);

const AddToAssetsIcon = props => (
<AddToAssetsIconComponent {...props} data-testid="add-to-assets-icon" />
);

export default AddToAssetsIcon;

Expand Down
2 changes: 1 addition & 1 deletion src/web/components/icon/alerticon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {Megaphone as Icon} from 'lucide-react';
import IconWithStrokeWidth from 'web/components/icon/IconWithStrokeWidth';

const AlertIcon = withSvgIcon()(props => (
<IconWithStrokeWidth IconComponent={Icon} {...props} />
<IconWithStrokeWidth IconComponent={Icon} {...props} data-testid="alert-icon"/>
));

export default AlertIcon;
Expand Down
2 changes: 1 addition & 1 deletion src/web/components/icon/alterableicon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {FilePenLine as Icon} from 'lucide-react';
import IconWithStrokeWidth from 'web/components/icon/IconWithStrokeWidth';

const AlterableIcon = withSvgIcon()(props => (
<IconWithStrokeWidth IconComponent={Icon} {...props} />
<IconWithStrokeWidth IconComponent={Icon} {...props} data-testid="alterable-icon"/>
));

export default AlterableIcon;
Expand Down
2 changes: 1 addition & 1 deletion src/web/components/icon/arrowicon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ const ArrowIcon = ({down = false, isLoading = false, size, ...props}) => {
icon = <Loading />;
}
return (
<Styled $height={height} $width={width} $lineHeight={height} {...props}>
<Styled $height={height} $width={width} $lineHeight={height} {...props} data-testid="arrow-icon">
{icon}
</Styled>
);
Expand Down
2 changes: 1 addition & 1 deletion src/web/components/icon/auditicon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {ClipboardCheck as Icon} from 'lucide-react';
import IconWithStrokeWidth from 'web/components/icon/IconWithStrokeWidth';

const AuditIcon = withSvgIcon()(props => (
<IconWithStrokeWidth IconComponent={Icon} {...props} />
<IconWithStrokeWidth IconComponent={Icon} {...props} data-testid="audit-icon"/>
));

export default AuditIcon;
Expand Down
2 changes: 1 addition & 1 deletion src/web/components/icon/calendaricon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {Calendar as Icon} from 'lucide-react';
import IconWithStrokeWidth from 'web/components/icon/IconWithStrokeWidth';

const CalendarIcon = withSvgIcon()(props => (
<IconWithStrokeWidth IconComponent={Icon} {...props} />
<IconWithStrokeWidth IconComponent={Icon} {...props} data-testid="calendar-icon"/>
));

export default CalendarIcon;
Expand Down
6 changes: 5 additions & 1 deletion src/web/components/icon/certbundadvicon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import withSvgIcon from './withSvgIcon';

import Icon from './svg/cert_bund_adv.svg';

const CertBundAdvIcon = withSvgIcon()(Icon);
const CertBundAdvIconComponent = withSvgIcon()(Icon);

const CertBundAdvIcon = props => (
<CertBundAdvIconComponent {...props} data-testid="cert-bund-adv-icon" />
);

export default CertBundAdvIcon;

Expand Down
4 changes: 3 additions & 1 deletion src/web/components/icon/cloneicon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import withSvgIcon from './withSvgIcon';

import Icon from './svg/clone.svg';

const CloneIcon = withSvgIcon()(Icon);
const CloneIconComponent = withSvgIcon()(Icon);

const CloneIcon = props => <CloneIconComponent {...props} data-testid="clone-icon" />;

export default CloneIcon;

Expand Down
2 changes: 1 addition & 1 deletion src/web/components/icon/cpeicon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const CpeIcon = ({name, ...props}) => {

const icon = isDefined(cpe) ? cpe.icon : 'cpe/other.svg';

return <Img {...props} width="16px" src={icon} />;
return <Img {...props} width="16px" src={icon} data-testid="cpe-icon"/>;
};

CpeIcon.propTypes = {
Expand Down
6 changes: 5 additions & 1 deletion src/web/components/icon/cpelogoicon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import withSvgIcon from './withSvgIcon';

import Icon from './svg/cpe.svg';

const CpeLogoIcon = withSvgIcon()(Icon);
const CpeLogoIconComponent = withSvgIcon()(Icon);

const CpeLogoIcon = props => (
<CpeLogoIconComponent {...props} data-testid="cpe-logo-icon" />
);

export default CpeLogoIcon;

Expand Down
2 changes: 1 addition & 1 deletion src/web/components/icon/credentialicon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {KeyRound as Icon} from 'lucide-react';
import IconWithStrokeWidth from 'web/components/icon/IconWithStrokeWidth';

const CredentialIcon = withSvgIcon()(props => (
<IconWithStrokeWidth IconComponent={Icon} {...props} />
<IconWithStrokeWidth IconComponent={Icon} {...props} data-testid="credential-icon"/>
));

export default CredentialIcon;
Expand Down
6 changes: 5 additions & 1 deletion src/web/components/icon/cveicon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import withSvgIcon from './withSvgIcon';

import Icon from './svg/cve.svg';

const CveIcon = withSvgIcon()(Icon);
const CveIconComponent = withSvgIcon()(Icon);

const CveIcon = props => (
<CveIconComponent {...props} data-testid="cve-icon" />
);

export default CveIcon;

Expand Down
6 changes: 5 additions & 1 deletion src/web/components/icon/cvssicon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import withSvgIcon from './withSvgIcon';

import Icon from './svg/cvss_calculator.svg';

const CvssIcon = withSvgIcon()(Icon);
const CvssIconComponent = withSvgIcon()(Icon);

const CvssIcon = props => (
<CvssIconComponent {...props} data-testid="cvss-icon" />
);

export default CvssIcon;

Expand Down
2 changes: 1 addition & 1 deletion src/web/components/icon/dashboardicon.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {BarChart3 as Icon} from 'lucide-react';
import IconWithStrokeWidth from 'web/components/icon/IconWithStrokeWidth';

const DashboardIcon = withSvgIcon()(props => (
<IconWithStrokeWidth IconComponent={Icon} {...props} />
<IconWithStrokeWidth IconComponent={Icon} {...props} data-testid="dashboard-icon"/>
));

export default DashboardIcon;
Expand Down
Loading

0 comments on commit 8d6368c

Please sign in to comment.