BigW Consortium Gitlab

Commit e7ddb40c by Phil Hughes

Merge branch '32617-fix-template-selector-menu-visibility' into 'master'

Resolve "Template selectors menu title mistakenly shown after toggling previewed changes" Closes #32617 See merge request gitlab-org/gitlab-ce!18118
parents e9947951 d2482f15
...@@ -94,7 +94,7 @@ export default class FileTemplateMediator { ...@@ -94,7 +94,7 @@ export default class FileTemplateMediator {
const hash = urlPieces[1]; const hash = urlPieces[1];
if (hash === 'preview') { if (hash === 'preview') {
this.hideTemplateSelectorMenu(); this.hideTemplateSelectorMenu();
} else if (hash === 'editor') { } else if (hash === 'editor' && !this.typeSelector.isHidden()) {
this.showTemplateSelectorMenu(); this.showTemplateSelectorMenu();
} }
}); });
......
...@@ -32,6 +32,10 @@ export default class FileTemplateSelector { ...@@ -32,6 +32,10 @@ export default class FileTemplateSelector {
} }
} }
isHidden() {
return this.$wrapper.hasClass('hidden');
}
getToggleText() { getToggleText() {
return this.$dropdownToggleText.text(); return this.$dropdownToggleText.text();
} }
......
---
title: Fix template selector menu visibility when toggling preview mode in file edit
view
merge_request: 18118
author: Fabian Schneider
type: fixed
require 'spec_helper'
feature 'Template selector menu', :js do
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
before do
project.add_master(user)
sign_in user
end
context 'editing a non-matching file' do
before do
create_and_edit_file('README.md')
end
scenario 'is not displayed' do
check_template_selector_menu_display(false)
end
context 'user toggles preview' do
before do
click_link 'Preview'
end
scenario 'template selector menu is not displayed' do
check_template_selector_menu_display(false)
click_link 'Write'
check_template_selector_menu_display(false)
end
end
end
context 'editing a matching file' do
before do
visit project_edit_blob_path(project, File.join(project.default_branch, 'LICENSE'))
end
scenario 'is displayed' do
check_template_selector_menu_display(true)
end
context 'user toggles preview' do
before do
click_link 'Preview'
end
scenario 'template selector menu is hidden and shown correctly' do
check_template_selector_menu_display(false)
click_link 'Write'
check_template_selector_menu_display(true)
end
end
end
end
def check_template_selector_menu_display(is_visible)
count = is_visible ? 1 : 0
expect(page).to have_css('.template-selectors-menu', count: count)
end
def create_and_edit_file(file_name)
visit project_new_blob_path(project, 'master', file_name: file_name)
click_button "Commit changes"
visit project_edit_blob_path(project, File.join(project.default_branch, file_name))
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment