diff options
Diffstat (limited to 'spec/features/groups/group_name_toggle_spec.rb')
-rw-r--r-- | spec/features/groups/group_name_toggle_spec.rb | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/spec/features/groups/group_name_toggle_spec.rb b/spec/features/groups/group_name_toggle_spec.rb index 8528718a2f7..8a1d415c4f1 100644 --- a/spec/features/groups/group_name_toggle_spec.rb +++ b/spec/features/groups/group_name_toggle_spec.rb @@ -6,39 +6,46 @@ feature 'Group name toggle', feature: true, js: true do let(:nested_group_2) { create(:group, parent: nested_group_1) } let(:nested_group_3) { create(:group, parent: nested_group_2) } + SMALL_SCREEN = 300 + before do login_as :user end - it 'is not present for less than 3 groups' do - visit group_path(group) - expect(page).not_to have_css('.group-name-toggle') + it 'is not present if enough horizontal space' do + visit group_path(nested_group_3) - visit group_path(nested_group_1) + container_width = page.evaluate_script("$('.title-container')[0].offsetWidth") + title_width = page.evaluate_script("$('.title')[0].offsetWidth") + + expect(container_width).to be > title_width expect(page).not_to have_css('.group-name-toggle') end - it 'is present for nested group of 3 or more in the namespace' do - visit group_path(nested_group_2) - expect(page).to have_css('.group-name-toggle') - + it 'is present if the title is longer than the container' do visit group_path(nested_group_3) - expect(page).to have_css('.group-name-toggle') + 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 end - context 'for group with at least 3 groups' do - before do - visit group_path(nested_group_2) - 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) - it 'should show the full group namespace when toggled' do - expect(page).not_to have_content(group.name) - expect(page).to have_css('.group-path.hidable', visible: false) + expect(page).not_to have_content(group.name) + expect(page).to have_css('.group-path.hidable', visible: false) - click_button '...' + click_button '...' - expect(page).to have_content(group.name) - expect(page).to have_css('.group-path.hidable', visible: true) - end + expect(page).to have_content(group.name) + expect(page).to have_css('.group-path.hidable', visible: true) end end |