Skip to content

Commit

Permalink
report only modified options in reportActionDone(closes DevExpress#4926)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexKamaev committed Mar 30, 2020
1 parent 34bce8d commit f30b52e
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/reporter/command/command-formatter.ts
Expand Up @@ -2,6 +2,8 @@ import { ExecuteSelectorCommand, ExecuteClientFunctionCommand } from '../../test
import { NavigateToCommand, SetNativeDialogHandlerCommand, UseRoleCommand } from '../../test-run/commands/actions';
import { createReplicator, SelectorNodeTransform } from '../../client-functions/replicator';
import { Command, FormattedCommand, SelectorInfo } from './interfaces';
import { ActionOptions } from '../../test-run/commands/options';
import diff from '../../utils/diff';

export class CommandFormatter {
private _elements: HTMLElement[] = [];
Expand Down Expand Up @@ -95,6 +97,12 @@ export class CommandFormatter {

if (prop instanceof ExecuteSelectorCommand)
formattedCommand[key] = this._prepareSelector(prop, key);
else if (prop instanceof ActionOptions) {
// @ts-ignore
const props = new prop.constructor();

formattedCommand[key] = diff(props, prop);
}
else
formattedCommand[key] = prop;
});
Expand Down
28 changes: 28 additions & 0 deletions src/utils/diff.ts
@@ -0,0 +1,28 @@
import { Dictionary } from '../configuration/interfaces';

function diff (object1: Dictionary<any>, object2: Dictionary<any>, result: Dictionary<any> = {}): Dictionary<any> {
for (const prop in object1) {
const value1 = object1[prop];
const value2 = object2[prop];

if (value1 !== value2) {
if (typeof value1 === 'object' && typeof value2 === 'object') {
result[prop] = {};

diff(value1 as Dictionary<object>, value2 as Dictionary<object>, result[prop]);
}
else
result[prop] = value2;
}
}

return result;
}

export default (object1: Dictionary<any>, object2: Dictionary<any>) => {
const result = {};

diff(object1, object2, result);

return result;
};

0 comments on commit f30b52e

Please sign in to comment.