mirror of https://github.com/nocodb/nocodb
Daniel Spaude
2 years ago
4 changed files with 160 additions and 0 deletions
@ -0,0 +1,124 @@
|
||||
import { test } from '@playwright/test'; |
||||
import { DashboardPage } from '../pages/Dashboard'; |
||||
import setup, { NcContext } from '../setup'; |
||||
import { isPg, isSqlite } from '../setup/db'; |
||||
|
||||
// Add formula to be verified here & store expected results for 5 rows
|
||||
// Column data from City table (Sakila DB)
|
||||
/** |
||||
* City LastUpdate Address List Country |
||||
* A Corua (La Corua) 2006-02-15 04:45:25 939 Probolinggo Loop Spain |
||||
* Abha 2006-02-15 04:45:25 733 Mandaluyong Place Saudi Arabia |
||||
* Abu Dhabi 2006-02-15 04:45:25 535 Ahmadnagar Manor United Arab Emirates |
||||
* Acua 2006-02-15 04:45:25 1789 Saint-Denis Parkway Mexico |
||||
* Adana 2006-02-15 04:45:25 663 Baha Blanca Parkway Turkey |
||||
*/ |
||||
// const formulaDataByDbType = (context: NcContext) => [
|
||||
// {
|
||||
// formula: '1 + 1',
|
||||
// result: ['2', '2', '2', '2', '2'],
|
||||
// },
|
||||
// {
|
||||
// formula: 'ADD({CityId}, {CountryId}) + AVG({CityId}, {CountryId}) + LEN({City})',
|
||||
// result: ['150', '130', '165', '100', '158'],
|
||||
// },
|
||||
// {
|
||||
// formula: `WEEKDAY("2022-07-19")`,
|
||||
// result: ['1', '1', '1', '1', '1'],
|
||||
// },
|
||||
// {
|
||||
// formula: `WEEKDAY("2022-07-19", "sunday")`,
|
||||
// result: ['2', '2', '2', '2', '2'],
|
||||
// },
|
||||
// {
|
||||
// formula: `CONCAT(UPPER({City}), LOWER({City}), TRIM(' trimmed '))`,
|
||||
// result: [
|
||||
// 'A CORUA (LA CORUA)a corua (la corua)trimmed',
|
||||
// 'ABHAabhatrimmed',
|
||||
// 'ABU DHABIabu dhabitrimmed',
|
||||
// 'ACUAacuatrimmed',
|
||||
// 'ADANAadanatrimmed',
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// formula: `CEILING(1.4) + FLOOR(1.6) + ROUND(2.5) + MOD({CityId}, 3) + MIN({CityId}, {CountryId}) + MAX({CityId}, {CountryId})`,
|
||||
// result: ['95', '92', '110', '71', '110'],
|
||||
// },
|
||||
// {
|
||||
// formula: `LOG({CityId}) + EXP({CityId}) + POWER({CityId}, 3) + SQRT({CountryId})`,
|
||||
// result: isPg(context)
|
||||
// ? ['13.04566088154786', '24.74547123273205', '57.61253379902822', '126.94617671688704', '283.9609869087087']
|
||||
// : ['13.04566088154786', '25.137588417628013', '58.23402483297667', '127.73041108667896', '284.8714548168068'],
|
||||
// },
|
||||
// {
|
||||
// formula: `NOW()`,
|
||||
// result: ['1', '1', '1', '1', '1'],
|
||||
// },
|
||||
// ];
|
||||
|
||||
const expectedQrCodeCellValues = [ |
||||
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJYAAACWCAYAAAA8AXHiAAAAAXNSR0IArs4c6QAAB+dJREFUeF7tne2W2jAMBZf3f2h66Om2TTB4ciMlLMz+RZHlq7Esm4+9XK/X65d/KlCswEWwihXV3W8FBEsQWhQQrBZZdSpYMtCigGC1yKpTwZKBFgUEq0VWnQqWDLQoIFgtsupUsGSgRQHBapFVp4IlAy0KCFaLrDoVLBloUUCwWmTVqWDJQIsCgtUiq04FSwZaFCgF63K5tARJna4/ZT2KJ/kkNplX4vfRvMh4VJOtdlXzECygPEl0VUJu4ZDxQNiRSdU8BAvITxJdlRDBGiSEJADkMTZxK4yl+/tg1QJprVhVQY7kIv0TAZ3EmI6Vgr4ej8SYItU1lmCBr1UK1nZsBUuwFtRUVUfBEizB+l+BdHtaF3WyQtOx7LG2b6HDJ0gjSBpqknySbDKtJB7i92bTCVYS92gRkZzR+S4WfuVvN5AguwQZJZIIksRD/AoW2QugkoK1FMqKBcGZmQmWYH0rcPipMNl6SG+Qbj1VvRq5xKWbw5kLlMY4LTLv3GMRaIjNTMRHrxNAUiC7FqhgDT6ik/Q0grX8qJNgCdbmQkpaCsESLMGa3ZjPFCIrrfI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R1+eK8AVqxn+hVr8igoVrU2/G2vWIr1IFB5oNwKXwgk5xz6DLsVuhUulurKk9sh1mipaX/JdkaZHbk9enhPMr9SgWnCq7ffdBzFak7ukdtwsjQqgmJd8IxFRaDbMO3PrRCQSi4U6dNH34TONjbA9X+IFav5YxWaDFo1aMI6rgH2Ok9RZtX50HF+9eF9DlKlglLoHdteMjat/pU+FWtCT7EqOj3bKpZiPQgkxwWinmIp1s8Ui9ifxCRvhUm/01i6ZY6uBF0vGKPneXjFqiSXHr5HQ0uSe+TYCdvR81SshP5LrBXrMzjFUizPWMQBz1iE0vcYt8IVbor1y8TattwxrarfbqBPMz13JfdG9EGhcWOIrvey2xlrfSp9EYrVx3apZ8UCzK1YANL0ornjT54kW0I+5byFFStnVm1hxQIErVgA0h4VK5+GLX4agZaK9dMguZ6cgGLlzGwBCCgWgGRITkCxcma2AAQUC0AyJCegWDkzWwACigUgGZITUKycmS0AAcUCkAzJCShWzswWgIBiAUiG5AQUK2dmC0BAsQAkQ3ICipUzswUgoFgAkiE5AcXKmdkCEFAsAMmQnIBi5cxsAQgoFoBkSE7gPxlL8reNvNsfAAAAAElFTkSuQmCC', |
||||
]; |
||||
|
||||
test.describe('Virtual Columns', () => { |
||||
let dashboard: DashboardPage; |
||||
let context: any; |
||||
|
||||
test.beforeEach(async ({ page }) => { |
||||
context = await setup({ page }); |
||||
dashboard = new DashboardPage(page, context.project); |
||||
}); |
||||
|
||||
async function formulaResultVerify({ |
||||
qrColumnTitle, |
||||
expectedQrCodes, |
||||
}: { |
||||
qrColumnTitle: string; |
||||
expectedQrCodes: string[]; |
||||
}) { |
||||
for (let i = 0; i < expectedQrCodes.length; i++) { |
||||
await dashboard.grid.cell.verify({ |
||||
index: i, |
||||
columnHeader: qrColumnTitle, |
||||
value: expectedQrCodes[i], |
||||
}); |
||||
} |
||||
} |
||||
|
||||
test('QrCode', async () => { |
||||
// close 'Team & Auth' tab
|
||||
// const formulaData = formulaDataByDbType(context);
|
||||
await dashboard.closeTab({ title: 'Team & Auth' }); |
||||
|
||||
await dashboard.treeView.openTable({ title: 'City' }); |
||||
// Create qr code column
|
||||
await dashboard.grid.column.create({ |
||||
title: 'QrCode1', |
||||
type: 'QrCode', |
||||
qrCodeValueColumnTitle: 'City', |
||||
}); |
||||
|
||||
// verify different formula's
|
||||
// for (let i = 1; i < formulaData.length; i++) {
|
||||
// // Sqlite does not support log function
|
||||
// if (isSqlite(context) && formulaData[i].formula.includes('LOG(')) continue;
|
||||
|
||||
// await dashboard.grid.column.openEdit({
|
||||
// title: 'NC_MATH_0',
|
||||
// type: 'Formula',
|
||||
// formula: formulaData[i].formula,
|
||||
// });
|
||||
// await dashboard.grid.column.save({ isUpdated: true });
|
||||
// if (formulaData[i].formula !== `NOW()`) {
|
||||
// await formulaResultVerify({
|
||||
// title: 'NC_MATH_0',
|
||||
// result: formulaData[i].result,
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
await dashboard.closeTab({ title: 'City' }); |
||||
}); |
||||
}); |
Loading…
Reference in new issue