You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@wicket.apache.org by Jeremy Thomerson <je...@wickettraining.com> on 2011/02/13 17:18:19 UTC

WicketTester#assertInvisible

I just ran across this nuance this week....  If you have this:

<wicket:enclosure child="comp1">
  <div wicket:id="comp1"></div>
  <div wicket:id="comp2"></div>
</wicket:enclosure>

Now, say comp1 is invisible, so the whole enclosure is invisible.  Now, in
WicketTester, if you test assertInvisible("comp2"), it will fail because
technically comp2 *is* visible itself, but it's not really visible because
its parent is not visible.

So, I want to fix this.  My question for the group is, which should I do:

1 - change assertInvisible to test that it is truly visible (i.e., in
hierarchy)?

2 - add a new method, assertInvisibleInHierarchy that tests for actual
visibility and add to the javadoc for assertInvisible that it only tests the
actual component's visibility, and not its true visibility (as in, in the
hierarchy)?

-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*

Re: WicketTester#assertInvisible

Posted by Jeremy Thomerson <je...@wickettraining.com>.
On Sun, Feb 13, 2011 at 1:32 PM, Martin Makundi <
martin.makundi@koodaripalvelut.com> wrote:

> > I haven't looked at the exact implementation of
> > WicketTester, but I think we should change the logic to pass
> assertInvisible
> > if the component's isVisible method returns true, but some parent of the
> > component (an enclosure, etc) is not visible, since in all reality, the
> > component is then also invisible.
>
> It is like that already:
>
>        public Result isVisible(String path)
>        {
>                Component component = getLastRenderedPage().get(path);
>                if (component == null)
>                {
>                        fail("path: '" + path + "' does no exist for page: "
>                                        +
> Classes.simpleName(getLastRenderedPage().getClass()));
>                }
>
>                return isTrue("component '" + path + "' is not visible",
> component.isVisibleInHierarchy());
>        }
>

Well, it doesn't work in the scenario I had, which may be specific to
enclosures.  I'll get my quickstart uploaded to a JIRA and fix it at some
point.


-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*

Re: WicketTester#assertInvisible

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
> I haven't looked at the exact implementation of
> WicketTester, but I think we should change the logic to pass assertInvisible
> if the component's isVisible method returns true, but some parent of the
> component (an enclosure, etc) is not visible, since in all reality, the
> component is then also invisible.

It is like that already:

	public Result isVisible(String path)
	{
		Component component = getLastRenderedPage().get(path);
		if (component == null)
		{
			fail("path: '" + path + "' does no exist for page: "
					+ Classes.simpleName(getLastRenderedPage().getClass()));
		}

		return isTrue("component '" + path + "' is not visible",
component.isVisibleInHierarchy());
	}


>
> --
> Jeremy Thomerson
> http://wickettraining.com
> *Need a CMS for Wicket?  Use Brix! http://brixcms.org*
>

Re: WicketTester#assertInvisible

Posted by Jeremy Thomerson <je...@wickettraining.com>.
On Sun, Feb 13, 2011 at 11:46 AM, Martin Makundi <
martin.makundi@koodaripalvelut.com> wrote:

> This is a fundamental dilemma ;) Also on implementation side somebody
> may implement:
>
> 1)
> isvisible() {
>  return super.isvisible() && businesslogic.isvisible();
> }
>
> or simply
>
> 2)
> isvisible() {
>  return businesslogic.isvisible();
> }
>
>
> So if 2) is allowed and recommended, then isvisible is really only
> businesslogic test instead of real visibilty check.
>

Yeah, but that's in the component itself - which means that the business
logic check IS the visibility determining factor.  Wicket will call
isVisible, and it won't appear because of your business logic.  You just
disabled people from calling setVisible(false) and also hiding it.

But, I'm asking more about WicketTester and related components that aren't
visible because something in the hierarchy above them is not visible - in
this case an enclosure.  I haven't looked at the exact implementation of
WicketTester, but I think we should change the logic to pass assertInvisible
if the component's isVisible method returns true, but some parent of the
component (an enclosure, etc) is not visible, since in all reality, the
component is then also invisible.

-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*

Re: WicketTester#assertInvisible

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
This is a fundamental dilemma ;) Also on implementation side somebody
may implement:

1)
isvisible() {
 return super.isvisible() && businesslogic.isvisible();
}

or simply

2)
isvisible() {
 return businesslogic.isvisible();
}


So if 2) is allowed and recommended, then isvisible is really only
businesslogic test instead of real visibilty check.


**
Martin

2011/2/13 Jeremy Thomerson <je...@wickettraining.com>:
> I just ran across this nuance this week....  If you have this:
>
> <wicket:enclosure child="comp1">
>  <div wicket:id="comp1"></div>
>  <div wicket:id="comp2"></div>
> </wicket:enclosure>
>
> Now, say comp1 is invisible, so the whole enclosure is invisible.  Now, in
> WicketTester, if you test assertInvisible("comp2"), it will fail because
> technically comp2 *is* visible itself, but it's not really visible because
> its parent is not visible.
>
> So, I want to fix this.  My question for the group is, which should I do:
>
> 1 - change assertInvisible to test that it is truly visible (i.e., in
> hierarchy)?
>
> 2 - add a new method, assertInvisibleInHierarchy that tests for actual
> visibility and add to the javadoc for assertInvisible that it only tests the
> actual component's visibility, and not its true visibility (as in, in the
> hierarchy)?
>
> --
> Jeremy Thomerson
> http://wickettraining.com
> *Need a CMS for Wicket?  Use Brix! http://brixcms.org*
>

Re: WicketTester#assertInvisible

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

On Sun, Feb 13, 2011 at 6:18 PM, Jeremy Thomerson <jeremy@wickettraining.com
> wrote:

> I just ran across this nuance this week....  If you have this:
>
> <wicket:enclosure child="comp1">
>  <div wicket:id="comp1"></div>
>  <div wicket:id="comp2"></div>
> </wicket:enclosure>
>
> Now, say comp1 is invisible, so the whole enclosure is invisible.  Now, in
> WicketTester, if you test assertInvisible("comp2"), it will fail because
> technically comp2 *is* visible itself, but it's not really visible because
> its parent is not visible.
>
> So, I want to fix this.  My question for the group is, which should I do:
>
> 1 - change assertInvisible to test that it is truly visible (i.e., in
> hierarchy)?
>
> 2 - add a new method, assertInvisibleInHierarchy that tests for actual
> visibility and add to the javadoc for assertInvisible that it only tests
> the
> actual component's visibility, and not its true visibility (as in, in the
> hierarchy)?
>
> I'm for 1)
Looks more natural to me.

Please don't forget to document the change (create a ticket which will
appear in the changelog).


> --
> Jeremy Thomerson
> http://wickettraining.com
> *Need a CMS for Wicket?  Use Brix! http://brixcms.org*
>