Skip to content

Commit 91af713

Browse files
author
Nils Henning
committed
update and fix specs
1 parent 59423a7 commit 91af713

20 files changed

+2177
-2596
lines changed

.byebug_history

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,85 @@
11
continue
2+
TestModel.destroy_all
3+
TestModel.first
4+
load "#{Rails.root}/app/models/test_model.rb"
5+
Object.send(:remove_const, :TestModel)
6+
TestModel.destroy_all
7+
continue
8+
ActiveRecord::Base.connection.execute("END")
9+
TestModel.destroy_all
10+
ActiveRecord::Base.connection.execute("BEGIN TRANSACTION\; END\;")
11+
TestModel.destroy_all
12+
ActiveRecord::Base.connection.execute("END")
13+
TestModel.destroy_all
14+
ActiveRecord::Base.connection.execute("BEGIN TRANSACTION\; END\;")
15+
ActiveRecord::Base.connection.execute("END")
16+
ActiveRecord::Base.connection.execute("BEGIN TRANSACTION\;")
17+
ActiveRecord::Base.connection.execute("BEGIN TRANSACTION")
18+
ActiveRecord::Base.connection.execute("BEGIN TRANSACTION;")
19+
ActiveRecord::Base.connection.execute("")
20+
ActiveRecord::Base.connection.execute("BEGIN TRANSACTION; END;")
21+
TestModel.destroy_all
22+
TestModel.first
23+
continue
24+
Rails.root
25+
continue
26+
save_screenshot
27+
continue
28+
save_screenshot
29+
continue
30+
save_screenshot
31+
continue
32+
save_screenshot
33+
continue
34+
save_screenshot
35+
continue
36+
HashTestModel.statuses
37+
continue
38+
HashTestModel.statuses
39+
save_screenshot
40+
HashTestModel.statuses
41+
continue
42+
HashTestModel.statuses
43+
HashTestModel.new.item
44+
HashTestModel.items
45+
HashTestModel.new.item
46+
HashTestModel.new
47+
HashTestModel.new.item
48+
HashTestModel.new.items
49+
HashTestModel
50+
continue
51+
save_screenshot
52+
HashTestModel.new.status
53+
HashTestModel.new.statuses
54+
HashTestModel.new
55+
HashTestModel.new.statuses
56+
HashTestModel.new.status
57+
TestModel.new.status
58+
TestModel.new.statuses
59+
TestModel.new
60+
continue
61+
TestModel.new
62+
save_screenshot
63+
continue
64+
save_screenshot
65+
save_screenshor
66+
continue
67+
save_screenshot
68+
continue
69+
save_screenshot
70+
continue
71+
save_screenshot
72+
continue
73+
save_screenshot
74+
continue
75+
save_screenshot
76+
continue
77+
super.merge(success: { emit: "my_form_success, transition: { path: :form_test_page_2_path, params: { id: 42 } }" })
78+
super.merge(success: { emit: "my_form_success" })
79+
super.merge(success: { })
80+
continue
81+
super
82+
continue
283
static_output
384
continue
485
static_output

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,15 @@ def my_simple_slot
363363
end
364364
```
365365

366+
### Removed Components
366367

368+
#### Inline Component
369+
370+
The Form Inline Component is removed and can no longer be used.
371+
372+
#### Absolute Component
373+
374+
The Absolute Component is removed and can no longer be used.
367375

368376

369377
## v0.7.6
Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
require_relative "../../../../support/utils"
2+
require_relative "../../../../support/test_controller"
3+
require_relative "support/form_test_controller"
4+
require_relative "support/model_form_test_controller"
5+
include Utils
6+
7+
describe "Form Component", type: :feature, js: true do
8+
9+
before :all do
10+
class BasePage < Matestack::Ui::Page
11+
def response
12+
form form_config, :include do
13+
form_input id: "my-test-input", key: :foo, type: :text
14+
form_submit do
15+
button text: "Submit me!"
16+
end
17+
end
18+
end
19+
20+
def form_config
21+
return {
22+
for: :my_object,
23+
method: :post,
24+
path: :async_request_success_form_test_path,
25+
params: {
26+
id: 42
27+
}
28+
}
29+
end
30+
end
31+
32+
Rails.application.routes.append do
33+
post '/success_form_test/:id', to: 'form_test#success_submit', as: 'async_request_success_form_test'
34+
post '/success_form_test_with_transition/:id', to: 'form_test#success_submit_with_transition', as: 'async_request_success_form_test_with_transition'
35+
post '/failure_form_test_with_transition/:id', to: 'form_test#failure_submit_with_transition', as: 'async_request_failure_form_test_with_transition'
36+
post '/success_form_test_with_redirect/:id', to: 'form_test#success_submit_with_redirect', as: 'async_request_success_form_test_with_redirect'
37+
post '/failure_form_test_with_redirect/:id', to: 'form_test#failure_submit_with_redirect', as: 'async_request_failure_form_test_with_redirect'
38+
post '/failure_form_test/:id', to: 'form_test#failure_submit', as: 'async_request_failure_form_test'
39+
post '/model_form_test', to: 'model_form_test#model_submit', as: 'async_request_model_form_test'
40+
end
41+
Rails.application.reload_routes!
42+
end
43+
44+
before :each do
45+
allow_any_instance_of(FormTestController).to receive(:expect_params)
46+
end
47+
48+
describe 'async submit' do
49+
before :all do
50+
class BaseExamplePage < BasePage
51+
end
52+
end
53+
54+
it "Example 1 - Async submit request with clientside payload" do
55+
visit "/base_example"
56+
fill_in "my-test-input", with: "bar"
57+
expect_any_instance_of(FormTestController).to receive(:expect_params)
58+
.with(hash_including(my_object: { foo: "bar" }))
59+
click_button "Submit me!"
60+
end
61+
62+
it "Example 2 - Async submit request and clears inputs on success" do
63+
visit "/base_example"
64+
fill_in "my-test-input", with: "bar"
65+
expect(find_field("my-test-input").value).to eq "bar"
66+
click_button "Submit me!"
67+
expect(find_field("my-test-input").value).to eq ""
68+
end
69+
70+
end
71+
72+
describe 'async emit' do
73+
74+
it "Example 1 - Async submit request with success event" do
75+
class BaseExamplePage < BasePage
76+
def response
77+
super
78+
async show_on: "my_form_success" do
79+
plain "{{event.data.message}}"
80+
end
81+
end
82+
83+
def form_config
84+
super.merge(success: { emit: "my_form_success" })
85+
end
86+
end
87+
88+
visit "/base_example"
89+
fill_in "my-test-input", with: "bar"
90+
click_button "Submit me!"
91+
expect(page).to have_content("server says: form submitted successfully")
92+
end
93+
94+
it "Example 3 - Async submit request with failure event" do
95+
class BaseExamplePage < BasePage
96+
def response
97+
super
98+
async show_on: "my_form_failure" do
99+
plain "{{event.data.message}}"
100+
plain "{{event.data.errors}}"
101+
end
102+
end
103+
104+
def form_config
105+
super.merge(path: :async_request_failure_form_test_path, failure: { emit: "my_form_failure" })
106+
end
107+
end
108+
109+
visit "/base_example"
110+
fill_in "my-test-input", with: "bar"
111+
click_button "Submit me!"
112+
expect(page).to have_content("server says: form had errors")
113+
expect(page).to have_content("\"foo\": [ \"seems to be invalid\" ]")
114+
end
115+
116+
end
117+
118+
end

0 commit comments

Comments
 (0)