Module: Workarea::Storefront::SystemTest
- Defined in:
- lib/workarea/storefront/system_test.rb
Instance Method Summary collapse
- #add_product_to_cart ⇒ Object
- #add_user_data ⇒ Object
- #create_supporting_data ⇒ Object
- #disable_analytics_dom_events ⇒ Object
- #fill_in_billing_address ⇒ Object
- #fill_in_credit_card ⇒ Object
- #fill_in_email ⇒ Object
- #fill_in_new_card_cvv ⇒ Object
- #fill_in_shipping_address ⇒ Object
- #find_analytics_events(for_event: nil) ⇒ Object
- #select_shipping_service ⇒ Object
- #setup_checkout_specs ⇒ Object
- #start_guest_checkout ⇒ Object
- #start_user_checkout ⇒ Object
Instance Method Details
#add_product_to_cart ⇒ Object
69 70 71 72 73 |
# File 'lib/workarea/storefront/system_test.rb', line 69 def add_product_to_cart product = Catalog::Product.find('INT_PRODUCT') visit storefront.product_path(product) t('workarea.storefront.products.add_to_cart') end |
#add_user_data ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/workarea/storefront/system_test.rb', line 33 def add_user_data user = User.find_by_email('[email protected]') user.auto_save_shipping_address( first_name: 'Ben', last_name: 'Crouse', street: '22 S. 3rd St.', city: 'Philadelphia', region: 'PA', postal_code: '19106', country: 'US', phone_number: '2159251800' ) user.auto_save_billing_address( first_name: 'Ben', last_name: 'Crouse', street: '1019 S. 47th St.', city: 'Philadelphia', region: 'PA', postal_code: '19143', country: 'US', phone_number: '2159251800' ) profile = Payment::Profile.lookup(PaymentReference.new(user)) profile.credit_cards.create!( first_name: 'Ben', last_name: 'Crouse', number: '4111111111111111', month: 1, year: Time.current.year + 1, cvv: '999' ) end |
#create_supporting_data ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/workarea/storefront/system_test.rb', line 9 def create_supporting_data create_tax_category( name: 'Sales Tax', code: '001', rates: [{ percentage: 0.07, country: 'US', region: 'PA' }] ) create_shipping_service( name: 'Ground', tax_code: '001', rates: [{ price: 7.to_m }] ) create_inventory(id: 'SKU', policy: 'standard', available: 5) @product = create_product( id: 'INT_PRODUCT', name: 'Integration Product', variants: [{ sku: 'SKU', tax_code: '001', regular: 5.to_m }] ) create_user(email: '[email protected]', password: 'W3bl1nc!') end |
#disable_analytics_dom_events ⇒ Object
141 142 143 |
# File 'lib/workarea/storefront/system_test.rb', line 141 def disable_analytics_dom_events page.execute_script('WORKAREA.analytics.disableDomEvents();') end |
#fill_in_billing_address ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/workarea/storefront/system_test.rb', line 121 def fill_in_billing_address fill_in 'billing_address[first_name]', with: 'Ben' fill_in 'billing_address[last_name]', with: 'Crouse' fill_in 'billing_address[street]', with: '1019 S. 47th St.' fill_in 'billing_address[city]', with: 'Philadelphia' if page.has_field?('billing_address[region]') fill_in 'billing_address[region]', with: 'PA' else select 'Pennsylvania', from: 'billing_address_region_select' end fill_in 'billing_address[postal_code]', with: '19143' fill_in 'billing_address[phone_number]', with: '2159251800' end |
#fill_in_credit_card ⇒ Object
114 115 116 117 118 119 |
# File 'lib/workarea/storefront/system_test.rb', line 114 def fill_in_credit_card fill_in 'credit_card[number]', with: '4111111111111111' next_year = (Time.current.year + 1).to_s select next_year, from: 'credit_card[year]' fill_in 'credit_card[cvv]', with: '999' end |
#fill_in_email ⇒ Object
90 91 92 |
# File 'lib/workarea/storefront/system_test.rb', line 90 def fill_in_email fill_in 'email', with: '[email protected]' end |
#fill_in_new_card_cvv ⇒ Object
110 111 112 |
# File 'lib/workarea/storefront/system_test.rb', line 110 def fill_in_new_card_cvv fill_in 'cvv[new_card]', with: '999' end |
#fill_in_shipping_address ⇒ Object
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/workarea/storefront/system_test.rb', line 94 def fill_in_shipping_address fill_in 'shipping_address[first_name]', with: 'Ben' fill_in 'shipping_address[last_name]', with: 'Crouse' fill_in 'shipping_address[street]', with: '22 S. 3rd St.' fill_in 'shipping_address[city]', with: 'Philadelphia' if page.has_field?('shipping_address[region]') fill_in 'shipping_address[region]', with: 'PA' else select 'Pennsylvania', from: 'shipping_address_region_select' end fill_in 'shipping_address[postal_code]', with: '19106' fill_in 'shipping_address[phone_number]', with: '2159251800' end |
#find_analytics_events(for_event: nil) ⇒ Object
145 146 147 148 149 150 151 152 153 |
# File 'lib/workarea/storefront/system_test.rb', line 145 def find_analytics_events(for_event: nil) all_events = page.evaluate_script('WORKAREA.analytics.events') if for_event.blank? all_events else all_events.select { |e| e['name'] == for_event } end end |
#select_shipping_service ⇒ Object
137 138 139 |
# File 'lib/workarea/storefront/system_test.rb', line 137 def select_shipping_service choose 'Ground' end |
#setup_checkout_specs ⇒ Object
4 5 6 7 |
# File 'lib/workarea/storefront/system_test.rb', line 4 def setup_checkout_specs create_supporting_data add_product_to_cart end |
#start_guest_checkout ⇒ Object
75 76 77 |
# File 'lib/workarea/storefront/system_test.rb', line 75 def start_guest_checkout visit storefront.checkout_path end |
#start_user_checkout ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'lib/workarea/storefront/system_test.rb', line 79 def start_user_checkout visit storefront.checkout_path click_link t('workarea.storefront.checkouts.login_title') within '#login_form' do fill_in 'email', with: '[email protected]' fill_in 'password', with: 'W3bl1nc!' t('workarea.storefront.users.login') end end |