Skip to content
This repository has been archived by the owner on Jul 14, 2020. It is now read-only.

Complex nested interactor functions do not work as expected #9

Closed
wwilsman opened this issue Apr 20, 2018 · 0 comments
Closed

Complex nested interactor functions do not work as expected #9

wwilsman opened this issue Apr 20, 2018 · 0 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@wwilsman
Copy link
Contributor

wwilsman commented Apr 20, 2018

Given these interactors:

@interactor class SignInInteractor {
  fillName = fillable('[data-test-name-input]')
  fillEmail = fillable('[data-test-email-input]')
  submit = clickable('[data-test-submit]')
  fillAndSubmit(name, email) {
    return this
      .fillName(name)
      .fillEmail(email)
      .submit()
  }
}

@interactor class PageInteractor {
  signInForm = new SignInInteractor('[data-test-signin-form]')
}

I would expect this to work:

new PageInteractor()
  .signInForm.fillAndSubmit('Wil', 'wil@frontside.io')

But instead, an error is throw that might look like this:

PageInteractor.fillEmail is not a function

This is because when an interactor is nested, it's methods return new instances of the parent interactor. So fillName() in SignInInteractor will return a new PageInteractor.

We should have a way to break out of this nested structure for complex methods such as this. Something like this.pure(), this.scoped(), or something akin to return an un-nested interactor.

@wwilsman wwilsman added bug Something isn't working enhancement New feature or request labels Apr 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant