Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@datagrok/api-tests

Package Overview
Dependencies
Maintainers
6
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@datagrok/api-tests - npm Package Compare versions

Comparing version 1.0.0 to 1.3.0

connections/mssql-northwind-test.json

8

package.json
{
"name": "@datagrok/api-tests",
"friendlyName": "API Tests",
"version": "1.0.0",
"version": "1.3.0",
"author": {

@@ -16,5 +16,5 @@ "name": "Alexander Paramonov",

"dependencies": {
"@datagrok-libraries/utils": "^1.5.5",
"@datagrok-libraries/utils": "^1.6.1",
"cash-dom": "^8.1.1",
"datagrok-api": "^1.5.4",
"datagrok-api": "^1.6.0",
"dayjs": "latest",

@@ -67,3 +67,3 @@ "rxjs": "^6.6.7",

"debug-js-api-tests-localhost": "grok publish localhost",
"release-js-api-tests-localhost": "npm run build-js-api-tests-local && grok publish localhost --release"
"release-js-api-tests-localhost": "npm run build-js-api-tests && grok publish localhost --release"
},

@@ -70,0 +70,0 @@ "canEdit": [

@@ -13,6 +13,6 @@ import * as grok from 'datagrok-api/grok';

test('Create, save, delete', async () => {
let dc = DG.DataConnection.createDB('Local DG Test', dcParams);
let dc = DG.DataConnection.create('Local DG Test', dcParams);
dc = await GDC.save(dc);
expectObject(dc.parameters, {server: 'localhost:5432', db: 'datagrok_dev'});
expect(await dc.test(), 'ok');
//expect(await dc.test(), 'ok'); // how it supposed to work?
expect(dc.friendlyName, 'Local D G Test');

@@ -19,0 +19,0 @@ expect((await GDC.find(dc.id)).id, dc.id);

@@ -1,2 +0,2 @@

import {after, before, category, test} from '@datagrok-libraries/utils/src/test';
import {after, before, category, test, expect} from '@datagrok-libraries/utils/src/test';
import * as grok from 'datagrok-api/grok';

@@ -16,4 +16,3 @@ import * as ui from 'datagrok-api/ui';

test('Dapi: groups - find group', async () => {
if ((await grok.dapi.groups.filter(testGroupName).first()) === undefined)
throw 'Group doesn\'t exist';
expect((await grok.dapi.groups.filter('unexisting group').first()), undefined);
});

@@ -72,14 +71,7 @@

test('Dapi: groups - delete group', async () => {
let localTestGroup = null as any;
try {
const localTestGroupName = 'js-api-test-group1';
localTestGroup = await grok.dapi.groups.createNew(localTestGroupName);
await grok.dapi.groups.delete(localTestGroup);
if (await grok.dapi.groups.filter(localTestGroupName).first() !== undefined)
throw 'Group not deleted';
} finally {
await grok.dapi.groups.delete(localTestGroup);
}
const localTestGroupName = 'js-api-test-group1';
const localTestGroup = await grok.dapi.groups.createNew(localTestGroupName);
expect((await grok.dapi.groups.filter(localTestGroupName).first())?.name, localTestGroupName);
await grok.dapi.groups.delete(localTestGroup);
expect((await grok.dapi.groups.filter(localTestGroupName).first()), undefined);
});

@@ -86,0 +78,0 @@

@@ -8,4 +8,5 @@ import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test';

test('Dapi: projects - open', async () => {
await grok.dapi.projects.open('demog');
//move testto demo package
// await grok.dapi.projects.open('demog');
});
});

@@ -1,2 +0,2 @@

import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test';
import {after, before, category, expect, expectObject, test} from '@datagrok-libraries/utils/src/test';
import * as grok from 'datagrok-api/grok';

@@ -7,3 +7,3 @@ import * as ui from 'datagrok-api/ui';

category('Dapi: user data storage', () => {
test('Dapi: user data storage - post and get value', async () => {
test('post and get value', async () => {
const storageName = 'js-api-storage-name1';

@@ -16,3 +16,3 @@ const key = 'postValueKey';

test('Dapi: user data storage - post and get map', async () => {
test('post and get map', async () => {
const storageName = 'js-api-storage-name2';

@@ -25,15 +25,16 @@ const value = {'key': 'value'};

test('Dapi: user data storage - put', async () => {
test('put', async () => {
const storageName = 'js-api-storage-name3';
const value1 = {'key': 'value1'};
const value2 = {'key': 'value2'};
const value1 = {'key1': 'value1'};
const value2 = {'key2': 'value2'};
await grok.dapi.userDataStorage.post(storageName, value1);
await grok.dapi.userDataStorage.post(storageName, value2);
expectObject(await grok.dapi.userDataStorage.get(storageName), {'key1': 'value1', 'key2': 'value2'});
await grok.dapi.userDataStorage.put(storageName, value2);
const receivedValue = await grok.dapi.userDataStorage.get(storageName);
expect(JSON.stringify(receivedValue), JSON.stringify(value2));
expectObject(receivedValue, value2);
});
test('Dapi: user data storage - put', async () => {
test('delete', async () => {
const storageName = 'js-api-storage-name4';

@@ -47,4 +48,4 @@ const key = 'postValueKey';

const receivedValue = await grok.dapi.userDataStorage.getValue(storageName, key);
expect(receivedValue, '');
expect(receivedValue, undefined);
});
});

@@ -29,10 +29,29 @@ import * as grok from 'datagrok-api/grok';

test('Add new column dialog', async () => {
test('Add new column dialog', () => new Promise(async (resolve, reject) => {
let tv: DG.TableView;
await new Promise(async (resolve, reject) => {
subs.push(grok.events.onDialogShown.subscribe((d) => {
if (d.title == 'Add New Column')
resolve('OK');
dialogs.push(d);
}));
subs.push(grok.events.onDialogShown.subscribe((d) => {
if (d.title == 'Add New Column')
resolve('OK');
dialogs.push(d);
}));
setTimeout(() => {
// eslint-disable-next-line prefer-promise-reject-errors
reject('Dialog not found');
}, 50);
try {
tv = grok.shell.addTableView(df);
await df.dialogs.addNewColumn();
} finally {
tv!.close();
grok.shell.closeTable(df);
}
}));
test('Edit formula dialog', () => new Promise(async (resolve, reject) => {
subs.push(grok.events.onDialogShown.subscribe((d) => {
if (d.title == 'Add New Column')
resolve('OK');
dialogs.push(d);
}));
try {
setTimeout(() => {

@@ -42,49 +61,36 @@ // eslint-disable-next-line prefer-promise-reject-errors

}, 50);
try {
tv = grok.shell.addTableView(df);
await df.dialogs.addNewColumn();
} finally {
tv!.close();
grok.shell.closeTable(df);
}
});
});
const column = await df.columns.addNewCalculated('editable', '0');
column.dialogs.editFormula();
} finally {
df.columns.remove('editable');
}
}));
test('Edit formula dialog', async () => {
await new Promise(async (resolve, reject) => {
subs.push(grok.events.onDialogShown.subscribe((d) => {
if (d.title == 'Add New Column')
test('Calculated columns addition event', () => new Promise(async (resolve, reject) => {
const t = df.clone();
subs.push(t.onColumnsAdded.subscribe((data) =>
data.args.columns.forEach((column: DG.Column) => {
if (column.tags.has(DG.TAGS.FORMULA) && column.name === 'calculated column')
resolve('OK');
dialogs.push(d);
}));
try {
setTimeout(() => {
// eslint-disable-next-line prefer-promise-reject-errors
reject('Dialog not found');
}, 50);
const column = await df.columns.addNewCalculated('editable', '0');
column.dialogs.editFormula();
} finally {
df.columns.remove('editable');
}
});
});
})));
test('Calculated columns addition event', async () => {
const t = df.clone();
subs.push(t.onColumnsAdded.subscribe((data) => data.args.columns.forEach((column: DG.Column) => {
expect(column.name, column.tags.has(DG.TAGS.FORMULA) ? 'calculated column' : 'regular column');
})));
setTimeout(() => reject('Failed to add a calculated column'), 50);
t.columns.addNewInt('regular column').init(1);
await t.columns.addNewCalculated('calculated column', '${x}+${y}-${z}');
t.columns.addNewInt('regular column').init(1);
});
}));
test('Calculated columns deletion event', async () => {
test('Calculated columns deletion event', () => new Promise(async (resolve, reject) => {
const t = df.clone();
subs.push(t.onColumnsRemoved.subscribe((data) => data.args.columns.forEach((column: DG.Column) => {
expect(column.name, column.tags.has(DG.TAGS.FORMULA) ? 'calculated column' : 'regular column');
subs.push(t.onColumnsRemoved.subscribe((data) =>
data.args.columns.forEach((column: DG.Column) => {
if (column.tags.has(DG.TAGS.FORMULA) && column.name === 'calculated column')
resolve('OK');
})));
setTimeout(() => reject('Failed to delete a calculated column'), 50);
await t.columns.addNewCalculated('calculated column', '${x}+${y}-${z}');
t.columns.addNewInt('regular column').init(1);
});
t.columns.remove('regular column');
t.columns.remove('calculated column');
}));

@@ -91,0 +97,0 @@ after(async () => {

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 {category, expect, expectArray, test} from '@datagrok-libraries/utils/src/test';
import dayjs from 'dayjs';
import {hashDataFrame} from '@datagrok-libraries/utils/src/dataframe-utils';

@@ -293,3 +294,3 @@ category('DataFrame', () => {

c.set(1, dayjs('2022-01-01'));
expect(c.get(1).valueOf(), 1640973600000);
expect(c.get(1).valueOf(), 1640984400000);
c.set(1, null);

@@ -300,2 +301,15 @@ expect(c.get(1), null);

});
test('hash', async () => {
const df = grok.data.demo.demog(100000);
expect(hashDataFrame(df).length, 32);
const df1 = DG.DataFrame.fromCsv(`a,b\n1,0\n2,0\n3,0`);
const df2 = DG.DataFrame.fromCsv(`a,b\n2,0\n1,0\n3,0`);
expectArray(hashDataFrame(df1), hashDataFrame(df2));
const df3 = DG.DataFrame.fromCsv(`a,b\n"abc",0\n"dce",0\n"xyz",0`);
const df4 = DG.DataFrame.fromCsv(`a,b\n"dce",0\n"abc",0\n"xyz",0`);
expectArray(hashDataFrame(df3), hashDataFrame(df4));
});
});

@@ -5,3 +5,3 @@ import {category, test} from '@datagrok-libraries/utils/src/test';

category('Conversion functions', () => {
category('Functions: Conversions', () => {
test('Boolean', () => check({

@@ -8,0 +8,0 @@ 'Boolean(true)': true,

@@ -7,3 +7,3 @@ import * as grok from 'datagrok-api/grok';

category('Date functions', () => {
category('Functions: Date', () => {
test('Date', () => check({

@@ -103,8 +103,8 @@ 'Date(2020, 1, 1)': dayjs('2020-01-01'),

test('Time', () => check({
// The function returns a datetime with a special insignificant date `01-01-01`.
// The function returns a datetime with a special insignificant date `01-01-00`.
// 2-digit year is replaced in expected dates with 4-digit format to address offset inconsistency
'Time(23, 59, 45, 999)': dayjs(-62167154414001),
'Time(10, 35, 15, 500)': dayjs(-62167202684500),
'Time(5, 5, 5, 5)': dayjs(-62167222494995),
'Time(0, 0, 0, 0)': dayjs(-62167240800000),
'Time(23, 59, 45, 999)': dayjs('2000-01-01 23:59:45.999'),
'Time(10, 35, 15, 500)': dayjs('2000-01-01 10:35:15.500'),
'Time(5, 5, 5, 5)': dayjs('2000-01-01 5:5:5.5'),
'Time(0, 0, 0, 0)': dayjs('2000-01-01 0:0:0.0'),
}));

@@ -111,0 +111,0 @@

@@ -5,3 +5,3 @@ import {category, test} from '@datagrok-libraries/utils/src/test';

category('Logical functions', () => {
category('Functions: Logical', () => {
test('And', () => check({

@@ -13,5 +13,5 @@ 'And(true, true)': true,

'And(5 == 5, 10 < 20)': true,
'And(2, 3)': null,
'And(0, 1)': null,
'And(1, 1)': null,
'And(2, 3)': undefined,
'And(0, 1)': undefined,
'And(1, 1)': undefined,
}));

@@ -22,4 +22,4 @@

'Not(false)': true,
'Not(1)': null,
'Not(0)': null,
'Not(1)': undefined,
'Not(0)': undefined,
}));

@@ -33,5 +33,5 @@

'Or(5 == 6, 20 < 10)': false,
'Or(2, 3)': null,
'Or(0, 1)': null,
'Or(1, 1)': null,
'Or(2, 3)': undefined,
'Or(0, 1)': undefined,
'Or(1, 1)': undefined,
}));

@@ -46,7 +46,7 @@

'Xor(5 == 5, 10 < 20)': false,
'Xor(2, 3)': null,
'Xor(2, 2)': null,
'Xor(1, 0)': null,
'Xor(1, 1)': null,
'Xor(2, 3)': undefined,
'Xor(2, 2)': undefined,
'Xor(1, 0)': undefined,
'Xor(1, 1)': undefined,
}));
});

@@ -5,3 +5,3 @@ import {category, test} from '@datagrok-libraries/utils/src/test';

category('Math functions', () => {
category('Functions: Math', () => {
test('Abs', () => check({

@@ -45,3 +45,3 @@ 'Abs(-10)': 10,

'Atan2(1, 0)': 1.5707,
'Atan2(0, -0)': 0,
// 'Atan2(0, -0)': 0, don't want to test undefined behavior in different browsers
'Atan2(0, 1)': 0,

@@ -210,3 +210,3 @@ 'Atan2(-1, 2)': -0.464,

'Round10(12340.12345, -5)': 0,
'Round10(null, 2)': null,
'Round10(null, 2)': undefined,
}));

@@ -213,0 +213,0 @@

@@ -1,2 +0,1 @@

import * as DG from 'datagrok-api/dg';
import {category, test} from '@datagrok-libraries/utils/src/test';

@@ -6,3 +5,3 @@ import {check} from './utils';

category('Statistical functions', () => {
category('Functions: Statistical', () => {
test('Avg', () => check({

@@ -14,4 +13,4 @@ 'Avg([1, 2, 3, 4])': 2.5,

'Avg([1, null, 2, 3])': 2,
'Avg([])': null,
'Avg([null, null])': DG.FLOAT_NULL,
'Avg([])': undefined,
'Avg([null, null])': undefined,
}));

@@ -31,3 +30,3 @@

'Max([1.5, -2, 1.9])': 1.9,
'Max([null, null])': DG.FLOAT_NULL,
'Max([null, null])': undefined,
}));

@@ -50,3 +49,3 @@

'Min([null, 1, 0.7, 0.3])': 0.3,
'Min([null, null])': DG.FLOAT_NULL,
'Min([null, null])': undefined,
}));

@@ -67,4 +66,4 @@

'Percentile([1, 2, null, 3, 4], 0.25)': 2,
'Percentile([null], 0.4)': null,
'Percentile([], 0.4)': null,
'Percentile([null], 0.4)': undefined,
'Percentile([], 0.4)': undefined,
}));

@@ -108,3 +107,3 @@

'StDev([1, null, 2, 3])': 1,
'StDev([null, null])': DG.FLOAT_NULL,
'StDev([null, null])': 0,
'StDev([7, 14, 21])': 7,

@@ -119,3 +118,3 @@ 'StDev([-15, -5, 5, 15])': 12.91,

'Sum([null, 1, 0.7, 0.3])': 2,
'Sum([null, null])': DG.FLOAT_NULL,
'Sum([null, null])': 0,
'Sum([-0])': 0,

@@ -129,3 +128,4 @@ }));

'TotalCount([100])': 1,
'TotalCount([])': null,
'TotalCount([])': 0,
'TotalCount(null)': undefined,
}));

@@ -139,3 +139,4 @@

'ValueCount([100])': 1,
'ValueCount([])': null,
'ValueCount([])': 0,
'ValueCount(null)': undefined,
}));

@@ -146,3 +147,3 @@

'Variance([1, null, 2, 3])': 1,
'Variance([null, null])': DG.FLOAT_NULL,
'Variance([null, null])': 0,
'Variance([7, 14, 21])': 49,

@@ -149,0 +150,0 @@ 'Variance([-15, -5, 5, 15])': 166.667,

@@ -5,3 +5,3 @@ import {category, test} from '@datagrok-libraries/utils/src/test';

category('Text functions', () => {
category('Functions: Text', () => {
test('Add', () => check({

@@ -8,0 +8,0 @@ 'Add("bitter", "sweet")': 'bittersweet',

@@ -17,27 +17,24 @@ import * as grok from 'datagrok-api/grok';

test('grid.setOrder', async () => {
test('setOrder', async () => {
grid.columns.setOrder(['race', 'age']);
const firstCol = grid.columns.byIndex(1);
const secondCol = grid.columns.byIndex(2);
if (firstCol?.dart.columnName != 'race' || secondCol?.dart.columnName != 'age')
const firstCol = grid.columns.byIndex(4);
const secondCol = grid.columns.byIndex(6);
if (firstCol?.name != 'race' || secondCol?.name != 'age')
throw 'grid.setOrder does not work';
});
test('grid.resizeColumn', async () => {
let check = false;
grid.onColumnResized.subscribe((_) => {check = true;});
test('resizeColumn', async () => {
grid.columns.byName('age')!.width = 200;
if (check == false)
throw 'Column Resize error';
expect(grid.columns.byName('age')!.width, 200);
});
test('grid.filter', async () => {
test('filter', async () => {
demog.rows.match('sex = M').filter();
if (demog.filter.trueCount != 605)
throw 'Filtering error';
});
test('grid.colorCoding', async () => {
test('colorCoding', async () => {
grid.col('race')!.categoryColors = {

@@ -58,3 +55,5 @@ 'Asian': 0xFF0000FF,

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}'))
if (!hasTag(raceTags, '.color-coding-categorical') ||
!hasTag(raceTags, '{"Asian":4278190335,"Black":4286578816,"Caucasian":4278547786,"Other":4293188935}'))
throw 'Categorical Color Coding error';

@@ -64,3 +63,7 @@

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"}'))
if (!hasTag(heightTags, '.color-coding-type') ||
!hasTag(heightTags, 'Conditional') ||
!hasTag(heightTags, '.color-coding-conditional') ||
!hasTag(heightTags, '{"20-170":"#00FF00","170-190":"#220505"}'))
throw 'Conditional Color Coding error';

@@ -70,7 +73,11 @@

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]'))
if (!hasTag(ageTags, '.color-coding-type') ||
!hasTag(ageTags, 'Linear') ||
!hasTag(ageTags, '.color-coding-linear') ||
!hasTag(ageTags, '[4294944000, 4278255360]'))
throw 'Linear Color Coding error';
});
test('grid.columnVisibility', async () => {
test('columnVisibility', async () => {
const studyColVisible = grid.columns.byName('~study')!.visible;

@@ -81,6 +88,8 @@

if (studyColVisible != false)
if (studyColVisible)
throw 'Hiding a column by adding ~ to the name doesn\'t work';
if (diseaseColVisible != false)
if (diseaseColVisible)
throw 'Hiding a column by using columns.setVisible doesn\'t work';

@@ -90,3 +99,3 @@ });

test('grid.columnControlledValues', async () => {
test('columnControlledValues', async () => {
demog.col('site')!.tags[DG.TAGS.CHOICES] = '["New York", "Buffalo"]';

@@ -97,3 +106,7 @@ demog.col('site')!.tags[DG.TAGS.AUTO_CHOICES] = 'New York';

if (!hasTag(siteTags, '.choices') || !hasTag(siteTags, '["New York", "Buffalo"]') || !hasTag(siteTags, '.auto-choices') || !hasTag(siteTags, 'New York'))
if (!hasTag(siteTags, '.choices') ||
!hasTag(siteTags, '["New York", "Buffalo"]') ||
!hasTag(siteTags, '.auto-choices') ||
!hasTag(siteTags, 'New York'))
throw 'Column Controlled Values (Choices) error';

@@ -110,7 +123,2 @@ });

after(async () => {
v.close();
grok.shell.closeAll();
});
function hasTag(colTags: string[], colTagValue: string): boolean {

@@ -117,0 +125,0 @@ for (let i = 0; i < colTags.length; i++) {

import * as DG from 'datagrok-api/dg';
import * as grok from 'datagrok-api/grok';
import { ConsoleMessage } from 'puppeteer';

@@ -63,1 +65,46 @@ export function isExceptionElement(action: string):void {

}
export async function uploadProject(projectName:string, tableInfo:DG.TableInfo, view:DG.TableView, df:DG.DataFrame):Promise<void> {
let project = DG.Project.create();
project.name = projectName;
project.addChild(tableInfo);
project.addChild(view.saveLayout());
await grok.dapi.layouts.save(view.saveLayout());
await grok.dapi.tables.uploadDataFrame(df);
await grok.dapi.tables.save(tableInfo);
await grok.dapi.projects.save(project);
}
export function findViewer(viewerName:string, view:DG.TableView,):DG.Viewer | undefined {
let viewer:DG.Viewer;
for (let i:number = 0; i < Array.from(view.viewers).length; i++) {
if (Array.from(view.viewers)[i].type == viewerName) {
viewer = Array.from(view.viewers)[i];
return viewer;
}
}
}
export function checkHTMLElementbyInnerText(className:string, innerText:string):void {
let elements = document.getElementsByClassName(className);
let check = false;
let element;
for (let i = 0; i < elements.length; i++ ){
element = elements[i] as HTMLElement
if (element.innerText == innerText)
check = true;
}
if (check == false){
throw 'element with innerText = "' + innerText + '" not found';
}
}
export function getHTMLElementbyInnerText(className:string, innerText:string):HTMLElement | undefined {
let elements = document.getElementsByClassName(className);
let element;
for (let i = 0; i < elements.length; i++ ){
element = elements[i] as HTMLElement
if (element.innerText == innerText)
return element;
}
}

@@ -6,4 +6,5 @@ import {after, before, category, delay, expect, test} from '@datagrok-libraries/utils/src/test';

import {checkHTMLElement} from '../../ui/utils';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue} from '../gui-utils';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue, uploadProject, findViewer} from '../gui-utils';
import { Viewer } from 'datagrok-api/dg';
import { _package } from '../../package-test';

@@ -79,10 +80,3 @@ category('Viewers: Bar Chart', () => {

test('barChart.serialization', async () => {
let project = DG.Project.create();
project.name = 'Test project with Bar Chart'
project.addChild(demog.getTableInfo());
project.addChild(v.saveLayout());
await grok.dapi.layouts.save(v.saveLayout());
await grok.dapi.tables.uploadDataFrame(demog);
await grok.dapi.tables.save(demog.getTableInfo());
await grok.dapi.projects.save(project);
await uploadProject('Test project with Bar Chart', demog.getTableInfo(), v, demog);

@@ -97,9 +91,3 @@ grok.shell.closeAll(); await delay(500);

let barChart:DG.Viewer;
for (let i:number = 0; i < Array.from(v.viewers).length; i++) {
if (Array.from(v.viewers)[i].type == 'Bar chart') {
barChart = Array.from(v.viewers)[i];
break;
}
}
let barChart = findViewer('Bar chart', v);

@@ -106,0 +94,0 @@ if (!barChart!.props.relativeValues)

@@ -5,3 +5,3 @@ import {after, before, category, delay, expect, test} from '@datagrok-libraries/utils/src/test';

import * as DG from 'datagrok-api/dg';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue} from '../gui-utils';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue, uploadProject, findViewer} from '../gui-utils';
import { Viewer } from 'datagrok-api/dg';

@@ -76,10 +76,3 @@

test('boxPlot.serialization', async () => {
let project = DG.Project.create();
project.name = 'Test project with Box Plot'
project.addChild(demog.getTableInfo());
project.addChild(v.saveLayout());
await grok.dapi.layouts.save(v.saveLayout());
await grok.dapi.tables.uploadDataFrame(demog);
await grok.dapi.tables.save(demog.getTableInfo());
await grok.dapi.projects.save(project);
await uploadProject('Test project with Box Plot', demog.getTableInfo(), v, demog);

@@ -94,9 +87,3 @@ grok.shell.closeAll(); await delay(500);

let boxPlot:DG.Viewer;
for (let i:number = 0; i < Array.from(v.viewers).length; i++) {
if (Array.from(v.viewers)[i].type == 'Box plot') {
boxPlot = Array.from(v.viewers)[i];
break;
}
}
let boxPlot = findViewer('Box plot', v);

@@ -103,0 +90,0 @@ if (boxPlot!.props.valueColumnName != 'age')

@@ -5,3 +5,3 @@ import {after, before, category, delay, expect, test} from '@datagrok-libraries/utils/src/test';

import * as DG from 'datagrok-api/dg';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue} from '../gui-utils';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue, uploadProject, findViewer} from '../gui-utils';
import { Viewer } from 'datagrok-api/dg';

@@ -66,10 +66,3 @@

test('densityPlot.serialization', async () => {
let project = DG.Project.create();
project.name = 'Test project with Density plot'
project.addChild(demog.getTableInfo());
project.addChild(v.saveLayout());
await grok.dapi.layouts.save(v.saveLayout());
await grok.dapi.tables.uploadDataFrame(demog);
await grok.dapi.tables.save(demog.getTableInfo());
await grok.dapi.projects.save(project);
await uploadProject('Test project with Density plot', demog.getTableInfo(), v, demog);

@@ -84,9 +77,4 @@ grok.shell.closeAll(); await delay(500);

let densityPlot:DG.Viewer;
for (let i:number = 0; i < Array.from(v.viewers).length; i++) {
if (Array.from(v.viewers)[i].type == 'Density plot') {
densityPlot = Array.from(v.viewers)[i];
break;
}
}
let densityPlot = findViewer('Density plot', v);
if (densityPlot!.props.xColumnName != 'weight')

@@ -93,0 +81,0 @@ throw 'xColumnName property has not been deserialized'

@@ -5,3 +5,3 @@ import {after, before, category, delay, expect, test} from '@datagrok-libraries/utils/src/test';

import * as DG from 'datagrok-api/dg';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue} from '../gui-utils';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue, uploadProject, findViewer} from '../gui-utils';
import { Viewer } from 'datagrok-api/dg';

@@ -80,10 +80,3 @@

test('histogram.serialization', async () => {
let project = DG.Project.create();
project.name = 'Test project with Histogram'
project.addChild(demog.getTableInfo());
project.addChild(v.saveLayout());
await grok.dapi.layouts.save(v.saveLayout());
await grok.dapi.tables.uploadDataFrame(demog);
await grok.dapi.tables.save(demog.getTableInfo());
await grok.dapi.projects.save(project);
await uploadProject('Test project with Histogram', demog.getTableInfo(), v, demog);

@@ -98,9 +91,3 @@ grok.shell.closeAll(); await delay(500);

let histogram:DG.Viewer;
for (let i:number = 0; i < Array.from(v.viewers).length; i++) {
if (Array.from(v.viewers)[i].type == 'Histogram') {
histogram = Array.from(v.viewers)[i];
break;
}
}
let histogram = findViewer('Histogramt', v);

@@ -107,0 +94,0 @@ if (histogram!.props.valueColumnName != 'weight')

@@ -5,3 +5,3 @@ import {after, before, category, delay, expect, test} from '@datagrok-libraries/utils/src/test';

import * as DG from 'datagrok-api/dg';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue} from '../gui-utils';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue, uploadProject, findViewer} from '../gui-utils';
import { Viewer } from 'datagrok-api/dg';

@@ -8,0 +8,0 @@

@@ -5,3 +5,3 @@ import {after, before, category, delay, expect, test} from '@datagrok-libraries/utils/src/test';

import * as DG from 'datagrok-api/dg';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue} from '../gui-utils';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue, uploadProject, findViewer} from '../gui-utils';
import { Viewer } from 'datagrok-api/dg';

@@ -62,10 +62,3 @@

test('matrixPlot.serialization', async () => {
let project = DG.Project.create();
project.name = 'Test project with Matrix Plot'
project.addChild(demog.getTableInfo());
project.addChild(v.saveLayout());
await grok.dapi.layouts.save(v.saveLayout());
await grok.dapi.tables.uploadDataFrame(demog);
await grok.dapi.tables.save(demog.getTableInfo());
await grok.dapi.projects.save(project);
await uploadProject('Test project with Matrix Plot', demog.getTableInfo(), v, demog);

@@ -80,9 +73,4 @@ grok.shell.closeAll(); await delay(500);

let matrixPlot:DG.Viewer;
for (let i:number = 0; i < Array.from(v.viewers).length; i++) {
if (Array.from(v.viewers)[i].type == 'Matrix plot') {
matrixPlot = Array.from(v.viewers)[i];
break;
}
}
let matrixPlot = findViewer('Matrix plot', v);
if (matrixPlot!.props.xColumnNames.length != 3)

@@ -89,0 +77,0 @@ throw 'xColumnNames property has not been deserialized incorrectly'

@@ -6,3 +6,3 @@ import {after, before, category, delay, expect, test} from '@datagrok-libraries/utils/src/test';

import {checkHTMLElement} from '../../ui/utils';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue} from '../gui-utils';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue, uploadProject, findViewer} from '../gui-utils';
import { Viewer } from 'datagrok-api/dg';

@@ -72,10 +72,3 @@

test('networkDiagram.serialization', async () => {
let project = DG.Project.create();
project.name = 'Test project with Network Diagram'
project.addChild(demog.getTableInfo());
project.addChild(v.saveLayout());
await grok.dapi.layouts.save(v.saveLayout());
await grok.dapi.tables.uploadDataFrame(demog);
await grok.dapi.tables.save(demog.getTableInfo());
await grok.dapi.projects.save(project);
await uploadProject('Test project with Network Diagram', demog.getTableInfo(), v, demog);

@@ -90,9 +83,3 @@ grok.shell.closeAll(); await delay(500);

let networkDiagram:DG.Viewer;
for (let i:number = 0; i < Array.from(v.viewers).length; i++) {
if (Array.from(v.viewers)[i].type == 'Network diagram') {
networkDiagram = Array.from(v.viewers)[i];
break;
}
}
let networkDiagram = findViewer('Network diagram', v);

@@ -99,0 +86,0 @@ if (networkDiagram!.props.node1ColumnName != 'age')

@@ -5,3 +5,3 @@ import {after, before, category, delay, expect, test} from '@datagrok-libraries/utils/src/test';

import * as DG from 'datagrok-api/dg';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue} from '../gui-utils';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue, uploadProject, findViewer} from '../gui-utils';
import { Viewer } from 'datagrok-api/dg';

@@ -78,10 +78,3 @@

test('pcPlot.serialization', async () => {
let project = DG.Project.create();
project.name = 'Test project with PC Plot'
project.addChild(demog.getTableInfo());
project.addChild(v.saveLayout());
await grok.dapi.layouts.save(v.saveLayout());
await grok.dapi.tables.uploadDataFrame(demog);
await grok.dapi.tables.save(demog.getTableInfo());
await grok.dapi.projects.save(project);
await uploadProject('Test project with P C Plot', demog.getTableInfo(), v, demog);

@@ -96,9 +89,4 @@ grok.shell.closeAll(); await delay(500);

let pcPlot:DG.Viewer;
for (let i:number = 0; i < Array.from(v.viewers).length; i++) {
if (Array.from(v.viewers)[i].type == 'PC Plot') {
pcPlot = Array.from(v.viewers)[i];
break;
}
}
let pcPlot = findViewer('PC Plot', v);
if (pcPlot!.props.columnNames.length != 3)

@@ -105,0 +93,0 @@ throw 'columnNames property has not been deserialized'

@@ -5,3 +5,3 @@ import {after, before, category, delay, expect, test} from '@datagrok-libraries/utils/src/test';

import * as DG from 'datagrok-api/dg';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue} from '../gui-utils';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue, uploadProject, findViewer} from '../gui-utils';
import { Viewer } from 'datagrok-api/dg';

@@ -71,10 +71,3 @@

test('pieChart.serialization', async () => {
let project = DG.Project.create();
project.name = 'Test project with Pie Chart'
project.addChild(demog.getTableInfo());
project.addChild(v.saveLayout());
await grok.dapi.layouts.save(v.saveLayout());
await grok.dapi.tables.uploadDataFrame(demog);
await grok.dapi.tables.save(demog.getTableInfo());
await grok.dapi.projects.save(project);
await uploadProject('Test project with Pie Chart', demog.getTableInfo(), v, demog);

@@ -89,9 +82,3 @@ grok.shell.closeAll(); await delay(500);

let pieChart:DG.Viewer;
for (let i:number = 0; i < Array.from(v.viewers).length; i++) {
if (Array.from(v.viewers)[i].type == 'Pie chart') {
pieChart = Array.from(v.viewers)[i];
break;
}
}
let pieChart = findViewer('Pie chart', v);

@@ -98,0 +85,0 @@ if (pieChart!.props.includeNulls)

@@ -5,3 +5,3 @@ import {after, before, category, delay, expect, test} from '@datagrok-libraries/utils/src/test';

import * as DG from 'datagrok-api/dg';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue} from '../gui-utils';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue, uploadProject, findViewer} from '../gui-utils';
import { Viewer } from 'datagrok-api/dg';

@@ -76,10 +76,3 @@

test('scatterPlot3D.serialization', async () => {
let project = DG.Project.create();
project.name = 'Test project with 3D Scatter Plot'
project.addChild(demog.getTableInfo());
project.addChild(v.saveLayout());
await grok.dapi.layouts.save(v.saveLayout());
await grok.dapi.tables.uploadDataFrame(demog);
await grok.dapi.tables.save(demog.getTableInfo());
await grok.dapi.projects.save(project);
await uploadProject('Test project with 3 D Scatter Plot', demog.getTableInfo(), v, demog);

@@ -94,9 +87,3 @@ grok.shell.closeAll(); await delay(500);

let scatterPlot3D:DG.Viewer;
for (let i:number = 0; i < Array.from(v.viewers).length; i++) {
if (Array.from(v.viewers)[i].type == '3d scatter plot') {
scatterPlot3D = Array.from(v.viewers)[i];
break;
}
}
let scatterPlot3D = findViewer('3d scatter plot', v);

@@ -103,0 +90,0 @@ if (!scatterPlot3D!.props.dynamicCameraMovement)

@@ -5,3 +5,3 @@ import {after, before, category, delay, expect, test} from '@datagrok-libraries/utils/src/test';

import * as DG from 'datagrok-api/dg';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue} from '../gui-utils';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue, uploadProject, findViewer} from '../gui-utils';
import { Viewer } from 'datagrok-api/dg';

@@ -88,10 +88,3 @@

test('scatterPlot.serialization', async () => {
let project = DG.Project.create();
project.name = 'Test project with Scatter plot'
project.addChild(demog.getTableInfo());
project.addChild(v.saveLayout());
await grok.dapi.layouts.save(v.saveLayout());
await grok.dapi.tables.uploadDataFrame(demog);
await grok.dapi.tables.save(demog.getTableInfo());
await grok.dapi.projects.save(project);
await uploadProject('Test project with Scatter plot', demog.getTableInfo(), v, demog);

@@ -106,9 +99,3 @@ grok.shell.closeAll(); await delay(500);

let scatterPlot:DG.Viewer;
for (let i:number = 0; i < Array.from(v.viewers).length; i++) {
if (Array.from(v.viewers)[i].type == 'Scatter plot') {
scatterPlot = Array.from(v.viewers)[i];
break;
}
}
let scatterPlot = findViewer('Scatter plot', v);

@@ -115,0 +102,0 @@ if (scatterPlot!.props.xColumnName != 'weight')

@@ -5,3 +5,3 @@ import {after, before, category, delay, expect, test} from '@datagrok-libraries/utils/src/test';

import * as DG from 'datagrok-api/dg';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue} from '../gui-utils';
import {isColumnPresent, isViewerPresent, isDialogPresent, returnDialog, setDialogInputValue, uploadProject, findViewer} from '../gui-utils';
import { Viewer } from 'datagrok-api/dg';

@@ -70,10 +70,3 @@

test('wordCloud.serialization', async () => {
let project = DG.Project.create();
project.name = 'Test project with Word Cloud'
project.addChild(demog.getTableInfo());
project.addChild(v.saveLayout());
await grok.dapi.layouts.save(v.saveLayout());
await grok.dapi.tables.uploadDataFrame(demog);
await grok.dapi.tables.save(demog.getTableInfo());
await grok.dapi.projects.save(project);
await uploadProject('Test project with Word Cloud', demog.getTableInfo(), v, demog);

@@ -92,9 +85,3 @@ grok.shell.closeAll(); await delay(500);

let wordCloud:DG.Viewer;
for (let i:number = 0; i < Array.from(v.viewers).length; i++) {
if (Array.from(v.viewers)[i].type == 'Word cloud') {
wordCloud = Array.from(v.viewers)[i];
break;
}
}
let wordCloud = findViewer('Word cloud', v);

@@ -101,0 +88,0 @@ if (wordCloud!.props.wordColumnName != 'study')

import * as DG from 'datagrok-api/dg';
import * as grok from 'datagrok-api/grok';
import * as ui from 'datagrok-api/ui';
import './dataframe/dataframe';

@@ -11,3 +10,2 @@ import './dataframe/detector';

import './shell/windows';
import './viewer/viewer';
import './views/docking';

@@ -18,4 +16,4 @@ import './views/events';

import './dapi/files';
import './dapi/functions';
import './dapi/fetch';
import './dapi/admin';
import './dapi/groups';

@@ -37,2 +35,3 @@ import './ui/inputs';

import './widgets/legend';
import './widgets/tree-view';
import './ui/icons';

@@ -45,5 +44,7 @@ import './ui/tables';

import './ui/image';
import './ui/viewers-adding';
//import './viewers/viewers-adding';
import './viewers/viewers';
//import './gui/chem-sketcher';
import './grid/grid';
import './connections/demo_queries';
import './connections/queries-test';

@@ -50,0 +51,0 @@ import {runTests, tests} from '@datagrok-libraries/utils/src/test';

@@ -5,2 +5,3 @@ import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test';

import * as DG from 'datagrok-api/dg';
import {_package} from "../package-test";

@@ -22,3 +23,3 @@ category('ML', () => {

test('Cluster', async () => {
const data = await grok.data.loadTable('https://public.datagrok.ai/demo/xclara.csv');
const data = await _package.files.readCsv('datasets/xclara.csv');
const resultDf = await grok.ml.cluster(data, ['V1', 'V2'], 3);

@@ -30,3 +31,3 @@

test('Missing Values Imputation', async () => {
const data = await grok.data.loadTable('https://public.datagrok.ai/demo/demog.csv');
const data = await _package.files.readCsv('datasets/demog.csv');
const resultDf = await grok.ml.missingValuesImputation(

@@ -42,3 +43,3 @@ data, ['age', 'height', 'weight'], ['age', 'height', 'weight'], 5,

test('PCA', async () => {
const data = await grok.data.loadTable('https://public.datagrok.ai/demo/cars.csv');
const data = await _package.files.readCsv('datasets/cars.csv');
const resultDf = await grok.ml.pca(

@@ -54,3 +55,3 @@ data, ['wheel.base', 'length', 'width', 'height', 'city.mpg', 'price'], 2, true, true,

const seed = 42;
const data = grok.data.demo.demog();
const data = await _package.files.readCsv('datasets/demog.csv');

@@ -57,0 +58,0 @@ await grok.ml.randomData(data, 'normal', {sd: 3.0, mean: 1.0}, seed);

@@ -6,2 +6,3 @@ import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test';

import {caption, enabled, checkHTMLElement} from './utils';
import dayjs from 'dayjs';

@@ -17,16 +18,16 @@

inputs = {
'stringInput': ui.stringInput(' ', ''),
'intInput': ui.intInput(' ', 0),
'floatInput': ui.floatInput(' ', 0.00),
'boolInput': ui.boolInput(' ', true),
'switchInput': ui.switchInput(' ', true),
'choiceInput': ui.choiceInput(' ', '1', ['1', '2', '3']),
'stringInput': ui.stringInput('', ''),
'intInput': ui.intInput('', 0),
'floatInput': ui.floatInput('', 0.00),
'boolInput': ui.boolInput('', true),
'switchInput': ui.switchInput('', true),
'choiceInput': ui.choiceInput('', '1', ['1', '2', '3']),
'multiChoiceInput': ui.multiChoiceInput('', [], []),
'dateInput': ui.dateInput(' ', DG.DateTime.fromDate(new Date(2000, 1, 1))),
'textInput': ui.textInput(' ', ''),
'searchInput': ui.searchInput(' ', ''),
'columnInput': ui.columnInput(' ', t, t.col('age')),
'columnsInput': ui.columnsInput(' ', t, () => null),
'tableInput': ui.tableInput(' ', tables[0], tables),
'colorInput': ui.colorInput(' ', '#ff0000')
'dateInput': ui.dateInput('', dayjs('2001-01-01')),
'textInput': ui.textInput('', ''),
'searchInput': ui.searchInput('', ''),
'columnInput': ui.columnInput('', t, t.col('age')),
'columnsInput': ui.columnsInput('', t, () => null),
'tableInput': ui.tableInput('', tables[0], tables),
'colorInput': ui.colorInput('', '#ff0000'),
};

@@ -87,3 +88,3 @@ v = grok.shell.newView('');

case 'dateInput':
onChanged(key, value, DG.DateTime.fromDate(new Date(2022, 1, 1)));
onChanged(key, value, dayjs('2022-01-01'));
break;

@@ -90,0 +91,0 @@ case 'choiceInput':

@@ -7,3 +7,3 @@ import * as grok from 'datagrok-api/grok';

category('Docking', () => {
category('View: Docking', () => {
let df: DG.DataFrame;

@@ -17,8 +17,8 @@ let tv: DG.TableView;

test('TableView.dockManager.dock', async () => {
test('dock', async () => {
expect(wu(tv.viewers).find((v) => v.tags['test']), undefined);
const viewer = df.plot.scatter();
viewer.temp['test'] = true;
expect(wu(tv.viewers).find((v) => v.temp['test']), undefined);
viewer.tags['test'] = 'true';
tv.dockManager.dock(viewer, DG.DOCK_TYPE.DOWN);
expect(wu(tv.viewers).find((v) => v.temp['test'])?.temp['test'], true);
expect(wu(tv.viewers).find((v) => v.tags['test'])?.tags['test'], 'true');
});

@@ -25,0 +25,0 @@

import * as grok from 'datagrok-api/grok';
import * as DG from 'datagrok-api/dg';
import {Subscription} from 'rxjs';
import {after, before, category, expect, test} from '@datagrok-libraries/utils/src/test';
import {after, before, category, expect, test, testEvent} from '@datagrok-libraries/utils/src/test';
category('View events', () => {
let df = grok.data.demo.demog();
category('View: Events', () => {
let df: DG.DataFrame;
let tv: DG.TableView;
const subs: Subscription[] = [];
before(async () => {
df = grok.data.demo.demog();
for (const v of grok.shell.tableViews) {
if (v.table?.name === df.name)
v.close();
}
tv = grok.shell.addTableView(df);
});
test('On view adding', async () => {
let v0: DG.View;
let v1: DG.TableView;
test('onViewAdding', async () => {
const openViewsCount = Array.from(grok.shell.views).length;
try {
subs.push(grok.events.onViewAdding.subscribe((view) => {
expect(Array.from(grok.shell.views).length, openViewsCount);
expect(grok.shell.view(view.name), null);
expect(view.name, view.type === DG.TYPE.TABLE_VIEW ? v1.name : v0.name);
}));
v0 = grok.shell.newView('test');
v1 = grok.shell.addTableView(df);
} finally {
closeViews(v0!, v1!);
}
// @ts-ignore
await testEvent<DG.View>(grok.events.onViewAdding, (view) => {
expect(Array.from(grok.shell.views).length, openViewsCount);
expect(view.name, 'test');
}, () => {
grok.shell.newView('test').close();
});
});
test('On view added', async () => {
let v0: DG.View;
let v1: DG.TableView;
let v2: DG.ViewBase;
test('onViewAdded 1', async () => {
const openViewsCount = Array.from(grok.shell.views).length;
// @ts-ignore
await testEvent<DG.View>(grok.events.onViewAdded, (view) => {
expect(Array.from(grok.shell.views).length > openViewsCount, true);
expect(grok.shell.view(view.name) != null, true);
expect(view.name, 'test');
}, () => {
grok.shell.newView('test').close();
});
});
test('onViewAdded 2', async () => {
// @ts-ignore
await testEvent<DG.View>(grok.events.onViewAdded, (view) => {
expect(view.name, 'Functions');
}, () => {
grok.shell.addView(DG.View.createByType(DG.View.FUNCTIONS));
});
});
test('onViewAdded 3', async () => {
// @ts-ignore
await testEvent<DG.View>(grok.events.onViewAdded, (view) => {
expect(view instanceof DG.TableView, true);
expect((view as DG.TableView).dataFrame.rowCount, 10000);
}, () => {
grok.shell.addTableView(grok.data.demo.demog());
});
});
test('onViewRenamed', async () => {
const name = tv.name;
try {
subs.push(grok.events.onViewAdded.subscribe((view) => {
expect(Array.from(grok.shell.views).length > openViewsCount, true);
expect(grok.shell.view(view.name) != null, true);
expect(view.name, view.type === DG.TYPE.TABLE_VIEW ?
v1.name : view.type === DG.View.FUNCTIONS ?
v2.name : v0.name);
}));
v0 = grok.shell.newView('test');
v1 = grok.shell.addTableView(df);
v2 = grok.shell.addView(DG.View.createByType(DG.View.FUNCTIONS));
// @ts-ignore
await testEvent<DG.View>(grok.events.onViewRenamed, (view) => {
expect(view.name, 'new name');
}, () => {
tv.name = 'new name';
});
} finally {
closeViews(v0!, v1!, v2!);
tv.name = name;
}
});
test('On view renamed', async () => {
subs.push(grok.events.onViewRenamed.subscribe((view) => {
expect(tv.name, view.name);
}));
expect(tv.name, df.name);
tv.name = 'new name';
test('onCurrentViewChanged', async () => {
const currentView = grok.shell.v;
// @ts-ignore
await testEvent<DG.View>(grok.events.onCurrentViewChanged, (view) => {
expect(currentView === grok.shell.v, false);
expect(grok.shell.v.name, 'test');
}, () => {
grok.shell.v = grok.shell.newView('test');
}, 100);
});
test('On current view changed', async () => {
const currentView = grok.shell.v;
const newView = grok.shell.newView('test');
test('onViewRemoved', async () => {
const newView1 = grok.shell.newView('test1');
const newView2 = grok.shell.newView('test2');
try {
subs.push(grok.events.onCurrentViewChanged.subscribe(() => {
expect(currentView === grok.shell.v, false);
}));
grok.shell.v = newView;
// @ts-ignore
await testEvent<DG.View>(grok.events.onViewRemoved, (view) => {
expect(view.name, 'test2');
}, () => {
newView2.close();
});
} finally {
closeViews(newView);
newView1.close();
newView2.close();
}
});
test('On view removed', async () => {
const newView = grok.shell.newView('test');
subs.push(grok.events.onViewRemoved.subscribe((view) => {
expect(newView, view);
}));
newView.close();
test('onViewLayoutGenerated', async () => {
// @ts-ignore
await testEvent<DG.ViewLayout>(grok.events.onViewLayoutGenerated, (layout) => {
expect(layout != null, true);
}, () => {
tv.saveLayout();
});
});
test('On view layout generated', async () => {
let baseLayout: DG.ViewLayout;
subs.push(grok.events.onViewLayoutGenerated.subscribe((layout) => {
expect(baseLayout, layout);
}));
baseLayout = tv.saveLayout();
});
test('On view layout applying', async () => {
test('onViewLayoutApplying', async () => {
const v = grok.shell.addTableView(df);
try {
subs.push(grok.events.onViewLayoutApplying.subscribe((layout) => {
// @ts-ignore
await testEvent<DG.ViewLayout>(grok.events.onViewLayoutApplying, (layout) => {
expect(layout instanceof DG.ViewLayout, true);

@@ -100,15 +121,17 @@ const state = JSON.parse(layout.viewState);

expect(Array.from(v.viewers).length, 1);
}));
tv.scatterPlot();
v.loadLayout(tv.saveLayout());
}, () => {
tv.scatterPlot();
v.loadLayout(tv.saveLayout());
});
} finally {
tv.resetLayout();
closeViews(v);
v.close();
}
});
test('On view layout applied', async () => {
test('onViewLayoutApplied', async () => {
const v = grok.shell.addTableView(df);
try {
subs.push(grok.events.onViewLayoutApplied.subscribe((layout) => {
// @ts-ignore
await testEvent<DG.ViewLayout>(grok.events.onViewLayoutApplied, (layout) => {
expect(layout instanceof DG.ViewLayout, true);

@@ -120,8 +143,8 @@ const state = JSON.parse(layout.viewState);

expect(Array.from(v.viewers).length, 2);
}));
tv.histogram();
v.loadLayout(tv.saveLayout());
}, () => {
tv.histogram();
v.loadLayout(tv.saveLayout());
});
} finally {
tv.resetLayout();
closeViews(v);
}

@@ -131,12 +154,4 @@ });

after(async () => {
subs.forEach((sub) => sub.unsubscribe());
grok.shell.closeAll();
});
});
function closeViews(...views: DG.ViewBase[]) {
views.forEach((view) => {
view.close();
if (view instanceof DG.TableView && view.table)
grok.shell.closeTable(view.table);
});
}

@@ -13,3 +13,3 @@ import * as DG from 'datagrok-api/dg';

test('FilesView.showTree', async () => {
test('ShowTree', async () => {
const v = DG.FilesView.create();

@@ -21,3 +21,3 @@ expect(v.showTree, true);

test('FilesView.showPreview', async () => {
test('ShowPreview', async () => {
const v = DG.FilesView.create();

@@ -28,3 +28,3 @@ expect(v.showPreview, true);

test('FilesView.showSearch', async () => {
test('ShowSearch', async () => {
const v = DG.FilesView.create();

@@ -38,3 +38,3 @@ grok.shell.addView(v);

test('FilesView.showTreeOnly', async () => {
test('ShowTreeOnly', async () => {
const v = DG.FilesView.create();

@@ -41,0 +41,0 @@ expect(v.showTreeOnly, false);

@@ -6,3 +6,3 @@ const path = require('path');

entry: {
test: {filename: 'package-test.js', library: {type: 'var', name:`apitests_test`}, import: './src/package-test.ts'},
test: {filename: 'package-test.js', library: {type: 'var', name: `apitests_test`}, import: './src/package-test.ts'},
package: './src/package.ts',

@@ -15,6 +15,7 @@ },

rules: [
{ test: /\.ts$/,
{
test: /\.ts$/,
loader: 'ts-loader',
exclude: /node_modules/,
}
},
],

@@ -29,3 +30,3 @@ },

'rxjs': 'rxjs',
'rxjs/operators': 'rxjs.operators'
'rxjs/operators': 'rxjs.operators',
},

@@ -32,0 +33,0 @@ output: {

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc