Skip to content

Commit

Permalink
Merge pull request #142 from triwav/update_readme_and_do_conditional_…
Browse files Browse the repository at this point in the history
…field_set

Update readme with contributing and getting help info, allow passing field to onFieldChangeOnce
  • Loading branch information
triwav authored Aug 16, 2024
2 parents 428639f + eef33f3 commit 7f7d0f6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@

Roku Test Automation (RTA from here on out) helps with automating functional tests for Roku devices. It has quite a bit more capabilities than [Roku's first party option](https://developer.roku.com/docs/developer-program/dev-tools/automated-channel-testing/automated-testing-overview.md) and does not require a Go server in the middle to convert ECP commands.

## Contributing & Getting Help

There is always more things that we would like to add than we have time for. If you would like to help contribute the best spot to reach out is in the [Roku Developers Slack](https://join.slack.com/t/rokudevelopers/shared_invite/zt-4vw7rg6v-NH46oY7hTktpRIBM_zGvwA). (We're in the #rta channel). If you are having trouble getting RTA working feel free to reach out there as well. If you see an issue or would like to see something added then feel free to [create a new Github Issue](https://github.com/triwav/roku-test-automation/issues/new)

## v2.0 Changes

Some incompatibility changes were made in v2.0. These include:
Expand Down
18 changes: 9 additions & 9 deletions client/src/OnDeviceComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,7 @@ export class OnDeviceComponent {

args.convertResponseToJsonCompatible = false;

let result: ODC.RequestResponse;
if (args.field !== undefined) {
result = await this.sendRequest(ODC.RequestType.setValue, args, options);
} else {
result = await this.sendRequest(ODC.RequestType.setValue, this.breakOutFieldFromKeyPath(args), options);
}
const result = await this.sendRequest(ODC.RequestType.setValue, this.breakOutFieldFromKeyPath(args), options);

return result.json as ODC.ReturnTimeTaken;
}
Expand Down Expand Up @@ -733,12 +728,17 @@ export class OnDeviceComponent {


// In some cases it makes sense to break out the last key path part as `field` to simplify code on the device
private breakOutFieldFromKeyPath(args: ODC.CallFuncArgs | ODC.OnFieldChangeOnceArgs | ODC.SetValueArgs) {
private breakOutFieldFromKeyPath(args: ODC.OnFieldChangeOnceArgs | ODC.SetValueArgs) {
if (!args.keyPath) {
args.keyPath = '';
}
const keyPathParts = args.keyPath.split('.');
return {...args, field: keyPathParts.pop(), keyPath: keyPathParts.join('.')};

if (args.field === undefined) {
const keyPathParts = args.keyPath.split('.');
return {...args, field: keyPathParts.pop(), keyPath: keyPathParts.join('.')};
}

return args;
}

private setupClientSocket(options: ODC.RequestOptions) {
Expand Down
3 changes: 3 additions & 0 deletions client/src/types/OnDeviceComponent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,9 @@ export interface OnFieldChangeOnceArgs extends BaseKeyPath {
/** If the `keyPath` does not exist yet, this specifies how long to wait before erroring out in milliseconds */
retryTimeout?: number;

/** The field that we want to observe for changes on. If not supplied, the last part of `keyPath` will be */
field?: string;

/** If provided will only return when this matches (including if it already equals that value) */
match?: MatchObject | ComparableValueTypes;
}
Expand Down

0 comments on commit 7f7d0f6

Please sign in to comment.