|
4 | 4 | include Utils
|
5 | 5 | include Matestack::Ui::Core::ApplicationHelper
|
6 | 6 |
|
| 7 | + before :each do |
| 8 | + |
| 9 | + end |
| 10 | + |
7 | 11 | it 'should have the typical matestack wrapping classes' do
|
8 | 12 | matestack_render do
|
9 | 13 | cable id: 'foobar' do
|
|
42 | 46 | expect(page).to have_selector('h1#id', text: 'replaced')
|
43 | 47 | reset_matestack_app
|
44 | 48 | end
|
45 |
| - |
| 49 | + |
46 | 50 | it 'should be possible to add vue.js components' do
|
47 | 51 | matestack_render do
|
48 | 52 | cable id: 'cable-replace', replace_on: 'replace' do
|
|
67 | 71 | expect(page).to have_content('event successful emitted')
|
68 | 72 | end
|
69 | 73 |
|
| 74 | + it 'should render Vue.js components and forms without Vue.js console error' do |
| 75 | + # unfortunately I can't test this as I'm not getting the browsers console.log via capybara/Selenium |
| 76 | + # tried all hints found on Stackoverflow etc |
| 77 | + matestack_render do |
| 78 | + cable id: 'cable-replace', replace_on: 'replace' do |
| 79 | + form for: :some_object, path: "/", method: :post do |
| 80 | + form_input key: :foo, type: :text, label: :foo, id: :foo |
| 81 | + end |
| 82 | + end |
| 83 | + end |
| 84 | + |
| 85 | + # this was throwing a console error in v.1.3.0 |
| 86 | + # "Interpolation inside attributes has been removed. Use v-bind or the colon shorthand instead. For example, instead of <div id="{{ val }}">, use <div :id="val">." |
| 87 | + # fixed in v.1.3.1 without explicitly testing it... |
| 88 | + |
| 89 | + expect(page).to have_selector('form') |
| 90 | + expect(page).to have_selector('input#foo') |
| 91 | + end |
| 92 | + |
| 93 | + it 'should work without any initial body given' do |
| 94 | + matestack_render do |
| 95 | + cable id: 'cable-replace', replace_on: 'replace' do |
| 96 | + # nothing |
| 97 | + end |
| 98 | + toggle show_on: 'test' do |
| 99 | + plain 'event successful emitted' |
| 100 | + end |
| 101 | + end |
| 102 | + |
| 103 | + expect(page).not_to have_content('event successful emitted') |
| 104 | + |
| 105 | + onclick = matestack_component(:onclick, emit: :test) { button text: 'Click' } |
| 106 | + script = "MatestackUiCore.matestackEventHub.$emit('replace', { data: \"#{onclick}\" })".gsub("\n", "") |
| 107 | + page.execute_script(script) |
| 108 | + |
| 109 | + expect(page).to have_selector('button', text: 'Click') |
| 110 | + expect(page).not_to have_content('event successful emitted') |
| 111 | + |
| 112 | + click_on 'Click' |
| 113 | + expect(page).to have_content('event successful emitted') |
| 114 | + end |
| 115 | + |
70 | 116 | end
|
0 commit comments