gitlab-org--gitlab-foss/spec/features/groups/group_name_toggle_spec.rb

52 lines
1.6 KiB
Ruby
Raw Normal View History

2017-02-28 21:59:55 -05:00
require 'spec_helper'
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) }
SMALL_SCREEN = 300
2017-02-28 21:59:55 -05:00
before do
login_as :user
end
it 'is not present if enough horizontal space' do
visit group_path(nested_group_3)
2017-02-28 21:59:55 -05: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
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)
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
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
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
click_button '...'
2017-02-28 21:59:55 -05: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