chore(data-cy): add test attributes for test automation [XT-1188]

pull/11395/head
testa113 2024-03-19 09:03:36 +13:00
parent bd3440bf3c
commit eea5543c61
16 changed files with 28 additions and 3 deletions

View File

@ -97,7 +97,7 @@
</div> </div>
<div class="table-responsive"> <div class="table-responsive">
<table class="table-hover nowrap-cells table"> <table class="table-hover nowrap-cells table" data-cy="k8sNamespace-namespaceTable">
<thead> <thead>
<tr> <tr>
<th class="dropdown"> <th class="dropdown">

View File

@ -49,6 +49,7 @@
ng-model="ctrl.formValues.Namespace" ng-model="ctrl.formValues.Namespace"
ng-change="ctrl.onChangeNamespace()" ng-change="ctrl.onChangeNamespace()"
ng-options="namespace.Name as namespace.Name for namespace in ctrl.namespaces" ng-options="namespace.Name as namespace.Name for namespace in ctrl.namespaces"
data-cy="k8sAppCreate-nsSelect"
></select> ></select>
<span ng-if="ctrl.formValues.namespace_toggle && ctrl.state.BuildMethod !== ctrl.BuildMethods.HELM" class="small text-muted pt-[7px]" <span ng-if="ctrl.formValues.namespace_toggle && ctrl.state.BuildMethod !== ctrl.BuildMethods.HELM" class="small text-muted pt-[7px]"
>Namespaces specified in the manifest will be used</span >Namespaces specified in the manifest will be used</span

View File

@ -13,7 +13,6 @@
remove-action="ctrl.removeAction" remove-action="ctrl.removeAction"
refresh-callback="ctrl.getResourcePools" refresh-callback="ctrl.getResourcePools"
endpoint="ctrl.endpoint" endpoint="ctrl.endpoint"
data-cy="k8sNamespace-namespaceTable"
></kubernetes-resource-pools-datatable> ></kubernetes-resource-pools-datatable>
</div> </div>
</div> </div>

View File

@ -34,6 +34,7 @@ export function InputSearch({
onChange={onChange} onChange={onChange}
placeholder={placeholder} placeholder={placeholder}
inputId={inputId} inputId={inputId}
data-cy="component-imageConfigInputSearch"
/> />
); );
} }

View File

