Browse Source

test: split to avoid timeout

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5185/head
Raju Udava 2 years ago
parent
commit
09b07d238c
  1. 235
      tests/playwright/tests/filters.spec.ts

235
tests/playwright/tests/filters.spec.ts

@ -57,6 +57,8 @@ async function verifyFilter(param: {
return; return;
} }
console.log(`Verifying filter: ${param.opType} ${param.opSubType}`);
await toolbar.clickFilter(); await toolbar.clickFilter();
await toolbar.filter.add({ await toolbar.filter.add({
columnTitle: param.column, columnTitle: param.column,
@ -596,8 +598,21 @@ test.describe('Filter Tests: Select based', () => {
// Date & Time related // Date & Time related
// //
test.describe('Filter Tests: Date & Time related', () => { test.describe('Filter Tests: Date based', () => {
async function dateTimeBasedFilterTest(dataType) { 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, suiteName) {
await dashboard.closeTab({ title: 'Team & Auth' }); await dashboard.closeTab({ title: 'Team & Auth' });
await dashboard.treeView.openTable({ title: 'dateTimeBased' }); await dashboard.treeView.openTable({ title: 'dateTimeBased' });
@ -612,19 +627,6 @@ test.describe('Filter Tests: Date & Time related', () => {
return date.getTime(); return date.getTime();
}); });
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);
const isFilterList = [ const isFilterList = [
{ {
opSub: 'today', opSub: 'today',
@ -671,29 +673,6 @@ test.describe('Filter Tests: Date & Time related', () => {
}, },
]; ];
for (let i = 0; i < isFilterList.length; i++) {
await verifyFilter({
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({
column: dataType,
opType: 'is not',
opSubType: isFilterList[i].opSub,
value: isFilterList[i]?.value?.toString() || '',
result: { rowCount: 800 - isFilterList[i].rowCount },
dataType: dataType,
});
}
// "is after" filter list // "is after" filter list
const isAfterFilterList = [ const isAfterFilterList = [
{ {
@ -741,50 +720,6 @@ test.describe('Filter Tests: Date & Time related', () => {
}, },
]; ];
for (let i = 0; i < isAfterFilterList.length; i++) {
await verifyFilter({
column: dataType,
opType: 'is after',
opSubType: isAfterFilterList[i].opSub,
value: isAfterFilterList[i]?.value?.toString() || '',
result: { rowCount: isAfterFilterList[i].rowCount },
dataType: dataType,
});
}
for (let i = 0; i < isAfterFilterList.length; i++) {
await verifyFilter({
column: dataType,
opType: 'is on or after',
opSubType: isAfterFilterList[i].opSub,
value: isAfterFilterList[i]?.value?.toString() || '',
result: { rowCount: 1 + isAfterFilterList[i].rowCount },
dataType: dataType,
});
}
for (let i = 0; i < isAfterFilterList.length; i++) {
await verifyFilter({
column: dataType,
opType: 'is before',
opSubType: isAfterFilterList[i].opSub,
value: isAfterFilterList[i]?.value?.toString() || '',
result: { rowCount: 800 - isAfterFilterList[i].rowCount - 1 },
dataType: dataType,
});
}
for (let i = 0; i < isAfterFilterList.length; i++) {
await verifyFilter({
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 within" filter list // "is within" filter list
const isWithinFilterList = [ const isWithinFilterList = [
{ {
@ -823,17 +758,6 @@ test.describe('Filter Tests: Date & Time related', () => {
}, },
]; ];
for (let i = 0; i < isWithinFilterList.length; i++) {
await verifyFilter({
column: dataType,
opType: 'is within',
opSubType: isWithinFilterList[i].opSub,
value: isWithinFilterList[i]?.value?.toString() || '',
result: { rowCount: isWithinFilterList[i].rowCount },
dataType: dataType,
});
}
// rest of the filters (without subop type) // rest of the filters (without subop type)
const filterList = [ const filterList = [
{ {
@ -846,15 +770,106 @@ test.describe('Filter Tests: Date & Time related', () => {
}, },
]; ];
for (let i = 0; i < filterList.length; i++) { switch (suiteName) {
await verifyFilter({ case 'is_is_not':
column: dataType, for (let i = 0; i < isFilterList.length; i++) {
opType: filterList[i].opType, await verifyFilter({
opSubType: null, column: dataType,
value: null, opType: 'is',
result: { rowCount: filterList[i].rowCount }, opSubType: isFilterList[i].opSub,
dataType: dataType, 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({
column: dataType,
opType: 'is not',
opSubType: isFilterList[i].opSub,
value: isFilterList[i]?.value?.toString() || '',
result: { rowCount: 800 - isFilterList[i].rowCount },
dataType: dataType,
});
}
break;
case 'is_before_is_on_or_before':
for (let i = 0; i < isAfterFilterList.length; i++) {
await verifyFilter({
column: dataType,
opType: 'is before',
opSubType: isAfterFilterList[i].opSub,
value: isAfterFilterList[i]?.value?.toString() || '',
result: { rowCount: 800 - isAfterFilterList[i].rowCount - 1 },
dataType: dataType,
});
}
for (let i = 0; i < isAfterFilterList.length; i++) {
await verifyFilter({
column: dataType,
opType: 'is on or before',
opSubType: isAfterFilterList[i].opSub,
value: isAfterFilterList[i]?.value?.toString() || '',
result: { rowCount: 800 - isAfterFilterList[i].rowCount },
dataType: dataType,
});
}
break;
case 'is_after_is_on_or_after':
for (let i = 0; i < isAfterFilterList.length; i++) {
await verifyFilter({
column: dataType,
opType: 'is after',
opSubType: isAfterFilterList[i].opSub,
value: isAfterFilterList[i]?.value?.toString() || '',
result: { rowCount: isAfterFilterList[i].rowCount },
dataType: dataType,
});
}
for (let i = 0; i < isAfterFilterList.length; i++) {
await verifyFilter({
column: dataType,
opType: 'is on or after',
opSubType: isAfterFilterList[i].opSub,
value: isAfterFilterList[i]?.value?.toString() || '',
result: { rowCount: 1 + isAfterFilterList[i].rowCount },
dataType: dataType,
});
}
break;
case 'is_within_is_blank':
for (let i = 0; i < isWithinFilterList.length; i++) {
await verifyFilter({
column: dataType,
opType: 'is within',
opSubType: isWithinFilterList[i].opSub,
value: isWithinFilterList[i]?.value?.toString() || '',
result: { rowCount: isWithinFilterList[i].rowCount },
dataType: dataType,
});
}
for (let i = 0; i < filterList.length; i++) {
await verifyFilter({
column: dataType,
opType: filterList[i].opType,
opSubType: null,
value: null,
result: { rowCount: filterList[i].rowCount },
dataType: dataType,
});
}
break;
default:
break;
} }
} }
@ -906,8 +921,20 @@ test.describe('Filter Tests: Date & Time related', () => {
} }
}); });
test('Date', async () => { test('Date : is, is not', async () => {
await dateTimeBasedFilterTest('Date'); await dateTimeBasedFilterTest('Date', 'is_is_not');
});
test('Date : is before, is on or before', async () => {
await dateTimeBasedFilterTest('Date', 'is_before_is_on_or_before');
});
test('Date : is after, is on or after', async () => {
await dateTimeBasedFilterTest('Date', 'is_after_is_on_or_after');
});
test('Date : is within, is blank', async () => {
await dateTimeBasedFilterTest('Date', 'is_within_is_blank');
}); });
}); });

Loading…
Cancel
Save