Sha256: b9206cbc45eff06ed83a7e2ca5a9a33b2673fc75189b55d55ccc306da85a9692

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 KB

Contents

require 'test_helper'

module Workarea
  decorate Storefront::BrowseSwatchesSystemTest, with: :one_theme do
    def test_swatches_on_browse_pages
      create_swatch(name: 'Red', image: product_image_file)
      create_swatch(name: 'Blue', hex: '0000ff')

      product = create_product(
        template: 'swatches',
        variants: [
          {
            sku: 'SKU1',
            details: { color: 'Red', size: 'Small', material: 'Cotton' }
          },
          {
            sku: 'SKU2',
            details: { color: 'Blue', size: 'Small', material: 'Suede' }
          }
        ]
      )

      category = create_category(product_ids: [product.id])

      visit storefront.category_path(category)

      assert_selector('.swatch-options__swatch-button-image--red')
      assert_selector('.swatch-options__swatch-button--blue')

      find('.swatch-options__swatch-button-image--red').click
      wait_for_xhr

      assert_selector(
        '.swatch-options__swatch--selected .swatch-options__swatch-button-image--red'
      )

      find('.swatch-options__swatch-button--blue').click
      wait_for_xhr

      assert_selector(
        '.swatch-options__swatch--selected .swatch-options__swatch-button--blue'
      )

      find('.product-summary__name a', match: :first).click
      assert_current_path(storefront.product_path(product, color: 'Blue'))
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
workarea-one_theme-1.3.1 test/system/workarea/storefront/browse_swatches_system_test.decorator
workarea-one_theme-1.3.0 test/system/workarea/storefront/browse_swatches_system_test.decorator