1
0
mirror of https://github.com/mattermost/focalboard.git synced 2024-12-24 13:43:12 +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:
Scott Bishel 2023-01-19 12:21:20 -07:00 committed by GitHub
parent 41a722049f
commit bd1532decf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 0 deletions

View File

@ -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()

View File

@ -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')) {