|
1 | 1 | require 'rails_helper' |
2 | 2 |
|
3 | | -describe "Cable Component - append", type: :feature, js: true do |
| 3 | +describe "Cable Component", type: :feature, js: true do |
4 | 4 | include Utils |
| 5 | + include Matestack::Ui::Core::ApplicationHelper |
5 | 6 |
|
6 | 7 | it 'should have the typical matestack wrapping classes' do |
7 | 8 | matestack_render do |
|
24 | 25 | end |
25 | 26 |
|
26 | 27 | it 'should work after a page transition' do |
27 | | - pending |
28 | | - fail |
| 28 | + matestack_render(reset_app: false, page: MatestackTransitionPage) do |
| 29 | + cable id: 'cable-replace', replace_on: 'replace' do |
| 30 | + paragraph id: 'id', text: 'Paragraph' |
| 31 | + end |
| 32 | + end |
| 33 | + matestack_render(reset_app: false) do |
| 34 | + transition path: :matestack_transition_test_path, text: 'Transition' |
| 35 | + end |
| 36 | + expect(page).to have_content('Transition') |
| 37 | + expect(page).not_to have_content('Paragraph') |
| 38 | + click_on 'Transition' |
| 39 | + expect(page).not_to have_content('Transition') |
| 40 | + expect(page).to have_selector('p#id', text: 'Paragraph') |
| 41 | + page.execute_script('MatestackUiCore.matestackEventHub.$emit("replace", { data: "<h1 id=\"id\">replaced</h1>" })') |
| 42 | + expect(page).to have_selector('h1#id', text: 'replaced') |
| 43 | + reset_matestack_app |
| 44 | + end |
| 45 | + |
| 46 | + it 'should be possible to add vue.js components' do |
| 47 | + matestack_render do |
| 48 | + cable id: 'cable-replace', replace_on: 'replace' do |
| 49 | + paragraph text: 'paragraph', id: 'id' |
| 50 | + end |
| 51 | + toggle show_on: 'test' do |
| 52 | + plain 'event successful emitted' |
| 53 | + end |
| 54 | + end |
| 55 | + expect(page).to have_selector('p#id', text: 'paragraph') |
| 56 | + expect(page).not_to have_selector('button', text: 'Click') |
| 57 | + expect(page).not_to have_content('event successful emitted') |
| 58 | + # onclick = matestack_component(:heading, text: 'test') |
| 59 | + onclick = matestack_component(:onclick, emit: :test) { button text: 'Click' } |
| 60 | + script = "MatestackUiCore.matestackEventHub.$emit('replace', { data: \"#{onclick}\" })".gsub("\n", "") |
| 61 | + page.execute_script(script) |
| 62 | + expect(page).not_to have_selector('p#id', text: 'paragraph') |
| 63 | + expect(page).to have_selector('button', text: 'Click') |
| 64 | + expect(page).not_to have_content('event successful emitted') |
| 65 | + |
| 66 | + click_on 'Click' |
| 67 | + expect(page).to have_content('event successful emitted') |
29 | 68 | end |
30 | 69 |
|
31 | 70 | end |
0 commit comments