Skip to content

Commit

Permalink
feature: open new browser for every specs
Browse files Browse the repository at this point in the history
  • Loading branch information
rezerbit committed Nov 8, 2017
1 parent 6db8488 commit 7332a48
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 129 deletions.
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
require 'spec_helper'

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

before(:all) do
@cs_eti_page = CompanySite::EtiPage.new
@cs_main_page = CompanySite::MainPage.new

log_in_as(:user)
navigate_to_eti
cs_main_page.close_banner
@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.set_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)
@cs_eti_page.add_product
@cs_eti_page.set_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
expect(@cs_eti_page.product_name?(@name)).to be true
end

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

after(:all) { cs_eti_page.delete_product(@name) }
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.set_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)
@cs_eti_page.add_product
@cs_eti_page.set_rubric(CONFIG['eti']['rubric'])
@cs_eti_page.set_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
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']
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
expect(@cs_eti_page.product_published?(@name)).to be true
end

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

context 'когда копируем товар' do
Expand All @@ -77,23 +77,23 @@
wholesale_price: {wholesale_price: Faker::Number.number(2), wholesale_number: Faker::Number.number(2)}
}

cs_eti_page.create_and_set_product_fields(@product)
@cs_eti_page.create_and_set_product_fields(@product)

cs_eti_page.search_product(@product[:name])
cs_eti_page.copy_product(@product[:name])
@cs_eti_page.search_product(@product[:name])
@cs_eti_page.copy_product(@product[:name])

cs_eti_page.refresh
cs_eti_page.search_product(@product[:name])
@cs_eti_page.refresh
@cs_eti_page.search_product(@product[:name])
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
@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
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
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
require 'spec_helper'

describe 'ЕТИ. Редактирование товара. Статусы' do
cs_eti_page = CompanySite::EtiPage.new
cs_main_page = CompanySite::MainPage.new
admin_menu = Admin::Menu.new
admin_products_page = Admin::ProductsPage.new

before(:all) do
@cs_eti_page = CompanySite::EtiPage.new
@cs_main_page = CompanySite::MainPage.new
@admin_menu = Admin::Menu.new
@admin_products_page = Admin::ProductsPage.new

log_in_as(:user)
navigate_to_eti
cs_main_page.close_banner
@cs_main_page.close_banner

@product_1 = {
name: Faker::Name.title,
Expand All @@ -31,85 +31,85 @@
rubric: CONFIG['eti']['rubric']
}

cs_eti_page.create_and_set_product_fields(@product_1)
cs_eti_page.create_and_set_product_fields(@product_2)
cs_eti_page.create_and_set_product_fields(@product_3)
cs_eti_page.create_and_set_product_fields(@product_4)
@cs_eti_page.create_and_set_product_fields(@product_1)
@cs_eti_page.create_and_set_product_fields(@product_2)
@cs_eti_page.create_and_set_product_fields(@product_3)
@cs_eti_page.create_and_set_product_fields(@product_4)

navigate_to_admin_page
admin_menu.products
admin_products_page.accept_product(@product_1[:name])
admin_products_page.accept_product(@product_2[:name])
admin_products_page.reject_product(@product_3[:name])
admin_products_page.reject_product(@product_4[:name])
@admin_menu.products
@admin_products_page.accept_product(@product_1[:name])
@admin_products_page.accept_product(@product_2[:name])
@admin_products_page.reject_product(@product_3[:name])
@admin_products_page.reject_product(@product_4[:name])

navigate_to_eti
log_in_as(:user)
navigate_to_eti

cs_eti_page.change_status_to_archived(@product_2[:name])
cs_eti_page.change_status_to_archived(@product_4[:name])
@cs_eti_page.change_status_to_archived(@product_2[:name])
@cs_eti_page.change_status_to_archived(@product_4[:name])
end

after(:all) do
navigate_to_eti
cs_eti_page.delete_product(@product_1[:name])
cs_eti_page.delete_product(@product_2[:name])
cs_eti_page.delete_product(@product_3[:name])
cs_eti_page.delete_product(@product_4[:name])
@cs_eti_page.delete_product(@product_1[:name])
@cs_eti_page.delete_product(@product_2[:name])
@cs_eti_page.delete_product(@product_3[:name])
@cs_eti_page.delete_product(@product_4[:name])
end

context 'когда товары подтверждены' do
before(:all) { navigate_to_eti }

context 'когда исходный статус "Опубликованный"' do
before(:all) { cs_eti_page.search_product(@product_1[:name]) }
before(:all) { @cs_eti_page.search_product(@product_1[:name]) }

