Skip to content

Commit 6e54231

Browse files
committed
system tests
1 parent 42c7548 commit 6e54231

File tree

2 files changed

+67
-10
lines changed

2 files changed

+67
-10
lines changed

test/system/line_item_dates_test.rb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@ class LineItemDatesTest < ApplicationSystemTestCase
2424
test "Updating a line item date" do
2525
assert_selector "h1", text: "First quote"
2626

27-
within id: dom_id(@line_item_date) do
28-
# within id: dom_id(@line_item_date, :edit) do
29-
within '.line-item-date__header' do
30-
click_on "Edit"
31-
end
27+
within id: dom_id(@line_item_date, :edit) do
28+
click_on "Edit"
3229
end
3330

3431
assert_selector "h1", text: "First quote"
@@ -43,11 +40,8 @@ class LineItemDatesTest < ApplicationSystemTestCase
4340
assert_text I18n.l(Date.current, format: :long)
4441

4542
accept_confirm do
46-
within id: dom_id(@line_item_date) do
47-
# within id: dom_id(@line_item_date, :edit) do
48-
within '.line-item-date__header' do
49-
click_on "Delete"
50-
end
43+
within id: dom_id(@line_item_date, :edit) do
44+
click_on "Delete"
5145
end
5246
end
5347

test/system/line_items_test.rb

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
require "application_system_test_case"
2+
3+
class LineItemSystemTest < ApplicationSystemTestCase
4+
include ActionView::Helpers::NumberHelper
5+
6+
setup do
7+
login_as users(:accountant)
8+
9+
@quote = quotes(:one)
10+
@line_item_date = line_item_dates(:today)
11+
@line_item = line_items(:room_today)
12+
13+
visit quote_path(@quote)
14+
end
15+
16+
test "Creating a new line item" do
17+
assert_selector "h1", text: "First quote"
18+
19+
within "##{dom_id(@line_item_date)}" do
20+
click_on "Add item", match: :first
21+
end
22+
assert_selector "h1", text: "First quote"
23+
24+
fill_in "Name", with: "Animation"
25+
fill_in "Quantity", with: 1
26+
fill_in "Unit price", with: 1234
27+
click_on "Create item"
28+
29+
assert_selector "h1", text: "First quote"
30+
assert_text "Animation"
31+
assert_text number_to_currency(1234)
32+
end
33+
34+
test "Updating a line item" do
35+
assert_selector "h1", text: "First quote"
36+
37+
within "##{dom_id(@line_item)}" do
38+
click_on "Edit"
39+
end
40+
assert_selector "h1", text: "First quote"
41+
42+
fill_in "Name", with: "Capybara article"
43+
fill_in "Unit price", with: 1234
44+
click_on "Update item"
45+
46+
assert_text "Capybara article"
47+
assert_text number_to_currency(1234)
48+
end
49+
50+
test "Destroying a line item" do
51+
within "##{dom_id(@line_item_date)}" do
52+
assert_text @line_item.name
53+
end
54+
55+
within "##{dom_id(@line_item)}" do
56+
click_on "Delete"
57+
end
58+
59+
within "##{dom_id(@line_item_date)}" do
60+
assert_no_text @line_item.name
61+
end
62+
end
63+
end

0 commit comments

Comments
 (0)