Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gradle/functional-test-config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ tasks.withType(Test).configureEach { Test task ->
// Make Geb tests more resilient in slow CI environments
if (project.hasProperty('gebAtCheckWaiting')) {
systemProperty('grails.geb.atCheckWaiting.enabled', 'true')
systemProperty('grails.geb.timeouts.timeout', '10')
}
}

Expand Down
2 changes: 1 addition & 1 deletion grails-geb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ The following system properties exist to configure timeouts:
* purpose: how often to retry waiting operations
* type: Number
* defaults to `0.1` seconds
* `grails.geb.timeouts.waiting`
* `grails.geb.timeouts.timeout`
* purpose: amount of time to wait for waiting operations
* type: Number
* defaults to `5.0` seconds
Expand Down
19 changes: 5 additions & 14 deletions grails-geb/src/main/templates/FunctionalSpec.groovy
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
package ${packageName}

import grails.gorm.transactions.Rollback
import geb.spock.GebSpec
import grails.testing.mixin.integration.Integration

import geb.spock.*

/**
* See https://groovy.apache.org/geb/manual/current/ for more instructions
*/
@Integration
@Rollback
class ${className}Spec extends GebSpec {

def setup() {
}

def cleanup() {
}

void "test something"() {
when:"The home page is visited"
void "home page loads"() {
when: 'The home page is visited'
go('/')

then:"The title is correct"
title == "Welcome to Grails"
then: 'The title is correct'
waitFor { title == 'Welcome to Grails' }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ class WebDriverContainerHolder {
if (settings.atCheckWaiting != DEFAULT_AT_CHECK_WAITING)
browser.config.atCheckWaiting = settings.atCheckWaiting
if (settings.timeout != Wait.DEFAULT_TIMEOUT)
(browser.config.rawConfig.waiting as ConfigObject).timeout = settings.timeout
browser.config.defaultWaitTimeout = settings.timeout
if (settings.retryInterval != Wait.DEFAULT_RETRY_INTERVAL)
(browser.config.rawConfig.waiting as ConfigObject).retryInterval = settings.retryInterval
browser.config.defaultWaitRetryInterval = settings.retryInterval
}

private static void startContainer(BrowserWebDriverContainer container, DockerImageName dockerImageName, String customBrowser) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,50 +16,49 @@
* specific language governing permissions and limitations
* under the License.
*/

package functionaltests

import functionaltests.pages.BookCreatePage
import functionaltests.pages.BookListPage
import functionaltests.pages.BookShowPage

import grails.gorm.transactions.Rollback
import grails.plugin.geb.ContainerGebSpec
import grails.testing.mixin.integration.Integration
import spock.lang.Issue

@Integration(applicationClass = functionaltests.Application)
@Integration
class BookFunctionalSpec extends ContainerGebSpec {

void "Test that when the /viewBooks URL is hit it redirects to the book list"() {
when: "We go to the book URI"
go "/book/index"

then: "Then thew show book view is rendered"
title == "Book List"
expect:
to(BookListPage)
}

void "Test that a book was created in the Bootstrap class"() {
when: "We go to the book URI"
go('/book/show/1')

then: "Then thew show book view is rendered"
title == "Show Book"
expect:
to(BookShowPage, 1)
}

void "Test that switching language results in correct encodings"() {
when: "the show page is rendered in german"
go "/book/show/1?lang=de"
println pageSource
then: "The language is correct"
$('a', class: 'create').text() == 'Book anlegen'
$('input', class: 'delete').@value == 'Löschen'
when: 'The show page is rendered in german'
def page = to(BookShowPage, 1, lang: 'de')

then: 'The language is correct'
page.createButton.text() == 'Book anlegen'
page.deleteButton.attr('value') == 'Löschen'
}

@Rollback
@Issue('10965')
void "When creating a book the params are not on the url"() {
when: 'creating a book'
go "/book/create"
$('#title').value('The Stand')
$('#create').click()
when: 'Creating a book'
to(BookCreatePage).createBook('The Stand')

then: 'The show book view is rendered'
at(BookShowPage)

then:
title == 'Show Book'
and: 'The params are not on the url'
!currentUrl.contains('title')
!currentUrl.contains('create')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,33 @@
* specific language governing permissions and limitations
* under the License.
*/

package functionaltests


import functionaltests.pages.HomePage
import grails.plugin.geb.ContainerGebSpec
import grails.testing.mixin.integration.Integration
import spock.lang.PendingFeature

@Integration(applicationClass = Application)
@Integration
class HomeSpec extends ContainerGebSpec {

void "Test the home page renders correctly"() {
when: "The home page is visited"
go('/')
if (title != "Welcome to Grails") {
println pageSource
}
then: "The title is correct"
title == "Welcome to Grails"
$('li.controller', text: 'demo.AlphaController')
$('li.controller', text: 'functionaltests.BookController')
$('li.controller', text: 'functionaltests.ErrorsController')
$('li.controller', text: 'functionaltests.ForwardingController')
$('li.controller', text: 'functionaltests.InspectConfigController')
$('li.controller', text: 'functionaltests.MiscController')
$('li.controller', text: 'functionaltests.UploadController')
$('li.controller', text: 'grails.functionaltests.InGrailsPackageController')
when: 'The home page is visited'
def page = to(HomePage)

then: 'The expected controllers are listed'
page.controllers.containsAll(
'demo.AlphaController',
'functionaltests.BookController',
'functionaltests.ErrorsController',
'functionaltests.ForwardingController',
'functionaltests.InspectConfigController',
'functionaltests.MiscController',
'functionaltests.UploadController',
'grails.functionaltests.InGrailsPackageController'
)

// SimpleController should not become a controller as it is not in a grails-app/controllers dir
!$('li.controller', text: 'functionaltests.SimpleController')
!('functionaltests.SimpleController' in page.controllers)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/

package functionaltests


import functionaltests.pages.LoginAuthPage
import grails.plugin.geb.ContainerGebSpec
import grails.testing.mixin.integration.Integration

@Integration
class LoadAfterSpec extends ContainerGebSpec {

void "Test override one plugin view from another plugin"() {
when:
go('/login/auth')

then:
title == "My Plugin Login Auth"
expect:
to(LoginAuthPage)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,39 +16,33 @@
* specific language governing permissions and limitations
* under the License.
*/

package functionaltests

import functionaltests.pages.ActionReturnsNullPage
import functionaltests.pages.BeanPropertyOverridePage
import functionaltests.pages.PlaceHolderConfigPage

import grails.plugin.geb.ContainerGebSpec
import grails.testing.mixin.integration.Integration
import spock.lang.Issue

@Integration(applicationClass = Application)
@Integration
class MiscFunctionalSpec extends ContainerGebSpec {

@Issue('9133')
void "Test that bean override configuration works"() {
when:
go('/misc/beanPropertyOverrideTest')

then:
pageSource.contains('Brian')
expect:
to(BeanPropertyOverridePage)
}

@Issue('GRAILS-12028')
void "Test that when an action returns null the view is rendered by convention"() {
when:
go('/misc/actionWhichReturnsNull')

then:
title == ('Action Which Returns Null GSP')
expect:
to(ActionReturnsNullPage)
}

void "Test that placeholder configuration works for the config object"() {
when:
go('/misc/placeHolderConfig')

then:
pageSource.contains('[test test test]')
expect:
to(PlaceHolderConfigPage)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,43 +16,36 @@
* specific language governing permissions and limitations
* under the License.
*/

package functionaltests.layout

import functionaltests.Application
import functionaltests.pages.ConventionLayoutPage
import functionaltests.pages.FooLayoutPage
import functionaltests.pages.FooLayoutSnippetPage
import grails.plugin.geb.ContainerGebSpec
import grails.testing.mixin.integration.Integration
import spock.lang.Issue

@Integration(applicationClass = Application)
@Integration
class LayoutFunctionalSpec extends ContainerGebSpec {

@Issue('GRAILS-12045')
void 'test layout by convention'() {
when:
go('/layoutByConvention')

then:
title == 'Convention Layout'
expect:
to(ConventionLayoutPage)
}

@Issue('GRAILS-12045')
void 'test layout specified in controller property'() {
when:
go('/layoutSpecifiedByProperty')

then:
title == 'Foo Layout'

expect:
to(FooLayoutPage)
}

@Issue('GRAILS-12045')
void 'test layout specified in controller property applied to a GSP that does not contain a root html tag'() {
when:
go('/layoutSpecifiedByProperty/snippetView')
to(FooLayoutSnippetPage)

then:
title == 'Foo Layout'
$().text().contains 'this is some content'
$().text().contains('this is some content')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/

package functionaltests.layout

import functionaltests.Application
import grails.gorm.transactions.Rollback
import functionaltests.pages.PartialPage
import grails.plugin.geb.ContainerGebSpec
import grails.testing.mixin.integration.Integration

@Integration(applicationClass = Application)
@Rollback
@Integration
class LayoutWithTemplateSpec extends ContainerGebSpec {

void "Test that a layout is not applied to a template rendered by a controller by default"() {
when:"The home page is visited"
go('/layoutTemplate/index')
then:"The title is correct"
title == "Welcome to My Partial"
expect:
to(PartialPage)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package functionaltests.pages

import geb.Page

class BarListPage extends Page {

static String pageTitle = 'Bar List'

static url = '/bar/index'
static at = { title == pageTitle }
}
Loading
Loading