2017-02-28 21:59:55 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-03-15 11:18:51 -04:00
|
|
|
feature 'Group name toggle', feature: true, js: true do
|
2017-02-28 21:59:55 -05:00
|
|
|
let(:group) { create(:group) }
|
|
|
|
let(:nested_group_1) { create(:group, parent: group) }
|
|
|
|
let(:nested_group_2) { create(:group, parent: nested_group_1) }
|
|
|
|
let(:nested_group_3) { create(:group, parent: nested_group_2) }
|
|
|
|
|
2017-03-18 08:01:00 -04:00
|
|
|
SMALL_SCREEN = 300
|
|
|
|
|
2017-02-28 21:59:55 -05:00
|
|
|
before do
|
|
|
|
login_as :user
|
|
|
|
end
|
|
|
|
|
2017-03-18 08:01:00 -04:00
|
|
|
it 'is not present if enough horizontal space' do
|
|
|
|
visit group_path(nested_group_3)
|
2017-02-28 21:59:55 -05:00
|
|
|
|
2017-03-18 08:01:00 -04:00
|
|
|
container_width = page.evaluate_script("$('.title-container')[0].offsetWidth")
|
|
|
|
title_width = page.evaluate_script("$('.title')[0].offsetWidth")
|
|
|
|
|
|
|
|
expect(container_width).to be > title_width
|
2017-02-28 21:59:55 -05:00
|
|
|
expect(page).not_to have_css('.group-name-toggle')
|
|
|
|
end
|
|
|
|
|
2017-03-18 08:01:00 -04:00
|
|
|
it 'is present if the title is longer than the container' do
|
2017-02-28 21:59:55 -05:00
|
|
|
visit group_path(nested_group_3)
|
2017-03-18 08:01:00 -04:00
|
|
|
title_width = page.evaluate_script("$('.title')[0].offsetWidth")
|
|
|
|
|
|
|
|
page_height = page.current_window.size[1]
|
|
|
|
page.current_window.resize_to(SMALL_SCREEN, page_height)
|
|
|
|
|
|
|
|
find('.group-name-toggle')
|
|
|
|
container_width = page.evaluate_script("$('.title-container')[0].offsetWidth")
|
|
|
|
|
|
|
|
expect(title_width).to be > container_width
|
2017-02-28 21:59:55 -05:00
|
|
|
end
|
|
|
|
|
2017-03-18 08:01:00 -04:00
|
|
|
it 'should show the full group namespace when toggled' do
|
|
|
|
page_height = page.current_window.size[1]
|
|
|
|
page.current_window.resize_to(SMALL_SCREEN, page_height)
|
|
|
|
visit group_path(nested_group_3)
|
2017-02-28 21:59:55 -05:00
|
|
|
|
2017-03-18 08:01:00 -04:00
|
|
|
expect(page).not_to have_content(group.name)
|
|
|
|
expect(page).to have_css('.group-path.hidable', visible: false)
|
2017-02-28 21:59:55 -05:00
|
|
|
|
2017-03-18 08:01:00 -04:00
|
|
|
click_button '...'
|
2017-02-28 21:59:55 -05:00
|
|
|
|
2017-03-18 08:01:00 -04:00
|
|
|
expect(page).to have_content(group.name)
|
|
|
|
expect(page).to have_css('.group-path.hidable', visible: true)
|
2017-02-28 21:59:55 -05:00
|
|
|
end
|
|
|
|
end
|