From 6f57f3d96f2ce48d964644a83886d95ccb47e1a0 Mon Sep 17 00:00:00 2001 From: DarkPhoenix2704 Date: Sun, 30 Jun 2024 09:45:44 +0000 Subject: [PATCH] tests: split tests into numerical, string, datetime --- .../db/features/column-aggregation.spec.ts | 443 ++++++++++-------- 1 file changed, 252 insertions(+), 191 deletions(-) diff --git a/tests/playwright/tests/db/features/column-aggregation.spec.ts b/tests/playwright/tests/db/features/column-aggregation.spec.ts index 41473da1f3..0c451110bc 100644 --- a/tests/playwright/tests/db/features/column-aggregation.spec.ts +++ b/tests/playwright/tests/db/features/column-aggregation.spec.ts @@ -177,23 +177,7 @@ const data = [ }, ]; -const verificationData = { - Title: { - count_unique: '2', - count_empty: '0', - count_filled: '2', - percent_unique: '100', - percent_filled: '100', - percent_empty: '0', - }, - LongText: { - count_unique: '2', - count_empty: '0', - count_filled: '2', - percent_unique: '100', - percent_filled: '100', - percent_empty: '0', - }, +const verificationNumericalData = { Number: { count_unique: '2', count_empty: '0', @@ -224,13 +208,14 @@ const verificationData = { std_dev: '0.2', range: '0.4', }, - Checkbox: { - checked: '1', - unchecked: '1', - percent_checked: '50', - percent_unchecked: '50', - }, - MultiSelect: { + Currency: { + sum: '300.5', + min: '100', + max: '200.5', + avg: '150.25', + median: '150.25', + std_dev: '0.2', + range: '100.5', count_unique: '2', count_empty: '0', count_filled: '2', @@ -238,7 +223,14 @@ const verificationData = { percent_filled: '100', percent_empty: '0', }, - SingleSelect: { + Percent: { + sum: '125', + min: '50', + max: '75', + avg: '62.5%', + median: '62.5%', + std_dev: '12.5%', + range: '25%', count_unique: '2', count_empty: '0', count_filled: '2', @@ -246,31 +238,41 @@ const verificationData = { percent_filled: '100', percent_empty: '0', }, - Date: { + Duration: { count_unique: '2', count_empty: '0', count_filled: '2', percent_unique: '100', percent_filled: '100', percent_empty: '0', - earliest_date: '2024-01-01', - latest_date: '2024-02-02', - date_range: '32 days', - month_range: '1 month', + sum: '00:55', + min: '00:22', + max: '00:33', + avg: '00:28', + median: '00:28', + std_dev: '00:06', + range: '00:12', }, - DateTime: { + + Rating: { count_unique: '2', count_empty: '0', count_filled: '2', percent_unique: '100', percent_filled: '100', percent_empty: '0', - earliest_date: '2024-01-01 10:00', - latest_date: '2024-02-02 12:00', - date_range: '32 days', - month_range: '1 month', + sum: '9', + min: '4', + max: '5', + avg: '4.5', + median: '4.5', + std_dev: '0.5', + range: '1', }, - Year: { +}; + +const verificationStringData = { + Title: { count_unique: '2', count_empty: '0', count_filled: '2', @@ -278,7 +280,7 @@ const verificationData = { percent_filled: '100', percent_empty: '0', }, - Time: { + LongText: { count_unique: '2', count_empty: '0', count_filled: '2', @@ -286,7 +288,7 @@ const verificationData = { percent_filled: '100', percent_empty: '0', }, - PhoneNumber: { + MultiSelect: { count_unique: '2', count_empty: '0', count_filled: '2', @@ -294,7 +296,7 @@ const verificationData = { percent_filled: '100', percent_empty: '0', }, - Email: { + SingleSelect: { count_unique: '2', count_empty: '0', count_filled: '2', @@ -310,14 +312,7 @@ const verificationData = { percent_filled: '100', percent_empty: '0', }, - Currency: { - sum: '300.5', - min: '100', - max: '200.5', - avg: '150.25', - median: '150.25', - std_dev: '0.2', - range: '100.5', + JSON: { count_unique: '2', count_empty: '0', count_filled: '2', @@ -325,97 +320,52 @@ const verificationData = { percent_filled: '100', percent_empty: '0', }, - Percent: { - sum: '125', - min: '50', - max: '75', - avg: '62.5%', - median: '62.5%', - std_dev: '12.5%', - range: '25%', - count_unique: '2', - count_empty: '0', - count_filled: '2', - percent_unique: '100', - percent_filled: '100', - percent_empty: '0', + User: { + count_unique: '1', + count_empty: '1', + count_filled: '1', + percent_unique: '50%', + percent_filled: '50%', + percent_empty: '50%', }, - Duration: { +}; + +const verificationDateTime = { + DateTime: { count_unique: '2', count_empty: '0', count_filled: '2', percent_unique: '100', percent_filled: '100', percent_empty: '0', - sum: '00:55', - min: '00:22', - max: '00:33', - avg: '00:28', - median: '00:28', - std_dev: '00:06', - range: '00:12', + earliest_date: '2024-01-01 10:00', + latest_date: '2024-02-02 12:00', + date_range: '32 days', + month_range: '1 month', }, - - Rating: { + Time: { count_unique: '2', count_empty: '0', count_filled: '2', percent_unique: '100', percent_filled: '100', percent_empty: '0', - sum: '9', - min: '4', - max: '5', - avg: '4.5', - median: '4.5', - std_dev: '0.5', - range: '1', }, - - JSON: { + Date: { count_unique: '2', count_empty: '0', count_filled: '2', percent_unique: '100', percent_filled: '100', percent_empty: '0', - }, - Attachment: { - attachment_size: '1.81 MiB', - count_unique: '1', - count_empty: '1', - count_filled: '1', - percent_unique: '50%', - percent_filled: '50%', - percent_empty: '50%', - }, - User: { - count_unique: '1', - count_empty: '1', - count_filled: '1', - percent_unique: '50%', - percent_filled: '50%', - percent_empty: '50%', + earliest_date: '2024-01-01', + latest_date: '2024-02-02', + date_range: '32 days', + month_range: '1 month', }, }; -const verificationDataAfterFilter = { - Title: { - count_unique: '2', - count_empty: '0', - count_filled: '2', - percent_unique: '100', - percent_filled: '100', - percent_empty: '0', - }, - LongText: { - count_unique: '1', - count_empty: '1', - count_filled: '1', - percent_unique: '50', - percent_filled: '50', - percent_empty: '50', - }, +const verificationNUmericalDataAfterFilter = { Number: { count_unique: '1', count_empty: '1', @@ -446,13 +396,14 @@ const verificationDataAfterFilter = { std_dev: '0', range: '0', }, - Checkbox: { - checked: '1', - unchecked: '1', - percent_checked: '50', - percent_unchecked: '50', - }, - MultiSelect: { + Currency: { + sum: '100', + min: '100', + max: '100', + avg: '100', + median: '100', + std_dev: '0', + range: '0', count_unique: '1', count_empty: '1', count_filled: '1', @@ -460,7 +411,14 @@ const verificationDataAfterFilter = { percent_filled: '50', percent_empty: '50', }, - SingleSelect: { + Percent: { + sum: '50', + min: '50', + max: '50', + avg: '50%', + median: '50%', + std_dev: '0%', + range: '0%', count_unique: '1', count_empty: '1', count_filled: '1', @@ -468,39 +426,49 @@ const verificationDataAfterFilter = { percent_filled: '50', percent_empty: '50', }, - Date: { + Duration: { count_unique: '1', count_empty: '1', count_filled: '1', percent_unique: '50', percent_filled: '50', percent_empty: '50', - earliest_date: '2024-01-01', - latest_date: '2024-01-01', - date_range: '0 days', - month_range: '0 month', + sum: '00:22', + min: '00:22', + max: '00:22', + avg: '00:22', + median: '00:22', + std_dev: '00:00', + range: '00:00', }, - DateTime: { + + Rating: { count_unique: '1', count_empty: '1', count_filled: '1', percent_unique: '50', percent_filled: '50', percent_empty: '50', - earliest_date: '2024-01-01 10:00', - latest_date: '2024-01-01 10:00', - date_range: '0 days', - month_range: '0 month', + sum: '4', + min: '4', + max: '4', + avg: '4', + median: '2', + std_dev: '0', + range: '4', }, - Year: { - count_unique: '1', - count_empty: '1', - count_filled: '1', - percent_unique: '50', - percent_filled: '50', - percent_empty: '50', +}; + +const verificationStringDataAfterFilter = { + Title: { + count_unique: '2', + count_empty: '0', + count_filled: '2', + percent_unique: '100', + percent_filled: '100', + percent_empty: '0', }, - Time: { + LongText: { count_unique: '1', count_empty: '1', count_filled: '1', @@ -508,7 +476,7 @@ const verificationDataAfterFilter = { percent_filled: '50', percent_empty: '50', }, - PhoneNumber: { + MultiSelect: { count_unique: '1', count_empty: '1', count_filled: '1', @@ -516,7 +484,7 @@ const verificationDataAfterFilter = { percent_filled: '50', percent_empty: '50', }, - Email: { + SingleSelect: { count_unique: '1', count_empty: '1', count_filled: '1', @@ -524,6 +492,7 @@ const verificationDataAfterFilter = { percent_filled: '50', percent_empty: '50', }, + Url: { count_unique: '1', count_empty: '1', @@ -532,14 +501,7 @@ const verificationDataAfterFilter = { percent_filled: '50', percent_empty: '50', }, - Currency: { - sum: '100', - min: '100', - max: '100', - avg: '100', - median: '100', - std_dev: '0', - range: '0', + JSON: { count_unique: '1', count_empty: '1', count_filled: '1', @@ -547,53 +509,42 @@ const verificationDataAfterFilter = { percent_filled: '50', percent_empty: '50', }, - Percent: { - sum: '50', - min: '50', - max: '50', - avg: '50%', - median: '50%', - std_dev: '0%', - range: '0%', + User: { count_unique: '1', count_empty: '1', count_filled: '1', - percent_unique: '50', - percent_filled: '50', - percent_empty: '50', + percent_unique: '50%', + percent_filled: '50%', + percent_empty: '50%', }, - Duration: { +}; + +const verificationDateTimeDataAfterFilter = { + Date: { count_unique: '1', count_empty: '1', count_filled: '1', percent_unique: '50', percent_filled: '50', percent_empty: '50', - sum: '00:22', - min: '00:22', - max: '00:22', - avg: '00:22', - median: '00:22', - std_dev: '00:00', - range: '00:00', + earliest_date: '2024-01-01', + latest_date: '2024-01-01', + date_range: '0 days', + month_range: '0 month', }, - - Rating: { + DateTime: { count_unique: '1', count_empty: '1', count_filled: '1', percent_unique: '50', percent_filled: '50', percent_empty: '50', - sum: '4', - min: '4', - max: '4', - avg: '4', - median: '2', - std_dev: '0', - range: '4', + earliest_date: '2024-01-01 10:00', + latest_date: '2024-01-01 10:00', + date_range: '0 days', + month_range: '0 month', }, - JSON: { + Time: { count_unique: '1', count_empty: '1', count_filled: '1', @@ -601,14 +552,6 @@ const verificationDataAfterFilter = { percent_filled: '50', percent_empty: '50', }, - User: { - count_unique: '1', - count_empty: '1', - count_filled: '1', - percent_unique: '50%', - percent_filled: '50%', - percent_empty: '50%', - }, }; const users: string[] = isEE() @@ -694,8 +637,126 @@ test.describe('Field Aggregation', () => { await unsetup(context); }); - test('Aggregation Grid Test', async ({ page }) => { - for (const x of Object.entries(verificationData)) { + test('Aggregation Grid Test - String Columns', async ({ page }) => { + for (const x of Object.entries(verificationStringData)) { + const colName = x[0]; + + for (const y of Object.entries(x[1])) { + await aggregationBar.updateAggregation({ + column_name: colName, + aggregation: y[0], + skipNetworkValidation: true, + }); + + await aggregationBar.verifyAggregation({ + column_name: colName, + aggregation: y[1], + }); + } + } + + const { api, table, base } = testContext; + + await api.dbTableRow.bulkCreate('noco', base.id, table.id, [ + { + Id: 3, + Title: 'Sample2', + }, + ]); + + await page.reload(); + + await dashboard.grid.toolbar.clickFilter(); + + await dashboard.grid.toolbar.filter.add({ + title: 'Title', + operation: 'is like', + value: 'Sample', + }); + + await page.waitForTimeout(4000); + + await dashboard.grid.toolbar.clickFilter(); + + for (const x of Object.entries(verificationStringDataAfterFilter)) { + const colName = x[0]; + + for (const y of Object.entries(x[1])) { + await aggregationBar.updateAggregation({ + column_name: colName, + aggregation: y[0], + skipNetworkValidation: true, + }); + + await aggregationBar.verifyAggregation({ + column_name: colName, + aggregation: y[1], + }); + } + } + }); + + test('Aggregation Grid Test - Numerical Columns', async ({ page }) => { + for (const x of Object.entries(verificationNumericalData)) { + const colName = x[0]; + + for (const y of Object.entries(x[1])) { + await aggregationBar.updateAggregation({ + column_name: colName, + aggregation: y[0], + skipNetworkValidation: true, + }); + + await aggregationBar.verifyAggregation({ + column_name: colName, + aggregation: y[1], + }); + } + } + + const { api, table, base } = testContext; + + await api.dbTableRow.bulkCreate('noco', base.id, table.id, [ + { + Id: 3, + Title: 'Sample2', + }, + ]); + + await page.reload(); + + await dashboard.grid.toolbar.clickFilter(); + + await dashboard.grid.toolbar.filter.add({ + title: 'Title', + operation: 'is like', + value: 'Sample', + }); + + await page.waitForTimeout(4000); + + await dashboard.grid.toolbar.clickFilter(); + + for (const x of Object.entries(verificationNUmericalDataAfterFilter)) { + const colName = x[0]; + + for (const y of Object.entries(x[1])) { + await aggregationBar.updateAggregation({ + column_name: colName, + aggregation: y[0], + skipNetworkValidation: true, + }); + + await aggregationBar.verifyAggregation({ + column_name: colName, + aggregation: y[1], + }); + } + } + }); + + test('Aggregation Grid Test - DateTime Columns', async ({ page }) => { + for (const x of Object.entries(verificationDateTime)) { const colName = x[0]; for (const y of Object.entries(x[1])) { @@ -735,7 +796,7 @@ test.describe('Field Aggregation', () => { await dashboard.grid.toolbar.clickFilter(); - for (const x of Object.entries(verificationDataAfterFilter)) { + for (const x of Object.entries(verificationDateTimeDataAfterFilter)) { const colName = x[0]; for (const y of Object.entries(x[1])) { @@ -762,7 +823,7 @@ test.describe('Field Aggregation', () => { await page.reload(); const sharedPage = new DashboardPage(page, context.base); - for (const x of Object.entries(verificationData)) { + for (const x of Object.entries(verificationStringData)) { const colName = x[0]; for (const y of Object.entries(x[1])) {