Skip to content

Add onError handler #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Oct 26, 2021
Merged

Add onError handler #6

merged 16 commits into from
Oct 26, 2021

Conversation

benogle
Copy link
Contributor

@benogle benogle commented Oct 22, 2021

Adds an onError handler to both components. It will emit the following payload

{
  action: "signerError",
  documentGroupEid: "jxvp0Z9OJeafwJdCnfsP",
  documentGroupStatus: "sent",
  error: "Token Expired",
  errorType: "tokenExpired",
  etchPacketEid: "tkpEqbyzIM1IMsFEW1JU",
  message: "Please contact the Workflow administrator to get a new link.",
  signerEid: "Pu7NW1y0BewNIIlFtuR1",
  signerStatus: "sent",
}

This PR also adds

  • A test harness and tests for the handling of the postMessage from the iframe.
  • Auto generation of a CHANGELOG.md in each package

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Comment on lines 40 to 49
it('does not call any callbacks when a string data passed in', async function () {
const origin = $.anvilURL
const data = { action: 'signerComplete' }
const wrapper = $.render
wrapper.instance().handleSignFinish({ origin, data })
expect($.handleLoad).not.to.have.been.called
expect($.handleError).not.to.have.been.called
expect($.handleFinish).not.to.have.been.called
expect($.handleFinishSigning).not.to.have.been.called
})
Copy link
Contributor

@Winggo Winggo Oct 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be does not call any callbacks when non-string data is passed in I believe

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated

Comment on lines +33 to +41
const payload = omit(parseURLParams(searchStr), IGNORED_KEYS)
const hasError = payload.action === 'signerError' || payload.error || payload.errorType
if (!payload.action) {
payload.action = hasError ? 'signerError' : 'signerComplete'
}
if (hasError) {
onError(payload)
} else {
searchObj = JSON.parse('{"' + decodeURI(searchStr).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}')
hasError = searchObj.error || searchObj.errorType
payload = {
action: 'signerComplete',
signerStatus: searchObj.signerStatus ?? null,
signerEid: searchObj.signerEid ?? null,
nextSignerEid: searchObj.nextSignerEid ?? null,
documentGroupStatus: searchObj.documentGroupStatus ?? null,
documentGroupEid: searchObj.documentGroupEid ?? null,
etchPacketEid: searchObj.etchPacketEid ?? null,
weldDataEid: searchObj.weldDataEid ?? null,
}
onFinishSigning(payload)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So much cleaner with the helpers

Copy link
Contributor

@Winggo Winggo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lookin good to me!

@benogle benogle self-assigned this Oct 26, 2021
@benogle benogle merged commit fbc0a96 into main Oct 26, 2021
@benogle benogle deleted the bo/on-error branch October 26, 2021 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants