|
3 | 3 |
|
4 | 4 | describe "Transition Component", type: :feature, js: true do
|
5 | 5 |
|
6 |
| - it "Example 1 - Perform transition from one page to another without page reload if related to app" do |
| 6 | + before :all do |
7 | 7 |
|
8 | 8 | class Apps::ExampleApp < Matestack::Ui::App
|
9 | 9 |
|
@@ -78,6 +78,10 @@ def page2
|
78 | 78 | end
|
79 | 79 | Rails.application.reload_routes!
|
80 | 80 |
|
| 81 | + end |
| 82 | + |
| 83 | + it "Example 1 - Perform transition from one page to another without page reload if related to app" do |
| 84 | + |
81 | 85 | visit "/my_example_app/page1"
|
82 | 86 |
|
83 | 87 | expect(page).to have_content("My Example App Layout")
|
@@ -113,6 +117,43 @@ def page2
|
113 | 117 | expect(first_content_on_page_1).not_to eq(refreshed_content_on_page_1)
|
114 | 118 | end
|
115 | 119 |
|
| 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 | + |
116 | 157 | # supposed to work, but doesn't. Suspect Vue is the culprint here
|
117 | 158 | # it "Example 2 - Perform transition from one page to another by providing route as string (not recommended)" do
|
118 | 159 | #
|
|
0 commit comments