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 @@
import { GlDeprecatedButton, GlDropdown, GlDropdownItem } from '@gitlab/ui';
const ANY_WEIGHT = 'Any Weight';
const NO_WEIGHT = 'No Weight';
const NO_WEIGHT = 'None';
export default {
components: {
......@@ -39,8 +39,8 @@ export default {
},
valueText() {
const { weight } = this.board;
if (weight > 0) return weight.toString();
if (weight === 0 || weight === NO_WEIGHT) return NO_WEIGHT;
if (weight > 0 || weight === 0) return weight.toString();
if (weight === -2) return NO_WEIGHT;
return ANY_WEIGHT;
},
},
......@@ -55,9 +55,10 @@ export default {
},
weightInt(weight) {
if (weight > 0) {
return weight;
}
if (weight === NO_WEIGHT) {
return parseInt(weight, 10);
} else if (weight === NO_WEIGHT) {
return -2;
} else if (weight === '0') {
return 0;
}
return -1;
......
......@@ -109,11 +109,16 @@ class BoardsStoreEE {
let { weight } = this.store.boardConfig;
if (weight !== -1) {
if (weight === 0) {
weight = '0';
}
if (weight === -2) {
/* eslint-disable-next-line @gitlab/require-i18n-strings */
weight = 'No+Weight';
weight = 'None';
}
updateFilterPath('weight', weight);
}
updateFilterPath('assignee_username', this.store.boardConfig.assigneeUsername);
if (this.store.boardConfig.assigneeUsername) {
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
context 'weight' do
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
create_board_weight(1)
......@@ -172,9 +174,21 @@ describe 'Scoped issue boards', :js do
it 'creates board filtering by "Any" weight' do
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)
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
create_board_weight(1)
......@@ -509,7 +523,9 @@ describe 'Scoped issue boards', :js do
if value.is_a?(Array)
value.each { |value| click_link value }
elsif filter == 'weight'
page.within(".dropdown-menu") do
click_button value
end
else
click_link value
end
......@@ -538,8 +554,11 @@ describe 'Scoped issue boards', :js do
page.within(".#{filter}") do
click_button 'Edit'
page.within(".dropdown-menu") do
filter == 'weight' ? click_button(value) : click_link(value)
end
end
click_on_board_modal
......
......@@ -11,7 +11,7 @@ describe('WeightSelect', () => {
const weightSelect = () => wrapper.find({ ref: 'weight-select' });
const defaultProps = {
weights: ['Any Weight', 'No Weight', 1, 2, 3],
weights: ['Any', 'None', 0, 1, 2, 3],
board: {
weight: null,
},
......@@ -98,11 +98,11 @@ describe('WeightSelect', () => {
describe('when a new weight value is selected', () => {
it.each`
weight | text
${'Any Weight'} | ${'Any Weight'}
${'No Weight'} | ${'No Weight'}
${0} | ${'No Weight'}
${-1} | ${'Any Weight'}
${null} | ${'Any Weight'}
${0} | ${'0'}
${1} | ${'1'}
${-1} | ${'Any Weight'}
${-2} | ${'None'}
`('$weight displays as "$text"', ({ weight, text }) => {
createComponent({ board: { weight } });
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