forked from playframework/play1
/
routing.test.html
162 lines (133 loc) · 4.88 KB
/
routing.test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
#{selenium 'Just test the simple scenario'}
open('/re/toto')
assertTextPresent('OK: toto')
open('/re/1234')
assertTextPresent('Not found')
open('/re/12345')
assertTextPresent('OK: 12345')
open('/re/T')
assertTextPresent('Not found')
open('/re/TITI')
assertTextPresent('OK: TITI')
open('/re/TITITOTO')
assertTextPresent('Not found')
open('/')
// Packages
assertAttribute('wp1@href', '/sample/photo/index')
assertAttribute('wp2@href', '/admin.test/index')
assertAttribute('wp3@href', 'http://localhost:9003/admin.test/index')
// Missing name
clickAndWait('sayHello')
assertTextPresent('Hello !')
// A name
clickAndWait('back')
type('name', 'Guillaume')
clickAndWait('sayHello')
assertTextPresent('Hello Guillaume !')
// test utf-8
clickAndWait('back')
type('name', '日本語')
clickAndWait('sayHello')
assertTextPresent('Hello 日本語 !')
// test escape
clickAndWait('back')
type('name', '<i>Italic &nbsp; Yop</i>')
clickAndWait('sayHello')
assertTextPresent('<i>Italic &nbsp; Yop</i>')
// Check URL
assertAttribute('back@href', '/')
clickAndWait('back')
assertAttribute('form@action', '/sayHello?x-http-method-override=PUT')
assertAttribute('form@method', 'regexpi:post')
// The yop form
assertElementPresent('css=form[action=/application/yop]')
assertAttribute('css=form[action=/application/yop]@method', 'regexpi:post')
clickAndWait('yop')
assertTextPresent('Yop')
clickAndWait('back')
assertTextPresent('It works !')
// A GET form
assertElementPresent('css=form[action=/aGetForm]')
assertAttribute('css=form[action=/aGetForm]@method', 'regexpi:get')
clickAndWait('yopGet')
assertTextPresent('Hello !')
clickAndWait('back')
// ... with a name
type('getName', 'Toto')
clickAndWait('yopGet')
assertTextPresent('Hello Toto !')
assertEval('window.document.location', '*/aGetForm?name=Toto')
// Direct URL with a trailing slash
open('/aGetForm/')
assertTextPresent('Hello 2null !')
open('/aGetForm')
assertTextPresent('Hello !')
// Optional slash
open('/optionalSlash/')
assertTextPresent('OK')
open('/optionalSlash')
assertTextPresent('OK')
open('/optionalSlash//')
assertTextPresent('Not found')
// Catch all route
open('/application/optional')
assertTextPresent('OK')
open('/Application/optional')
assertTextPresent('OK')
open('/Application/Optional')
assertTextPresent('OK')
// Alternative URL
open('/index')
assertTextPresent('It works !')
// Reverse
open('@{Application.reverserouting()}')
assertText('a', '/')
assertText('b', '/sayHello')
assertText('c', '/sayHello?name=Guillaume')
assertText('d', '/application/yop')
assertText('e', '/aGetForm')
assertText('f', '/aGetForm/')
assertText('g', '/aGetForm?name=Yop')
assertText('h', '/aGetForm/?name=Yop')
assertText('i', '/optionalSlash')
assertText('j', '/withQueryParam')
assertText('k', '/withQueryParam?lucky=duck')
// Reverse
open('@{Application.reverserouting2()}')
assertTextPresent('/jpabinding/save?project.name=colcoz')
// Reverse
open('@{Application.reverserouting3()}')
assertTextPresent('/jpabinding/save?project.name=COLCOZ')
// Host
open('/')
assertTextPresent('1: http://static.foo.com:9003/assets/hello.html')
assertTextPresent('2: /assets/hello.html')
assertTextPresent('3: http://static2.foo.com:9003/x/hello.html')
assertTextPresent('4: /x/hello.html')
assertTextPresent('5: http://localhost:9003/public/image.gif')
assertTextPresent('6: /public/image.gif')
assertTextPresent('7: /hello')
assertTextPresent('8: http://www.zenexity.com:9003/hello')
assertTextPresent('9: /')
assertTextPresent('10: http://localhost:9003/')
assertTextPresent('11: /home')
assertTextPresent('12: http://bob.myApp.com:9003/home')
assertTextPresent('13: http://localhost:9003/strike/doIt')
assertTextPresent('14: http://localhost:9003/re/titi')
assertTextPresent('15: http://localhost:9003/application/ok?re=123')
assertTextPresent('16: http://localhost:9003/re/12345')
assertTextPresent('17: http://localhost:9003/application/ok?re=A')
assertTextPresent('18: http://localhost:9003/re/TITI')
assertTextPresent('19: http://assets.localhost:9003/images')
open('/client')
assertTextPresent('localhost')
// jsRoute tag
open('@{Application.jsRoute()}')
assertText('a-url', '/')
assertText('a-method', 'GET')
assertText('b-url', '/sayHello')
assertText('b-method', 'PUT')
assertText('c', '/ressource/foo')
open('@{Application.jsRouteError()}')
assertTextPresent('Wrong parameter type')
#{/selenium}