Skip to content

Commit

Permalink
refactor: change name from Anchors to RelationsForConvenienceMethods;…
Browse files Browse the repository at this point in the history
… Refactor TypeScript-Doctype
  • Loading branch information
JohannesDienst-askui committed Apr 12, 2024
1 parent c791274 commit 72c9518
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 30 deletions.
2 changes: 1 addition & 1 deletion packages/askui-nodejs/src/execution/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { UiControlClient, Anchor as Anchors } from './ui-control-client';
export { UiControlClient, RelationsForConvenienceMethods } from './ui-control-client';
57 changes: 29 additions & 28 deletions packages/askui-nodejs/src/execution/ui-control-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { ClientArgs } from './ui-controller-client-interface';
import { UiControlClientDependencyBuilder } from './ui-control-client-dependency-builder';
import { Instruction, StepReporter } from '../core/reporting';

export type Anchor = 'nearestTo' | 'leftOf' | 'above' | 'rightOf' | 'below' | 'contains';
export type RelationsForConvenienceMethods = 'nearestTo' | 'leftOf' | 'above' | 'rightOf' | 'below' | 'contains';

export class UiControlClient extends ApiCommands {
private constructor(
Expand Down Expand Up @@ -351,11 +351,11 @@ export class UiControlClient extends ApiCommands {
// eslint-disable-next-line class-methods-use-this
private evaluateRelation(
command: FluentFiltersOrRelations,
position: Anchor,
relation: RelationsForConvenienceMethods,
text: string,
) {
let commando = command;
switch (position) {
switch (relation) {
case 'nearestTo':
commando = command.nearestTo().text(text);
break;
Expand All @@ -375,7 +375,7 @@ export class UiControlClient extends ApiCommands {
commando = command.contains().text(text);
break;
default:
throw new ValidationError('No valid Position.Type was passed.');
throw new ValidationError('No valid Relation.Type was passed.');
}
return commando;
}
Expand All @@ -396,14 +396,14 @@ export class UiControlClient extends ApiCommands {
* @property {string} [params.label] - The text label of the button. Defaults to an empty string.
* @property {Object} [params.relation] - Object describing the relationship between
* the clicked button and another element.
* @property {Anchor} params.relation.type - The type of relation.
* @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
* @property {string} params.relation.text - The text element the relation is based on.
*/
async clickButton(
params: {
label?: string,
relation?: {
type: Anchor,
type: RelationsForConvenienceMethods,
text: string
}
},
Expand Down Expand Up @@ -434,15 +434,15 @@ export class UiControlClient extends ApiCommands {
* @param {Object} params - Object containing required `label` property and
* optional `relation` property.
* @property {string} params.label - The label for the checkbox.
* @property {Object} [params.relation] - Object describing the relationship between
* the clicked checkbox and another element.
* @property {Anchor} params.relation.type - The type of relation.
* @property {Object} params.relation - Object describing the relationship between
* the clicked checkbox and another element.
* @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
*/
async clickCheckbox(
params: {
label: string,
relation?: {
type: Anchor
type: RelationsForConvenienceMethods
}
},
) {
Expand Down Expand Up @@ -470,15 +470,15 @@ export class UiControlClient extends ApiCommands {
* @param {Object} params - Object containing required `label` property and
* optional `relation` property.
* @property {string} params.label - The label for the checkbox.
* @property {Object} [params.relation] - Object describing the relationship between
* the clicked checkbox and another element.
* @property {Anchor} params.relation.type - The type of relation.
* @property {Object} params.relation - Object describing the relationship between
* the clicked checkbox and another element.
* @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
*/
async clickSwitch(
params: {
label: string,
relation?: {
type: Anchor
type: RelationsForConvenienceMethods
}
},
) {
Expand Down Expand Up @@ -522,15 +522,16 @@ export class UiControlClient extends ApiCommands {
* @property {string} params.textToWrite - The text to be typed into the textfield.
* @property {Object} params.relation - Object describing the relationship between the
* textfield being interacted with and another element.
* @property {Anchor} [params.relation.type] - The type of relation, optional.
* @property {RelationsForConvenienceMethods} params.relation.type - The type of
* relation, optional.
* @property {string} params.relation.label - The label associated with the related
* element, optional.
*/
async typeIntoTextfield(
params: {
textToWrite: string,
relation: {
type?: Anchor,
type?: RelationsForConvenienceMethods,
label: string
}
},
Expand Down Expand Up @@ -561,20 +562,19 @@ export class UiControlClient extends ApiCommands {
*
* // Click the text 'TERMINAL' that is left of the text 'Ports'
* await aui.clickText({
* text: 'TERMINAL',
* type: "exact",
* relation: {type: 'leftOf', text: 'PORTS'}})
* text: 'TERMINAL',
* type: "exact",
* relation: { type: 'leftOf', text: 'PORTS' }
* })
* ```
* @param {Object} params - Object containing required `text` property and optional properties
* for regular expression matching and relation.
* @property {string} params.text - The text to be clicked.
* @property {boolean} [params.regex=false] - Whether the text is matched using a regular
* expression, default is false.
* @property {boolean} [params.exact=false] - Whether an exact match of the text is required
* when using regex, default is false.
* @property {Object} [params.relation] - Object describing the relationship between the
* clicked text and another element.
* @property {Anchor} params.relation.type - The type of relation.
* @property {string} params.type - Whether the text is matched using similarity,
* exact match or a regular expression.
* @property {Object} params.relation - Object describing the relationship between the
* clicked text and another element.
* @property {RelationsForConvenienceMethods} params.relation.type - The type of relation.
* @property {string} params.relation.text - The label or text associated with the
* related element or state.
*/
Expand All @@ -583,8 +583,9 @@ export class UiControlClient extends ApiCommands {
text: string,
type: 'similar' | 'exact' | 'regex',
relation?: {
type: Anchor,
text: string }
type: RelationsForConvenienceMethods,
text: string
}
},
) {
let command = this.click().text();
Expand Down
2 changes: 1 addition & 1 deletion packages/askui-nodejs/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export { UiController } from './lib';
export { UiControlClient, Anchors } from './execution';
export { UiControlClient, RelationsForConvenienceMethods } from './execution';
export {
Instruction,
Reporter,
Expand Down

0 comments on commit 72c9518

Please sign in to comment.