Skip to content
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

Feature-Request: Add body() method #57

Open
hepiyellow opened this issue Mar 28, 2019 · 4 comments
Open

Feature-Request: Add body() method #57

hepiyellow opened this issue Mar 28, 2019 · 4 comments
Labels
enhancement New feature or request good first issue Good for newcomers OSSGoodnessSquad

Comments

@hepiyellow
Copy link
Contributor

hepiyellow commented Mar 28, 2019

In all platforms (adapter), there is a body.
But in each platform getting the body element is different.

Some component, render stuff to the body (Modals, Popovers with Portal), and need to expose drivers that can query the body, and abstract inner implementation.

@GabiGrin Is this legitimate?

@hepiyellow hepiyellow added the enhancement New feature or request label Mar 28, 2019
@jonathanadler
Copy link

+1

@GabiGrin
Copy link
Contributor

@jonathanadler what's your use case?
isn't this feasible for modals / popovers?

@jonathanadler
Copy link

@jonathanadler what's your use case?
isn't this feasible for modals / popovers?

@GabiGrin !! how are you feeling?? 😁

So yeah, actually we're using this pattern, but as I understand we need to pass "theOuterWorld" driver ourselves.
I guess my thought was, that instead of wrapping the body in a Unidriver in each library, it could be something we get from this library as a helper.

@jonathanadler
Copy link

@GabiGrin

The use-case for this is when one driver uses another driver that accepts an outerWorld.

For instance, if we have an input component that has a tooltip, and we want to have a getTooltipContent method in the input driver.
What we would like to do is use the Tooltip's already existing driver (which accepts theOuterWorld), in order to get its content.
This means that the input will also need to accept theOuterWorld unidriver.
But that's something we would prefer to not expose to our consumers.

To put it in code, it would look like this:

export const inputDriver = (wrapper: UniDriver, theOuterWorld: UniDriver) => {
  const tooltipDriver = createTooltipDriver(wrapper.$('tooltipSelector').getNative(), theOuterWorld);
  return {
    ...
    getTooltipContent() {
      return tooltipDriver.getContent();
    }
    ...
  }
}

This means our consumers will need to create a "body" unidriver when they use our testkits.
(what we actually do is we pre-wrap our testkits with theOuterWorld driver, which means we effectively create a "body" unidriver for all our testkits).

I think the body is pretty much a constant and can be reached in all environments
So I really think that this can be very useful to maintain one in this library.

In addition, these types of components usually use a portal which is outside of the wrapper element passed to the driver.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers OSSGoodnessSquad
Projects
None yet
Development

No branches or pull requests

3 participants