diff --git a/lib/apress/selenium_eti/spec/company_site/minieti_spec.rb b/lib/apress/selenium_eti/spec/company_site/minieti_spec.rb index d054381..e9531ca 100644 --- a/lib/apress/selenium_eti/spec/company_site/minieti_spec.rb +++ b/lib/apress/selenium_eti/spec/company_site/minieti_spec.rb @@ -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 @@ -27,7 +26,7 @@ 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 @@ -35,17 +34,19 @@ 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) @@ -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)} @@ -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)} @@ -94,7 +97,11 @@ 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(/[Вв] наличии/) @@ -102,7 +109,12 @@ 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'] @@ -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 @@ -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 diff --git a/lib/pages/company_site/eti_page.rb b/lib/pages/company_site/eti_page.rb index 305953a..b41c298 100644 --- a/lib/pages/company_site/eti_page.rb +++ b/lib/pages/company_site/eti_page.rb @@ -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') @@ -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']") @@ -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) @@ -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