Skip to content

Commit

Permalink
Merge pull request #21 from Copperface/feature/AT-215
Browse files Browse the repository at this point in the history
fix: minieti_spec
  • Loading branch information
Artemklochkov authored May 4, 2018
2 parents c8ec27e + 4185185 commit b119dee
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 19 deletions.
41 changes: 26 additions & 15 deletions lib/apress/selenium_eti/spec/company_site/minieti_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@
end

describe 'Поля' do
before(:all) { @cs_eti_page.add_product }

context 'когда заполняем имя' do
before(:all) do
@cs_eti_page.add_product
@name = Faker::Number.number(5)
@cs_eti_page.set_name(@name)
end
Expand All @@ -27,25 +26,27 @@

context 'когда добавляем картинку', skip: !RUN_CONFIG.fetch('local_running', false).to_b do
before(:all) do
@thermometer_value = @cs_eti_page.thermometer_value
@therm_value = @cs_eti_page.thermometer_value
@cs_eti_page.set_image(IMAGE_PATH)
end

it 'картинка появляется' do
expect(@cs_eti_page.image_loaded?).to be true
end

# Подсказка о том что изменения сохранены не появляется
it 'увеличивается градус на термометре' do
@cs_eti_page.wait_saving
expect(@cs_eti_page.thermometer_value).to be @thermometer_value + CONFIG['battery_percents']['image']
expect(
wait_until? { @cs_eti_page.thermometer_value == (@therm_value + CONFIG['battery_percents']['image']) }
).to be true
end

after(:all) { @cs_eti_page.close_image_uploader }
end
end

context 'когда заполняем цену' do
before(:all) do
@cs_eti_page.add_product
@cs_eti_page.set_name(Faker::Number.number(5))
@thermometer_value = @cs_eti_page.thermometer_value
@price = Faker::Number.number(3)

Expand All @@ -64,6 +65,7 @@
context 'когда заполняем цену от и до' do
before(:all) do
@cs_eti_page.add_product
@cs_eti_page.set_name(Faker::Number.number(5))

@thermometer_value = @cs_eti_page.thermometer_value
@price_from_to = {from: Faker::Number.number(2), to: Faker::Number.number(3)}
Expand All @@ -79,6 +81,7 @@
context 'когда заполняем цену со скидкой' do
before(:all) do
@cs_eti_page.add_product
@cs_eti_page.set_name(Faker::Number.number(5))

@thermometer_value = @cs_eti_page.thermometer_value
@discount_price = {previous: Faker::Number.number(3), discount: Faker::Number.number(2)}
Expand All @@ -94,15 +97,24 @@
end

context 'когда заполняем наличие' do
before { @cs_eti_page.set_exists(CONFIG['eti']['exists']['in stock']) }
before do
@cs_eti_page.add_product
@cs_eti_page.set_name(Faker::Number.number(5))
@cs_eti_page.set_exists(CONFIG['eti']['exists']['in stock'])
end

it 'для товара отобразится статус "В наличии"' do
expect(@cs_eti_page.exists_value).to match(/[Вв] наличии/)
end
end

context 'когда заполняем рубрику' do
before(:all) { @cs_eti_page.set_rubric(CONFIG['eti']['rubric']) }
before(:all) do
@cs_eti_page.add_product
@cs_eti_page.set_name(Faker::Number.number(5))
@rubric = @cs_eti_page.rubric_cell
@cs_eti_page.set_rubric(CONFIG['eti']['rubric'])
end

it 'привязывается рубрика' do
expect(@cs_eti_page.rubric_cell).to include CONFIG['eti']['rubric']
Expand All @@ -112,7 +124,7 @@
before(:all) { @cs_eti_page.operation_undo }

it 'рубрика исчезает' do
expect(@cs_eti_page.rubric_cell).to include 'Указать рубрику'
expect(@cs_eti_page.rubric_cell).to eq @rubric
end

context 'когда повторяем отмененное действие' do
Expand Down Expand Up @@ -179,13 +191,12 @@
end

context 'когда выбираем количество товаров на странице' do
before do
@cs_eti_page.choose_amount_of_products_on_page = '50'
@cs_eti_page.wait_saving
end
before { @cs_eti_page.choose_amount_of_products_on_page(50) }

it 'количество товаров на странице равно выбранному значению' do
expect((@cs_eti_page.product_elements.size <= 50) && (@cs_eti_page.product_elements.size > 20))
expect(
wait_until? { (@cs_eti_page.product_elements.size <= 50) && (@cs_eti_page.product_elements.size > 20) }
).to be true
end
end
end
14 changes: 10 additions & 4 deletions lib/pages/company_site/eti_page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class EtiPage < Page
button(:close_image_uploader, css: '.ui-resizable .ui-dialog-titlebar-close')

span(:image_uploader, css: '.ui-dialog.ui-widget.ui-widget-content.ui-corner-all.ui-front.ui-draggable')
button(:image_cell, xpath: "//*[@class='ibb-no-photo']/i[@class='fa fa-camera blank-image']")
button(:image_cell, css: '.js-upload-photo .blank-image')
button(:image_upload_btn, css: '.js-upload-input')
span(:thermometer, css: '.js-battery-wrapper')
span(:rubric_cell, css: '.js-rubric-preview-link')
Expand All @@ -68,7 +68,7 @@ class EtiPage < Page
button(:publish_product, css: '.dialog-status .published')
button(:archive_product, css: '.dialog-status .archived')

select_list(:choose_amount_of_products_on_page, css: '.ptrfap-choose-amount')
button(:amount_selector, css: '.ptrfap-choose-amount-wrapper>.custom-combobox>.ui-button')
divs(:product, css: 'tr.pt-tr')
div(:save_status, css: '.js-status-bar-content')
text_area(:product_search, xpath: "//*[@id='product-bindings-search']")
Expand Down Expand Up @@ -194,8 +194,7 @@ def set_image(path)
image_cell
upload_file(upload_image_element, path)
wait_until { image_loaded? }
# TODO
# добавить закрытие попапа (close_image_uploader) и изменить кейс в mini_eti_spec
close_image_uploader
end

def set_short_description(text)
Expand Down Expand Up @@ -365,6 +364,13 @@ def set_group(name)
submit
end

def choose_amount_of_products_on_page(count)
amount_selector
Page.button(:product_amount,
xpath: "//*[contains(@class, 'js-choose-amount-combobox')]//*[contains(text(), '#{count}')]")
product_amount
end

ActiveSupport.run_load_hooks(:'apress/selenium_eti/company_site/eti_page', self)
end
end

0 comments on commit b119dee

Please sign in to comment.