|
|
@ -5,6 +5,7 @@ import { ToolbarPage } from '../pages/Dashboard/common/Toolbar'; |
|
|
|
import { UITypes } from 'nocodb-sdk'; |
|
|
|
import { UITypes } from 'nocodb-sdk'; |
|
|
|
import { Api } from 'nocodb-sdk'; |
|
|
|
import { Api } from 'nocodb-sdk'; |
|
|
|
import { rowMixedValue } from '../setup/xcdb-records'; |
|
|
|
import { rowMixedValue } from '../setup/xcdb-records'; |
|
|
|
|
|
|
|
import dayjs from 'dayjs'; |
|
|
|
|
|
|
|
|
|
|
|
let dashboard: DashboardPage, toolbar: ToolbarPage; |
|
|
|
let dashboard: DashboardPage, toolbar: ToolbarPage; |
|
|
|
let context: any; |
|
|
|
let context: any; |
|
|
@ -654,19 +655,23 @@ test.describe('Filter Tests: Select based', () => { |
|
|
|
// Date & Time related
|
|
|
|
// Date & Time related
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
test.describe('Filter Tests: Date based', () => { |
|
|
|
function getUTCEpochTime(date) { |
|
|
|
const today = new Date().setHours(0, 0, 0, 0); |
|
|
|
return Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), 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); |
|
|
|
test.describe.only('Filter Tests: Date based', () => { |
|
|
|
const oneWeekFromNow = new Date(new Date().setDate(new Date().getDate() + 7)).setHours(0, 0, 0, 0); |
|
|
|
const today = getUTCEpochTime(new Date()); |
|
|
|
const oneMonthAgo = new Date(new Date().setMonth(new Date().getMonth() - 1)).setHours(0, 0, 0, 0); |
|
|
|
const tomorrow = getUTCEpochTime(new Date(new Date().setDate(new Date().getDate() + 1))); |
|
|
|
const oneMonthFromNow = new Date(new Date().setMonth(new Date().getMonth() + 1)).setHours(0, 0, 0, 0); |
|
|
|
const yesterday = getUTCEpochTime(new Date(new Date().setDate(new Date().getDate() - 1))); |
|
|
|
const daysAgo45 = new Date(new Date().setDate(new Date().getDate() - 45)).setHours(0, 0, 0, 0); |
|
|
|
const oneWeekAgo = getUTCEpochTime(new Date(new Date().setDate(new Date().getDate() - 7))); |
|
|
|
const daysFromNow45 = new Date(new Date().setDate(new Date().getDate() + 45)).setHours(0, 0, 0, 0); |
|
|
|
const oneWeekFromNow = getUTCEpochTime(new Date(new Date().setDate(new Date().getDate() + 7))); |
|
|
|
const thisMonth15 = new Date(new Date().setDate(15)).setHours(0, 0, 0, 0); |
|
|
|
const oneMonthAgo = getUTCEpochTime(dayjs().subtract(1, 'month').toDate()); |
|
|
|
const oneYearAgo = new Date(new Date().setFullYear(new Date().getFullYear() - 1)).setHours(0, 0, 0, 0); |
|
|
|
const oneMonthFromNow = getUTCEpochTime(dayjs().add(1, 'month').toDate()); |
|
|
|
const oneYearFromNow = new Date(new Date().setFullYear(new Date().getFullYear() + 1)).setHours(0, 0, 0, 0); |
|
|
|
const daysAgo45 = getUTCEpochTime(new Date(new Date().setDate(new Date().getDate() - 45))); |
|
|
|
|
|
|
|
const daysFromNow45 = getUTCEpochTime(new Date(new Date().setDate(new Date().getDate() + 45))); |
|
|
|
|
|
|
|
const thisMonth15 = getUTCEpochTime(new Date(new Date().setDate(15))); |
|
|
|
|
|
|
|
const oneYearAgo = getUTCEpochTime(new Date(new Date().setFullYear(new Date().getFullYear() - 1))); |
|
|
|
|
|
|
|
const oneYearFromNow = getUTCEpochTime(new Date(new Date().setFullYear(new Date().getFullYear() + 1))); |
|
|
|
|
|
|
|
|
|
|
|
async function dateTimeBasedFilterTest(dataType, setCount) { |
|
|
|
async function dateTimeBasedFilterTest(dataType, setCount) { |
|
|
|
await dashboard.closeTab({ title: 'Team & Auth' }); |
|
|
|
await dashboard.closeTab({ title: 'Team & Auth' }); |
|
|
@ -679,8 +684,7 @@ test.describe('Filter Tests: Date based', () => { |
|
|
|
// records array with time set to 00:00:00; store time in unix epoch
|
|
|
|
// records array with time set to 00:00:00; store time in unix epoch
|
|
|
|
const recordsTimeSetToZero = records.list.map(r => { |
|
|
|
const recordsTimeSetToZero = records.list.map(r => { |
|
|
|
const date = new Date(r[dataType]); |
|
|
|
const date = new Date(r[dataType]); |
|
|
|
date.setHours(0, 0, 0, 0); |
|
|
|
return getUTCEpochTime(date); |
|
|
|
return date.getTime(); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
const isFilterList = [ |
|
|
|
const isFilterList = [ |
|
|
@ -977,11 +981,11 @@ test.describe('Filter Tests: Date based', () => { |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Date : filters-1', async () => { |
|
|
|
test('Date : filters-1', async () => { |
|
|
|
await dateTimeBasedFilterTest('Date', 1); |
|
|
|
await dateTimeBasedFilterTest('Date', 0); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
test('Date : filters-2', async () => { |
|
|
|
test('Date : filters-2', async () => { |
|
|
|
await dateTimeBasedFilterTest('Date', 2); |
|
|
|
await dateTimeBasedFilterTest('Date', 1); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|