mirror of
https://github.com/mattermost/focalboard.git
synced 2024-11-24 08:22:29 +02:00
Gh 4482 fix empty filters (#4485)
* if no value on isBefore, isAfter return true * add unit tests Co-authored-by: Mattermost Build <build@mattermost.com>
This commit is contained in:
parent
41a722049f
commit
bd1532decf
@ -280,6 +280,10 @@ describe('src/cardFilter', () => {
|
||||
}
|
||||
|
||||
test('verify isBefore clause', () => {
|
||||
const filterClauseIsBeforeEmpty = createFilterClause({propertyId: 'datePropertyID', condition: 'isBefore', values: []})
|
||||
const resulta = CardFilter.isClauseMet(filterClauseIsBeforeEmpty, [template], dateCard)
|
||||
expect(resulta).toBeTruthy()
|
||||
|
||||
const filterClauseIsBefore = createFilterClause({propertyId: 'datePropertyID', condition: 'isBefore', values: [beforeRange.toString()]})
|
||||
const result = CardFilter.isClauseMet(filterClauseIsBefore, [template], dateCard)
|
||||
expect(result).toBeFalsy()
|
||||
@ -294,6 +298,10 @@ describe('src/cardFilter', () => {
|
||||
})
|
||||
|
||||
test('verify isAfter clauses', () => {
|
||||
const filterClauseIsAfterEmpty = createFilterClause({propertyId: 'datePropertyID', condition: 'isBefore', values: []})
|
||||
const resulta = CardFilter.isClauseMet(filterClauseIsAfterEmpty, [template], dateCard)
|
||||
expect(resulta).toBeTruthy()
|
||||
|
||||
const filterClauseIsAfter = createFilterClause({propertyId: 'datePropertyID', condition: 'isAfter', values: [afterRange.toString()]})
|
||||
const result = CardFilter.isClauseMet(filterClauseIsAfter, [template], dateCard)
|
||||
expect(result).toBeFalsy()
|
||||
@ -308,6 +316,10 @@ describe('src/cardFilter', () => {
|
||||
})
|
||||
|
||||
test('verify is clause', () => {
|
||||
const filterClauseIsEmpty = createFilterClause({propertyId: 'datePropertyID', condition: 'isBefore', values: []})
|
||||
const resulta = CardFilter.isClauseMet(filterClauseIsEmpty, [template], dateCard)
|
||||
expect(resulta).toBeTruthy()
|
||||
|
||||
const filterClauseIsBefore = createFilterClause({propertyId: 'datePropertyID', condition: 'is', values: [beforeRange.toString()]})
|
||||
const result = CardFilter.isClauseMet(filterClauseIsBefore, [template], dateCard)
|
||||
expect(result).toBeFalsy()
|
||||
|
@ -175,6 +175,9 @@ class CardFilter {
|
||||
return !(value as string || '').endsWith(filter.values[0]?.toLowerCase())
|
||||
}
|
||||
case 'isBefore': {
|
||||
if (filter.values.length === 0) {
|
||||
return true
|
||||
}
|
||||
if (dateValue !== undefined) {
|
||||
const numericFilter = parseInt(filter.values[0], 10)
|
||||
if (template && (template.type === 'createdTime' || template.type === 'updatedTime')) {
|
||||
@ -192,6 +195,9 @@ class CardFilter {
|
||||
return false
|
||||
}
|
||||
case 'isAfter': {
|
||||
if (filter.values.length === 0) {
|
||||
return true
|
||||
}
|
||||
if (dateValue !== undefined) {
|
||||
const numericFilter = parseInt(filter.values[0], 10)
|
||||
if (template && (template.type === 'createdTime' || template.type === 'updatedTime')) {
|
||||
|
Loading…
Reference in New Issue
Block a user