Setting up content of single page webapp as hierarchy of modules?

26 views
Skip to first unread message

steve....@synergistcomputing.com

unread,
Jun 26, 2017, 12:39:36 PM6/26/17
to Geb User Mailing List
Hello.  If I have a single-page webapp and if I want to set up the content to be a hierarchy of Modules, how can I ensure that if I navigate to a page object, it will look at the hierarchy of modules and verify the content?  For example, if I have the following page class:
class HomePage extends Page {
   
static url = 'home'
   
static at = {
        title
== 'Home Page' && mainViewModule.displayed
   
}
   
static content = {
        mainViewModule
{ module MainViewModule }
   
}
}

and then MainViewModule is defined like this:
class MainViewModule extends Module {
   
static content = {
        mainView
{ $('div', class: 'main-view') }
        dashboardModule
{ module DashboardModule }
   
}
}

then DashboardModule:
class DashboardModule extends Module {
   
static content = {
        dashboard
= { MainViewModule.find 'dashboard' }
        subModule1
= { module SubModule1 }
        subModule2
= { module SubModule2 }
   
}
}

where the submodules generally look like this:
class SubModuleX extends Module {
   
static content = {
       
...
   
}
}

If my tests (using Spock) do the following:
class SomeSpec extends GebReportingSpec {
   
def 'navigate to the home page'() {
       
when:
        to
HomePage

       
then:
        at
HomePage
   
}
}

How can I ensure that it verifies the content defined in the HomePage class, as well as down through the hierarchy of modules?  The way that I have the code (as described above), I can change the selectors to incorrect values, but it still doesn't fail the test.

Thanks,
Steve

Marcin Erdmann

unread,
Jun 27, 2017, 3:02:45 PM6/27/17
to Geb User Mailing List
Hi Steve,

Can you please explain what you mean by "it will look at the hierarchy of modules and verify the content"? I don't follow what made you believe that if you call an at checker of a page type its content will be "verified". Is there a section in the manual that made you believe that?

There is nothing in Geb that walks content defintions when switching pages. You will on the other hand start getting test failures with RequiredPageContentNotPresent exception as soon as you start accessing content definitions returning empty navigators, which should be the case if you use obviously wrong selectors.

Cheers,
Marcin

--
You received this message because you are subscribed to the Google Groups "Geb User Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geb-user+unsubscribe@googlegroups.com.
To post to this group, send email to geb-...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/geb-user/88b88a53-8125-446a-a2d6-d91c695f9335%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages