Skip to content

Commit

Permalink
fix(eti): delete product after copy
Browse files Browse the repository at this point in the history
  • Loading branch information
ovsyanik committed Nov 20, 2017
1 parent 4b96e71 commit 09e3e64
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,36 +65,37 @@
@product = {
name: Faker::Name.title,
rubric: CONFIG['eti']['rubric'],
portal_traits: {
gost: CONFIG['eti']['portal_traits']['gost'],
condition: CONFIG['eti']['portal_traits']['condition'],
manufacturer_country: CONFIG['eti']['portal_traits']['manufacturer_country']
},
exists: CONFIG['eti']['exists']['in stock'],
short_description: CONFIG['product_creation']['short_description']['valid'],
description: 'description',
price_from_to: {from: Faker::Number.number(3), to: Faker::Number.number(4)},
wholesale_price: {wholesale_price: Faker::Number.number(2), wholesale_number: Faker::Number.number(2)}
}

@cs_eti_page.create_and_set_product_fields(@product)
@portal_traits = {
trait_1: CONFIG['eti']['portal_traits']['trait_value_1'],
trait_2: CONFIG['eti']['portal_traits']['trait_value_2']
}

@cs_eti_page.create_and_set_product_fields(@product)
@cs_eti_page.refresh
@cs_eti_page.search_product(@product[:name])
@cs_eti_page.set_portal_traits(@product[:name], @portal_traits)
@cs_eti_page.copy_product(@product[:name])

@cs_eti_page.refresh
@cs_eti_page.search_product(@product[:name])
@cs_eti_page.wait_saving
end

# TODO: поправить удаление
# after(:all) { 2.times { cs_eti_page.delete_product(@product[:name])} }

it 'отобразится 2 идентичных товара' do
@first_product = @cs_eti_page.product_rows_elements[0].text

expect(@cs_eti_page.product_rows_elements.length).to eq 2
expect(@cs_eti_page.product_rows_elements[1].text).to eq @first_product
end

after(:all) { 2.times { @cs_eti_page.delete_product(@product[:name]) } }
end
end
end
33 changes: 14 additions & 19 deletions lib/pages/company_site/eti_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ class EtiPage < Page
span(:price_cell, xpath: "//*[contains(text(), 'Указать розничную цену')]")
span(:wholesale_price_cell, css: '.js-eti-wholesaleprice .bp-price-free')
span(:exist_cell, xpath: "//*[contains(text(), 'Указать наличие')]")
span(:portal_traits_cell, css: '.js-eti-traits-edit')
button(:add_product, css: '.new.js-add-product')
text_area(:edit_text_area, css: '.edit-text')

Expand All @@ -35,9 +34,6 @@ class EtiPage < Page
text_area(:description, css: '.cke_textarea_inline')
text_area(:wholesale_price, css: '.js-wholesale-price')
text_area(:wholesale_number, css: '.js-wholesale-min-qty')
text_area(:gost, xpath: "//input[@data-name='ГОСТ']")
text_area(:condition, xpath: "//input[@data-name='Состояние']")
text_area(:manufacturer_country, xpath: "//input[@data-name='Страна-производитель']")
button(:save_price, css: '.ui-button.ui-widget.ui-state-default.ui-corner-all.ui-button-text-only')

span(:price_value, css: '.bp-price.fsn')
Expand Down Expand Up @@ -234,30 +230,29 @@ def set_description(text)
wait_saving
end

def set_portal_traits(options = {})
Page.link(:gost_link, xpath: "//a[text()='#{options.fetch(:gost, '')}']")
Page.link(:condition_link, xpath: "//a[text()='#{options.fetch(:condition, '')}']")
Page.link(:manufacturer_country_link, xpath: "//a[text()='#{options.fetch(:manufacturer_country, '')}']")
def set_portal_traits(name, options = {})
Page.text_area(:trait_1, xpath: "//input[@data-name='#{CONFIG['eti']['portal_traits']['trait_1']}']")
Page.text_area(:trait_2, xpath: "//input[@data-name='#{CONFIG['eti']['portal_traits']['trait_2']}']")
Page.link(:trait_link1, xpath: "//a[text()='#{options.fetch(:trait_1, '')}']")
Page.link(:trait_link2, xpath: "//a[text()='#{options.fetch(:trait_2, '')}']")
Page.span(:portal_traits_cell, xpath:
"//td[@data-text='#{name}']/..//*[contains(text(), 'указать характеристики')]")

wait_until { portal_traits_cell_element.text.include?('указать характеристики') }
wait_until { portal_traits_cell? }

browser
.action
.move_to(portal_traits_cell_element.element)
.click
.perform

self.gost = options.fetch(:gost, '')
wait_until { gost_link? }
gost_link
self.trait_1 = options.fetch(:trait_1, '')
wait_until { trait_link1? }
trait_link1

self.condition = options.fetch(:condition, '')
wait_until { condition_link? }
condition_link

self.manufacturer_country = options.fetch(:manufacturer_country, '')
wait_until { manufacturer_country_link? }
manufacturer_country_link
self.trait_2 = options.fetch(:trait_2, '')
wait_until { trait_link2? }
trait_link2

save_portal_traits
wait_saving
Expand Down

0 comments on commit 09e3e64

Please sign in to comment.