interactors icon indicating copy to clipboard operation
interactors copied to clipboard

Update Action wrappers to make sure they can represent any interactor

Open cowboyd opened this issue 3 years ago • 8 comments

In order to integrate with the storybook debugger, we need to be able to represent interactors in code form and not just in text description form. Currently, an interactor sequence such as

async function play() {
  await TextField('Username').fillIn('cowboyd');
  await TextField('Password').fillIn('secure-password');
}

will be rendered in storybook as:

  1. fill in "cowboyd" into the textfield "Username"
  2. fill in "secure-password" into the textfield "Password"

That's because the current facilities to generate a textual representation of interactors is optimized for rendering user-readable errors inside the test failure output. However, we want to be able to render the interaction as close to code as possible, so that the storybook output looks like:

  1. TextField('Username').fillIn('cowboyd');
  2. TextField('Password').fillIn('secure-password');

This issue is set up to track that we have the pieces in place to do this:

  • [ ] print the interactor constructor, the locator and filters, and action name along with arguments.
  • [ ] represent hiearchies of interactors
  • [ ] print matchers as code instead of descriptions

cowboyd avatar Nov 19 '21 11:11 cowboyd

Also, I think we'll need to be able to remove a wrapper too right?

cowboyd avatar Nov 19 '21 11:11 cowboyd

@cowboyd What wrapper do you mean?

wKich avatar Nov 22 '21 14:11 wKich

@wKich I'm referring to the action wrapper and that it receives enough information to render the storybook step.

cowboyd avatar Nov 22 '21 15:11 cowboyd

But why do we need to be able to remote it?

wKich avatar Nov 24 '21 10:11 wKich

I'm not sure what you mean by remote it?

cowboyd avatar Nov 24 '21 12:11 cowboyd

I mean that you said Also, I think we'll need to be able to remove a wrapper too right? Why do we need to remote it?

wKich avatar Nov 24 '21 13:11 wKich

Ah yes, remove, not "remote".

The answer is flexibility and embeddability. If we don't have the ability to remove it, then we cannot safely use it at any other scope other than the global scope. For example, it lets us scope the action wrapper to the context of the storybook interaction.

onPlay((step, signal) => {
  let remove = addActionWrapper(createWrapper(step));
  signal.addEventListener('abort', remove);
})

cowboyd avatar Nov 24 '21 14:11 cowboyd

Oh, sorry. I didn't notice, that I did a typo :)

wKich avatar Nov 26 '21 05:11 wKich