Browse Source

test: filters for checkbox

Signed-off-by: Raju Udava <86527202+dstala@users.noreply.github.com>
pull/5106/head
Raju Udava 1 year ago
parent
commit
9cad5bd0b4
  1. 4
      tests/playwright/setup/xcdb-records.ts
  2. 81
      tests/playwright/tests/filters.spec.ts

4
tests/playwright/setup/xcdb-records.ts

@ -96,7 +96,11 @@ const rowMixedValue = (column: ColumnType, index: number) => {
const multiSelect = ['jan,feb,mar', 'apr,may,jun', 'jul,aug,sep', 'oct,nov,dec', 'jan,feb,mar', null];
const checkbox = [true, false, false, true, false, true, false, false, true, true];
switch (column.uidt) {
case UITypes.Checkbox:
return checkbox[index % checkbox.length];
case UITypes.Number:
case UITypes.Percent:
return numbers[index % numbers.length];

81
tests/playwright/tests/filters.spec.ts

@ -572,3 +572,84 @@ test.describe('Filter Tests: Select based', () => {
await selectBasedFilterTest('MultiSelect', '', 'jan,feb,mar', 'jan,feb,mar');
});
});
test.describe('Filter Tests: AddOn', () => {
async function addOnFilterTest(dataType) {
await dashboard.closeTab({ title: 'Team & Auth' });
await dashboard.treeView.openTable({ title: 'addOnTypes' });
const filterList = [
{
op: 'is checked',
value: null,
rowCount: records.list.filter(r => r[dataType] === 1).length,
},
{
op: 'is not checked',
value: null,
rowCount: records.list.filter(r => r[dataType] !== 1).length,
},
];
for (let i = 0; i < filterList.length; i++) {
await verifyFilter({
column: dataType,
opType: filterList[i].op,
value: filterList[i].value,
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: 'Checkbox',
title: 'Checkbox',
uidt: UITypes.Checkbox,
},
];
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: 'addOnTypes',
title: 'addOnTypes',
columns: columns,
});
const rowAttributes = [];
for (let i = 0; i < 400; i++) {
const row = {
Checkbox: 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: 400 });
} catch (e) {
console.error(e);
}
});
test('Filter: Checkbox', async () => {
await addOnFilterTest('Checkbox');
});
});

Loading…
Cancel
Save