Skip to content

Commit

Permalink
feature(eti): creation product
Browse files Browse the repository at this point in the history
  • Loading branch information
ovsyanik-ka committed Oct 17, 2017
1 parent f1a3118 commit 13d992d
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
require 'spec_helper'

describe 'ЕТИ' do
cs_eti_page = CompanySite::EtiPage.new
cs_main_page = CompanySite::MainPage.new

before(:all) do
log_in_as(:user)
navigate_to_eti
cs_main_page.close_banner
end

describe 'Создание товара' do
context 'когда товар без рубрики' do
before(:all) do
@name = Faker::Number.number(5)
cs_eti_page.add_product
cs_eti_page.name = @name
cs_eti_page.wait_until { cs_eti_page.save_status == 'Все изменения сохранены' }
cs_eti_page.refresh
cs_eti_page.wait_until { cs_eti_page.save_status == 'Все изменения сохранены' }
cs_eti_page.search_product(@name)
end

it 'введенное имя отображается' do
expect(cs_eti_page.product_name?(@name)).to be true
end

it 'товар не опубликован' do
expect(cs_eti_page.product_unpublished?(@name)).to be true
end

after(:all) { cs_eti_page.delete_product(@name) }
end

context 'когда товар с рубрикой' do
before(:all) do
@name = Faker::Number.number(5)
cs_eti_page.add_product
cs_eti_page.set_rubric(CONFIG['eti']['rubric'])
cs_eti_page.name = @name
cs_eti_page.wait_until { cs_eti_page.first_product_status_element.attribute('title') == 'Опубликованные' }
cs_eti_page.refresh
cs_eti_page.wait_until { cs_eti_page.save_status == 'Все изменения сохранены' }
cs_eti_page.search_product(@name)
end

it 'введенное имя отображается' do
expect(cs_eti_page.product_name?(@name)).to be true
end

it 'рубрика привязана' do
expect(cs_eti_page.product_rubric_tree(@name)).to include CONFIG['eti']['rubric']
end

it 'товар опубликован' do
expect(cs_eti_page.product_published?(@name)).to be true
end

after(:all) { cs_eti_page.delete_product(@name) }
end
end
end
10 changes: 5 additions & 5 deletions lib/apress/selenium_eti/spec/company_site/minieti_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
end

it 'введенное имя отображается' do
expect(cs_eti_page.product_name).to include @name
expect(cs_eti_page.product_name?(@name)).to be true
end

context 'когда добавляем картинку' do
Expand Down Expand Up @@ -101,10 +101,10 @@
end

context 'когда заполняем рубрику' do
before(:all) { cs_eti_page.set_rubric(CONFIG['mini_eti']['rubric']) }
before(:all) { cs_eti_page.set_rubric(CONFIG['eti']['rubric']) }

it 'привязывается рубрика' do
expect(cs_eti_page.rubric_cell).to include CONFIG['mini_eti']['rubric']
expect(cs_eti_page.rubric_cell).to include CONFIG['eti']['rubric']
end

context 'когда отменяем действие' do
Expand All @@ -118,7 +118,7 @@
before(:all) { cs_eti_page.operation_redo }

it 'привязывается рубрика' do
expect(cs_eti_page.rubric_cell).to include CONFIG['mini_eti']['rubric']
expect(cs_eti_page.rubric_cell).to include CONFIG['eti']['rubric']
end
end
end
Expand Down Expand Up @@ -156,7 +156,7 @@
end

it 'товар удаляется' do
expect(cs_eti_page.product_name).not_to eq @name
expect(cs_eti_page.product_name?(@name)).to be false
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ class EtiPage < Page
button(:save, xpath: "//*[contains(text(), 'Подтвердить актуальность')]")
span(:progress_bar, css: '#pb')
button(:to_catalog, css: '.ml15')
span(:product_name, css: '.js-eti-name > .pt-td-content-wrapper')
span(:save_status, css: '.js-status-bar-content')
button(:add_products_menu, css: '.sb-label')
button(:add_product_manually, css: '.js-add-product')
span(:empty_product_name, xpath: "//*[text()[contains(.,'Указать название')]]")
span(:empty_product_name, xpath: "//*[text()[contains(., 'Указать название')]]")

span(:name_cell, xpath: "//*[@data-placeholder='Указать название']")
span(:price_cell, xpath: "//*[contains(text(), 'Указать цену')]")
span(:price_cell, xpath: "//*[contains(text(), 'Указать розничную цену')]")
span(:exist_cell, xpath: "//*[contains(text(), 'Указать наличие')]")
button(:add_product, css: '.new.js-add-product')
text_area(:edit_text_area, css: '.edit-text')
Expand Down Expand Up @@ -51,7 +50,6 @@ class EtiPage < Page
button(:first_rubric_search_result, css: '.src-link')
link(:page_2, xpath: "//*[@data-page='2']")
link(:page_1, xpath: "//*[@data-page='1']")
button(:delete_product, css: '.js-delete-product')
button(:copy_product, css: '.js-copy-product')
span(:found_products_count, css: '.js-products-count')
radio_button(:from_to, xpath: "(//*[@class = 'va-1 mr5 js-select-type-price'])[2]")
Expand All @@ -62,6 +60,10 @@ class EtiPage < Page

select_list(:choose_amount_of_products_on_page, css: '.ptrfap-choose-amount')
divs(:product, css: 'tr.pt-tr')
div(:save_status, css: ".js-status-bar-content")
text_area(:product_search, xpath: "//*[@id='product-bindings-search']")
button(:search_button, css: '.js-search-submit')
span(:first_product_status, css: ".js-eti-status > div > i")

alias old_confirm confirm
def save
Expand All @@ -70,7 +72,8 @@ def save
end

def delete
confirm(true) { delete_product }
Page.button(:delete_product_button, css: '.js-delete-product')
confirm(true) { delete_product_button }
end

def set_rubric(text)
Expand Down Expand Up @@ -169,6 +172,42 @@ def exists=(is_exist)
exists_true if is_exist
end

ActiveSupport.run_load_hooks(:'apress/selenium_eti/company_site/mini_eti_page', self)
def product_name?(name)
Page.span(:product_name_span, xpath: "//*[contains(text(), '#{name}')]")
product_name_span?
end

def product_rubric_tree(name)
Page.span(:rubric_header_span, xpath:
"//td[@data-text='#{name}']/..//span[@class='dashed-span js-rubric-preview-link']")
rubric_header_span_element.text
end

def product_published?(name)
Page.span(:publish_status_icon, xpath: "//td[@data-text='#{name}']/..//i[contains(@class, 'published')]")
publish_status_icon?
end

def product_unpublished?(name)
Page.span(:unpublish_status_icon, xpath: "//td[@data-text='#{name}']/..//i[contains(@class, 'unpublished')]")
unpublish_status_icon?
end

def search_product(name)
self.product_search = name
search_button
end

def delete_product(name)
search_product(name)
Page.button(:delete_product_icon, xpath:
"//td[@data-text='#{name}']/..//i[contains(@class, 'js-delete-product')]")

confirm(true) { delete_product_icon }
sleep 0.2
wait_until { save_status == 'Все изменения сохранены' }
end

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

0 comments on commit 13d992d

Please sign in to comment.