source: branches/features/purchaseOrders/test/functional/gnumims/functional/LoginSpec.groovy @ 925

Last change on this file since 925 was 925, checked in by gav, 13 years ago

Make functional test URL's dynamic and relative.

File size: 1.3 KB
Line 
1package gnumims.functional
2
3import grails.plugin.geb.GebSpec
4import gnumims.functional.pages.LoginPage
5import geb.spock.GebReportingSpec
6import geb.Browser
7import geb.junit3.GebTest
8import gnumims.functional.pages.HomePage
9import spock.lang.Stepwise
10
11@Stepwise
12class LoginSpec extends GebReportingSpec {
13    def appName = grails.util.Metadata.current.'app.name'
14    String getBaseUrl() { "http://localhost:8080/$appName/" }
15    File getReportDir() { new File("target/reports/geb") }
16
17    def "We start at the login page"() {
18        when:
19        go getBaseUrl()
20
21        then:
22        $("h1").text() == "Welcome to gnuMims please log in"
23    }
24
25    def "When we click login we go to the home page"() {
26        when:
27        to LoginPage
28        form.j_username = "admin"
29        form.j_password = "pass"
30        login.click(HomePage)
31
32        then:
33        at(HomePage)
34    }
35
36    def "When we click logout, we go back to the login page"() {
37        when:
38        to HomePage
39        logout.click()
40
41        then:
42        at(LoginPage)
43    }
44
45    def "If we type in the wrong password"() {
46        when:
47        to LoginPage
48        form.j_username = "admin"
49        form.j_password = "bogus"
50        login.click(LoginPage)
51
52        then:
53        $("div.login_message").text() == "[admin] wrong username/password."
54    }
55
56}
Note: See TracBrowser for help on using the repository browser.