chore(automation): give unique selectors [r8s-168] (#345)

Co-authored-by: JamesPlayer <james.player@portainer.io>
pull/12512/head
Ali 2025-01-30 15:42:32 +13:00 committed by GitHub
parent b30a1b5250
commit c80cc6e268
29 changed files with 38 additions and 4 deletions

View File

@ -104,6 +104,7 @@ export function TagSelector({
onCreateOption={handleCreateOption}
aria-label="Tags"
data-cy="environment-tags-selector"
id="environment-tags-selector"
/>
</FormControl>
</>

View File

@ -36,6 +36,7 @@ export function UsersSelector({
onChange(selectedUsers.map((user) => user.Id))
}
data-cy={dataCy}
id={dataCy}
inputId={inputId}
placeholder={placeholder}
isDisabled={disabled}

View File

@ -18,6 +18,7 @@ export function Select<T extends number | string>({
options,
className,
'data-cy': dataCy,
id,
...props
}: Props<T> & SelectHTMLAttributes<HTMLSelectElement>) {
return (

View File

@ -111,6 +111,7 @@ export function SingleSelect<TValue = string>({
onChange={(option) => onChange(option ? option.value : null)}
isOptionDisabled={(option) => !!option.disabled}
data-cy={dataCy}
id={dataCy}
inputId={inputId}
placeholder={placeholder}
isDisabled={disabled}
@ -177,6 +178,7 @@ export function MultiSelect<TValue = string>({
closeMenuOnSelect={false}
onChange={(newValue) => onChange(newValue.map((option) => option.value))}
data-cy={dataCy}
id={dataCy}
inputId={inputId}
placeholder={placeholder}
isDisabled={disabled}

View File

@ -65,6 +65,7 @@ export function Select<
}: Props<Option, IsMulti, Group> &
AutomationTestingProps & {
isItemVisible?: (item: Option, search: string) => boolean;
id: string;
}) {
const Component = isCreatable ? ReactSelectCreatable : ReactSelect;
const { options } = props;

View File

@ -152,6 +152,7 @@ export function GpuFieldset({
options={options}
components={{ MultiValueRemove }}
data-cy="docker-containers-gpu-select"
id="docker-containers-gpu-select"
/>
</div>
)}
@ -173,6 +174,7 @@ export function GpuFieldset({
components={{ Option }}
onChange={onChangeSelectedCaps}
data-cy="docker-containers-gpu-capabilities-select"
id="docker-containers-gpu-capabilities-select"
/>
</div>
</div>

View File

@ -44,6 +44,7 @@ export function VolumeSelector({
onChange={(vol) => onChange(vol?.Name)}
inputId={inputId}
data-cy="docker-containers-volume-selector"
id="docker-containers-volume-selector"
size="sm"
/>
);

View File

@ -43,6 +43,7 @@ export function CreatableSelector({
isDisabled={isLoading}
closeMenuOnSelect={false}
data-cy="edge-devices-assignment-selector"
id="edge-devices-assignment-selector"
/>
);

View File

@ -45,6 +45,7 @@ export function GroupSelector() {
placeholder="Select a group"
isClearable
data-cy="edge-devices-assignment-selector"
id="edge-devices-assignment-selector"
/>
);

View File

@ -50,6 +50,7 @@ export function TemplateSelector({
onChange(getTemplate({ type, id: templateId }), type);
}}
data-cy="edge-stacks-create-template-selector"
id="edge-stacks-create-template-selector"
/>
{isLoadingValues && (
<InlineLoader>Loading template values...</InlineLoader>

View File

@ -97,6 +97,7 @@ function InnerSelector({
placeholder="Select one or multiple group(s)"
closeMenuOnSelect={false}
data-cy="edge-stacks-groups-selector"
id="edge-stacks-groups-selector"
inputId={inputId}
/>
) : (

View File

@ -102,6 +102,7 @@ export function PrivateRegistryFieldset({
onChange={(value) => onSelect(value?.Id)}
className="w-full"
data-cy="private-registry-selector"
id="private-registry-selector"
/>
{method !== 'repository' && (
<Button

View File

@ -122,6 +122,7 @@ export function AppIngressPathForm({
onChangeIngressPath(newIngressPath);
}}
data-cy="k8sAppCreate-ingressPathHostSelect"
id="k8sAppCreate-ingressPathHostSelect"
/>
<InputGroup.ButtonWrapper>
<Button

View File

@ -60,6 +60,7 @@ export function ConfigurationItem({
onChange={onSelectConfigMap}
size="sm"
data-cy={`k8sAppCreate-add${configurationType}Select_${index}`}
id={`k8sAppCreate-add${configurationType}Select_${index}`}
/>
</InputGroup>
{formikError?.selectedConfiguration && (

View File

@ -144,6 +144,7 @@ export function PersistedFolderItem({
applicationValues.Containers.length > 1
}
data-cy={`k8sAppCreate-persistentFolderSizeUnitSelect_${index}`}
id={`k8sAppCreate-persistentFolderSizeUnitSelect_${index}`}
/>
</InputGroup>
{formikError?.size && <FormError>{formikError?.size}</FormError>}
@ -175,6 +176,7 @@ export function PersistedFolderItem({
storageClasses.length <= 1
}
data-cy={`k8sAppCreate-storageSelect_${index}`}
id={`k8sAppCreate-storageSelect_${index}`}
/>
</InputGroup>
</>
@ -207,6 +209,7 @@ export function PersistedFolderItem({
availableVolumes.length < 1
}
data-cy={`k8sAppCreate-pvcSelect_${index}`}
id={`k8sAppCreate-pvcSelect_${index}`}
/>
</InputGroup>
)}

View File

@ -49,6 +49,7 @@ export function PlacementItem({
className={clsx({ striked: !!item.needsDeletion })}
isDisabled={!!item.needsDeletion}
data-cy={`k8sAppCreate-placementLabel_${index}`}
id={`k8sAppCreate-placementLabel_${index}`}
/>
{placementError?.label && (
<FormError>{placementError.label}</FormError>
@ -65,6 +66,7 @@ export function PlacementItem({
className={clsx({ striked: !!item.needsDeletion })}
isDisabled={!!item.needsDeletion}
data-cy={`k8sAppCreate-placementName_${index}`}
id={`k8sAppCreate-placementName_${index}`}
/>
{placementError?.value && (
<FormError>{placementError.value}</FormError>

View File

@ -35,6 +35,7 @@ export function StorageAccessModeSelector({
inputId={inputId}
placeholder="Not configured"
data-cy={`kubeSetup-storageAccessSelect${storageClassName}`}
id={`kubeSetup-storageAccessSelect${storageClassName}`}
/>
);
}

View File

@ -43,6 +43,7 @@ export function NamespacesSelector({
onChange(selectedTeams.map((namespace) => namespace.name))
}
data-cy={dataCy}
id={dataCy}
inputId={inputId}
placeholder={placeholder}
/>

View File

@ -184,6 +184,7 @@ export function IngressForm({
}
noOptionsMessage={() => 'No namespaces available'}
data-cy="k8sAppCreate-namespaceSelect"
id="k8sAppCreate-namespaceSelect"
/>
)}
</div>
@ -266,6 +267,7 @@ export function IngressForm({
}
noOptionsMessage={() => 'No ingress classes available'}
data-cy="k8sAppCreate-ingressClassSelect"
id="k8sAppCreate-ingressClassSelect"
/>
{errors.className && (
<FormError className="error-inline mt-1">
@ -464,6 +466,7 @@ export function IngressForm({
noOptionsMessage={() => 'No TLS secrets available'}
size="sm"
data-cy={`k8sAppCreate-tlsSelect_${hostIndex}`}
id={`k8sAppCreate-tlsSelect_${hostIndex}`}
/>
{!host.NoHost && (
<div className="input-group-btn">

View File

@ -35,6 +35,7 @@ export function NamespaceAccessUsersSelector({
closeMenuOnSelect={false}
onChange={onChange}
data-cy={dataCy}
id={dataCy}
inputId={inputId}
placeholder={placeholder}
components={{ MultiValueLabel, Option: OptionComponent }}

View File

@ -67,6 +67,7 @@ export function RegistriesSelector({
onChange={onChange}
inputId={inputId}
data-cy="namespaceCreate-registrySelect"
id="namespaceCreate-registrySelect"
placeholder="Select one or more registries"
isDisabled={isEditingDisabled}
/>

View File

@ -37,6 +37,7 @@ export function PorAccessManagementUsersSelector({
closeMenuOnSelect={false}
onChange={onChange}
data-cy="component-selectUser"
id="component-selectUser"
inputId="users-selector"
placeholder="Select one or more users and/or teams"
components={{ MultiValueLabel, Option: OptionComponent }}

View File

@ -30,7 +30,7 @@ export function TeamsField({
'You can select which team(s) will be able to manage this resource.'
: undefined
}
inputId="teams-selector"
inputId="authorized-teams-selector"
errors={errors}
>
{teams.length > 0 ? (
@ -39,7 +39,7 @@ export function TeamsField({
teams={teams}
onChange={onChange}
value={value}
inputId="teams-selector"
inputId="authorized-teams-selector"
dataCy="teams-selector"
/>
) : (

View File

@ -21,7 +21,7 @@ export function UsersField({ name, users, value, onChange, errors }: Props) {
? 'You can select which user(s) will be able to manage this resource.'
: undefined
}
inputId="users-selector"
inputId="authorized-users-selector"
errors={errors}
>
{users.length > 0 ? (
@ -30,7 +30,7 @@ export function UsersField({ name, users, value, onChange, errors }: Props) {
users={users}
onChange={onChange}
value={value}
inputId="users-selector"
inputId="authorized-users-selector"
dataCy="users-selector"
/>
) : (

View File

@ -26,6 +26,7 @@ export function PorAccessControlFormTeamSelector({
closeMenuOnSelect={false}
onChange={onChange}
data-cy="portainer-selectTeamAccess"
id="portainer-selectTeamAccess"
inputId={inputId}
placeholder="Select one or more teams"
/>

View File

@ -26,6 +26,7 @@ export function PorAccessControlFormUserSelector({
closeMenuOnSelect={false}
onChange={onChange}
data-cy="portainer-selectUserAccess"
id="portainer-selectUserAccess"
inputId={inputId}
placeholder="Select one or more users"
/>

View File

@ -112,6 +112,7 @@ export function TimeWindowPickerInputGroup({
onChangeTimeZone(newTimeZone.value);
}}
data-cy="time-window-picker-timezone-select"
id="time-window-picker-timezone-select"
/>
</div>
{errors?.StartTime && <FormError>{errors.StartTime}</FormError>}

View File

@ -54,6 +54,7 @@ export function EdgeGroupsField({
closeMenuOnSelect={false}
isDisabled={disabled}
data-cy="update-schedules-edge-groups-select"
id="update-schedules-edge-groups-select"
/>
</FormControl>
<TextTip color="blue">

View File

@ -41,6 +41,7 @@ export function CredentialSelector({
noOptionsMessage={() => 'no saved credentials'}
inputId="git-creds-selector"
data-cy="git-credentials-selector"
id="git-credentials-selector"
/>
</FormControl>
</div>