Commit 3179bdcc authored by Eugenia Grieff's avatar Eugenia Grieff Committed by Mike Greiling

Include none and 0 values for board weight

Add specs for new weight values

Change None persisted value to -2
parent f0cfb07c
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import { GlDeprecatedButton, GlDropdown, GlDropdownItem } from '@gitlab/ui'; import { GlDeprecatedButton, GlDropdown, GlDropdownItem } from '@gitlab/ui';
const ANY_WEIGHT = 'Any Weight'; const ANY_WEIGHT = 'Any Weight';
const NO_WEIGHT = 'No Weight'; const NO_WEIGHT = 'None';
export default { export default {
components: { components: {
...@@ -39,8 +39,8 @@ export default { ...@@ -39,8 +39,8 @@ export default {
}, },
valueText() { valueText() {
const { weight } = this.board; const { weight } = this.board;
if (weight > 0) return weight.toString(); if (weight > 0 || weight === 0) return weight.toString();
if (weight === 0 || weight === NO_WEIGHT) return NO_WEIGHT; if (weight === -2) return NO_WEIGHT;
return ANY_WEIGHT; return ANY_WEIGHT;
}, },
}, },
...@@ -55,9 +55,10 @@ export default { ...@@ -55,9 +55,10 @@ export default {
}, },
weightInt(weight) { weightInt(weight) {
if (weight > 0) { if (weight > 0) {
return weight; return parseInt(weight, 10);
} } else if (weight === NO_WEIGHT) {
if (weight === NO_WEIGHT) { return -2;
} else if (weight === '0') {
return 0; return 0;
} }
return -1; return -1;
......
...@@ -109,11 +109,16 @@ class BoardsStoreEE { ...@@ -109,11 +109,16 @@ class BoardsStoreEE {
let { weight } = this.store.boardConfig; let { weight } = this.store.boardConfig;
if (weight !== -1) { if (weight !== -1) {
if (weight === 0) { if (weight === 0) {
weight = '0';
}
if (weight === -2) {
/* eslint-disable-next-line @gitlab/require-i18n-strings */ /* eslint-disable-next-line @gitlab/require-i18n-strings */
weight = 'No+Weight'; weight = 'None';
} }
updateFilterPath('weight', weight); updateFilterPath('weight', weight);
} }
updateFilterPath('assignee_username', this.store.boardConfig.assigneeUsername); updateFilterPath('assignee_username', this.store.boardConfig.assigneeUsername);
if (this.store.boardConfig.assigneeUsername) { if (this.store.boardConfig.assigneeUsername) {
this.store.cantEdit.push('assignee'); this.store.cantEdit.push('assignee');
......
---
title: Fix board edit weight values 0 or None
merge_request: 29606
author:
type: fixed
...@@ -153,6 +153,8 @@ describe 'Scoped issue boards', :js do ...@@ -153,6 +153,8 @@ describe 'Scoped issue boards', :js do
context 'weight' do context 'weight' do
let!(:issue_weight_1) { create(:issue, project: project, weight: 1) } let!(:issue_weight_1) { create(:issue, project: project, weight: 1) }
let!(:issue_weight_0) { create(:issue, project: project, weight: 0) }
let!(:issue_weight_none) { create(:issue, project: project, weight: nil) }
it 'creates board filtering by weight' do it 'creates board filtering by weight' do
create_board_weight(1) create_board_weight(1)
...@@ -172,9 +174,21 @@ describe 'Scoped issue boards', :js do ...@@ -172,9 +174,21 @@ describe 'Scoped issue boards', :js do
it 'creates board filtering by "Any" weight' do it 'creates board filtering by "Any" weight' do
create_board_weight('Any') create_board_weight('Any')
expect(page).to have_selector('.board-card', count: 6)
end
it 'creates board filtering by "None" weight' do
create_board_weight('None')
expect(page).to have_selector('.board-card', count: 4) expect(page).to have_selector('.board-card', count: 4)
end end
it 'creates board filtering by "0" weight' do
create_board_weight(0)
expect(page).to have_selector('.board-card', count: 1)
end
it 'displays dot highlight and tooltip' do it 'displays dot highlight and tooltip' do
create_board_weight(1) create_board_weight(1)
...@@ -509,7 +523,9 @@ describe 'Scoped issue boards', :js do ...@@ -509,7 +523,9 @@ describe 'Scoped issue boards', :js do
if value.is_a?(Array) if value.is_a?(Array)
value.each { |value| click_link value } value.each { |value| click_link value }
elsif filter == 'weight' elsif filter == 'weight'
click_button value page.within(".dropdown-menu") do
click_button value
end
else else
click_link value click_link value
end end
...@@ -538,7 +554,10 @@ describe 'Scoped issue boards', :js do ...@@ -538,7 +554,10 @@ describe 'Scoped issue boards', :js do
page.within(".#{filter}") do page.within(".#{filter}") do
click_button 'Edit' click_button 'Edit'
filter == 'weight' ? click_button(value) : click_link(value)
page.within(".dropdown-menu") do
filter == 'weight' ? click_button(value) : click_link(value)
end
end end
click_on_board_modal click_on_board_modal
......
...@@ -11,7 +11,7 @@ describe('WeightSelect', () => { ...@@ -11,7 +11,7 @@ describe('WeightSelect', () => {
const weightSelect = () => wrapper.find({ ref: 'weight-select' }); const weightSelect = () => wrapper.find({ ref: 'weight-select' });
const defaultProps = { const defaultProps = {
weights: ['Any Weight', 'No Weight', 1, 2, 3], weights: ['Any', 'None', 0, 1, 2, 3],
board: { board: {
weight: null, weight: null,
}, },
...@@ -97,12 +97,12 @@ describe('WeightSelect', () => { ...@@ -97,12 +97,12 @@ describe('WeightSelect', () => {
describe('when a new weight value is selected', () => { describe('when a new weight value is selected', () => {
it.each` it.each`
weight | text weight | text
${'Any Weight'} | ${'Any Weight'} ${null} | ${'Any Weight'}
${'No Weight'} | ${'No Weight'} ${0} | ${'0'}
${0} | ${'No Weight'} ${1} | ${'1'}
${-1} | ${'Any Weight'} ${-1} | ${'Any Weight'}
${1} | ${'1'} ${-2} | ${'None'}
`('$weight displays as "$text"', ({ weight, text }) => { `('$weight displays as "$text"', ({ weight, text }) => {
createComponent({ board: { weight } }); createComponent({ board: { weight } });
expect(valueContainer().text()).toEqual(text); expect(valueContainer().text()).toEqual(text);
......
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