fix new label errors not visible in dropdown for #27287, also humanize error key, improve testing hieararchy for reuse, remove duplicate test

This commit is contained in:
Tom Koole 2017-02-05 22:39:20 -05:00
parent 110cd58999
commit 7f67b6c210
3 changed files with 44 additions and 33 deletions

View file

@ -107,9 +107,9 @@
if (typeof label.message === 'string') { if (typeof label.message === 'string') {
errors = label.message; errors = label.message;
} else { } else {
errors = label.message.map(function (value, key) { errors = Object.keys(label.message).map(key =>
return key + " " + value[0]; `${gl.text.humanize(key)} ${label.message[key].join(', ')}`
}).join("<br/>"); ).join("<br/>");
} }
this.$newLabelError this.$newLabelError

View file

@ -0,0 +1,4 @@
---
title: Fix displaying error messages for create label dropdown
merge_request: 9058
author: Tom Koole

View file

@ -7,9 +7,9 @@ feature 'Issue Sidebar', feature: true do
let(:project) { create(:project, :public) } let(:project) { create(:project, :public) }
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let!(:user) { create(:user)} let!(:user) { create(:user)}
let!(:label) { create(:label, project: project, title: 'bug') }
before do before do
create(:label, project: project, title: 'bug')
login_as(user) login_as(user)
end end
@ -50,16 +50,6 @@ feature 'Issue Sidebar', feature: true do
visit_issue(project, issue) visit_issue(project, issue)
end end
describe 'when clicking on edit labels', js: true do
it 'shows dropdown option to create a new label' do
find('.block.labels .edit-link').click
page.within('.block.labels') do
expect(page).to have_content 'Create new'
end
end
end
context 'sidebar', js: true do context 'sidebar', js: true do
it 'changes size when the screen size is smaller' do it 'changes size when the screen size is smaller' do
sidebar_selector = 'aside.right-sidebar.right-sidebar-collapsed' sidebar_selector = 'aside.right-sidebar.right-sidebar-collapsed'
@ -77,36 +67,53 @@ feature 'Issue Sidebar', feature: true do
end end
end end
context 'creating a new label', js: true do context 'editing issue labels', js: true do
it 'shows option to crate a new label is present' do before do
page.within('.block.labels') do page.within('.block.labels') do
find('.edit-link').click find('.edit-link').click
end
end
it 'shows option to create a new label' do
page.within('.block.labels') do
expect(page).to have_content 'Create new' expect(page).to have_content 'Create new'
end end
end end
it 'shows dropdown switches to "create label" section' do context 'creating a new label', js: true do
page.within('.block.labels') do before do
find('.edit-link').click page.within('.block.labels') do
click_link 'Create new' click_link 'Create new'
end
expect(page).to have_content 'Create new label'
end end
end
it 'adds new label' do it 'shows dropdown switches to "create label" section' do
page.within('.block.labels') do page.within('.block.labels') do
find('.edit-link').click expect(page).to have_content 'Create new label'
sleep 1 end
click_link 'Create new' end
fill_in 'new_label_name', with: 'wontfix' it 'adds new label' do
page.find(".suggest-colors a", match: :first).click page.within('.block.labels') do
click_button 'Create' fill_in 'new_label_name', with: 'wontfix'
page.find(".suggest-colors a", match: :first).click
click_button 'Create'
page.within('.dropdown-page-one') do page.within('.dropdown-page-one') do
expect(page).to have_content 'wontfix' expect(page).to have_content 'wontfix'
end
end
end
it 'shows error message if label title is taken' do
page.within('.block.labels') do
fill_in 'new_label_name', with: label.title
page.find('.suggest-colors a', match: :first).click
click_button 'Create'
page.within('.dropdown-page-two') do
expect(page).to have_content 'Title has already been taken'
end
end end
end end
end end