mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Moves helper into support folder
Wraps SubscripionHelper module around definitions
This commit is contained in:
34
spec/support/subscription_helper.rb
Normal file
34
spec/support/subscription_helper.rb
Normal file
@@ -0,0 +1,34 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module SubscriptionHelper
|
||||
def fill_in_subscription_basic_details
|
||||
select2_select customer.email, from: "customer_id"
|
||||
select2_select schedule.name, from: "schedule_id"
|
||||
select2_select payment_method.name, from: "payment_method_id"
|
||||
select2_select shipping_method.name, from: "shipping_method_id"
|
||||
|
||||
find_field("begins_at").click
|
||||
choose_today_from_datepicker
|
||||
end
|
||||
|
||||
def expect_not_in_open_or_upcoming_order_cycle_warning(count)
|
||||
expect(page).to have_content(variant_not_in_open_or_upcoming_order_cycle_warning, count:)
|
||||
end
|
||||
|
||||
def add_variant_to_subscription(variant, quantity)
|
||||
row_count = all("#subscription-line-items .item").length
|
||||
variant_name = if variant.full_name.present?
|
||||
"#{variant.name} - #{variant.full_name}"
|
||||
else
|
||||
variant.name
|
||||
end
|
||||
select2_select variant.name, from: "add_variant_id", search: true, select_text: variant_name
|
||||
fill_in "add_quantity", with: quantity
|
||||
click_link "Add"
|
||||
expect(page).to have_selector("#subscription-line-items .item", count: row_count + 1)
|
||||
end
|
||||
|
||||
def variant_not_in_open_or_upcoming_order_cycle_warning
|
||||
'There are no open or upcoming order cycles for this product.'
|
||||
end
|
||||
end
|
||||
@@ -1,11 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require './spec/system/admin/subscriptions/helper'
|
||||
require 'system_helper'
|
||||
|
||||
describe 'Subscriptions' do
|
||||
include AdminHelper
|
||||
include AuthenticationHelper
|
||||
include WebHelper
|
||||
include SubscriptionHelper
|
||||
|
||||
context "as an enterprise user" do
|
||||
let!(:user) { create(:user) }
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'system_helper'
|
||||
|
||||
def fill_in_subscription_basic_details
|
||||
select2_select customer.email, from: "customer_id"
|
||||
select2_select schedule.name, from: "schedule_id"
|
||||
select2_select payment_method.name, from: "payment_method_id"
|
||||
select2_select shipping_method.name, from: "shipping_method_id"
|
||||
|
||||
find_field("begins_at").click
|
||||
choose_today_from_datepicker
|
||||
end
|
||||
|
||||
def expect_not_in_open_or_upcoming_order_cycle_warning(count)
|
||||
expect(page).to have_content(variant_not_in_open_or_upcoming_order_cycle_warning, count:)
|
||||
end
|
||||
|
||||
def add_variant_to_subscription(variant, quantity)
|
||||
row_count = all("#subscription-line-items .item").length
|
||||
variant_name = if variant.full_name.present?
|
||||
"#{variant.name} - #{variant.full_name}"
|
||||
else
|
||||
variant.name
|
||||
end
|
||||
select2_select variant.name, from: "add_variant_id", search: true, select_text: variant_name
|
||||
fill_in "add_quantity", with: quantity
|
||||
click_link "Add"
|
||||
expect(page).to have_selector("#subscription-line-items .item", count: row_count + 1)
|
||||
end
|
||||
|
||||
def variant_not_in_open_or_upcoming_order_cycle_warning
|
||||
'There are no open or upcoming order cycles for this product.'
|
||||
end
|
||||
@@ -1,11 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require './spec/system/admin/subscriptions/helper'
|
||||
require 'system_helper'
|
||||
|
||||
describe 'Subscriptions' do
|
||||
include AdminHelper
|
||||
include AuthenticationHelper
|
||||
include WebHelper
|
||||
include SubscriptionHelper
|
||||
|
||||
context "as an enterprise user" do
|
||||
let!(:user) { create(:user) }
|
||||
|
||||
Reference in New Issue
Block a user