context 'когда меняем статус на архивный' do
before(:all) do
cs_eti_page.change_status_to_archived(@product_1[:name])
@cs_eti_page.change_status_to_archived(@product_1[:name])
Page.browser.navigate.refresh
end

it 'статус изменится на архивный' do
expect(cs_eti_page.product_archived?(@product_1[:name])).to be_truthy
expect(@cs_eti_page.product_archived?(@product_1[:name])).to be_truthy
end
end

context 'когда меняем статус с архивного на опубликованный' do
before(:all) do
cs_eti_page.change_status_to_published(@product_1[:name])
@cs_eti_page.change_status_to_published(@product_1[:name])
Page.browser.navigate.refresh
end

it 'статус изменится на опубликованный' do
expect(cs_eti_page.product_published?(@product_1[:name])).to be_truthy
expect(@cs_eti_page.product_published?(@product_1[:name])).to be_truthy
end
end
end

context 'когда исходный статус "Архивный"' do
before(:all) { cs_eti_page.search_product(@product_2[:name]) }
before(:all) { @cs_eti_page.search_product(@product_2[:name]) }

context 'когда меняем статус на опубликованный' do
before(:all) do
cs_eti_page.change_status_to_published(@product_2[:name])
@cs_eti_page.change_status_to_published(@product_2[:name])
Page.browser.navigate.refresh
end

it 'статус изменится на опубликованный' do
expect(cs_eti_page.product_published?(@product_2[:name])).to be_truthy
expect(@cs_eti_page.product_published?(@product_2[:name])).to be_truthy
end
end

context 'когда меняем статус с опубликованного на архивный' do
before(:all) do
cs_eti_page.change_status_to_archived(@product_2[:name])
@cs_eti_page.change_status_to_archived(@product_2[:name])
Page.browser.navigate.refresh
end

it 'статус изменится на архивный' do
expect(cs_eti_page.product_archived?(@product_2[:name])).to be_truthy
expect(@cs_eti_page.product_archived?(@product_2[:name])).to be_truthy
end
end
end
Expand All @@ -119,53 +119,53 @@
before(:all) { navigate_to_eti }

context 'когда исходный статус "Отклоненный"' do
before(:all) { cs_eti_page.search_product(@product_3[:name]) }
before(:all) { @cs_eti_page.search_product(@product_3[:name]) }

context 'когда меняем статус на архивный' do
before(:all) do
cs_eti_page.change_status_to_archived(@product_3[:name])
@cs_eti_page.change_status_to_archived(@product_3[:name])
Page.browser.navigate.refresh
end

it 'статус изменится на архивный' do
expect(cs_eti_page.product_archived?(@product_3[:name])).to be_truthy
expect(@cs_eti_page.product_archived?(@product_3[:name])).to be_truthy
end
end

context 'когда меняем статус с архивного на опубликованный' do
before(:all) do
cs_eti_page.change_status_to_published(@product_3[:name])
@cs_eti_page.change_status_to_published(@product_3[:name])
Page.browser.navigate.refresh
end

it 'статус изменится на отклоненный' do
expect(cs_eti_page.product_declined?(@product_3[:name])).to be_truthy
expect(@cs_eti_page.product_declined?(@product_3[:name])).to be_truthy
end
end
end

context 'когда исходный статус "Архивный"' do
before(:all) { cs_eti_page.search_product(@product_4[:name]) }
before(:all) { @cs_eti_page.search_product(@product_4[:name]) }

context 'когда меняем статус на опубликованный' do
before(:all) do
cs_eti_page.change_status_to_published(@product_4[:name])
@cs_eti_page.change_status_to_published(@product_4[:name])
Page.browser.navigate.refresh
end

it 'статус изменится на отклоненный' do
expect(cs_eti_page.product_declined?(@product_4[:name])).to be_truthy
expect(@cs_eti_page.product_declined?(@product_4[:name])).to be_truthy
end
end

context 'когда меняем статус с отклоненного на архивный' do
before(:all) do
cs_eti_page.change_status_to_archived(@product_4[:name])
@cs_eti_page.change_status_to_archived(@product_4[:name])
Page.browser.navigate.refresh
end

it 'статус изменится на архивный' do
expect(cs_eti_page.product_archived?(@product_4[:name])).to be_truthy
expect(@cs_eti_page.product_archived?(@product_4[:name])).to be_truthy
end
end
end
Expand Down
Loading

0 comments on commit 7332a48

Please sign in to comment.