mirror of
https://github.com/we-promise/sure.git
synced 2026-09-03 13:51:29 +00:00
* Add inline category creation to transaction form * Address category selector review feedback * Fix category system test regression * Address category selector review feedback * Use Rails field ID for category selector
56 lines
1.5 KiB
Ruby
56 lines
1.5 KiB
Ruby
require "application_system_test_case"
|
|
|
|
class TransactionCategorySelectTest < ApplicationSystemTestCase
|
|
setup do
|
|
sign_in @user = users(:family_admin)
|
|
end
|
|
|
|
test "can create a category from the transaction form" do
|
|
visit new_transaction_url
|
|
|
|
assert_difference "Category.count", +1 do
|
|
find("[data-controller='category-select'] button").click
|
|
|
|
within "[data-controller='category-select']" do
|
|
fill_in "Search categories", with: "Inline Test Category"
|
|
|
|
assert_text 'Create "Inline Test Category"'
|
|
click_button 'Create "Inline Test Category"'
|
|
|
|
assert_text "Inline Test Category"
|
|
end
|
|
end
|
|
|
|
assert Category.exists?(name: "Inline Test Category")
|
|
end
|
|
|
|
test "can clear a category from an existing transaction" do
|
|
transaction = transactions(:one)
|
|
transaction.update!(category: categories(:food_and_drink))
|
|
entry = transaction.entry
|
|
|
|
visit transactions_url
|
|
|
|
page.execute_script <<~JS
|
|
const frame = document.querySelector("turbo-frame#drawer")
|
|
frame.src = "#{transaction_url(entry)}"
|
|
JS
|
|
|
|
within "turbo-frame#drawer", visible: :all do
|
|
assert_selector "[data-controller='category-select']"
|
|
|
|
within "[data-controller='category-select']" do
|
|
find("button", match: :first).click
|
|
click_button "(uncategorized)"
|
|
end
|
|
end
|
|
|
|
assert_selector(
|
|
"##{ActionView::RecordIdentifier.dom_id(entry)}",
|
|
text: "Uncategorized"
|
|
)
|
|
|
|
assert_nil transaction.reload.category_id
|
|
end
|
|
end
|