mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-22 21:36:00 +00:00
some perspective tests fixed
This commit is contained in:
@@ -201,7 +201,7 @@ export function processPerspectiveDefaultColunns(
|
|||||||
dbInfos: MultipleDatabaseInfo,
|
dbInfos: MultipleDatabaseInfo,
|
||||||
conid: string,
|
conid: string,
|
||||||
database: string
|
database: string
|
||||||
) {
|
): PerspectiveConfig {
|
||||||
while (config.nodes.filter(x => !x.defaultColumnsProcessed).length > 0) {
|
while (config.nodes.filter(x => !x.defaultColumnsProcessed).length > 0) {
|
||||||
const newConfig = processPerspectiveDefaultColunnsStep(config, dbInfos, conid, database);
|
const newConfig = processPerspectiveDefaultColunnsStep(config, dbInfos, conid, database);
|
||||||
if (!newConfig) {
|
if (!newConfig) {
|
||||||
|
|||||||
@@ -6,29 +6,30 @@ import { createPerspectiveConfig, createPerspectiveNodeConfig } from '../Perspec
|
|||||||
import artistDataFlat from './artistDataFlat';
|
import artistDataFlat from './artistDataFlat';
|
||||||
import artistDataAlbum from './artistDataAlbum';
|
import artistDataAlbum from './artistDataAlbum';
|
||||||
import artistDataAlbumTrack from './artistDataAlbumTrack';
|
import artistDataAlbumTrack from './artistDataAlbumTrack';
|
||||||
|
import { processPerspectiveDefaultColunns } from '../processPerspectiveDefaultColunns';
|
||||||
|
|
||||||
test('test flat view', () => {
|
test('test flat view', () => {
|
||||||
const artistTable = chinookDbInfo.tables.find(x => x.pureName == 'Artist');
|
const artistTable = chinookDbInfo.tables.find(x => x.pureName == 'Artist');
|
||||||
|
const configColumns = processPerspectiveDefaultColunns(
|
||||||
|
createPerspectiveConfig({ pureName: 'Artist' }),
|
||||||
|
{ conid: { db: chinookDbInfo } },
|
||||||
|
'conid',
|
||||||
|
'db'
|
||||||
|
);
|
||||||
const root = new PerspectiveTableNode(
|
const root = new PerspectiveTableNode(
|
||||||
artistTable,
|
artistTable,
|
||||||
{ conid: { db: chinookDbInfo } },
|
{ conid: { db: chinookDbInfo } },
|
||||||
createPerspectiveConfig({ pureName: 'Artist' }),
|
configColumns,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
{ conid: 'conid', database: 'db' },
|
{ conid: 'conid', database: 'db' },
|
||||||
null,
|
null,
|
||||||
'1'
|
configColumns.rootDesignerId
|
||||||
);
|
);
|
||||||
const display = new PerspectiveDisplay(root, artistDataFlat);
|
const display = new PerspectiveDisplay(root, artistDataFlat);
|
||||||
|
|
||||||
// console.log(display.loadIndicatorsCounts);
|
|
||||||
// console.log(display.rows);
|
|
||||||
expect(display.rows.length).toEqual(4);
|
expect(display.rows.length).toEqual(4);
|
||||||
expect(display.rows[0]).toEqual(
|
expect(display.rows[0].rowData).toEqual(['AC/DC']);
|
||||||
expect.objectContaining({
|
|
||||||
rowData: ['AC/DC'],
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(display.loadIndicatorsCounts).toEqual({
|
expect(display.loadIndicatorsCounts).toEqual({
|
||||||
Artist: 4,
|
Artist: 4,
|
||||||
});
|
});
|
||||||
@@ -36,17 +37,30 @@ test('test flat view', () => {
|
|||||||
|
|
||||||
test('test one level nesting', () => {
|
test('test one level nesting', () => {
|
||||||
const artistTable = chinookDbInfo.tables.find(x => x.pureName == 'Artist');
|
const artistTable = chinookDbInfo.tables.find(x => x.pureName == 'Artist');
|
||||||
|
|
||||||
const config = createPerspectiveConfig({ pureName: 'Artist' });
|
const config = createPerspectiveConfig({ pureName: 'Artist' });
|
||||||
config.nodes[0].checkedColumns = ['Album'];
|
config.nodes.push(createPerspectiveNodeConfig({ pureName: 'Album' }));
|
||||||
|
config.references.push({
|
||||||
|
sourceId: config.nodes[0].designerId,
|
||||||
|
targetId: config.nodes[1].designerId,
|
||||||
|
designerId: '1',
|
||||||
|
columns: [{ source: 'ArtistId', target: 'ArtistId' }],
|
||||||
|
});
|
||||||
|
|
||||||
|
const configColumns = processPerspectiveDefaultColunns(config, { conid: { db: chinookDbInfo } }, 'conid', 'db');
|
||||||
|
|
||||||
|
// const config = createPerspectiveConfig({ pureName: 'Artist' });
|
||||||
|
// config.nodes[0].checkedColumns = ['Album'];
|
||||||
|
|
||||||
const root = new PerspectiveTableNode(
|
const root = new PerspectiveTableNode(
|
||||||
artistTable,
|
artistTable,
|
||||||
{ conid: { db: chinookDbInfo } },
|
{ conid: { db: chinookDbInfo } },
|
||||||
config,
|
configColumns,
|
||||||
null,
|
null,
|
||||||
null,
|
null,
|
||||||
{ conid: 'conid', database: 'db' },
|
{ conid: 'conid', database: 'db' },
|
||||||
null,
|
null,
|
||||||
config.nodes[0].designerId
|
configColumns.nodes[0].designerId
|
||||||
);
|
);
|
||||||
const display = new PerspectiveDisplay(root, artistDataAlbum);
|
const display = new PerspectiveDisplay(root, artistDataAlbum);
|
||||||
|
|
||||||
@@ -54,33 +68,21 @@ test('test one level nesting', () => {
|
|||||||
// console.log(display.rows);
|
// console.log(display.rows);
|
||||||
|
|
||||||
expect(display.rows.length).toEqual(6);
|
expect(display.rows.length).toEqual(6);
|
||||||
expect(display.rows[0]).toEqual(
|
|
||||||
expect.objectContaining({
|
expect(display.rows[0].rowData).toEqual(['AC/DC', 'For Those About To Rock We Salute You']);
|
||||||
rowData: ['AC/DC', 'For Those About To Rock We Salute You'],
|
expect(display.rows[0].rowSpans).toEqual([2, 1]);
|
||||||
rowSpans: [2, 1],
|
expect(display.rows[0].rowCellSkips).toEqual([false, false]);
|
||||||
rowCellSkips: [false, false],
|
|
||||||
})
|
expect(display.rows[1].rowData).toEqual([undefined, 'Let There Be Rock']);
|
||||||
);
|
expect(display.rows[1].rowSpans).toEqual([1, 1]);
|
||||||
expect(display.rows[1]).toEqual(
|
expect(display.rows[1].rowCellSkips).toEqual([true, false]);
|
||||||
expect.objectContaining({
|
|
||||||
rowData: [undefined, 'Let There Be Rock'],
|
expect(display.rows[2].rowData).toEqual(['Accept', 'Balls to the Wall']);
|
||||||
rowSpans: [1, 1],
|
expect(display.rows[2].rowSpans).toEqual([2, 1]);
|
||||||
rowCellSkips: [true, false],
|
expect(display.rows[2].rowCellSkips).toEqual([false, false]);
|
||||||
})
|
|
||||||
);
|
expect(display.rows[5].rowData).toEqual(['Alanis Morissette', 'Jagged Little Pill']);
|
||||||
expect(display.rows[2]).toEqual(
|
expect(display.rows[5].rowSpans).toEqual([1, 1]);
|
||||||
expect.objectContaining({
|
|
||||||
rowData: ['Accept', 'Balls to the Wall'],
|
|
||||||
rowSpans: [2, 1],
|
|
||||||
rowCellSkips: [false, false],
|
|
||||||
})
|
|
||||||
);
|
|
||||||
expect(display.rows[5]).toEqual(
|
|
||||||
expect.objectContaining({
|
|
||||||
rowData: ['Alanis Morissette', 'Jagged Little Pill'],
|
|
||||||
rowSpans: [1, 1],
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
expect(display.loadIndicatorsCounts).toEqual({
|
expect(display.loadIndicatorsCounts).toEqual({
|
||||||
Artist: 6,
|
Artist: 6,
|
||||||
|
|||||||
Reference in New Issue
Block a user