1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2026-08-05 07:19:17 +08:00
This commit is contained in:
lana-k
2026-07-21 22:55:03 +02:00
parent 9838421d65
commit 6fbddb69bb
2 changed files with 238 additions and 24 deletions

View File

@@ -8,14 +8,22 @@ describe('_migrations.js', () => {
id: '123',
name: 'foo',
query: 'SELECT * FROM foo',
chart: { here_are: 'foo chart settings' },
chart: {
data: [{ selectedpoints: ['some selected points'] }, {}],
layout: { selections: [{}, {}] },
frames: 'foo chart frames'
},
createdAt: '2021-05-06T11:05:50.877Z'
},
{
id: '456',
name: 'bar',
query: 'SELECT * FROM bar',
chart: { here_are: 'bar chart settings' },
chart: {
data: [{}, {}],
layout: {},
frames: 'bar chart frames'
},
createdAt: '2021-05-07T11:05:50.877Z'
}
]
@@ -26,7 +34,11 @@ describe('_migrations.js', () => {
name: 'foo',
query: 'SELECT * FROM foo',
viewType: 'chart',
viewOptions: { here_are: 'foo chart settings' },
viewOptions: {
data: [{}, {}],
layout: { selections: [] },
frames: 'foo chart frames'
},
createdAt: '2021-05-06T11:05:50.877Z'
},
{
@@ -34,7 +46,7 @@ describe('_migrations.js', () => {
name: 'bar',
query: 'SELECT * FROM bar',
viewType: 'chart',
viewOptions: { here_are: 'bar chart settings' },
viewOptions: { data: [{}, {}], layout: {}, frames: 'bar chart frames' },
createdAt: '2021-05-07T11:05:50.877Z'
}
])
@@ -47,7 +59,11 @@ describe('_migrations.js', () => {
name: 'foo',
query: 'SELECT * FROM foo',
viewType: 'chart',
viewOptions: { here_are: 'foo chart settings' },
viewOptions: {
data: [{ selectedpoints: ['some selected points'] }, {}],
layout: { selections: [{}, {}] },
frames: 'foo chart frames'
},
createdAt: '2021-05-06T11:05:50.877Z'
},
{
@@ -108,7 +124,11 @@ describe('_migrations.js', () => {
name: 'foo',
query: 'SELECT * FROM foo',
viewType: 'chart',
viewOptions: { here_are: 'foo chart settings' },
viewOptions: {
data: [{}, {}],
layout: { selections: [] },
frames: 'foo chart frames'
},
createdAt: '2021-05-06T11:05:50.877Z'
},
{
@@ -175,7 +195,11 @@ describe('_migrations.js', () => {
name: 'foo',
query: 'SELECT * FROM foo',
viewType: 'chart',
viewOptions: { here_are: 'foo chart settings' },
viewOptions: {
data: [{ selectedpoints: ['some selected points'] }, {}],
layout: { selections: [{}, {}] },
frames: 'foo chart frames'
},
createdAt: '2021-05-06T11:05:50.877Z'
},
{
@@ -238,7 +262,150 @@ describe('_migrations.js', () => {
name: 'foo',
query: 'SELECT * FROM foo',
viewType: 'chart',
viewOptions: { here_are: 'foo chart settings' },
viewOptions: {
data: [{}, {}],
layout: { selections: [] },
frames: 'foo chart frames'
},
createdAt: '2021-05-06T11:05:50.877Z'
},
{
id: '456',
name: 'bar',
query: 'SELECT * FROM bar',
viewType: 'graph',
viewOptions: {
structure: {
nodeId: 'node_id',
objectType: 'object_type',
edgeSource: 'source',
edgeTarget: 'target'
},
style: {
backgroundColor: 'white',
highlightMode: 'node_and_neighbors',
nodes: {
size: { type: 'constant', value: 10 },
color: {
type: 'calculated',
method: 'degree',
colorscale: null,
mode: 'continious',
colorscaleDirection: 'reversed',
opacity: 100
},
label: { source: 'label', color: '#444444' }
},
edges: {
showDirection: true,
size: { type: 'constant', value: 2 },
color: { type: 'constant', value: '#a2b1c6' },
label: { source: null, color: '#a2b1c6' }
}
},
layout: {
type: 'forceAtlas2',
options: {
initialAlgorithm: 'circular',
initialIterationsAmount: 50,
adjustSizes: false,
barnesHutOptimize: false,
barnesHutTheta: 0.5,
edgeWeightInfluence: 0,
gravity: 1,
linLogMode: false,
outboundAttractionDistribution: false,
scalingRatio: 1,
slowDown: 1,
strongGravityMode: false
}
}
},
createdAt: '2021-05-07T11:05:50.877Z'
}
])
})
it('migrates from version 4 to the current', () => {
const oldInquiries = [
{
id: '123',
name: 'foo',
query: 'SELECT * FROM foo',
viewType: 'chart',
viewOptions: {
data: [{ selectedpoints: ['some selected points'] }, {}],
layout: { selections: [{}, {}] },
frames: 'foo chart frames'
},
createdAt: '2021-05-06T11:05:50.877Z'
},
{
id: '456',
name: 'bar',
query: 'SELECT * FROM bar',
viewType: 'graph',
viewOptions: {
structure: {
nodeId: 'node_id',
objectType: 'object_type',
edgeSource: 'source',
edgeTarget: 'target'
},
style: {
backgroundColor: 'white',
highlightMode: 'node_and_neighbors',
nodes: {
size: { type: 'constant', value: 10 },
color: {
type: 'calculated',
method: 'degree',
colorscale: null,
mode: 'continious',
colorscaleDirection: 'reversed',
opacity: 100
},
label: { source: 'label', color: '#444444' }
},
edges: {
showDirection: true,
size: { type: 'constant', value: 2 },
color: { type: 'constant', value: '#a2b1c6' },
label: { source: null, color: '#a2b1c6' }
}
},
layout: {
type: 'forceAtlas2',
options: {
initialAlgorithm: 'circular',
initialIterationsAmount: 50,
adjustSizes: false,
barnesHutOptimize: false,
barnesHutTheta: 0.5,
edgeWeightInfluence: 0,
gravity: 1,
linLogMode: false,
outboundAttractionDistribution: false,
scalingRatio: 1,
slowDown: 1,
strongGravityMode: false
}
}
},
createdAt: '2021-05-07T11:05:50.877Z'
}
]
expect(migrations._migrate(4, oldInquiries)).to.eql([
{
id: '123',
name: 'foo',
query: 'SELECT * FROM foo',
viewType: 'chart',
viewOptions: {
data: [{}, {}],
layout: { selections: [] },
frames: 'foo chart frames'
},
createdAt: '2021-05-06T11:05:50.877Z'
},
{