Re: Test Select2Choice with WicketTester

2013-02-14 Thread Ulf Gitschthaler
Thanks for your answer, I'll try this out today.
 
On Feb 14, 2013, at 11:53 AM, Ernesto Reinaldo Barreiro  
wrote:

> Hi,
> 
> On Thu, Feb 14, 2013 at 10:12 AM, Ulf Gitschthaler <
> ulf.gitschtha...@comsysto.com> wrote:
> 
>> In most cases I want to simulate a user typing something in and selecting
>> one of the offered choices. Afterwards I'd also like to submit the form and
>> check if the model object of the Select2Choice field contains the right
>> value, respectively I want to be able to submit the form if a Select2Choice
>> field is a required field.
>> 
> 
> 
> Mind that  this component do is:
> 
> 1- It implements IResourceListener to be able to stream back JSON like:
> 
> {"results":[{"id":2,"text":"Air Show"},{"id":180,"text":"American
> Football"},{"id":4,"text":"Anniversary"
> },{"id":6,"text":"Aquarium"},{"id":116,"text":"Babies"},{"id":8,"text":"Bar"},{"id":10,"text":"Baseball"},{"id":12,"text":"Basketball"},{"id":14,"text":"Beach
> Volleyball"},{"id":16,"text":"Beergarden"},{"id"
> :18,"text":"Billard"},{"id":22,"text":"Botellón"},{"id":20,"text":"Bowling"},{"id":24,"text":"Bullfight"},{"id":36,"text":"Cafeteria"},{"id":26,"text":"Casino"},{"id":28,"text":"Child
> Museum"},{"id":176,"text"
> :"Childrem"},{"id":30,"text":"Cinema"},{"id":32,"text":"Circus"},{"id":34,"text":"Climbing"},{"id":38,"text":"Comedy
> Club"},{"id":110,"text":"Concert"},{"id":40,"text":"Cricket"},{"id":42,"text":"DanceClass"},{"id":44,"text":"Dancing"},{"id":46,"text":"Daycare"},{"id":48,"text":"Deep
> Sea Fishing"},{"id"
> :50,"text":"Dinopark"},{"id":52,"text":"Diving"},{"id":54,"text":"Fair"},{"id":206,"text":"Family"},
> {"id":208,"text":"Female"},{"id":56,"text":"Fireworks"},{"id":58,"text":"Fishing"},{"id":182,"text":"Forest"
> },{"id":60,"text":"Gay-Female"},{"id":62,"text":"Gay-Male"},{"id":64,"text":"Golfing"},{"id":66,"text":"Handball"},{"id":68,"text":"Hang
> Gliding"},{"id":70,"text":"Hiking"},{"id":108,"text":"Hiphop
> Concert"},{"id":72,"text":"Historical
> Museum"},{"id":74,"text":"Horse
> Riding"},{"id":76,"text":"Hunting"},{"id":78,"text":"Jazz
> Club"},{"id":80,"text":"Kayaking"},{"id":82,"text":"Kitesurfing"},{"id":84,"text":"Library"},{"id":184,"text":"Love"},{"id":86,"text":"Magic
> Show"},{"id":178,"text":"Male"},{"id":88,"text":"Mountainbiking"
> },{"id":90,"text":"Museum-Archeological"},{"id":92,"text":"Museum-Art"},{"id":94,"text":"Museum-Crafts"
> },{"id":96,"text":"Museum-Industry"},{"id":98,"text":"Museum-Naval"},{"id":100,"text":"Museum-Science"
> },{"id":102,"text":"Museum-War"},{"id":104,"text":"Music-choral"},{"id":106,"text":"Music-Classical"
> },{"id":114,"text":"Nanny"},{"id":118,"text":"Paintball"},{"id":120,"text":"Paragliding"},{"id":122,"text"
> :"Parasailing"},{"id":124,"text":"Party"},{"id":126,"text":"Planetarium"},{"id":128,"text":"Playground"},{"id":130,"text":"Poker"},{"id":132,"text":"Public
> Art"},{"id":112,"text":"Rock Concert"},{"id":134,"text":"Ropes
> course"},{"id":136,"text":"Row Boat"},{"id":138,"text":"Rugby
> field"},{"id":140,"text":"Sailing"},{"id":142,"text":"Scout
> group"},{"id":144,"text":"Scuba
> Diving"},{"id":146,"text":"Snorkeling"},{"id":148,"text":"soccer"},{"id":150,"text":"Speed
> riding"},{"id":152,"text":"spelunking"},{"id":154,"text":"Squash"},{"id":156,"text":"Strip
> Club"},{"id":160,"text":"Surf
> Paddle"},{"id":158,"text":"Surfing"},{"id":162,"text":"Swimming"},{"id":166,"text":"Table
> Tennis"},{"id":164,"text":"Tea
> House"},{"id":168,"text":"Tennis"},{"id":170,"text":"Terrace"},{"id":172,"text":"Theater"},{"id":174,"text":"Theme
> Park"},{"id":186,"text":"Video
> Games"},{"id":188,"text":"Volleyball"},{"id":190,"text":"Walking
> Tour"},{"id":194,"text":"Water Park"},{"id":196,"text":"Water
> Skiing"},{"id":192,"text":"Watercraft"},{"id":198,"text":"Windsurfing"},{"id":200,"text":"Wine
> bar"},{"id":202,"text":"Wine Tasting"},{"id":204,"text":"Zoo"}],"more":null}
> 
> For this it uses ChoiceProvider. So, you could test user typing directly
> using ChoiceProvider or for instance
> 
> https://github.com/reiern70/wicket-select2/blob/master/wicket-select2/src/main/java/com/vaynberg/wicket/select2/AbstractSelect2Choice.java#L235
> 
> to test produced JSON. (This is not part of offcial select2 but it is a
> pending pull request). Maybe I can factor out this a bit more and add a
> method that receives int page and String term so that testing is even
> easier.
> 
> 2-On client side widget uses a hidden input to represent selections as
> 
>  value="2,4" style="display: none;">
> 
> Those "selected" values are initially  assigned via JSON when widget is
> constructed.  See method
> 
> https://github.com/reiern70/wicket-select2/blob/master/wicket-select2/src/main/java/com/vaynberg/wicket/select2/Select2MultiChoice.java#L114
> 
> So one way... to simulate this might be as in
> 
> TestMultiSelectPage testPage =tester.startPage(TestMultiSelectPage.class);
> tester.assertRenderedPage(TestMultiSelectPage.class);
> tester.getRequest().setParameter("countri

Re: Test Select2Choice with WicketTester

2013-02-14 Thread Ulf Gitschthaler
In most cases I want to simulate a user typing something in and selecting one 
of the offered choices. Afterwards I'd also like to submit the form and check 
if the model object of the Select2Choice field contains the right value, 
respectively I want to be able to submit the form if a Select2Choice field is a 
required field. 

Up to now it always failes because the model object is null. Just a simple 
example test case would be nice that shows how to test Select2Choice fields in 
a form. 

 

On Feb 13, 2013, at 9:41 PM, Ernesto Reinaldo Barreiro  
wrote:

> What exactly do you want to test? E.g. simulate user typing on field?
> 
> On Wed, Feb 13, 2013 at 8:25 PM, Stephen Walsh <
> step...@connectwithawalsh.com> wrote:
> 
>> I may have the same question. How do you go about testing a select2 box
>> with wicket tester?
>> 
>> 
>> Additionally, is there any documentation on how to use wicket tester?
>> —
>> Stephen Walsh
>> 
>> On Wed, Feb 13, 2013 at 6:08 AM, Sven Meier  wrote:
>> 
>>> What's your problem with Select2Choice and WicketTester?
>>> Sven
>>> On 02/13/2013 10:59 AM, Ulf Gitschthaler wrote:
 Hi,
 
 We currently use Select2Choice (http://tinyurl.com/ab7hm8g) on almost
>> every form on our website. Regretfully we didn't find a proper way to test
>> it with WicketTester so far.
 
 Thus, I'd like to know if anybody figured out how to include
>> Select2Choices in unit tests that use WicketTester. I didn't find anything
>> useful on the web so far, even the select2 github repo does not contain any
>> sample test.
 
 Thanks for your answers,
 Ulf
>>> -
>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
>>> For additional commands, e-mail: users-h...@wicket.apache.org
>> 
> 
> 
> 
> -- 
> Regards - Ernesto Reinaldo Barreiro
> Antilia Soft
> http://antiliasoft.com/ 


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org