Moves helper into support folder

Wraps SubscripionHelper module around definitions
This commit is contained in:
filipefurtad0
2023-10-02 16:13:03 +01:00
committed by Filipe
parent 181ddcefbc
commit 14caf3b25c
4 changed files with 38 additions and 36 deletions

View 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

View File

@@ -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) }

View File

@@ -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

View File

@@ -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) }