@datagrok/api-tests
Advanced tools
Comparing version 1.7.15-rc.abc to 1.7.16
{ | ||
"name": "@datagrok/api-tests", | ||
"friendlyName": "API Tests", | ||
"version": "1.7.15-rc.abc", | ||
"version": "1.7.16", | ||
"author": { | ||
@@ -13,10 +13,9 @@ "name": "Anna Muzychyna", | ||
"type": "git", | ||
"url": "git+https://github.com/datagrok-ai/public.git", | ||
"url": "https://github.com/datagrok-ai/public.git", | ||
"directory": "packages/ApiTests" | ||
}, | ||
"dependencies": { | ||
"@datagrok-libraries/utils": "^4.1.41", | ||
"@datagrok/api-tests": "^1.7.15-rc.test2", | ||
"@datagrok-libraries/utils": "^4.2.13", | ||
"cash-dom": "^8.1.1", | ||
"datagrok-api": "../../js-api", | ||
"datagrok-api": "^1.20.0", | ||
"dayjs": "^1.11.10", | ||
@@ -23,0 +22,0 @@ "rxjs": "^6.6.7", |
import * as grok from 'datagrok-api/grok'; | ||
import * as DG from 'datagrok-api/dg'; | ||
import {before, category, expect, test, expectArray, after} from '@datagrok-libraries/utils/src/test'; | ||
import { before, category, expect, test, expectArray, after } from '@datagrok-libraries/utils/src/test'; | ||
import { delay, delayWhen } from "rxjs/operators"; | ||
@@ -9,3 +10,4 @@ | ||
const dcParams = { | ||
dataSource: 'PostgresDart', server: 'localhost:5432', db: 'datagrok_dev', login: 'datagrok_dev', password: '123'}; | ||
dataSource: 'PostgresDart', server: 'localhost:5432', db: 'datagrok_dev', login: 'datagrok_dev', password: '123' | ||
}; | ||
@@ -50,9 +52,110 @@ test('Create, save, delete, share', async () => { | ||
const query = await grok.dapi.queries.save(q); | ||
await query.setProperties({jsScript: script}); | ||
await query.setProperties({ jsScript: script }); | ||
expect((await query.getProperties()).jsScript, script); | ||
await query.executeTable(); | ||
await grok.dapi.queries.delete(query); | ||
}, {skipReason: 'GROK-11670'}); | ||
}, { skipReason: 'GROK-11670' }); | ||
}); | ||
category('Dapi: connection cache', () => { | ||
const testFilePath1: string = 'System:AppData/ApiTests/test_files.txt'; | ||
const testFilePath2: string = 'System:AppData/ApiTests/renamed_test_files.txt'; | ||
before(async () => { | ||
const connection: DG.DataConnection = await grok.dapi.connections.filter(`shortName="AppData"`).first(); | ||
await grok.functions.call('DropConnectionCache', { 'connection': connection }); | ||
}); | ||
test('Invalidation, performance', async () => { | ||
// write file to trigger cache bump | ||
await grok.dapi | ||
.files.writeAsText(testFilePath1, 'Hello World!'); | ||
// measure first execution time | ||
let start = Date.now(); | ||
let list = await grok.dapi.files.list('System:AppData/ApiTests'); | ||
const first = Date.now() - start; | ||
// check if cache was bumped | ||
expect(list.some((f) => f.name === 'test_files.txt')); | ||
const second = await getExecutionTime(async () => { | ||
await grok.dapi.files.list('System:AppData/ApiTests'); | ||
}); | ||
// second execution should be faster | ||
expect(second * 10 < first); | ||
// cache should be bumped after renaming | ||
await grok.dapi.files.rename(testFilePath1, 'renamed_test_files.txt'); | ||
list = await grok.dapi.files.list('System:AppData/ApiTests'); | ||
expect(list.some((f) => f.name === 'renamed_test_files.txt')); | ||
// cache should be bumped after delete | ||
await grok.dapi.files.delete(testFilePath2); | ||
list = await grok.dapi.files.list('System:AppData/ApiTests'); | ||
expect(list.every((f) => f.name !== 'renamed_test_files.txt')); | ||
}); | ||
test('Dataframe: Ids', async () => { | ||
// not from cache | ||
const table1 = (await grok.dapi.files.readBinaryDataFrames('System:AppData/ApiTests/datasets/demog.csv'))[0]; | ||
// from cache | ||
const table2 = (await grok.dapi.files.readBinaryDataFrames('System:AppData/ApiTests/datasets/demog.csv'))[0]; | ||
// id should be absent when we read as csv, and second time from cache | ||
expect(!table1.id && !table2.id, true); | ||
}); | ||
test('Performance: read csv', async () => { | ||
const first = await getExecutionTime(async () => { | ||
await grok.dapi.files.readCsv('System:AppData/ApiTests/datasets/demog.csv'); | ||
}); | ||
const second = await getExecutionTime(async () => { | ||
await grok.dapi.files.readCsv('System:AppData/ApiTests/datasets/demog.csv'); | ||
}); | ||
// second execution should be faster | ||
expect(second * 2 < first); | ||
}); | ||
test('Sequential stress test', async () => { | ||
const times = DG.Test.isInBenchmark ? 1000 : 100; | ||
let demogCsvReads1 = []; | ||
await grok.dapi.files.readCsv('System:AppData/ApiTests/datasets/demog.csv'); | ||
await grok.dapi.files.readCsv('System:AppData/ApiTests/cars.csv'); | ||
for (let i = 0; i < times; i++) | ||
demogCsvReads1.push(await getExecutionTime(async () => { | ||
await grok.dapi.files.readCsv('System:AppData/ApiTests/datasets/demog.csv'); | ||
})); | ||
let carsReads1 = []; | ||
for (let i = 0; i < times; i++) | ||
carsReads1.push(await getExecutionTime(async () => { | ||
await grok.dapi.files.readCsv('System:AppData/ApiTests/cars.csv'); | ||
})); | ||
let carsReads2 = []; | ||
let demogCsvReads2 = []; | ||
for (let i = 0; i < times; i++) { | ||
demogCsvReads2.push(await getExecutionTime(async () => { | ||
await grok.dapi.files.readCsv('System:AppData/ApiTests/datasets/demog.csv'); | ||
})); | ||
carsReads2.push(await getExecutionTime(async () => { | ||
await grok.dapi.files.readCsv('System:AppData/ApiTests/cars.csv'); | ||
})); | ||
} | ||
const demog1Median = median(demogCsvReads1); | ||
const demog2Median = median(demogCsvReads2); | ||
expect(demog2Median < demog1Median * 1.5, true); | ||
const cars1Median = median(carsReads1); | ||
const cars2Median = median(carsReads2); | ||
expect(cars2Median < cars1Median * 1.5, true); | ||
}, { benchmark: true }); | ||
after(async () => { | ||
try { | ||
await grok.dapi.files.delete(testFilePath1); | ||
} catch (_) { } | ||
try { | ||
await grok.dapi.files.delete(testFilePath2); | ||
} catch (_) { } | ||
}); | ||
}); | ||
category('Dapi: TableQuery', () => { | ||
@@ -83,4 +186,6 @@ let dc: DG.DataConnection; | ||
from = fromTable.name; | ||
const dcParams = {dataSource: 'Postgres', server: 'dev.datagrok.ai:54322', db: 'northwind', | ||
login: 'datagrok', password: 'datagrok'}; | ||
const dcParams = { | ||
dataSource: 'Postgres', server: 'dev.datagrok.ai:54322', db: 'northwind', | ||
login: 'datagrok', password: 'datagrok' | ||
}; | ||
dc = DG.DataConnection.create('test', dcParams); | ||
@@ -139,3 +244,3 @@ dc = await grok.dapi.connections.save(dc); | ||
expect(dtqb instanceof DG.TableQueryBuilder, true); | ||
}, {skipReason: 'GROK-11670'}); | ||
}, { skipReason: 'GROK-11670' }); | ||
@@ -145,3 +250,3 @@ test('From', async () => { | ||
expect(dtqb instanceof DG.TableQueryBuilder, true); | ||
}, {skipReason: 'GROK-11670'}); | ||
}, { skipReason: 'GROK-11670' }); | ||
}); | ||
@@ -224,1 +329,15 @@ | ||
*/ | ||
async function getExecutionTime(f: () => any) { | ||
const start = Date.now(); | ||
await f(); | ||
return Date.now() - start; | ||
} | ||
function median(numbers: number[]) { | ||
const sorted = Array.from(numbers).sort((a, b) => a - b); | ||
const middle = Math.floor(sorted.length / 2); | ||
if (sorted.length % 2 === 0) | ||
return (sorted[middle - 1] + sorted[middle]) / 2; | ||
return sorted[middle]; | ||
} |
@@ -39,3 +39,2 @@ import * as grok from 'datagrok-api/grok'; | ||
test('users', async () => { | ||
expect((await grok.dapi.users.filter('selenium').list()).length, 11); | ||
expect((await grok.dapi.users.filter('firstName = "admin"').list()).length, 1); | ||
@@ -42,0 +41,0 @@ expect((await grok.dapi.users.filter('status = "active"').list({pageSize: 5})).length, 5); |
@@ -175,2 +175,28 @@ import * as grok from 'datagrok-api/grok'; | ||
test('list package funccall with func\'s valid nqName', async () => { | ||
const packFunc: DG.Func = await grok.functions.eval('ApiTests:dummyPackageFunction'); | ||
const funcCall = await packFunc.prepare({a: 1, b: 2}).call(); | ||
funcCall.newId(); | ||
await GDF.calls.save(funcCall); | ||
const loadedWithFuncs = await GDF.calls | ||
.filter(`func.name="dummyPackageFunction"`) | ||
.include('func') | ||
.list({pageSize: 10}); | ||
expect(loadedWithFuncs[0].func.nqName, 'ApiTests:dummyPackageFunction'); | ||
}, {skipReason: 'GROK-16228'}); | ||
test('list script funccall with func\'s valid nqName', async () => { | ||
const scriptFunc: DG.Func = await grok.functions.eval('ApiTests:dummyPackageScript'); | ||
const funcCall = await scriptFunc.prepare({a: 1, b: 2}).call(); | ||
funcCall.newId(); | ||
await GDF.calls.save(funcCall); | ||
const loadedWithFuncs = await GDF.calls | ||
.filter(`func.name="dummyPackageScript"`) | ||
.include('func') | ||
.list({pageSize: 10}); | ||
expect(loadedWithFuncs[0].func.nqName, 'ApiTests:DummyPackageScript'); | ||
}, {skipReason: 'GROK-16228'}); | ||
test('list', async () => { | ||
@@ -229,2 +255,32 @@ const func: DG.Func = await grok.functions.eval('Sin'); | ||
test('list package script funccalls with package', async () => { | ||
const loadedCalls = await grok.dapi.functions.calls | ||
.allPackageVersions() | ||
.include('func,func.package').filter(`func.name="dummyPackageScript"`).list(); | ||
expect(loadedCalls[0].func.package, 'ApiTests'); | ||
}, {skipReason: 'GROK-16230'}); | ||
test('list package function funccalls with package', async () => { | ||
const loadedCalls = await grok.dapi.functions.calls | ||
.allPackageVersions() | ||
.include('func,func.package').filter(`func.name="dummyPackageFunction"`).list(); | ||
expect(loadedCalls[0].func.package, 'ApiTests'); | ||
}, {skipReason: 'GROK-16230'}); | ||
test('filter script funcCalls by nqName', async () => { | ||
// expect no-throw | ||
await grok.dapi.functions.calls | ||
.allPackageVersions() | ||
.include('func,func.package').filter(`func.nqName="ApiTests:dummyPackageScript"`).list(); | ||
}, {skipReason: 'GROK-16229'}); | ||
test('filter package function funcCalls by nqName', async () => { | ||
// expect no-throw | ||
await grok.dapi.functions.calls | ||
.allPackageVersions() | ||
.include('func,func.package').filter(`func.nqName="ApiTests:dummyPackageFunction"`).list(); | ||
}, {skipReason: 'GROK-16229'}); | ||
test('find', async () => { | ||
@@ -231,0 +287,0 @@ const func: DG.Func = await grok.functions.eval('Sin'); |
@@ -15,3 +15,3 @@ import {category, expect, test, expectExceptionAsync} from '@datagrok-libraries/utils/src/test'; | ||
const apiTestsPackage = await grok.dapi.packages.find(_package.id); | ||
expect(apiTestsPackage.updatedOn.toString(), _package.updatedOn.toString()); | ||
expect(apiTestsPackage.updatedOn?.toString(), _package.updatedOn?.toString()); | ||
await expectExceptionAsync(() => grok.dapi.packages.find('00000').then()); | ||
@@ -18,0 +18,0 @@ }); |
@@ -36,3 +36,3 @@ import * as grok from 'datagrok-api/grok'; | ||
if (entityType == undefined) { | ||
entityType = DG.EntityType.create('test', 'semtype=test'); | ||
entityType = DG.EntityType.create('apiTest', 'semtype=test'); | ||
var et = schema.entityTypes; | ||
@@ -39,0 +39,0 @@ et.push(entityType); |
@@ -20,3 +20,3 @@ import * as grok from 'datagrok-api/grok'; | ||
expect(df.columns.contains(column.name), true); | ||
expect(column.tags[DG.TAGS.FORMULA], '${x}+${y}-${z}'); | ||
expect(column.meta.formula, '${x}+${y}-${z}'); | ||
expect(column.get(0), -2); | ||
@@ -89,3 +89,3 @@ expect(column.get(1), -1); | ||
const column = await df.columns.addNewCalculated('editable', '0'); | ||
column.dialogs.editFormula(); | ||
column.meta.dialogs.editFormula(); | ||
} finally { | ||
@@ -101,3 +101,3 @@ df.columns.remove('editable'); | ||
data.args.columns.forEach((column: DG.Column) => { | ||
if (column.tags.has(DG.TAGS.FORMULA) && column.name === 'calculated column') | ||
if (column.meta.formula !== null && column.name === 'calculated column') | ||
resolve('OK'); | ||
@@ -115,3 +115,3 @@ }))); | ||
data.args.columns.forEach((column: DG.Column) => { | ||
if (column.tags.has(DG.TAGS.FORMULA) && column.name === 'calculated column') | ||
if (column.meta.formula !== null && column.name === 'calculated column') | ||
resolve('OK'); | ||
@@ -118,0 +118,0 @@ }))); |
@@ -102,4 +102,4 @@ import * as DG from 'datagrok-api/dg'; | ||
const df1 = createDf(); | ||
df1.columns.byName('population').setTag('units', 'm'); | ||
expect('m', df1.columns.byName('population').getTag('units')); | ||
df1.columns.byName('population').meta.units = 'm'; | ||
expect('m', df1.columns.byName('population').meta.units); | ||
}); | ||
@@ -143,2 +143,21 @@ | ||
test('toCsv with grid settings', async () => { | ||
const t = DG.DataFrame.fromCsv(`x, y, z, a | ||
1, 6, 3, 4 | ||
5, 2, 7, 8 | ||
9, 10, 11, 12`); | ||
const grid = DG.Grid.create(t); | ||
grid.columns.byName('a')!.visible = false; | ||
grid.columns.setOrder(['x', 'z', 'y', 'a']); | ||
grid.sort(['x'], [false]); | ||
const t2 = DG.DataFrame.fromCsv(t.toCsv({visibleColumnsOnly: true}, grid)); | ||
expect(t2.columns.length === 3); | ||
expect(t2.columns.names()[1] === 'z'); | ||
expect(t2.columns.names()[2] === 'y'); | ||
expect(t2.columns.byName('x').getNumber(0) === 9); | ||
expect(t2.columns.byName('z').getNumber(1) === 7); | ||
expect(t2.columns.byName('y').getNumber(2) === 6); | ||
}); | ||
test('toJson | fromJson', async () => { | ||
@@ -145,0 +164,0 @@ const t = createDf(); |
@@ -42,3 +42,3 @@ /* eslint-disable */ | ||
return DG.toDart(await runLoop(false, tiny, getTinyGenerator(true, iterations))); | ||
}, {timeout: 400000}); | ||
}, {timeout: 400000, benchmark: true}); | ||
@@ -49,3 +49,3 @@ test('Tiny scalar calls with cache', async () => { | ||
return DG.toDart(await runLoop(true, tiny, getTinyGenerator(true, iterations))); | ||
}, {timeout: 400000}); | ||
}, {timeout: 400000, benchmark: true}); | ||
@@ -55,3 +55,3 @@ test('Cached dataframe', async () => { | ||
return DG.toDart(await runLoop(true, demog, getHeavyGenerator(10, type))); | ||
}, {timeout: 180000}); | ||
}, {timeout: 180000, benchmark: true}); | ||
@@ -58,0 +58,0 @@ test('Records limit, tiny', async () => { |
@@ -214,18 +214,18 @@ import {category, test} from '@datagrok-libraries/utils/src/test'; | ||
test('Round10', () => check({ | ||
'Round10(12345.12345, 6)': 12345.12345, | ||
'Round10(12345.12345, 4)': 12345.1235, | ||
'Round10(12345.12345, 0)': 12345, | ||
'Round10(PI, 2)': 3.14, | ||
'Round10(0.5, 0)': 1, | ||
'Round10(0.3, 0)': 0, | ||
'Round10(-0.5, 0)': -1, | ||
'Round10(175, -1)': 180, | ||
'Round10(170, -1)': 170, | ||
'Round10(175, -2)': 200, | ||
'Round10(125, -2)': 100, | ||
'Round10(12340.12345, -3.8)': 12000, | ||
'Round10(12340.12345, -4.2)': 10000, | ||
'Round10(12340.12345, -5)': 0, | ||
'Round10(null, 2)': undefined, | ||
test('RoundFloat', () => check({ | ||
'RoundFloat(12345.12345, 6)': 12345.12345, | ||
'RoundFloat(12345.12345, 4)': 12345.1235, | ||
'RoundFloat(12345.12345, 0)': 12345, | ||
'RoundFloat(PI, 2)': 3.14, | ||
'RoundFloat(0.5, 0)': 1, | ||
'RoundFloat(0.3, 0)': 0, | ||
'RoundFloat(-0.5, 0)': -1, | ||
'RoundFloat(175, -1)': 180, | ||
'RoundFloat(170, -1)': 170, | ||
'RoundFloat(175, -2)': 200, | ||
'RoundFloat(125, -2)': 100, | ||
'RoundFloat(12340.12345, -3.8)': 12000, | ||
'RoundFloat(12340.12345, -4.2)': 10000, | ||
'RoundFloat(12340.12345, -5)': 0, | ||
'RoundFloat(null, 2)': undefined, | ||
})); | ||
@@ -232,0 +232,0 @@ |
@@ -429,18 +429,18 @@ import * as grok from 'datagrok-api/grok'; | ||
}, | ||
Round10: { | ||
'Round10(12345.12345, 6)': 12345.12345, | ||
'Round10(12345.12345, 4)': 12345.1235, | ||
'Round10(12345.12345, 0)': 12345, | ||
'Round10(PI, 2)': 3.14, | ||
'Round10(0.5, 0)': 1, | ||
'Round10(0.3, 0)': 0, | ||
'Round10(-0.5, 0)': -1, | ||
'Round10(175, -1)': 180, | ||
'Round10(170, -1)': 170, | ||
'Round10(175, -2)': 200, | ||
'Round10(125, -2)': 100, | ||
'Round10(12340.12345, -3.8)': 12000, | ||
'Round10(12340.12345, -4.2)': 10000, | ||
'Round10(12340.12345, -5)': 0, | ||
'Round10(null, 2)': undefined, | ||
RoundFloat: { | ||
'RoundFloat(12345.12345, 6)': 12345.12345, | ||
'RoundFloat(12345.12345, 4)': 12345.1235, | ||
'RoundFloat(12345.12345, 0)': 12345, | ||
'RoundFloat(PI, 2)': 3.14, | ||
'RoundFloat(0.5, 0)': 1, | ||
'RoundFloat(0.3, 0)': 0, | ||
'RoundFloat(-0.5, 0)': -1, | ||
'RoundFloat(175, -1)': 180, | ||
'RoundFloat(170, -1)': 170, | ||
'RoundFloat(175, -2)': 200, | ||
'RoundFloat(125, -2)': 100, | ||
'RoundFloat(12340.12345, -3.8)': 12000, | ||
'RoundFloat(12340.12345, -4.2)': 10000, | ||
'RoundFloat(12340.12345, -5)': 0, | ||
'RoundFloat(null, 2)': undefined, | ||
}, | ||
@@ -447,0 +447,0 @@ Sin: { |
@@ -15,6 +15,6 @@ import * as grok from 'datagrok-api/grok'; | ||
grid = v.grid; | ||
demog.col('age')!.colors.setLinear(); | ||
demog.col('age')!.colors.setConditional({'<30': DG.Color.green, '30-70': '#ff0000'}); | ||
demog.col('sex')!.colors.setCategorical({'M': 0xFF0000FF, 'F': 0xFF800080}); | ||
demog.col('started')!.colors.setLinear([DG.Color.white, DG.Color.red]); | ||
demog.col('age')!.meta.colors.setLinear(); | ||
demog.col('age')!.meta.colors.setConditional({'<30': DG.Color.green, '30-70': '#ff0000'}); | ||
demog.col('sex')!.meta.colors.setCategorical({'M': 0xFF0000FF, 'F': 0xFF800080}); | ||
demog.col('started')!.meta.colors.setLinear([DG.Color.white, DG.Color.red]); | ||
grid.setOptions({colorCoding: 'None'}); | ||
@@ -37,23 +37,17 @@ grid.setOptions({colorCoding: 'Auto'}); | ||
function testTags(after: string = '') { | ||
const ageTags: any[] = Array.from(demog.col('age')!.tags); | ||
if (!hasTag(ageTags, '.color-coding-type') || | ||
!hasTag(ageTags, 'Conditional') || | ||
!hasTag(ageTags, '.color-coding-conditional') || | ||
!hasTag(ageTags, '{"<30":"#00ff00","30-70":"#ff0000"}')) | ||
const ageCol = demog.col('age')!; | ||
if (ageCol.meta.colors.getType() !== DG.COLOR_CODING_TYPE.CONDITIONAL || | ||
ageCol.getTag(DG.TAGS.COLOR_CODING_CONDITIONAL) !== '{"<30":"#00ff00","30-70":"#ff0000"}') | ||
throw new Error('Conditional Color Coding error on Age column' + after); | ||
const sexTags: any[] = Array.from(demog.col('sex')!.tags); | ||
if (!hasTag(sexTags, '.color-coding-type') || | ||
!hasTag(sexTags, 'Categorical') || | ||
!hasTag(sexTags, '.color-coding-categorical') || | ||
!hasTag(sexTags, '{"M":4278190335,"F":4286578816}')) | ||
const sexCol = demog.col('sex')!; | ||
if (sexCol.meta.colors.getType() !== DG.COLOR_CODING_TYPE.CATEGORICAL || | ||
sexCol.getTag(DG.TAGS.COLOR_CODING_CATEGORICAL) !== '{"M":4278190335,"F":4286578816}') | ||
throw new Error('Categorical Color Coding error on Sex column' + after); | ||
const startedTags: any[] = Array.from(demog.col('started')!.tags); | ||
if (!hasTag(startedTags, '.color-coding-type') || | ||
!hasTag(startedTags, 'Linear') || | ||
!hasTag(startedTags, '.color-coding-linear') || | ||
!hasTag(startedTags, '[4294967295,4294901760]')) | ||
const startedCol = demog.col('started')!; | ||
if (startedCol.meta.colors.getType() !== DG.COLOR_CODING_TYPE.LINEAR || | ||
startedCol.getTag(DG.TAGS.COLOR_CODING_LINEAR) !== '[4294967295,4294901760]') | ||
throw new Error('Linear Color Coding error on Started column' + after); | ||
} | ||
}); |
@@ -52,31 +52,20 @@ import * as grok from 'datagrok-api/grok'; | ||
demog.col('height')!.tags[DG.TAGS.COLOR_CODING_TYPE] = 'Conditional'; | ||
demog.col('height')!.tags[DG.TAGS.COLOR_CODING_CONDITIONAL] = `{"20-170":"#00FF00","170-190":"#220505"}`; | ||
demog.col('height')?.meta.colors.setConditional({'20-170': '#00FF00', '170-190': '#220505'}); | ||
demog.col('age')?.meta.colors.setLinear([DG.Color.orange, DG.Color.green]); | ||
demog.col('age')!.tags[DG.TAGS.COLOR_CODING_TYPE] = 'Linear'; | ||
demog.col('age')!.tags[DG.TAGS.COLOR_CODING_LINEAR] = `[${DG.Color.orange}, ${DG.Color.green}]`; | ||
//categorical RACE column check | ||
const raceTags: string[] = Array.from(demog.col('race')!.tags); | ||
if (!hasTag(raceTags, '.color-coding-categorical') || | ||
!hasTag(raceTags, '{"Asian":4278190335,"Black":4286578816,"Caucasian":4278547786,"Other":4293188935}')) | ||
const raceCol = demog.col('race')!; | ||
if (raceCol.getTag(DG.TAGS.COLOR_CODING_CATEGORICAL) !== '{"Asian":4278190335,"Black":4286578816,"Caucasian":4278547786,"Other":4293188935}') | ||
throw new Error('Categorical Color Coding error'); | ||
//numerical HEIGHT column check for Conditional ColorCoding | ||
const heightTags: string[] = Array.from(demog.col('height')!.tags); | ||
if (!hasTag(heightTags, '.color-coding-type') || | ||
!hasTag(heightTags, 'Conditional') || | ||
!hasTag(heightTags, '.color-coding-conditional') || | ||
!hasTag(heightTags, '{"20-170":"#00FF00","170-190":"#220505"}')) | ||
const heightCol = demog.col('height')!; | ||
if (heightCol.meta.colors.getType() !== DG.COLOR_CODING_TYPE.CONDITIONAL || | ||
heightCol.getTag(DG.TAGS.COLOR_CODING_CONDITIONAL) !== '{"20-170":"#00FF00","170-190":"#220505"}') | ||
throw new Error('Conditional Color Coding error'); | ||
//numerical AGE column check for Linear ColorCoding | ||
const ageTags: string[] = Array.from(demog.col('age')!.tags); | ||
if (!hasTag(ageTags, '.color-coding-type') || | ||
!hasTag(ageTags, 'Linear') || | ||
!hasTag(ageTags, '.color-coding-linear') || | ||
!hasTag(ageTags, '[4294944000, 4278255360]')) | ||
const ageCol = demog.col('age')!; | ||
if (ageCol.meta.colors.getType() !== DG.COLOR_CODING_TYPE.LINEAR || | ||
ageCol.getTag(DG.TAGS.COLOR_CODING_LINEAR) !== '[4294944000,4278255360]') | ||
throw new Error('Linear Color Coding error'); | ||
@@ -94,12 +83,7 @@ }); | ||
test('columnControlledValues', async () => { | ||
demog.col('site')!.tags[DG.TAGS.CHOICES] = '["New York", "Buffalo"]'; | ||
demog.col('site')!.tags[DG.TAGS.AUTO_CHOICES] = 'New York'; | ||
const col = demog.col('site'); | ||
col!.meta.choices = ['New York', 'Buffalo']; | ||
col!.meta.autoChoices = false; | ||
const siteTags: string[] = Array.from(demog.col('site')!.tags); | ||
if (!hasTag(siteTags, '.choices') || | ||
!hasTag(siteTags, '["New York", "Buffalo"]') || | ||
!hasTag(siteTags, '.auto-choices') || | ||
!hasTag(siteTags, 'New York')) | ||
if (JSON.stringify(col?.meta.choices) !== '["New York","Buffalo"]' || col?.meta.autoChoices !== false) | ||
throw new Error('Column Controlled Values (Choices) error'); | ||
@@ -106,0 +90,0 @@ }); |
@@ -15,3 +15,3 @@ import {category, test} from '@datagrok-libraries/utils/src/test'; | ||
French"`); | ||
table.col('Languages')!.setTag(DG.TAGS.MULTI_VALUE_SEPARATOR, '\n'); | ||
table.col('Languages')!.meta.multiValueSeparator = '\n'; | ||
@@ -18,0 +18,0 @@ test('grid.multiValuesColumn', async () => { |
@@ -50,2 +50,4 @@ import * as DG from 'datagrok-api/dg'; | ||
import './valuematcher/valuematcher'; | ||
import './property/property'; | ||
import './widgets/input-form'; | ||
@@ -52,0 +54,0 @@ import {runTests, tests, TestContext} from '@datagrok-libraries/utils/src/test'; |
/* Do not change these import lines. Datagrok will import API library in exactly the same manner */ | ||
import * as grok from 'datagrok-api/grok'; | ||
// import * as ui from 'datagrok-api/ui'; | ||
import * as ui from 'datagrok-api/ui'; | ||
import * as DG from 'datagrok-api/dg'; | ||
@@ -89,1 +89,11 @@ | ||
} | ||
//name: CustomStringInput | ||
//input: object params | ||
//output: object input | ||
export function CustomStringInput(params: any) { | ||
const defaultInput = ui.input.string('Custom input', {value: ''}); | ||
defaultInput.root.style.backgroundColor = 'aqua'; | ||
defaultInput.input.style.backgroundColor = 'aqua'; | ||
return defaultInput; | ||
} |
@@ -33,4 +33,4 @@ import * as grok from 'datagrok-api/grok'; | ||
expect(response.status, 200, `Container response status was ${response.status}`); | ||
const result = await response.json(); | ||
const result: { [key: string]: any } = await response.json() as { [key: string]: any }; | ||
expectObject(result, {"result": 16}); | ||
} |
import * as grok from 'datagrok-api/grok'; | ||
import * as ui from 'datagrok-api/ui'; | ||
import * as DG from 'datagrok-api/dg'; | ||
import {category, test, expect, expectExceptionAsync} from '@datagrok-libraries/utils/src/test'; | ||
import {category, test, expect, expectExceptionAsync, expectArray, before} from '@datagrok-libraries/utils/src/test'; | ||
@@ -11,3 +12,3 @@ category('Property: General', () => { | ||
expect(dfList[0].columns instanceof DG.ColumnList, true); | ||
}); | ||
}, {skipReason: 'https://reddata.atlassian.net/browse/GROK-13478'}); | ||
@@ -18,9 +19,8 @@ test('call', async () => { | ||
expect(dfList[0].columns instanceof DG.ColumnList, true); | ||
}); | ||
}, {skipReason: 'https://reddata.atlassian.net/browse/GROK-13478'}); | ||
test('def param', async () => { | ||
await grok.functions.call('AddNewColumn', {table: grok.data.demo.demog(), expression: 'test', name: 'test'}); | ||
}); | ||
}, {skipReason: 'https://reddata.atlassian.net/browse/GROK-13478'}); | ||
// GROK-13478 | ||
test('call params', async () => { | ||
@@ -31,3 +31,3 @@ expect(await grok.functions.call('sin', {y: 0.5}), null, '{y: 0.5}'); | ||
await expectExceptionAsync(() => grok.functions.call('qqqqqq')); | ||
}); | ||
}, {skipReason: 'https://reddata.atlassian.net/browse/GROK-13478'}); | ||
@@ -39,3 +39,51 @@ test('query params', async () => { | ||
await expectExceptionAsync(() => grok.data.query('ApiTests:qqqqqq')); | ||
}, {skipReason: 'https://reddata.atlassian.net/browse/GROK-13478'}); | ||
}); | ||
category('Property: Header parsing', () => { | ||
let func!: DG.Func; | ||
before(async () => { | ||
func = await grok.functions.eval(`ApiTests:propertyParsing`); | ||
}); | ||
test('Choices', async () => { | ||
expectArray(func.inputs[0].choices, ['Standardized', 'Actual']); | ||
}, {skipReason: 'https://reddata.atlassian.net/browse/GROK-15701'}); | ||
test('Default string val', async () => { | ||
expect(JSON.parse(func.inputs[1].options['default']), 'Default val'); | ||
}); | ||
test('Default int val', async () => { | ||
expect(JSON.parse(func.inputs[2].options['default']), 3); | ||
}); | ||
test('Caption', async () => { | ||
expect(func.inputs[3].caption, 'My custom caption'); | ||
}); | ||
test('Category', async () => { | ||
expect(func.inputs[4].category, 'My custom category'); | ||
}); | ||
test('showSlider', async () => { | ||
expect(func.inputs[5].showSlider, true); | ||
}); | ||
test('showPlusMinus', async () => { | ||
expect(func.inputs[6].showPlusMinus, true); | ||
}); | ||
test('step', async () => { | ||
expect(func.inputs[7].step, 2); | ||
}); | ||
test('min', async () => { | ||
expect(func.inputs[8].min, 1); | ||
}); | ||
test('max', async () => { | ||
expect(func.inputs[8].max, 10); | ||
}); | ||
test('format', async () => { | ||
expect(func.inputs[9].format, '#.000'); | ||
}); | ||
test('description', async () => { | ||
expect(func.inputs[10].description, 'My best description'); | ||
}); | ||
test('Complex caption', async () => { | ||
expect(func.inputs[11].caption, 'MIC O2 P/V exponent'); | ||
expect(ui.input.forProperty(func.inputs[11]).caption, 'MIC O2 P/V exponent'); | ||
}, {skipReason: 'https://reddata.atlassian.net/browse/GROK-15768'}); | ||
}); |
@@ -24,3 +24,2 @@ import {before, category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
expect(gss.apiUrl.endsWith('/api'), true, 'apiUrl'); | ||
expect(gss.helpBaseUrl, '', 'helpBaseUrl'); | ||
expect(gss.jupyterNotebook, `${gss.cvmUrl}/notebook`, 'jupyterNotebook'); | ||
@@ -27,0 +26,0 @@ expect(typeof gss.jupyterGatewayToken, 'string', 'jupyterGatewayToken'); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6
98
0
1
1784658
6267
6
- Removed@datagrok/api-tests@^1.7.15-rc.test2
- Removed@datagrok/api-tests@1.9.0(transitive)
Updateddatagrok-api@^1.20.0