Skip to content

Commit 523c7fc

Browse files
committed
added failing spec for browser history button transition+
1 parent 852c29a commit 523c7fc

File tree

1 file changed

+42
-1
lines changed

1 file changed

+42
-1
lines changed

spec/usage/components/transition_spec.rb

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
describe "Transition Component", type: :feature, js: true do
55

6-
it "Example 1 - Perform transition from one page to another without page reload if related to app" do
6+
before :all do
77

88
class Apps::ExampleApp < Matestack::Ui::App
99

@@ -78,6 +78,10 @@ def page2
7878
end
7979
Rails.application.reload_routes!
8080

81+
end
82+
83+
it "Example 1 - Perform transition from one page to another without page reload if related to app" do
84+
8185
visit "/my_example_app/page1"
8286

8387
expect(page).to have_content("My Example App Layout")
@@ -113,6 +117,43 @@ def page2
113117
expect(first_content_on_page_1).not_to eq(refreshed_content_on_page_1)
114118
end
115119

120+
it "Example 2 - Perform transition from one page to another without page reload when using page history buttons" do
121+
122+
visit "/my_example_app/page1"
123+
124+
expect(page).to have_content("My Example App Layout")
125+
expect(page).to have_button("Page 1")
126+
expect(page).to have_button("Page 2")
127+
128+
expect(page).to have_content("This is Page 1")
129+
expect(page).not_to have_content("This is Page 2")
130+
131+
element = page.find("#my-div-on-page-1")
132+
first_content_on_page_1 = element.text
133+
134+
page.evaluate_script('document.body.classList.add("not-reloaded")')
135+
expect(page).to have_selector("body.not-reloaded")
136+
137+
click_button("Page 2")
138+
139+
expect(page).to have_content("My Example App Layout")
140+
expect(page).not_to have_content("This is Page 1")
141+
expect(page).to have_content("This is Page 2")
142+
expect(page).to have_selector("body.not-reloaded")
143+
144+
page.evaluate_script('window.history.back()')
145+
146+
element = page.find("#my-div-on-page-1")
147+
refreshed_content_on_page_1 = element.text
148+
149+
expect(page).to have_content("My Example App Layout")
150+
expect(page).to have_content("This is Page 1")
151+
expect(page).not_to have_content("This is Page 2")
152+
expect(page).to have_selector("body.not-reloaded")
153+
154+
expect(first_content_on_page_1).not_to eq(refreshed_content_on_page_1)
155+
end
156+
116157
# supposed to work, but doesn't. Suspect Vue is the culprint here
117158
# it "Example 2 - Perform transition from one page to another by providing route as string (not recommended)" do
118159
#

0 commit comments

Comments
 (0)