@datagrok/api-tests
Advanced tools
Comparing version 1.7.5 to 1.7.7
{ | ||
"name": "@datagrok/api-tests", | ||
"friendlyName": "API Tests", | ||
"version": "1.7.5", | ||
"version": "1.7.7", | ||
"author": { | ||
@@ -16,3 +16,3 @@ "name": "Anna Muzychyna", | ||
"dependencies": { | ||
"@datagrok-libraries/utils": "^4", | ||
"@datagrok-libraries/utils": "^4.0.16", | ||
"cash-dom": "^8.1.1", | ||
@@ -19,0 +19,0 @@ "datagrok-api": "^1.14.0", |
import * as DG from 'datagrok-api/dg'; | ||
import * as grok from 'datagrok-api/grok'; | ||
import {category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
// import * as grok from 'datagrok-api/grok'; | ||
import {before, category, expect, test, expectArray} from '@datagrok-libraries/utils/src/test'; | ||
category('BitSet', () => { | ||
let t1: DG.BitSet; | ||
let t2: DG.BitSet; | ||
before(async () => { | ||
t1 = DG.BitSet.create(5); | ||
t2 = DG.BitSet.fromString('11001'); | ||
}); | ||
test('create', async () => { | ||
@@ -19,5 +27,2 @@ expect(DG.BitSet.create(5).toBinaryString(), '00000'); | ||
const t1 = DG.BitSet.create(5); | ||
const t2 = DG.BitSet.fromString('11001'); | ||
test('and method', async () => { | ||
@@ -52,3 +57,3 @@ expect(t1.and(t2).toBinaryString(), '00000'); | ||
test('getBuffer method', async () => { | ||
return t2.getBuffer(); | ||
expectArray(Array.from(t2.getBuffer()), [19]); | ||
}); | ||
@@ -65,3 +70,3 @@ | ||
test('or method', async () => { | ||
expect(t1.or(t2).toBinaryString(), '11001'); | ||
expect(t1.or(t2).toBinaryString(), '11111'); | ||
}); | ||
@@ -71,3 +76,3 @@ | ||
t2.set(2, true); | ||
expect(t2.toBinaryString(), '11101'); | ||
expect(t2.toBinaryString(), '00110'); | ||
}); | ||
@@ -82,11 +87,11 @@ | ||
const t3 = DG.BitSet.fromString('11111'); | ||
expect(t2.similarityTo(t3).toString(), '0.6'); | ||
expect(t2.similarityTo(t3).toString(), '1'); | ||
}); | ||
test('toBinaryString method', async () => { | ||
expect(t2.toBinaryString(), '11001'); | ||
expect(t2.toBinaryString(), '11111'); | ||
}); | ||
test('toString method', async () => { | ||
expect(t2.toString(), '5 bits, 3 set'); | ||
expect(t2.toString(), '5 bits, 5 set'); | ||
}); | ||
@@ -96,4 +101,4 @@ | ||
const t3 = DG.BitSet.fromString('11111'); | ||
expect(t2.xor(t3).toBinaryString(), '00110'); | ||
expect(t2.xor(t3).toBinaryString(), '00000'); | ||
}); | ||
}); | ||
}, {clear: false}); |
import * as grok from 'datagrok-api/grok'; | ||
import * as DG from 'datagrok-api/dg'; | ||
import {category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import {before, category, expect, test, expectArray} from '@datagrok-libraries/utils/src/test'; | ||
@@ -23,1 +23,161 @@ const GDC = grok.dapi.connections; | ||
}); | ||
category('Dapi: TableQuery', () => { | ||
let dc: DG.DataConnection; | ||
const tableName = 'public.orders'; | ||
const fields = ['orderid', 'freight']; | ||
const whereClauses = [{ | ||
field: 'orderid', | ||
pattern: '10250', | ||
}]; | ||
const aggregationsDb = [{ | ||
colName: 'orderid', | ||
aggType: 'count', | ||
}]; | ||
const havingDb = [{ | ||
field: 'COUNT(shipcountry)', | ||
pattern: '2', | ||
}]; | ||
const orderByDb = [{ | ||
field: 'orderid', | ||
}]; | ||
let fromTable: DG.TableInfo; | ||
let from: string; | ||
before(async () => { | ||
fromTable = DG.TableInfo.fromDataFrame(grok.data.testData('demog', 5000)); | ||
from = fromTable.name; | ||
const dcParams = {dataSource: 'Postgres', server: 'dev.datagrok.ai:54322', db: 'northwind', | ||
login: 'datagrok', password: 'datagrok'}; | ||
dc = DG.DataConnection.create('test', dcParams); | ||
dc = await grok.dapi.connections.save(dc); | ||
}); | ||
test('Create', async () => { | ||
const tq = DG.TableQuery.create(dc); | ||
expect(tq instanceof DG.TableQuery, true); | ||
}); | ||
test('Table', async () => { | ||
const tq = DG.TableQuery.create(dc); | ||
tq.table = tableName; | ||
expect(tq.table, tableName); | ||
}); | ||
test('Fields', async () => { | ||
const tq = DG.TableQuery.create(dc); | ||
tq.fields = fields; | ||
expectArray(tq.fields, fields); | ||
}); | ||
test('Where clauses', async () => { | ||
const tq = DG.TableQuery.create(dc); | ||
tq.fields = fields; | ||
tq.where = whereClauses; | ||
expectArray(tq.where, whereClauses); | ||
}); | ||
test('Aggregations', async () => { | ||
const tq = DG.TableQuery.create(dc); | ||
tq.aggregations = aggregationsDb; | ||
expectArray(tq.aggregations, aggregationsDb); | ||
}); | ||
test('Having', async () => { | ||
const tq = DG.TableQuery.create(dc); | ||
tq.having = havingDb; | ||
expectArray(tq.having, havingDb); | ||
}); | ||
test('Order by', async () => { | ||
const tq = DG.TableQuery.create(dc); | ||
tq.orderBy = orderByDb; | ||
expectArray(tq.orderBy, orderByDb); | ||
}); | ||
test('From table', async () => { | ||
const dtqb = DG.TableQuery.fromTable(fromTable); | ||
expect(dtqb instanceof DG.TableQueryBuilder, true); | ||
}, {skipReason: 'GROK-11670'}); | ||
test('From', async () => { | ||
const dtqb = DG.TableQuery.from(from); | ||
expect(dtqb instanceof DG.TableQueryBuilder, true); | ||
}, {skipReason: 'GROK-11670'}); | ||
}, {clear: false}); | ||
/* | ||
category('Dapi: TableQueryBuilder', () => { | ||
before(async () => { | ||
table = grok.data.testData('demog', 5000); | ||
fromTable = DG.TableInfo.fromDataFrame(table); | ||
from = fromTable.name; | ||
}); | ||
let fromTable: DG.TableInfo; | ||
let from: string; | ||
let table: DG.DataFrame; | ||
const fields = ['race']; | ||
test('From table', async () => { | ||
const dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
expect(dtqb instanceof DG.TableQueryBuilder, true); | ||
}); | ||
test('From', async () => { | ||
const dtqb = DG.TableQueryBuilder.from(from); | ||
expect(dtqb instanceof DG.TableQueryBuilder, true); | ||
}); | ||
test('Select all', async () => { | ||
let dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
dtqb = dtqb.selectAll(); | ||
const tq = dtqb.build(); | ||
expectArray(tq.fields, table.columns.names()); | ||
}); | ||
test('Select', async () => { | ||
let dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
dtqb = dtqb.select(fields); | ||
const tq = dtqb.build(); | ||
expectArray(tq.fields, fields); | ||
}); | ||
test('Group by', async () => { | ||
let dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
dtqb = dtqb.groupBy(fields); | ||
dtqb.build(); | ||
}); | ||
test('Pivot on', async () => { | ||
let dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
dtqb = dtqb.pivotOn(fields); | ||
dtqb.build(); | ||
}); | ||
test('Where', async () => { | ||
let dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
dtqb = dtqb.where('race', 'Asian'); | ||
const tq = dtqb.build(); | ||
expectObject(tq.where[0], {field: 'race', pattern: 'Asian'}); | ||
}); | ||
test('Sort by', async () => { | ||
let dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
dtqb = dtqb.sortBy('age'); | ||
dtqb.build(); | ||
}); | ||
test('Limit', async () => { | ||
let dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
dtqb = dtqb.limit(10); | ||
dtqb.build(); | ||
}); | ||
test('Build', async () => { | ||
const dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
const tq = dtqb.build(); | ||
expect(tq instanceof DG.TableQuery, true); | ||
}); | ||
}); | ||
*/ |
@@ -1,8 +0,8 @@ | ||
import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import {category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
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'; | ||
category('Dapi', () => { | ||
test('Dapi: all data sources', async () => { | ||
test('all data sources', async () => { | ||
await grok.dapi.queries.first(); | ||
@@ -22,5 +22,5 @@ await grok.dapi.connections.first(); | ||
await grok.dapi.environments.first(); | ||
}); | ||
}, {skipReason: 'GROK-11670'}); | ||
test('Dapi: logging', async () => { | ||
test('logging', async () => { | ||
const logger = new DG.Logger((m) => (m.params as {[key: string]: any})['jsApiTest2'] = 'jsApiTest3'); | ||
@@ -27,0 +27,0 @@ const jsApiTestType = 'jsApiTestType'; |
@@ -1,2 +0,1 @@ | ||
import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import * as grok from 'datagrok-api/grok'; | ||
@@ -6,4 +5,7 @@ // import * as ui from 'datagrok-api/ui'; | ||
//@ts-ignore | ||
import {version} from '../../package.json'; | ||
import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
category('Dapi: properties', () => { | ||
category('Dapi: entities', () => { | ||
let group: DG.Group; | ||
@@ -19,3 +21,2 @@ | ||
}; | ||
//@ts-ignore | ||
await group.setProperties(properties); | ||
@@ -31,3 +32,2 @@ }); | ||
test('setProperties', async () => { | ||
//@ts-ignore | ||
await group.setProperties({testProp1: 'prop1', testProp2: 'prop2'}); | ||
@@ -42,163 +42,20 @@ expect(Object.keys(await group.getProperties()).length, 5); | ||
category('Dapi: entities: smart search', () => { | ||
test('users', async () => { | ||
expect((await grok.dapi.users.filter('selenium').list()).length, 11); | ||
expect((await grok.dapi.users.filter('firstName = "admin"').list()).length, 1); | ||
expect((await grok.dapi.users.filter('status = "active"').list({pageSize: 5})).length, 5); | ||
expect((await grok.dapi.users.filter('id = "878c42b0-9a50-11e6-c537-6bf8e9ab02ee"').list()).length, 1); | ||
}); | ||
// category('DataConnection', () => { | ||
// }); | ||
test('groups', async () => { | ||
expect((await grok.dapi.groups.filter('develop').list()).length, 1); | ||
expect((await grok.dapi.groups.filter('friendlyName = "all users"').list()).length, 1); | ||
expect((await grok.dapi.groups.filter('id = "1ab8b38d-9c4e-4b1e-81c3-ae2bde3e12c5"').list()).length, 1); | ||
}); | ||
// category('TableQuery', () => { | ||
// let dc: DG.DataConnection; | ||
// const tableName = 'public.orders'; | ||
// const fields = ['orderid', 'freight']; | ||
// const whereClauses = [{ | ||
// field: 'orderid', | ||
// pattern: '10250', | ||
// }]; | ||
// const aggregationsDb = [{ | ||
// colName: 'orderid', | ||
// aggType: 'count', | ||
// }]; | ||
// const havingDb = [{ | ||
// field: 'COUNT(shipcountry)', | ||
// pattern: '2', | ||
// }]; | ||
// const orderByDb = [{ | ||
// field: 'orderid', | ||
// }]; | ||
// let fromTable: DG.TableInfo; | ||
// let from: string; | ||
// before(async () => { | ||
// fromTable = DG.TableInfo.fromDataFrame(grok.data.testData('demog', 5000)); | ||
// from = fromTable.name; | ||
// const dcParams = {dataSource: 'Postgres', server: 'dev.datagrok.ai:54322', db: 'northwind', | ||
// login: 'datagrok', password: 'datagrok'}; | ||
// dc = DG.DataConnection.create('test', dcParams); | ||
// dc = await grok.dapi.connections.save(dc); | ||
// }); | ||
// test('Create', async () => { | ||
// const tq = DG.TableQuery.create(dc); | ||
// expect(tq instanceof DG.TableQuery, true); | ||
// }); | ||
// test('Table', async () => { | ||
// const tq = DG.TableQuery.create(dc); | ||
// tq.table = tableName; | ||
// expect(tq.table, tableName); | ||
// }); | ||
// test('Fields', async () => { | ||
// const tq = DG.TableQuery.create(dc); | ||
// tq.fields = fields; | ||
// expectArray(tq.fields, fields); | ||
// }); | ||
// test('Where clauses', async () => { | ||
// const tq = DG.TableQuery.create(dc); | ||
// tq.fields = fields; | ||
// tq.where = whereClauses; | ||
// expectArray(tq.where, whereClauses); | ||
// }); | ||
// test('Aggregations', async () => { | ||
// const tq = DG.TableQuery.create(dc); | ||
// tq.aggregations = aggregationsDb; | ||
// expectArray(tq.aggregations, aggregationsDb); | ||
// }); | ||
// test('Having', async () => { | ||
// const tq = DG.TableQuery.create(dc); | ||
// tq.having = havingDb; | ||
// expectArray(tq.having, havingDb); | ||
// }); | ||
// test('Order by', async () => { | ||
// const tq = DG.TableQuery.create(dc); | ||
// tq.orderBy = orderByDb; | ||
// expectArray(tq.orderBy, orderByDb); | ||
// }); | ||
// test('From table', async () => { | ||
// const dtqb = DG.TableQuery.fromTable(fromTable); | ||
// expect(dtqb instanceof DG.TableQueryBuilder, true); | ||
// }); | ||
// test('From', async () => { | ||
// const dtqb = DG.TableQuery.from(from); | ||
// expect(dtqb instanceof DG.TableQueryBuilder, true); | ||
// }); | ||
// }); | ||
// category('TableQueryBuilder', () => { | ||
// before(async () => { | ||
// table = grok.data.testData('demog', 5000); | ||
// fromTable = DG.TableInfo.fromDataFrame(table); | ||
// from = fromTable.name; | ||
// }); | ||
// let fromTable: DG.TableInfo; | ||
// let from: string; | ||
// let table: DG.DataFrame; | ||
// const fields = ['race']; | ||
// test('From table', async () => { | ||
// const dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
// expect(dtqb instanceof DG.TableQueryBuilder, true); | ||
// }); | ||
// test('From', async () => { | ||
// const dtqb = DG.TableQueryBuilder.from(from); | ||
// expect(dtqb instanceof DG.TableQueryBuilder, true); | ||
// }); | ||
// test('Select all', async () => { | ||
// let dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
// dtqb = dtqb.selectAll(); | ||
// const tq = dtqb.build(); | ||
// expectArray(tq.fields, table.columns.names()); | ||
// }); | ||
// test('Select', async () => { | ||
// let dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
// dtqb = dtqb.select(fields); | ||
// const tq = dtqb.build(); | ||
// expectArray(tq.fields, fields); | ||
// }); | ||
// test('Group by', async () => { | ||
// let dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
// dtqb = dtqb.groupBy(fields); | ||
// dtqb.build(); | ||
// }); | ||
// test('Pivot on', async () => { | ||
// let dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
// dtqb = dtqb.pivotOn(fields); | ||
// dtqb.build(); | ||
// }); | ||
// test('Where', async () => { | ||
// let dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
// dtqb = dtqb.where('race', 'Asian'); | ||
// const tq = dtqb.build(); | ||
// expectObject(tq.where[0], {field: 'race', pattern: 'Asian'}); | ||
// }); | ||
// test('Sort by', async () => { | ||
// let dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
// dtqb = dtqb.sortBy('age'); | ||
// dtqb.build(); | ||
// }); | ||
// test('Limit', async () => { | ||
// let dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
// dtqb = dtqb.limit(10); | ||
// dtqb.build(); | ||
// }); | ||
// test('Build', async () => { | ||
// const dtqb = DG.TableQueryBuilder.fromTable(fromTable); | ||
// const tq = dtqb.build(); | ||
// expect(tq instanceof DG.TableQuery, true); | ||
// }); | ||
// }); | ||
test('packages', async () => { | ||
expect((await grok.dapi.packages.filter('name="Api Tests" & author.login="system"').list({pageSize: 3})).length, 3); | ||
expect((await grok.dapi.packages.filter(`version = "${version}"`).list()).length > 0, true); | ||
}); | ||
}); |
@@ -1,4 +0,4 @@ | ||
import {after, before, category, test} from '@datagrok-libraries/utils/src/test'; | ||
import {category, test} from '@datagrok-libraries/utils/src/test'; | ||
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'; | ||
@@ -8,3 +8,3 @@ | ||
category('Dapi: fetch', () => { | ||
test('Dapi: fetch - post', async () => { | ||
test('post', async () => { | ||
const url = 'https://jsonplaceholder.typicode.com/posts'; | ||
@@ -20,7 +20,7 @@ const data = {name: 'username', password: 'password'}; | ||
if (!res.ok) | ||
throw 'Post failed'; | ||
throw new Error('Post failed'); | ||
}); | ||
test('Dapi: fetch - get', async () => { | ||
const url = 'https://public.datagrok.ai/demo/demog.csv'; | ||
test('get', async () => { | ||
const url = 'https://dev.datagrok.ai/demo/demog.csv'; | ||
@@ -31,3 +31,3 @@ const res = await grok.dapi.fetchProxy(url); | ||
if (resText.length == 0) | ||
throw 'Response text is empty'; | ||
throw new Error('Response text is empty'); | ||
@@ -34,0 +34,0 @@ DG.DataFrame.fromCsv(resText); |
@@ -103,11 +103,12 @@ import * as grok from 'datagrok-api/grok'; | ||
category('Dapi: files: formats', () => { | ||
const extensions = ['csv', 'd42', 'json', 'tar', 'tar.gz', 'tsv', 'txt', 'xlsx', 'xml', 'zip']; //kml, kmz | ||
const extensions = ['csv', 'd42', 'json', 'tar', 'tar.gz', 'tsv', 'txt', 'xlsx', 'xml', 'zip', 'kmz', 'kml']; | ||
for (const ext of extensions) { | ||
test(ext, async () => { | ||
const df = await grok.data.files.openTable('System:AppData/ApiTests/datasets/formats/cars.' + ext); | ||
expect(df.rowCount, 10, 'wrong rows number'); | ||
expect(df.columns.length, 10, 'wrong columns number'); | ||
}); | ||
grok.data.files.openTable('System:AppData/ApiTests/datasets/formats/cars.' + ext).then((df) => { | ||
expect(df.rowCount, 10, 'wrong rows number'); | ||
expect(df.columns.length, 10, 'wrong columns number'); | ||
}); | ||
}, ['kmz', 'kml'].includes(ext) ? {skipReason: 'GROK-13263'} : undefined); | ||
} | ||
}); |
@@ -8,3 +8,3 @@ import * as grok from 'datagrok-api/grok'; | ||
category('Dapi: functions.calls', async () => { | ||
category('Dapi: functions calls', async () => { | ||
const xValue = 1.5; | ||
@@ -72,2 +72,22 @@ | ||
test('load 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 loadedWithFunc = await GDF.calls.include('func').find(funcCall.id); | ||
expect(loadedWithFunc.func.nqName, 'ApiTests:dummyPackageFunction'); | ||
}); | ||
test('load 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 loadedWithFunc = await GDF.calls.include('func').find(funcCall.id); | ||
expect(loadedWithFunc.func.nqName, 'ApiTests:DummyPackageScript'); | ||
}); | ||
test('list', async () => { | ||
@@ -78,3 +98,3 @@ const func: DG.Func = await grok.functions.eval('Sin'); | ||
await GDF.calls.save(funcCall); | ||
const loadedFuncCalls = await GDF.calls.filter(`func.id="${funcCall.func.id}"`).list(); | ||
const loadedFuncCalls = await GDF.calls.filter(`id="${funcCall.id}"`).list({pageSize: 5}); | ||
expect(loadedFuncCalls.some((loadedCall) => loadedCall.id === funcCall.id), true); | ||
@@ -105,6 +125,26 @@ }); | ||
const funcCall = await func.prepare({x: xValue}).call(); | ||
expect((await GDF.calls.filter(`func.id="${funcCall.func.id}"`).list()).includes(funcCall), false); | ||
funcCall.newId(); | ||
await GDF.calls.save(funcCall); | ||
expect(await GDF.calls.find(funcCall.id) !== undefined, true, 'funcCall was not saved'); | ||
await GDF.calls.delete(funcCall); | ||
expect((await GDF.calls.filter(`func.id="${funcCall.func.id}"`).list()).includes(funcCall), false); | ||
expect(await GDF.calls.find(funcCall.id) === undefined, true, 'funcCall was not deleted'); | ||
}); | ||
}); | ||
category('Dapi: functions', async () => { | ||
test('Load package function with package', async () => { | ||
const func = await grok.functions.eval('ApiTests:dummyPackageFunction'); | ||
const loadedFunc = await GDF.include('package').find(func!.id); | ||
console.log(loadedFunc); | ||
expect(loadedFunc.package.name, 'ApiTests'); | ||
}); | ||
test('Load script function with package', async () => { | ||
const func = await grok.functions.eval('ApiTests:dummyPackageScript'); | ||
const loadedFunc = await GDF.include('package').find(func!.id); | ||
console.log(loadedFunc); | ||
expect(loadedFunc.package.name, 'ApiTests'); | ||
}); | ||
}); |
@@ -1,10 +0,11 @@ | ||
import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import {category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import * as grok from 'datagrok-api/grok'; | ||
import * as ui from 'datagrok-api/ui'; | ||
import * as DG from 'datagrok-api/dg'; | ||
// import * as ui from 'datagrok-api/ui'; | ||
// import * as DG from 'datagrok-api/dg'; | ||
category('Dapi: layouts', () => { | ||
test('Dapi: layouts - get applicable', async () => { | ||
const layouts = await grok.dapi.layouts.getApplicable(grok.data.demo.demog()); | ||
test('get applicable', async () => { | ||
grok.dapi.layouts.getApplicable(grok.data.demo.demog(10)) | ||
.then((res) => expect(res.length, 'number', 'error in Dapi: layouts - get applicable')); | ||
}); | ||
}); |
@@ -1,5 +0,5 @@ | ||
import {category, expect, expectObject, test} from '@datagrok-libraries/utils/src/test'; | ||
import {category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import * as grok from 'datagrok-api/grok'; | ||
import * as ui from 'datagrok-api/ui'; | ||
import * as DG from 'datagrok-api/dg'; | ||
// import * as ui from 'datagrok-api/ui'; | ||
// import * as DG from 'datagrok-api/dg'; | ||
import {_package} from '../package-test'; | ||
@@ -17,2 +17,7 @@ | ||
}); | ||
test('webRoot content', async () => { | ||
const apiTestsPackage = await grok.dapi.packages.find(_package.id); | ||
expect(apiTestsPackage.webRoot, _package.webRoot); | ||
}); | ||
}); |
@@ -1,8 +0,8 @@ | ||
import {after, before, category, test} from '@datagrok-libraries/utils/src/test'; | ||
import {category, test} from '@datagrok-libraries/utils/src/test'; | ||
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'; | ||
category('Dapi: tables', () => { | ||
test('Dapi: tables - create and upload table', async () => { | ||
test('create and upload table', async () => { | ||
const df = DG.DataFrame.fromColumns([DG.Column.fromStrings('col', ['1', '2', '3'])]); | ||
@@ -9,0 +9,0 @@ df.name = 'dataframe'; |
@@ -1,5 +0,5 @@ | ||
import {after, before, category, expect, expectObject, test} from '@datagrok-libraries/utils/src/test'; | ||
import {category, expect, expectObject, test} from '@datagrok-libraries/utils/src/test'; | ||
import * as grok from 'datagrok-api/grok'; | ||
import * as ui from 'datagrok-api/ui'; | ||
import * as DG from 'datagrok-api/dg'; | ||
// import * as ui from 'datagrok-api/ui'; | ||
// import * as DG from 'datagrok-api/dg'; | ||
@@ -6,0 +6,0 @@ category('Dapi: user data storage', () => { |
@@ -1,14 +0,14 @@ | ||
import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import {category, test} from '@datagrok-libraries/utils/src/test'; | ||
import * as grok from 'datagrok-api/grok'; | ||
import * as ui from 'datagrok-api/ui'; | ||
import * as DG from 'datagrok-api/dg'; | ||
// import * as ui from 'datagrok-api/ui'; | ||
// import * as DG from 'datagrok-api/dg'; | ||
category('Dapi: users', () => { | ||
test('Dapi: users - current', async () => { | ||
test('current', async () => { | ||
await grok.dapi.users.current(); | ||
}); | ||
test('Dapi: users - current session', async () => { | ||
test('current session', async () => { | ||
await grok.dapi.users.currentSession(); | ||
}); | ||
}); |
@@ -7,3 +7,3 @@ import * as grok from 'datagrok-api/grok'; | ||
category('DataFrame', () => { | ||
category('DataFrame: Calculated columns', () => { | ||
const df = DG.DataFrame.fromColumns([ | ||
@@ -82,5 +82,5 @@ DG.Column.fromList(DG.TYPE.FLOAT, 'x', [1, 2, 3]), | ||
resolve('OK'); | ||
}))); | ||
}))); | ||
setTimeout(() => reject('Failed to add a calculated column'), 50); | ||
setTimeout(() => reject(new Error('Failed to add a calculated column')), 50); | ||
t.columns.addNewInt('regular column').init(1); | ||
@@ -96,5 +96,5 @@ await t.columns.addNewCalculated('calculated column', '${x}+${y}-${z}'); | ||
resolve('OK'); | ||
}))); | ||
}))); | ||
setTimeout(() => reject('Failed to delete a calculated column'), 50); | ||
setTimeout(() => reject(new Error('Failed to delete a calculated column')), 50); | ||
await t.columns.addNewCalculated('calculated column', '${x}+${y}-${z}'); | ||
@@ -101,0 +101,0 @@ t.columns.addNewInt('regular column').init(1); |
@@ -1,3 +0,3 @@ | ||
import * as ui from 'datagrok-api/ui'; | ||
import * as grok from 'datagrok-api/grok'; | ||
// import * as ui from 'datagrok-api/ui'; | ||
// import * as grok from 'datagrok-api/grok'; | ||
import * as DG from 'datagrok-api/dg'; | ||
@@ -7,3 +7,3 @@ | ||
category('DataFrame', () => { | ||
category('DataFrame: Join', () => { | ||
test('join.inPlace.fullTargetColumnList', async () => { | ||
@@ -10,0 +10,0 @@ const tgtDf1: DG.DataFrame = DG.DataFrame.fromCsv(`id,length |
@@ -309,3 +309,3 @@ import * as DG from 'datagrok-api/dg'; | ||
test('hash', async () => { | ||
const df = grok.data.demo.demog(100000); | ||
const df = grok.data.demo.demog(10); | ||
expect(hashDataFrame(df).length, 32); | ||
@@ -325,5 +325,4 @@ | ||
const csv: string = df.toCsv(); | ||
expect(csv, ''); | ||
}); | ||
}); |
@@ -39,2 +39,3 @@ /* eslint-disable max-len */ | ||
for (const detector of detectors) { | ||
if (detector.friendlyName === 'detectMolecules') continue; | ||
test(detector.friendlyName, async () => { | ||
@@ -41,0 +42,0 @@ const arr = []; |
@@ -114,3 +114,3 @@ import * as grok from 'datagrok-api/grok'; | ||
'Today()': dayjs.utc().hour(0).minute(0).second(0).millisecond(0), | ||
})); | ||
}), {skipReason: 'GROK-11670'}); | ||
@@ -117,0 +117,0 @@ test('Weeknum', () => check({ |
@@ -13,12 +13,16 @@ import './date-functions'; | ||
test('Eval', async () => { | ||
let dfList: DG.DataFrame[] = await grok.functions.eval('OpenServerFile("System:AppData/ApiTests/datasets/demog.csv")'); | ||
const dfList: DG.DataFrame[] = await grok.functions | ||
.eval('OpenServerFile("System:AppData/ApiTests/datasets/demog.csv")'); | ||
expect(dfList[0].columns instanceof DG.ColumnList, true); | ||
}); | ||
test('Call', async () => { | ||
let dfList: DG.DataFrame[] = await grok.functions.call('OpenServerFile', {'fullPath': 'System:AppData/ApiTests/datasets/demog.csv'}); | ||
const dfList: DG.DataFrame[] = await grok.functions | ||
.call('OpenServerFile', {'fullPath': 'System:AppData/ApiTests/datasets/demog.csv'}); | ||
expect(dfList[0].columns instanceof DG.ColumnList, true); | ||
}); | ||
test('Def param', async () => { | ||
await grok.functions.call('AddNewColumn', {table: grok.data.demo.demog(), expression: 'test', name: 'test'}); | ||
await grok.functions.call('AddNewColumn', {table: grok.data.demo.demog(), expression: 'test', name: 'test'}); | ||
}); | ||
}); |
@@ -9,5 +9,5 @@ import * as grok from 'datagrok-api/grok'; | ||
const result = await grok.functions.eval(expression); | ||
console.log('expression', expression); | ||
console.log('expected', expected); | ||
console.log('result', result); | ||
// console.log('expression', expression); | ||
// console.log('expected', expected); | ||
// console.log('result', result); | ||
if (Array.isArray(expected)) | ||
@@ -14,0 +14,0 @@ expectArray(result, expected); |
import * as grok from 'datagrok-api/grok'; | ||
import * as DG from 'datagrok-api/dg'; | ||
import {before, after, category, test} from '@datagrok-libraries/utils/src/test'; | ||
import {category, test} from '@datagrok-libraries/utils/src/test'; | ||
import {hasTag} from './grid'; | ||
@@ -12,8 +12,5 @@ | ||
before(async () => { | ||
test('colorCoding.api', async () => { | ||
v = grok.shell.addTableView(demog); | ||
grid = v.grid; | ||
}); | ||
test('colorCoding.api', async () => { | ||
demog.col('age')!.colors.setLinear(); | ||
@@ -33,3 +30,2 @@ demog.col('age')!.colors.setConditional({'<30': DG.Color.green, '30-70': '#ff0000'}); | ||
v = grok.shell.addTableView(demog); | ||
//grid = v.grid; | ||
v.loadLayout(layout); | ||
@@ -39,7 +35,2 @@ testTags(); | ||
after(async () => { | ||
v.close(); | ||
grok.shell.closeTable(demog); | ||
}); | ||
function testTags() { | ||
@@ -46,0 +37,0 @@ const ageTags: any[] = Array.from(demog.col('age')!.tags); |
@@ -18,10 +18,8 @@ import * as grok from 'datagrok-api/grok'; | ||
category('Grid', () => { | ||
let v: DG.TableView; | ||
let grid: DG.Grid; | ||
const demog = grok.data.demo.demog(1000); | ||
const demog = grok.data.demo.demog(100); | ||
demog.columns.byName('study').name = '~study'; | ||
before(async () => { | ||
v = grok.shell.addTableView(demog); | ||
grid = v.grid; | ||
grid = demog.plot.grid(); | ||
}); | ||
@@ -33,5 +31,4 @@ | ||
const secondCol = grid.columns.byIndex(6); | ||
if (firstCol?.name != 'race' || secondCol?.name != 'age') | ||
throw new Error('grid.setOrder does not work'); | ||
expect(firstCol?.name, 'race'); | ||
expect(secondCol?.name, 'age'); | ||
}); | ||
@@ -46,5 +43,3 @@ | ||
demog.rows.match('sex = M').filter(); | ||
if (demog.filter.trueCount != 605) | ||
throw new Error('Filtering error'); | ||
expect(demog.filter.trueCount, 73); | ||
}); | ||
@@ -94,13 +89,6 @@ | ||
const studyColVisible = grid.columns.byName('~study')!.visible; | ||
grid.columns.setVisible(['age', 'sex', 'race', 'height', 'weight', 'site', 'subj', 'started']); | ||
const diseaseColVisible = grid.columns.byName('disease')!.visible; | ||
if (studyColVisible) | ||
throw new Error('Hiding a column by adding ~ to the name doesn\'t work'); | ||
if (diseaseColVisible) | ||
throw new Error('Hiding a column by using columns.setVisible doesn\'t work'); | ||
expect(studyColVisible, false, 'Hiding a column by adding ~ to the name doesn\'t work'); | ||
expect(diseaseColVisible, false, 'Hiding a column by using columns.setVisible doesn\'t work'); | ||
}); | ||
@@ -129,2 +117,11 @@ | ||
}); | ||
test('getOptions', async () => { | ||
expect(Object.keys(grid.getOptions().look).length, 2); | ||
}); | ||
test('setOptions', async () => { | ||
grid.setOptions({allowEdit: false, showColumnLabels: false, colHeaderHeight: 100}); | ||
expect(Object.keys(grid.getOptions().look).length, 5); | ||
}); | ||
}); |
@@ -1,2 +0,2 @@ | ||
import {after, before, category, delay, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import {category, test} from '@datagrok-libraries/utils/src/test'; | ||
import * as grok from 'datagrok-api/grok'; | ||
@@ -6,3 +6,2 @@ import * as DG from 'datagrok-api/dg'; | ||
category('Grid: MultiValuesColumn', () => { | ||
let v: DG.TableView; | ||
const table = DG.DataFrame.fromCsv(`Country, Languages | ||
@@ -17,20 +16,11 @@ Belgium,"Dutch | ||
French"`); | ||
table.col('Languages')!.setTag(DG.TAGS.MULTI_VALUE_SEPARATOR, '\n'); | ||
table.col('Languages')!.setTag(DG.TAGS.MULTI_VALUE_SEPARATOR, '\n'); | ||
test('grid.multiValuesColumn', async () => { | ||
grok.shell.addTableView(table); | ||
const languageTags: string[] = Array.from(table.col('Languages')!.tags); | ||
before(async () => { | ||
v = grok.shell.addTableView(table); | ||
}); | ||
test('grid.multiValuesColumn', async () => { | ||
const languageTags: string[] = Array.from(table.col('Languages')!.tags); | ||
if (languageTags[0][0] != DG.TAGS.MULTI_VALUE_SEPARATOR) | ||
throw 'multi-value-separator not assigned to column'; | ||
}); | ||
after(async () => { | ||
v.close(); | ||
grok.shell.closeAll(); | ||
}); | ||
if (languageTags[0][0] != DG.TAGS.MULTI_VALUE_SEPARATOR) | ||
throw new Error('multi-value-separator not assigned to column'); | ||
}); | ||
}); |
@@ -9,5 +9,13 @@ import * as DG from 'datagrok-api/dg'; | ||
import './dataframe/dataframe-join'; | ||
import './dataframe/dataframe-link'; | ||
import './functions/functions'; | ||
import './functions/conversion-functions'; | ||
import './functions/date-functions'; | ||
import './functions/logical-functions'; | ||
import './functions/math-functions'; | ||
import './functions/stats-functions'; | ||
import './functions/text-functions'; | ||
import './shell/shell'; | ||
import './shell/windows'; | ||
import './shell/ml'; | ||
import './shell/settings'; | ||
import './dapi/files'; | ||
@@ -27,4 +35,2 @@ import './dapi/functions'; | ||
import './dapi/benchmarks'; | ||
import './shell/ml'; | ||
import './shell/settings'; | ||
import './widgets/files-widget'; | ||
@@ -34,5 +40,9 @@ import './widgets/legend'; | ||
import './utils/color'; | ||
import './package/upload'; | ||
// import './package/upload'; | ||
import './grid/grid'; | ||
import './grid/color-coding'; | ||
import './grid/multi-value-column'; | ||
import './stats/stats'; | ||
// import './bitset/bitset'; | ||
import './valuematcher/valuematcher'; | ||
@@ -39,0 +49,0 @@ import {runTests, tests, TestContext} from '@datagrok-libraries/utils/src/test'; |
import * as DG from 'datagrok-api/dg'; | ||
import * as grok from 'datagrok-api/grok'; | ||
import {before, after, category, expect, test, expectTable} from '@datagrok-libraries/utils/src/test'; | ||
import {before, category, expect, test, expectTable} from '@datagrok-libraries/utils/src/test'; | ||
import {_package} from '../package-test'; | ||
@@ -48,6 +48,2 @@ | ||
}); | ||
after(async () => { | ||
DG.Balloon.closeAll(); | ||
}); | ||
}); |
@@ -1,2 +0,2 @@ | ||
import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import {before, category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import * as grok from 'datagrok-api/grok'; | ||
@@ -73,7 +73,2 @@ import * as DG from 'datagrok-api/dg'; | ||
}); | ||
after(async () => { | ||
// views.forEach((v) => v.close()); | ||
grok.shell.closeAll(); | ||
}); | ||
}); |
@@ -1,4 +0,4 @@ | ||
import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import {category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
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'; | ||
@@ -9,6 +9,2 @@ | ||
category('Shell', () => { | ||
before(async () => { | ||
grok.shell.closeAll(); | ||
}); | ||
test('AddView', async () => { | ||
@@ -24,7 +20,2 @@ const v = grok.shell.addTableView(demog); | ||
}); | ||
after(async () => { | ||
// v.close(); | ||
// grok.shell.closeTable(v.table!); | ||
}); | ||
}); |
import * as DG from 'datagrok-api/dg'; | ||
import * as grok from 'datagrok-api/grok'; | ||
// import * as grok from 'datagrok-api/grok'; | ||
import {category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
@@ -4,0 +4,0 @@ |
@@ -1,9 +0,9 @@ | ||
import * as grok from 'datagrok-api/grok'; | ||
import * as DG from 'datagrok-api/dg'; | ||
// import * as grok from 'datagrok-api/grok'; | ||
// import * as DG from 'datagrok-api/dg'; | ||
import {after, before, category, expect, test, delay, testViewer} from '@datagrok-libraries/utils/src/test'; | ||
import {category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
import { | ||
intToHtmlA, intToHtml, | ||
intToRgba, intToRgb, | ||
htmlToInt, htmlToIntA | ||
htmlToInt, htmlToIntA, | ||
} from '@datagrok-libraries/utils/src/color'; | ||
@@ -10,0 +10,0 @@ |
import * as DG from 'datagrok-api/dg'; | ||
import * as grok from 'datagrok-api/grok'; | ||
// import * as grok from 'datagrok-api/grok'; | ||
import {category, expect, test} from '@datagrok-libraries/utils/src/test'; | ||
@@ -4,0 +4,0 @@ |
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 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
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
1350425
3589
4