← Back to team overview

launchpad-dev team mailing list archive

Re: Javascript learnings #1: YUI tests

 

Hi,

On Thu, Apr 14, 2011 at 2:16 AM, Ian Booth <ian.booth@xxxxxxxxxxxxx> wrote:
>>> You really only need Windmill when you want to check
>>> that data sent from the client is correctly stored/processed on the
>>> server side, not simply to check that the ui updates after a user
>>> initiated action.
>>
>> By "user-initiated action", do you you mean simulating mouse clicks?  I
>> would have though you'd be testing callbacks rather than the actual UI.
>
> Yes, simulating mouse clicks. Think of it as black box testing. Often
> the callbacks are not exposed and accessible to the test harness and you
> want to see that all the internal wiring of handlers and callbacks is
> correct and the DOM is properly updated (the output) in response to a
> user action (the input), albeit short circuiting that aspect of the
> interaction that occurs outside the component under test.

You can simulate clicks with Y.Event.simulate.  You need to pass it
the DOM node and the name of the event you want to simulate.  There's
a helper to make it more friendly, by accepting CSS selectors and Node
instances, in the Landscape code base.  You can find the relevant code
by grepping for 'simulate' in $landscape/canonical/landscape/javascript.

It's used heavily in the Landscape unit tests.  It's especially useful
for testing custom widgets.

Thanks,
J.



Follow ups

References