serenity-js / serenity-js

A next generation, full-stack acceptance testing framework optimised for collaboration, speed and scale!
https://serenity-js.org
Apache License 2.0
563 stars 162 forks source link

actions and questions accessing object within an angular controller. (Leaflet testing) #297

Closed scaddenp closed 1 year ago

scaddenp commented 5 years ago

I have an application using Leafletjs for mapping and I am struggling with how to test interactions with the map. Eg a mouse hovering over a particular map position should create a pop up; clicks on map tools will change the map content. These are easily emulated by using setters (for action) and getters (for questions) on an instance of an L.Map object.

What I am baffled with though, is that the map variable ( map = L.Map(etc) ) is buried within am angular controller. It seems I would have to expose it to global scope to use it within a serentityjs test. I think I must be missing something very obvious here and surely it must be a common enough requirement for angular developers using serentityjs.

jan-molak commented 5 years ago

Hi @scaddenp!

There are several ways you could approach it:

What version of Angular are you using? If you could put together a minimal example on github it would be easier for myself or other members of the Serenity/JS community to propose an approach.

Best, Jan

scaddenp commented 5 years ago

Thanks for those suggestions. Currently using angularjs but looking at transitioning as I refactor to improve the test environment. Leaflet is currently buried in a directive but not "pure" angular so map variable is exposed to controller. I will look at getting a minimal version together if I cant figure it out from your suggestion.

jan-molak commented 5 years ago

Sure, please keep me posted.

jan-molak commented 5 years ago

Note: Serenity/JS 2.0 will come with improved ExecuteScript interactions that could be useful here. Preview.

scaddenp commented 5 years ago

Looks useful. battling away with need to simulate mouse clicks on specific screen x,y locations. There are cases where cannot use the L.Map methods ( a masking DOM element), so having to do very low level in scripts.