Add operators to all field check steps
Closed this issue · 0 comments
iamEAP commented
Problem / Motivation
Currently, field check steps on all objects are limited to simply evaluating equality; it's not possible to make any other assertions about the state of records/objects in the system. This is especially problematic on date fields.
In order to support more test cases, we should add an operator
field to all field check steps.
In particular, we should support the following operators:be
, not be
, contain
, not contain
, be greater than
, be less than
Scope / UAT Target
The following should hold true for all currently supported Salesforce Objects:
-
account
-
campaign member
-
contact
-
lead
-
opportunity
- There should be an
operator
field (typestring
) listed between thefield
andexpectedValue
fields. - The
operator
field should be markedoptional
(for backward compatibility) - The
operator
field description should readCheck Logic (be, not be, contain, not contain, be greater than, or be less than)
- The step text should be modified so that
should be
is replaced withshould (?<operator>be less than|be greater than|be|contain|not be|not contain)
- Field check evaluation logic should follow the following guidelines:
-
be
should map to what happens currently (==
) -
not be
should map to!=
-
contain
should cast both values tostring
can call.includes()
-
not contain
should cast both values tostring
and call! .includes()
-
be greater than
should map to>
- For values which conform to a
date
(e.g.YYYY-MM-DD
format), values should be converted tomoment.js
dates and compared using Moment().isBefore() or.isAfter()
- For values which conform to a
datetime
(e.g.YYYY-MM-DDTHH:mm:ss
), values should be converted tomoment.js
dates and compared using.isBefore()
orisAfter()
- For numeric values, if necessary, both values should be cast to numbers (could be
int
orfloat
) before comparison - If either value is non-numeric or does not map to a
date
ordatetime
format, an error should be thrown.
- For values which conform to a
-
- If a step is executed with no
operator
value, it should assume the logic forbe
(==
)
Proposed Resolution
We may want to centralize field comparison logic in a method on the BaseStep
so that any step could just call this.compare(operator, field, value)
Sample UAT scenarios:
scenario: Backwards Compatibility Test
description: Proves that field check steps can still be run without an operator provided.
tokens:
test.email: lead-operator-bc@automatoninc.com
test.name: Atoma
steps:
- step: create a salesforce lead
data:
lead:
Email: '{{test.email}}'
FirstName: '{{test.name}}'
- cog: automatoninc/salesforce
stepId: LeadFieldEquals
data:
email: '{{test.email}}'
field: FirstName
expectedValue: '{{test.name}}'
# Note: operator is ommitted.
- step: delete the {{test.email}} salesforce lead