|
|
|
@ -44,9 +44,39 @@ async function validateRowArray(param) {
|
|
|
|
|
await dashboard.grid.verifyTotalRowCount({ count: rowCount }); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function verifyFilter_withFixedModal(param: { |
|
|
|
|
column: string; |
|
|
|
|
opType: string; |
|
|
|
|
opSubType?: string; |
|
|
|
|
value?: string; |
|
|
|
|
result: { rowCount: number }; |
|
|
|
|
dataType?: string; |
|
|
|
|
}) { |
|
|
|
|
// if opType was included in skip list, skip it
|
|
|
|
|
if (skipList[param.column]?.includes(param.opType)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
await toolbar.filter.add({ |
|
|
|
|
columnTitle: param.column, |
|
|
|
|
opType: param.opType, |
|
|
|
|
opSubType: param.opSubType, |
|
|
|
|
value: param.value, |
|
|
|
|
isLocallySaved: false, |
|
|
|
|
dataType: param?.dataType, |
|
|
|
|
openModal: true, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// verify filtered rows
|
|
|
|
|
await validateRowArray({ |
|
|
|
|
rowCount: param.result.rowCount, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
async function verifyFilter(param: { |
|
|
|
|
column: string; |
|
|
|
|
opType: string; |
|
|
|
|
opSubType?: string; |
|
|
|
|
value?: string; |
|
|
|
|
result: { rowCount: number }; |
|
|
|
|
dataType?: string; |
|
|
|
@ -56,10 +86,13 @@ async function verifyFilter(param: {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
console.log(`Verifying filter: ${param.opType} ${param.opSubType}`); |
|
|
|
|
|
|
|
|
|
await toolbar.clickFilter(); |
|
|
|
|
await toolbar.filter.add({ |
|
|
|
|
columnTitle: param.column, |
|
|
|
|
opType: param.opType, |
|
|
|
|
opSubType: param.opSubType, |
|
|
|
|
value: param.value, |
|
|
|
|
isLocallySaved: false, |
|
|
|
|
dataType: param?.dataType, |
|
|
|
@ -591,6 +624,334 @@ test.describe('Filter Tests: Select based', () => {
|
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Date & Time related
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
test.describe('Filter Tests: Date based', () => { |
|
|
|
|
const today = new Date().setHours(0, 0, 0, 0); |
|
|
|
|
const tomorrow = new Date(new Date().setDate(new Date().getDate() + 1)).setHours(0, 0, 0, 0); |
|
|
|
|
const yesterday = new Date(new Date().setDate(new Date().getDate() - 1)).setHours(0, 0, 0, 0); |
|
|
|
|
const oneWeekAgo = new Date(new Date().setDate(new Date().getDate() - 7)).setHours(0, 0, 0, 0); |
|
|
|
|
const oneWeekFromNow = new Date(new Date().setDate(new Date().getDate() + 7)).setHours(0, 0, 0, 0); |
|
|
|
|
const oneMonthAgo = new Date(new Date().setMonth(new Date().getMonth() - 1)).setHours(0, 0, 0, 0); |
|
|
|
|
const oneMonthFromNow = new Date(new Date().setMonth(new Date().getMonth() + 1)).setHours(0, 0, 0, 0); |
|
|
|
|
const daysAgo45 = new Date(new Date().setDate(new Date().getDate() - 45)).setHours(0, 0, 0, 0); |
|
|
|
|
const daysFromNow45 = new Date(new Date().setDate(new Date().getDate() + 45)).setHours(0, 0, 0, 0); |
|
|
|
|
const thisMonth15 = new Date(new Date().setDate(15)).setHours(0, 0, 0, 0); |
|
|
|
|
const oneYearAgo = new Date(new Date().setFullYear(new Date().getFullYear() - 1)).setHours(0, 0, 0, 0); |
|
|
|
|
const oneYearFromNow = new Date(new Date().setFullYear(new Date().getFullYear() + 1)).setHours(0, 0, 0, 0); |
|
|
|
|
|
|
|
|
|
async function dateTimeBasedFilterTest(dataType) { |
|
|
|
|
await dashboard.closeTab({ title: 'Team & Auth' }); |
|
|
|
|
await dashboard.treeView.openTable({ title: 'dateTimeBased' }); |
|
|
|
|
|
|
|
|
|
// Enable NULL & EMPTY filters
|
|
|
|
|
await dashboard.gotoSettings(); |
|
|
|
|
await dashboard.settings.toggleNullEmptyFilters(); |
|
|
|
|
|
|
|
|
|
// records array with time set to 00:00:00; store time in unix epoch
|
|
|
|
|
const recordsTimeSetToZero = records.list.map(r => { |
|
|
|
|
const date = new Date(r[dataType]); |
|
|
|
|
date.setHours(0, 0, 0, 0); |
|
|
|
|
return date.getTime(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const isFilterList = [ |
|
|
|
|
{ |
|
|
|
|
opSub: 'today', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r === today).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'tomorrow', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r === tomorrow).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'yesterday', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r === yesterday).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'one week ago', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r === oneWeekAgo).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'one week from now', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r === oneWeekFromNow).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'one month ago', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r === oneMonthAgo).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'one month from now', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r === oneMonthFromNow).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'number of days ago', |
|
|
|
|
value: 45, |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r === daysAgo45).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'number of days from now', |
|
|
|
|
value: 45, |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r === daysFromNow45).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'exact date', |
|
|
|
|
value: 15, |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r === thisMonth15).length, |
|
|
|
|
}, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
// "is after" filter list
|
|
|
|
|
const isAfterFilterList = [ |
|
|
|
|
{ |
|
|
|
|
opSub: 'today', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r > today).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'tomorrow', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r > tomorrow).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'yesterday', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r > yesterday).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'one week ago', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r > oneWeekAgo).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'one week from now', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r > oneWeekFromNow).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'one month ago', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r > oneMonthAgo).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'one month from now', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r > oneMonthFromNow).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'number of days ago', |
|
|
|
|
value: 45, |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r > daysAgo45).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'number of days from now', |
|
|
|
|
value: 45, |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r > daysFromNow45).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'exact date', |
|
|
|
|
value: 15, |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r > thisMonth15).length, |
|
|
|
|
}, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
// "is within" filter list
|
|
|
|
|
const isWithinFilterList = [ |
|
|
|
|
{ |
|
|
|
|
opSub: 'the past week', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r >= oneWeekAgo && r <= today).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'the past month', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r >= oneMonthAgo && r <= today).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'the past year', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r >= oneYearAgo && r <= today).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'the next week', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r >= today && r <= oneWeekFromNow).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'the next month', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r >= today && r <= oneMonthFromNow).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'the next year', |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r >= today && r <= oneYearFromNow).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'the next number of days', |
|
|
|
|
value: 45, |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r >= today && r <= daysFromNow45).length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opSub: 'the past number of days', |
|
|
|
|
value: 45, |
|
|
|
|
rowCount: recordsTimeSetToZero.filter(r => r >= daysAgo45 && r <= today).length, |
|
|
|
|
}, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
// rest of the filters (without subop type)
|
|
|
|
|
const filterList = [ |
|
|
|
|
{ |
|
|
|
|
opType: 'is blank', |
|
|
|
|
rowCount: records.list.filter(r => r[dataType] === null || r[dataType] === '').length, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
opType: 'is not blank', |
|
|
|
|
rowCount: records.list.filter(r => r[dataType] !== null && r[dataType] !== '').length, |
|
|
|
|
}, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
await toolbar.clickFilter(); |
|
|
|
|
await toolbar.filter.clickAddFilter(); |
|
|
|
|
|
|
|
|
|
// "is" filter list
|
|
|
|
|
for (let i = 0; i < isFilterList.length; i++) { |
|
|
|
|
await verifyFilter_withFixedModal({ |
|
|
|
|
column: dataType, |
|
|
|
|
opType: 'is', |
|
|
|
|
opSubType: isFilterList[i].opSub, |
|
|
|
|
value: isFilterList[i]?.value?.toString() || '', |
|
|
|
|
result: { rowCount: isFilterList[i].rowCount }, |
|
|
|
|
dataType: dataType, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// mutually exclusive of "is" filter list
|
|
|
|
|
for (let i = 0; i < isFilterList.length; i++) { |
|
|
|
|
await verifyFilter_withFixedModal({ |
|
|
|
|
column: dataType, |
|
|
|
|
opType: 'is not', |
|
|
|
|
opSubType: isFilterList[i].opSub, |
|
|
|
|
value: isFilterList[i]?.value?.toString() || '', |
|
|
|
|
result: { rowCount: 800 - isFilterList[i].rowCount }, |
|
|
|
|
dataType: dataType, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// "is before" filter list
|
|
|
|
|
for (let i = 0; i < isAfterFilterList.length; i++) { |
|
|
|
|
await verifyFilter_withFixedModal({ |
|
|
|
|
column: dataType, |
|
|
|
|
opType: 'is before', |
|
|
|
|
opSubType: isAfterFilterList[i].opSub, |
|
|
|
|
value: isAfterFilterList[i]?.value?.toString() || '', |
|
|
|
|
result: { rowCount: 800 - isAfterFilterList[i].rowCount - 1 }, |
|
|
|
|
dataType: dataType, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// "is on or before" filter list
|
|
|
|
|
for (let i = 0; i < isAfterFilterList.length; i++) { |
|
|
|
|
await verifyFilter_withFixedModal({ |
|
|
|
|
column: dataType, |
|
|
|
|
opType: 'is on or before', |
|
|
|
|
opSubType: isAfterFilterList[i].opSub, |
|
|
|
|
value: isAfterFilterList[i]?.value?.toString() || '', |
|
|
|
|
result: { rowCount: 800 - isAfterFilterList[i].rowCount }, |
|
|
|
|
dataType: dataType, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// "is after" filter list
|
|
|
|
|
for (let i = 0; i < isAfterFilterList.length; i++) { |
|
|
|
|
await verifyFilter_withFixedModal({ |
|
|
|
|
column: dataType, |
|
|
|
|
opType: 'is after', |
|
|
|
|
opSubType: isAfterFilterList[i].opSub, |
|
|
|
|
value: isAfterFilterList[i]?.value?.toString() || '', |
|
|
|
|
result: { rowCount: isAfterFilterList[i].rowCount }, |
|
|
|
|
dataType: dataType, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// "is on or after" filter list
|
|
|
|
|
for (let i = 0; i < isAfterFilterList.length; i++) { |
|
|
|
|
await verifyFilter_withFixedModal({ |
|
|
|
|
column: dataType, |
|
|
|
|
opType: 'is on or after', |
|
|
|
|
opSubType: isAfterFilterList[i].opSub, |
|
|
|
|
value: isAfterFilterList[i]?.value?.toString() || '', |
|
|
|
|
result: { rowCount: 1 + isAfterFilterList[i].rowCount }, |
|
|
|
|
dataType: dataType, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// "is within" filter list
|
|
|
|
|
for (let i = 0; i < isWithinFilterList.length; i++) { |
|
|
|
|
await verifyFilter_withFixedModal({ |
|
|
|
|
column: dataType, |
|
|
|
|
opType: 'is within', |
|
|
|
|
opSubType: isWithinFilterList[i].opSub, |
|
|
|
|
value: isWithinFilterList[i]?.value?.toString() || '', |
|
|
|
|
result: { rowCount: isWithinFilterList[i].rowCount }, |
|
|
|
|
dataType: dataType, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// "is blank" and "is not blank" filter list
|
|
|
|
|
for (let i = 0; i < filterList.length; i++) { |
|
|
|
|
await verifyFilter_withFixedModal({ |
|
|
|
|
column: dataType, |
|
|
|
|
opType: filterList[i].opType, |
|
|
|
|
opSubType: null, |
|
|
|
|
value: null, |
|
|
|
|
result: { rowCount: filterList[i].rowCount }, |
|
|
|
|
dataType: dataType, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
test.beforeEach(async ({ page }) => { |
|
|
|
|
context = await setup({ page }); |
|
|
|
|
dashboard = new DashboardPage(page, context.project); |
|
|
|
|
toolbar = dashboard.grid.toolbar; |
|
|
|
|
|
|
|
|
|
api = new Api({ |
|
|
|
|
baseURL: `http://localhost:8080/`, |
|
|
|
|
headers: { |
|
|
|
|
'xc-auth': context.token, |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const columns = [ |
|
|
|
|
{ |
|
|
|
|
column_name: 'Id', |
|
|
|
|
title: 'Id', |
|
|
|
|
uidt: UITypes.ID, |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
column_name: 'Date', |
|
|
|
|
title: 'Date', |
|
|
|
|
uidt: UITypes.Date, |
|
|
|
|
}, |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
const project = await api.project.read(context.project.id); |
|
|
|
|
const table = await api.base.tableCreate(context.project.id, project.bases?.[0].id, { |
|
|
|
|
table_name: 'dateTimeBased', |
|
|
|
|
title: 'dateTimeBased', |
|
|
|
|
columns: columns, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
const rowAttributes = []; |
|
|
|
|
for (let i = 0; i < 800; i++) { |
|
|
|
|
const row = { |
|
|
|
|
Date: rowMixedValue(columns[1], i), |
|
|
|
|
}; |
|
|
|
|
rowAttributes.push(row); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
await api.dbTableRow.bulkCreate('noco', context.project.id, table.id, rowAttributes); |
|
|
|
|
records = await api.dbTableRow.list('noco', context.project.id, table.id, { limit: 800 }); |
|
|
|
|
} catch (e) { |
|
|
|
|
console.error(e); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
test('Date : filters', async () => { |
|
|
|
|
await dateTimeBasedFilterTest('Date'); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// Misc : Checkbox
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|