@@ -14,7 +14,7 @@ def response
14
14
transition path : :page1_path do
15
15
button text : "Page 1"
16
16
end
17
- transition path : :page2_path do
17
+ transition path : :page2_path , params : { some_other_param : "bar" } do
18
18
button text : "Page 2"
19
19
end
20
20
end
@@ -37,6 +37,7 @@ def response
37
37
div id : "my-div-on-page-1" do
38
38
heading size : 2 , text : "This is Page 1"
39
39
plain "#{ DateTime . now . strftime ( '%Q' ) } "
40
+ plain "#{ context [ :params ] [ :some_param ] } "
40
41
end
41
42
}
42
43
end
@@ -53,6 +54,7 @@ def response
53
54
end
54
55
transition path : :page1_path do
55
56
button text : "Back to Page 1"
57
+ plain "#{ context [ :params ] [ :some_other_param ] } "
56
58
end
57
59
}
58
60
end
@@ -157,6 +159,53 @@ def page2
157
159
expect ( page ) . to have_selector ( "body.not-reloaded" )
158
160
end
159
161
162
+ it "Example 3 - Perform transition from one page to another without page reload when using page history buttons" do
163
+
164
+ visit "/my_example_app/page1?some_param=foo"
165
+
166
+ expect ( page ) . to have_content ( "My Example App Layout" )
167
+ expect ( page ) . to have_button ( "Page 1" )
168
+ expect ( page ) . to have_button ( "Page 2" )
169
+
170
+ expect ( page ) . to have_content ( "This is Page 1" )
171
+ expect ( page ) . to have_content ( "foo" )
172
+ expect ( page ) . not_to have_content ( "This is Page 2" )
173
+
174
+ element = page . find ( "#my-div-on-page-1" )
175
+ first_content_on_page_1 = element . text
176
+
177
+ page . evaluate_script ( 'document.body.classList.add("not-reloaded")' )
178
+ expect ( page ) . to have_selector ( "body.not-reloaded" )
179
+
180
+ click_button ( "Page 2" )
181
+
182
+ expect ( page ) . to have_content ( "My Example App Layout" )
183
+ expect ( page ) . not_to have_content ( "This is Page 1" )
184
+ expect ( page ) . not_to have_content ( "foo" )
185
+ expect ( page ) . to have_content ( "This is Page 2" )
186
+ expect ( page ) . to have_content ( "bar" )
187
+ expect ( page ) . to have_selector ( "body.not-reloaded" )
188
+
189
+ page . go_back
190
+
191
+ expect ( page ) . to have_content ( "My Example App Layout" )
192
+ expect ( page ) . to have_content ( "This is Page 1" )
193
+ expect ( page ) . to have_content ( "foo" )
194
+ expect ( page ) . not_to have_content ( "This is Page 2" )
195
+ expect ( page ) . not_to have_content ( "bar" )
196
+ expect ( page ) . to have_selector ( "body.not-reloaded" )
197
+ expect ( page ) . to have_no_content ( first_content_on_page_1 )
198
+
199
+ page . go_forward
200
+
201
+ expect ( page ) . to have_content ( "My Example App Layout" )
202
+ expect ( page ) . not_to have_content ( "This is Page 1" )
203
+ expect ( page ) . not_to have_content ( "foo" )
204
+ expect ( page ) . to have_content ( "This is Page 2" )
205
+ expect ( page ) . to have_content ( "bar" )
206
+ expect ( page ) . to have_selector ( "body.not-reloaded" )
207
+ end
208
+
160
209
# supposed to work, but doesn't. Suspect Vue is the culprint here
161
210
# it "Example 2 - Perform transition from one page to another by providing route as string (not recommended)" do
162
211
#
0 commit comments