@ -171,6 +171,7 @@ export function Datatable<D extends DefaultType>({
return ( return (
<Table.Container noWidget={noWidget} aria-label={title}> <Table.Container noWidget={noWidget} aria-label={title}>
<DatatableHeader <DatatableHeader
data-cy={dataCy}
onSearchChange={handleSearchBarChange} onSearchChange={handleSearchBarChange}
searchValue={settings.search} searchValue={settings.search}
title={title} title={title}

View File

@ -14,6 +14,7 @@ type Props = {
renderTableActions?(): ReactNode; renderTableActions?(): ReactNode;
description?: ReactNode; description?: ReactNode;
titleId?: string; titleId?: string;
'data-cy'?: string;
}; };
export function DatatableHeader({ export function DatatableHeader({
@ -25,12 +26,19 @@ export function DatatableHeader({
titleIcon, titleIcon,
description, description,
titleId, titleId,
'data-cy': dataCy,
}: Props) { }: Props) {
if (!title) { if (!title) {
return null; return null;
} }
const searchBar = <SearchBar value={searchValue} onChange={onSearchChange} />; const searchBar = (
<SearchBar
value={searchValue}
onChange={onSearchChange}
data-cy={`${dataCy}-searchInput`}
/>
);
const tableActions = !!renderTableActions && ( const tableActions = !!renderTableActions && (
<Table.Actions>{renderTableActions()}</Table.Actions> <Table.Actions>{renderTableActions()}</Table.Actions>
); );

View File

@ -23,6 +23,7 @@ export function AutocompleteSelect({
searchResults, searchResults,
readOnly, readOnly,
inputId, inputId,
'data-cy': dataCy,
}: { }: {
value: string; value: string;
/** /**
@ -35,6 +36,7 @@ export function AutocompleteSelect({
searchResults?: Option<string>[]; searchResults?: Option<string>[];
readOnly?: boolean; readOnly?: boolean;
inputId: string; inputId: string;
'data-cy': string;
}) { }) {
const [searchTerm, setSearchTerm] = useDebounce(value, onChange); const [searchTerm, setSearchTerm] = useDebounce(value, onChange);
const [selected, setSelected] = useState(false); const [selected, setSelected] = useState(false);
@ -53,6 +55,7 @@ export function AutocompleteSelect({
placeholder={placeholder} placeholder={placeholder}
readOnly={readOnly} readOnly={readOnly}
id={inputId} id={inputId}
data-cy={dataCy}
autoComplete="off" autoComplete="off"
/> />
{!selected && searchResults && searchResults.length > 0 && ( {!selected && searchResults && searchResults.length > 0 && (

View File

@ -71,6 +71,7 @@ export function StackName({
onChange={setStackName} onChange={setStackName}
placeholder="e.g. myStack" placeholder="e.g. myStack"
inputId="stack_name" inputId="stack_name"
data-cy="component-stackNameInput"
/> />
</div> </div>
</div> </div>

View File

@ -66,6 +66,7 @@ export function ComposePathField({
placeholder={isCompose ? 'docker-compose.yml' : 'manifest.yml'} placeholder={isCompose ? 'docker-compose.yml' : 'manifest.yml'}
model={model} model={model}
inputId="stack_repository_path" inputId="stack_repository_path"
data-cy="component-gitPathInput"
createdFromCustomTemplateId={createdFromCustomTemplateId} createdFromCustomTemplateId={createdFromCustomTemplateId}
/> />
) : ( ) : (
@ -76,6 +77,7 @@ export function ComposePathField({
}} }}
placeholder={isCompose ? 'docker-compose.yml' : 'manifest.yml'} placeholder={isCompose ? 'docker-compose.yml' : 'manifest.yml'}
id="stack_repository_path" id="stack_repository_path"
data-cy="component-gitPathInput"
/> />
)} )}
</FormControl> </FormControl>

View File

@ -13,6 +13,7 @@ export function PathSelector({
dirOnly, dirOnly,
readOnly, readOnly,
inputId, inputId,
'data-cy': dataCy,
createdFromCustomTemplateId, createdFromCustomTemplateId,
}: { }: {
value: string; value: string;
@ -22,6 +23,7 @@ export function PathSelector({
dirOnly?: boolean; dirOnly?: boolean;
readOnly?: boolean; readOnly?: boolean;
inputId: string; inputId: string;
'data-cy': string;
createdFromCustomTemplateId?: number; createdFromCustomTemplateId?: number;
}) { }) {
const creds = getAuthentication(model); const creds = getAuthentication(model);
@ -50,6 +52,7 @@ export function PathSelector({
placeholder={placeholder} placeholder={placeholder}
readOnly={readOnly} readOnly={readOnly}
inputId={inputId} inputId={inputId}
data-cy={dataCy}
/> />
); );
} }

View File

@ -75,6 +75,7 @@ export function RefField({
value={inputValue} value={inputValue}
onChange={(e) => updateInputValue(e.target.value)} onChange={(e) => updateInputValue(e.target.value)}
placeholder="refs/heads/main" placeholder="refs/heads/main"
data-cy="component-gitRefInput"
/> />
</Wrapper> </Wrapper>
); );

View File

@ -187,6 +187,7 @@ export function RelativePathFieldset({
readOnly={isEditing} readOnly={isEditing}
dirOnly dirOnly
inputId="per_device_configs_path_input" inputId="per_device_configs_path_input"
data-cy="component-perDeviceConfigsPathInput"
/> />
</FormControl> </FormControl>
</div> </div>

View File

@ -28,6 +28,7 @@ export function HelmSection() {
<Field <Field
as={Input} as={Input}
id="helm-repo-url" id="helm-repo-url"
data-cy="helm-repo-url"
name={name} name={name}
placeholder="https://charts.bitnami.com/bitnami" placeholder="https://charts.bitnami.com/bitnami"
/> />

View File

@ -38,6 +38,7 @@ export function KubeConfigSection() {
value={value} value={value}
options={options} options={options}
onChange={(value) => value && setValue(value)} onChange={(value) => value && setValue(value)}
inputId="kubeconfig-expiry-select"
/> />
</FormControl> </FormControl>
</FormSection> </FormSection>

View File

@ -61,6 +61,7 @@ export function KubeSettingsPanel({ settings }: { settings: Settings }) {
isLoading={mutation.isLoading} isLoading={mutation.isLoading}
loadingText="Saving" loadingText="Saving"
className="!ml-0" className="!ml-0"
data-cy="save-kubernetes-settings-button"
> >
Save Kubernetes settings Save Kubernetes settings
</LoadingButton> </LoadingButton>

View File

@ -52,6 +52,7 @@ export function TeamMembersList({ users, roles, disabled, teamId }: Props) {
return ( return (
<RowProvider context={rowContext}> <RowProvider context={rowContext}>
<Datatable<User> <Datatable<User>
data-cy="team-members-table"
dataset={users} dataset={users}
columns={columns} columns={columns}
titleIcon={Users} titleIcon={Users}