Skip to content

Commit

Permalink
Merge pull request #2188 from metalice/CNV-47153-add-data-test-ids
Browse files Browse the repository at this point in the history
CNV-47153: Add data test ids
  • Loading branch information
openshift-merge-bot[bot] authored Sep 19, 2024
2 parents cecf904 + ab8cee5 commit 4e53e61
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ const SourceTypeSelection: FC<SourceTypeSelectionProps> = ({
<FormGroup fieldId="source-type" label={t('Source type')}>
<Select
toggle={SelectToggle({
'data-test-id': 'source-type-select',
isExpanded: isOpen,
isFullWidth: true,
onClick: onToggle,
Expand All @@ -68,20 +69,23 @@ const SourceTypeSelection: FC<SourceTypeSelectionProps> = ({
{...(!canUploadImage && {
description: t("You don't have permission to perform this action"),
})}
data-test-id="upload-volume"
>
{optionsValueLabelMapper[DROPDOWN_FORM_SELECTION.UPLOAD_VOLUME]}
</SelectOption>
</SelectGroup>
<Divider />
<SelectGroup label={t('Use existing')}>
<SelectOption
data-test-id="use-existing-volume"
description={t('Use volume already available on the cluster')}
isDisabled={!canCreatePVC}
value={DROPDOWN_FORM_SELECTION.USE_EXISTING_PVC}
>
{optionsValueLabelMapper[DROPDOWN_FORM_SELECTION.USE_EXISTING_PVC]}
</SelectOption>
<SelectOption
data-test-id="use-snapshot"
isDisabled={!canCreateSnapshots}
value={DROPDOWN_FORM_SELECTION.USE_SNAPSHOT}
>
Expand All @@ -91,6 +95,7 @@ const SourceTypeSelection: FC<SourceTypeSelectionProps> = ({
<Divider />
<SelectGroup label={t('Import from')}>
<SelectOption
data-test-id="use-registry"
description={t('Content from container registry')}
isDisabled={!canCreateDS}
value={DROPDOWN_FORM_SELECTION.USE_REGISTRY}
Expand Down
9 changes: 7 additions & 2 deletions src/utils/components/toggles/SelectToggle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,17 @@ import React, { Ref } from 'react';
import { MenuToggle, MenuToggleElement, MenuToggleProps } from '@patternfly/react-core';

type SelectToggleProps = MenuToggleProps & {
'data-test-id'?: string;
selected: any;
};

const SelectToggle = ({ selected, ...menuProps }: SelectToggleProps) => {
const SelectToggle = ({
'data-test-id': dataTestID,
selected,
...menuProps
}: SelectToggleProps) => {
return (toggleRef: Ref<MenuToggleElement>) => (
<MenuToggle ref={toggleRef} {...menuProps}>
<MenuToggle data-test-id={dataTestID} ref={toggleRef} {...menuProps}>
{selected}
</MenuToggle>
);
Expand Down

0 comments on commit 4e53e61

Please sign in to comment.