|
21 | 21 | expect(Spree::TaxRate.count).to eq(1) |
22 | 22 | expect(page).to be_axe_clean |
23 | 23 | end |
| 24 | + |
| 25 | + context "creating new tax rate" do |
| 26 | + before do |
| 27 | + create(:zone, name: "EU") |
| 28 | + create(:tax_category, name: "Default") |
| 29 | + create(:tax_category, name: "Specific") |
| 30 | + end |
| 31 | + |
| 32 | + it "creates new tax rate" do |
| 33 | + visit "/admin/tax_rates" |
| 34 | + click_on "Add new" |
| 35 | + expect(page).to have_current_path("/admin/tax_rates/new") |
| 36 | + expect(page).to be_axe_clean |
| 37 | + |
| 38 | + fill_in "Name", with: "Clothing" |
| 39 | + solidus_select "EU", from: "Zone" |
| 40 | + solidus_select %w[Default Specific], from: "Tax Categories" |
| 41 | + switch "Show Rate in Label" |
| 42 | + solidus_select "Default Tax", from: "Calculator" |
| 43 | + fill_in "Rate", with: "0.18" |
| 44 | + solidus_select "Item level", from: "Tax Rate Level" |
| 45 | + switch "Included in Price" |
| 46 | + fill_in "Start Date", with: "20/06/2024" |
| 47 | + fill_in "Expiration Date", with: "20/06/2026" |
| 48 | + |
| 49 | + within("header") { click_on "Save" } |
| 50 | + |
| 51 | + expect(page).to have_current_path("/admin/tax_rates") |
| 52 | + expect(page).to have_content("Tax rate was successfully created.") |
| 53 | + expect(page).to have_content("EU") |
| 54 | + expect(page).to have_content("Clothing") |
| 55 | + expect(page).to have_content("Default, Specific") |
| 56 | + expect(page).to have_content("18.0%") |
| 57 | + expect(page).to have_content("2026-06-20") |
| 58 | + expect(page).to have_content("Default Tax") |
| 59 | + end |
| 60 | + |
| 61 | + context "with invalid attributes" do |
| 62 | + it "shows validation errors" do |
| 63 | + visit "/admin/tax_rates" |
| 64 | + click_on "Add new" |
| 65 | + |
| 66 | + within("header") { click_on "Save" } |
| 67 | + |
| 68 | + expect(page).to have_current_path("/admin/tax_rates/new") |
| 69 | + expect(page).to have_content("can't be blank") |
| 70 | + expect(page).to have_content("is not a number") |
| 71 | + end |
| 72 | + end |
| 73 | + end |
24 | 74 | end |
0 commit comments