mirror of
https://github.com/lana-k/sqliteviz.git
synced 2026-08-05 23:39:17 +08:00
Compare commits
11 Commits
0.30.0
...
62786e7dda
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
62786e7dda | ||
|
|
6fbddb69bb | ||
|
|
9838421d65 | ||
|
|
686a09a8ce | ||
|
|
4e9d1a785c | ||
|
|
2b6de12dc5 | ||
|
|
39d1604959 | ||
|
|
053b8fbecb | ||
|
|
1043a03c96 | ||
|
|
b6ec71338b | ||
|
|
4bb6676648 |
6
package-lock.json
generated
6
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "sqliteviz",
|
"name": "sqliteviz",
|
||||||
"version": "0.29.0",
|
"version": "0.30.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "sqliteviz",
|
"name": "sqliteviz",
|
||||||
"version": "0.29.0",
|
"version": "0.30.0",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -24,7 +24,7 @@
|
|||||||
"nanoid": "^3.1.12",
|
"nanoid": "^3.1.12",
|
||||||
"papaparse": "^5.4.1",
|
"papaparse": "^5.4.1",
|
||||||
"pivottable": "^2.23.0",
|
"pivottable": "^2.23.0",
|
||||||
"plotly.js": "^2.35.2",
|
"plotly.js": "^2.35.3",
|
||||||
"promise-worker": "^2.0.1",
|
"promise-worker": "^2.0.1",
|
||||||
"react": "^16.14.0",
|
"react": "^16.14.0",
|
||||||
"react-chart-editor": "^0.46.1",
|
"react-chart-editor": "^0.46.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sqliteviz",
|
"name": "sqliteviz",
|
||||||
"version": "0.30.0",
|
"version": "0.30.1",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
"nanoid": "^3.1.12",
|
"nanoid": "^3.1.12",
|
||||||
"papaparse": "^5.4.1",
|
"papaparse": "^5.4.1",
|
||||||
"pivottable": "^2.23.0",
|
"pivottable": "^2.23.0",
|
||||||
"plotly.js": "^2.35.2",
|
"plotly.js": "^2.35.3",
|
||||||
"promise-worker": "^2.0.1",
|
"promise-worker": "^2.0.1",
|
||||||
"react": "^16.14.0",
|
"react": "^16.14.0",
|
||||||
"react-chart-editor": "^0.46.1",
|
"react-chart-editor": "^0.46.1",
|
||||||
|
|||||||
26
patches/plotly.js+2.35.3.patch
Normal file
26
patches/plotly.js+2.35.3.patch
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
diff --git a/node_modules/plotly.js/dist/plotly.js b/node_modules/plotly.js/dist/plotly.js
|
||||||
|
index 28f5612..5b9956d 100644
|
||||||
|
--- a/node_modules/plotly.js/dist/plotly.js
|
||||||
|
+++ b/node_modules/plotly.js/dist/plotly.js
|
||||||
|
@@ -34384,6 +34384,9 @@ var layoutUIControlPatterns = [{
|
||||||
|
pattern: /^(shapes|annotations)/,
|
||||||
|
attr: 'editrevision'
|
||||||
|
}, {
|
||||||
|
+ pattern: /^selections/,
|
||||||
|
+ attr: 'selectionrevision'
|
||||||
|
+},{
|
||||||
|
pattern: /^title\.text$/,
|
||||||
|
attr: 'editrevision'
|
||||||
|
}];
|
||||||
|
diff --git a/node_modules/plotly.js/src/plot_api/plot_api.js b/node_modules/plotly.js/src/plot_api/plot_api.js
|
||||||
|
index 75e98f5..5c38053 100644
|
||||||
|
--- a/node_modules/plotly.js/src/plot_api/plot_api.js
|
||||||
|
+++ b/node_modules/plotly.js/src/plot_api/plot_api.js
|
||||||
|
@@ -2394,6 +2394,7 @@ var layoutUIControlPatterns = [
|
||||||
|
|
||||||
|
{pattern: /^legend\.(x|y)$/, attr: 'editrevision'},
|
||||||
|
{pattern: /^(shapes|annotations)/, attr: 'editrevision'},
|
||||||
|
+ {pattern: /^selections/, attr: 'selectionrevision'},
|
||||||
|
{pattern: /^title\.text$/, attr: 'editrevision'}
|
||||||
|
];
|
||||||
|
|
||||||
@@ -1,30 +1,45 @@
|
|||||||
<template>
|
<template>
|
||||||
<div ref="chartContainer" class="chart-container">
|
<div class="chart-container">
|
||||||
<div v-show="!dataSources" class="warning data-view-warning">
|
<div v-show="!dataSources" class="warning data-view-warning">
|
||||||
There is no data to build a chart. Run your SQL query and make sure the
|
There is no data to build a chart. Run your SQL query and make sure the
|
||||||
result is not empty.
|
result is not empty.
|
||||||
</div>
|
</div>
|
||||||
<div
|
<splitpanes
|
||||||
|
:before="{ size: 70, max: 100 }"
|
||||||
|
:after="{ size: 30, max: 50, hidden: !showValueViewer }"
|
||||||
|
:default="{ before: 70, after: 30 }"
|
||||||
class="chart"
|
class="chart"
|
||||||
:style="{ height: !dataSources ? 'calc(100% - 40px)' : '100%' }"
|
:style="{ height: !dataSources ? 'calc(100% - 40px)' : '100%' }"
|
||||||
>
|
>
|
||||||
<PlotlyEditor
|
<template #left-pane>
|
||||||
ref="plotlyEditor"
|
<div ref="chartContainer" :style="{ height: '100%' }">
|
||||||
:data="state.data"
|
<PlotlyEditor
|
||||||
:layout="state.layout"
|
ref="plotlyEditor"
|
||||||
:frames="state.frames"
|
:data="state.data"
|
||||||
:config="config"
|
:layout="state.layout"
|
||||||
:dataSources="dataSources"
|
:frames="state.frames"
|
||||||
:dataSourceOptions="dataSourceOptions"
|
:config="config"
|
||||||
:plotly="plotly"
|
:dataSources="dataSources"
|
||||||
:useResizeHandler="useResizeHandler"
|
:dataSourceOptions="dataSourceOptions"
|
||||||
:debug="true"
|
:plotly="plotly"
|
||||||
:advancedTraceTypeSelector="true"
|
:useResizeHandler="useResizeHandler"
|
||||||
:hideControls="!showViewSettings"
|
:debug="true"
|
||||||
@update="update"
|
:advancedTraceTypeSelector="true"
|
||||||
@render="onRender"
|
:hideControls="!showViewSettings"
|
||||||
/>
|
@update="update"
|
||||||
</div>
|
@render="onRender"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<template v-if="showValueViewer" #right-pane>
|
||||||
|
<value-viewer
|
||||||
|
:empty="!selectedItems || selectedItems.length === 0"
|
||||||
|
emptyMessage="No points selected to view"
|
||||||
|
:value="JSON.stringify(selectedItems)"
|
||||||
|
defaultFormat="json"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
</splitpanes>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -37,11 +52,16 @@ import chartHelper from '@/lib/chartHelper'
|
|||||||
import * as dereference from 'react-chart-editor/lib/lib/dereference'
|
import * as dereference from 'react-chart-editor/lib/lib/dereference'
|
||||||
import fIo from '@/lib/utils/fileIo'
|
import fIo from '@/lib/utils/fileIo'
|
||||||
import events from '@/lib/utils/events'
|
import events from '@/lib/utils/events'
|
||||||
|
import Splitpanes from '@/components/Common/Splitpanes'
|
||||||
|
import ValueViewer from '@/components/ValueViewer.vue'
|
||||||
|
import { nextTick } from 'vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Chart',
|
name: 'Chart',
|
||||||
components: {
|
components: {
|
||||||
PlotlyEditor: applyPureReactInVue(ReactPlotlyEditorWithPlotRef)
|
PlotlyEditor: applyPureReactInVue(ReactPlotlyEditorWithPlotRef),
|
||||||
|
Splitpanes,
|
||||||
|
ValueViewer
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
dataSources: Object,
|
dataSources: Object,
|
||||||
@@ -49,7 +69,8 @@ export default {
|
|||||||
exportToPngEnabled: Boolean,
|
exportToPngEnabled: Boolean,
|
||||||
exportToSvgEnabled: Boolean,
|
exportToSvgEnabled: Boolean,
|
||||||
forPivot: Boolean,
|
forPivot: Boolean,
|
||||||
showViewSettings: Boolean
|
showViewSettings: Boolean,
|
||||||
|
showValueViewer: Boolean
|
||||||
},
|
},
|
||||||
emits: [
|
emits: [
|
||||||
'update:exportToSvgEnabled',
|
'update:exportToSvgEnabled',
|
||||||
@@ -60,18 +81,21 @@ export default {
|
|||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
plotly,
|
plotly,
|
||||||
state: this.initOptions || {
|
state: this.initOptions
|
||||||
data: [],
|
? JSON.parse(JSON.stringify(this.initOptions))
|
||||||
layout: { autosize: true },
|
: {
|
||||||
frames: []
|
data: [],
|
||||||
},
|
layout: { autosize: true },
|
||||||
|
frames: []
|
||||||
|
},
|
||||||
config: {
|
config: {
|
||||||
editable: true,
|
editable: true,
|
||||||
displaylogo: false,
|
displaylogo: false,
|
||||||
modeBarButtonsToRemove: ['toImage']
|
modeBarButtonsToRemove: ['toImage']
|
||||||
},
|
},
|
||||||
resizeObserver: null,
|
resizeObserver: null,
|
||||||
useResizeHandler: this.$store.state.isWorkspaceVisible
|
useResizeHandler: this.$store.state.isWorkspaceVisible,
|
||||||
|
selectedItems: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@@ -81,6 +105,7 @@ export default {
|
|||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
dataSources() {
|
dataSources() {
|
||||||
|
chartHelper.clearSelection(this.state.data, this.state.layout)
|
||||||
// we need to update state.data in order to update the graph
|
// we need to update state.data in order to update the graph
|
||||||
// https://github.com/plotly/react-chart-editor/issues/948
|
// https://github.com/plotly/react-chart-editor/issues/948
|
||||||
if (this.dataSources) {
|
if (this.dataSources) {
|
||||||
@@ -115,13 +140,27 @@ export default {
|
|||||||
this.$emit('update:exportToSvgEnabled', true)
|
this.$emit('update:exportToSvgEnabled', true)
|
||||||
this.$emit('update:exportToHtmlEnabled', true)
|
this.$emit('update:exportToHtmlEnabled', true)
|
||||||
},
|
},
|
||||||
mounted() {
|
async mounted() {
|
||||||
this.resizeObserver = new ResizeObserver(this.handleResize)
|
this.resizeObserver = new ResizeObserver(this.handleResize)
|
||||||
this.resizeObserver.observe(this.$refs.chartContainer)
|
this.resizeObserver.observe(this.$refs.chartContainer)
|
||||||
if (this.dataSources) {
|
if (this.dataSources) {
|
||||||
dereference.default(this.state.data, this.dataSources)
|
dereference.default(this.state.data, this.dataSources)
|
||||||
}
|
}
|
||||||
this.handleResize()
|
this.handleResize()
|
||||||
|
await nextTick()
|
||||||
|
const plotlyDiv =
|
||||||
|
this.$refs.plotlyEditor?.$el?.querySelector('.js-plotly-plot')
|
||||||
|
plotlyDiv?.on('plotly_selected', selectionEvent => {
|
||||||
|
if (selectionEvent) {
|
||||||
|
this.selectedItems = chartHelper.getRowsByIndexFromDataSources(
|
||||||
|
this.dataSources,
|
||||||
|
selectionEvent.points.map(point => point.pointIndex)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
plotlyDiv?.on('plotly_deselect', () => {
|
||||||
|
this.selectedItems = null
|
||||||
|
})
|
||||||
},
|
},
|
||||||
activated() {
|
activated() {
|
||||||
this.useResizeHandler = true
|
this.useResizeHandler = true
|
||||||
@@ -144,6 +183,8 @@ export default {
|
|||||||
// TODO: check changes and enable Save button if needed
|
// TODO: check changes and enable Save button if needed
|
||||||
},
|
},
|
||||||
update(data, layout, frames) {
|
update(data, layout, frames) {
|
||||||
|
chartHelper.clearSelection(data, layout)
|
||||||
|
|
||||||
this.state = { data, layout, frames }
|
this.state = { data, layout, frames }
|
||||||
this.$emit('update')
|
this.$emit('update')
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -58,9 +58,9 @@
|
|||||||
</icon-button>
|
</icon-button>
|
||||||
|
|
||||||
<icon-button
|
<icon-button
|
||||||
v-if="mode === 'graph'"
|
v-if="mode !== 'pivot'"
|
||||||
ref="viewNodeOrEdgeBtn"
|
ref="viewDetailsBtn"
|
||||||
tooltip="View node or edge details"
|
tooltip="View details"
|
||||||
tooltipPosition="top-left"
|
tooltipPosition="top-left"
|
||||||
:active="viewValuePanelVisible"
|
:active="viewValuePanelVisible"
|
||||||
@click="viewValuePanelVisible = !viewValuePanelVisible"
|
@click="viewValuePanelVisible = !viewValuePanelVisible"
|
||||||
|
|||||||
@@ -125,6 +125,13 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async checkFile(file) {
|
async checkFile(file) {
|
||||||
|
if (!file) {
|
||||||
|
alert(
|
||||||
|
'You should drop a file. ' +
|
||||||
|
'It can be an SQLite database, CSV file, JSON or NDJSON file.'
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
this.state = 'dropping'
|
this.state = 'dropping'
|
||||||
this.newDb = database.getNewDatabase()
|
this.newDb = database.getNewDatabase()
|
||||||
|
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ export default {
|
|||||||
events.send(eventName)
|
events.send(eventName)
|
||||||
},
|
},
|
||||||
_keyListener(e) {
|
_keyListener(e) {
|
||||||
if (this.$route.path === '/workspace') {
|
if (this.$route.path === '/workspace' && this.currentInquiryTab) {
|
||||||
// Run query Ctrl+R or Ctrl+Enter
|
// Run query Ctrl+R or Ctrl+Enter
|
||||||
if ((e.key === 'r' || e.key === 'Enter') && (e.ctrlKey || e.metaKey)) {
|
if ((e.key === 'r' || e.key === 'Enter') && (e.ctrlKey || e.metaKey)) {
|
||||||
e.preventDefault()
|
e.preventDefault()
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
<chart
|
<chart
|
||||||
ref="customChart"
|
ref="customChart"
|
||||||
v-bind="customChartComponentProps"
|
v-bind="customChartComponentProps"
|
||||||
|
:showViewSettings="showViewSettings"
|
||||||
@update="$emit('update')"
|
@update="$emit('update')"
|
||||||
@loading-image-completed="$emit('loadingImageCompleted')"
|
@loading-image-completed="$emit('loadingImageCompleted')"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -13,6 +13,27 @@ export function getOptionsFromDataSources(dataSources) {
|
|||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function getRowsByIndexFromDataSources(dataSources, rowIndexes) {
|
||||||
|
if (!dataSources) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
const dataSourceColumns = Object.keys(dataSources)
|
||||||
|
return rowIndexes.map(rowIndex =>
|
||||||
|
dataSourceColumns.reduce((result, columnName) => {
|
||||||
|
result[columnName] = dataSources[columnName][rowIndex]
|
||||||
|
return result
|
||||||
|
}, {})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function clearSelection(data, layout) {
|
||||||
|
if (layout?.selections?.length > 0) {
|
||||||
|
layout.selections = []
|
||||||
|
data.forEach(dataItem => delete dataItem.selectedpoints)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function getOptionsForSave(state, dataSources) {
|
export function getOptionsForSave(state, dataSources) {
|
||||||
// we don't need to save the data, only settings
|
// we don't need to save the data, only settings
|
||||||
// so we modify state.data using dereference
|
// so we modify state.data using dereference
|
||||||
@@ -22,6 +43,9 @@ export function getOptionsForSave(state, dataSources) {
|
|||||||
emptySources[key] = []
|
emptySources[key] = []
|
||||||
}
|
}
|
||||||
dereference.default(stateCopy.data, emptySources)
|
dereference.default(stateCopy.data, emptySources)
|
||||||
|
|
||||||
|
// Also, we don't need to save selections
|
||||||
|
clearSelection(stateCopy.data, stateCopy.layout)
|
||||||
return stateCopy
|
return stateCopy
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,5 +96,7 @@ export default {
|
|||||||
getOptionsForSave,
|
getOptionsForSave,
|
||||||
getImageDataUrl,
|
getImageDataUrl,
|
||||||
getHtml,
|
getHtml,
|
||||||
getChartData
|
getChartData,
|
||||||
|
getRowsByIndexFromDataSources,
|
||||||
|
clearSelection
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { clearSelection } from '@/lib/chartHelper'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
_migrate(installedVersion, inquiries) {
|
_migrate(installedVersion, inquiries) {
|
||||||
if (installedVersion < 2) {
|
if (installedVersion < 2) {
|
||||||
@@ -28,6 +30,14 @@ export default {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (installedVersion < 5) {
|
||||||
|
inquiries.forEach(inquiry => {
|
||||||
|
if (inquiry.viewType === 'chart') {
|
||||||
|
clearSelection(inquiry.viewOptions.data, inquiry.viewOptions.layout)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
return inquiries
|
return inquiries
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import migration from './_migrations'
|
|||||||
|
|
||||||
const migrate = migration._migrate
|
const migrate = migration._migrate
|
||||||
const myInquiriesKey = 'myInquiries'
|
const myInquiriesKey = 'myInquiries'
|
||||||
const latestVersion = 4
|
const latestVersion = 5
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
version: latestVersion,
|
version: latestVersion,
|
||||||
|
|||||||
@@ -429,37 +429,44 @@ describe('DataView.vue', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// viewNodeOrEdgeBtn is not disaplyed in chart mode
|
// viewDetailsBtn is disaplyed in chart mode
|
||||||
expect(
|
expect(wrapper.findComponent({ ref: 'viewDetailsBtn' }).exists()).to.equal(
|
||||||
wrapper.findComponent({ ref: 'viewNodeOrEdgeBtn' }).exists()
|
true
|
||||||
).to.equal(false)
|
)
|
||||||
|
|
||||||
// Switch to pivot
|
// Switch to pivot
|
||||||
const pivotBtn = wrapper.findComponent({ ref: 'pivotBtn' })
|
const pivotBtn = wrapper.findComponent({ ref: 'pivotBtn' })
|
||||||
await pivotBtn.trigger('click')
|
await pivotBtn.trigger('click')
|
||||||
|
|
||||||
// viewNodeOrEdgeBtn is not disaplyed in pivot mode
|
// viewDetailsBtn is not disaplyed in pivot mode
|
||||||
expect(
|
expect(wrapper.findComponent({ ref: 'viewDetailsBtn' }).exists()).to.equal(
|
||||||
wrapper.findComponent({ ref: 'viewNodeOrEdgeBtn' }).exists()
|
false
|
||||||
).to.equal(false)
|
)
|
||||||
|
|
||||||
// Switch to graph
|
// Switch to graph
|
||||||
const graphBtn = wrapper.findComponent({ ref: 'graphBtn' })
|
const graphBtn = wrapper.findComponent({ ref: 'graphBtn' })
|
||||||
await graphBtn.trigger('click')
|
await graphBtn.trigger('click')
|
||||||
|
|
||||||
// viewNodeOrEdgeBtn is disaplyed in graph mode
|
// viewDetailsBtn is disaplyed in graph mode
|
||||||
const viewNodeOrEdgeBtn = wrapper.findComponent({
|
const viewDetailsBtn = wrapper.findComponent({
|
||||||
ref: 'viewNodeOrEdgeBtn'
|
ref: 'viewDetailsBtn'
|
||||||
})
|
})
|
||||||
expect(viewNodeOrEdgeBtn.exists()).to.equal(true)
|
expect(viewDetailsBtn.exists()).to.equal(true)
|
||||||
|
|
||||||
// by default node viewer is hidden
|
// by default details viewer is hidden
|
||||||
expect(wrapper.findComponent({ name: 'value-viewer' }).exists()).to.equal(
|
expect(wrapper.findComponent({ name: 'value-viewer' }).exists()).to.equal(
|
||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
// Click to show node viewer
|
// Click to show details viewer
|
||||||
await viewNodeOrEdgeBtn.trigger('click')
|
await viewDetailsBtn.trigger('click')
|
||||||
|
expect(wrapper.findComponent({ name: 'value-viewer' }).exists()).to.equal(
|
||||||
|
true
|
||||||
|
)
|
||||||
|
|
||||||
|
// Switch to chart
|
||||||
|
const chartBtn = wrapper.findComponent({ ref: 'chartBtn' })
|
||||||
|
await chartBtn.trigger('click')
|
||||||
expect(wrapper.findComponent({ name: 'value-viewer' }).exists()).to.equal(
|
expect(wrapper.findComponent({ name: 'value-viewer' }).exists()).to.equal(
|
||||||
true
|
true
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -210,8 +210,8 @@ describe('MainMenu.vue', () => {
|
|||||||
isSaved: false
|
isSaved: false
|
||||||
}
|
}
|
||||||
const state = {
|
const state = {
|
||||||
currentTab: tab,
|
currentTab: null,
|
||||||
tabs: [tab],
|
tabs: [],
|
||||||
db: {}
|
db: {}
|
||||||
}
|
}
|
||||||
const store = createStore({ state })
|
const store = createStore({ state })
|
||||||
@@ -228,6 +228,17 @@ describe('MainMenu.vue', () => {
|
|||||||
|
|
||||||
const ctrlR = new KeyboardEvent('keydown', { key: 'r', ctrlKey: true })
|
const ctrlR = new KeyboardEvent('keydown', { key: 'r', ctrlKey: true })
|
||||||
const metaR = new KeyboardEvent('keydown', { key: 'r', metaKey: true })
|
const metaR = new KeyboardEvent('keydown', { key: 'r', metaKey: true })
|
||||||
|
|
||||||
|
// execute is not called - no tabs open
|
||||||
|
document.dispatchEvent(ctrlR)
|
||||||
|
expect(tab.execute.calledOnce).to.equal(false)
|
||||||
|
document.dispatchEvent(metaR)
|
||||||
|
expect(tab.execute.calledOnce).to.equal(false)
|
||||||
|
|
||||||
|
// Open a tab
|
||||||
|
store.state.currentTab = tab
|
||||||
|
store.state.tabs = [tab]
|
||||||
|
|
||||||
// Running is enabled and route path is workspace
|
// Running is enabled and route path is workspace
|
||||||
document.dispatchEvent(ctrlR)
|
document.dispatchEvent(ctrlR)
|
||||||
expect(state.currentTab.execute.calledOnce).to.equal(true)
|
expect(state.currentTab.execute.calledOnce).to.equal(true)
|
||||||
@@ -257,8 +268,8 @@ describe('MainMenu.vue', () => {
|
|||||||
isSaved: false
|
isSaved: false
|
||||||
}
|
}
|
||||||
const state = {
|
const state = {
|
||||||
currentTab: tab,
|
currentTab: null,
|
||||||
tabs: [tab],
|
tabs: [],
|
||||||
db: {}
|
db: {}
|
||||||
}
|
}
|
||||||
const store = createStore({ state })
|
const store = createStore({ state })
|
||||||
@@ -281,6 +292,17 @@ describe('MainMenu.vue', () => {
|
|||||||
key: 'Enter',
|
key: 'Enter',
|
||||||
metaKey: true
|
metaKey: true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// execute is not called - no tabs open
|
||||||
|
document.dispatchEvent(ctrlEnter)
|
||||||
|
expect(tab.execute.calledOnce).to.equal(false)
|
||||||
|
document.dispatchEvent(metaEnter)
|
||||||
|
expect(tab.execute.calledOnce).to.equal(false)
|
||||||
|
|
||||||
|
// Open a tab
|
||||||
|
store.state.currentTab = tab
|
||||||
|
store.state.tabs = [tab]
|
||||||
|
|
||||||
// Running is enabled and route path is workspace
|
// Running is enabled and route path is workspace
|
||||||
document.dispatchEvent(ctrlEnter)
|
document.dispatchEvent(ctrlEnter)
|
||||||
expect(state.currentTab.execute.calledOnce).to.equal(true)
|
expect(state.currentTab.execute.calledOnce).to.equal(true)
|
||||||
@@ -347,8 +369,8 @@ describe('MainMenu.vue', () => {
|
|||||||
isSaved: false
|
isSaved: false
|
||||||
}
|
}
|
||||||
const state = {
|
const state = {
|
||||||
currentTab: tab,
|
currentTab: null,
|
||||||
tabs: [tab],
|
tabs: [],
|
||||||
db: {}
|
db: {}
|
||||||
}
|
}
|
||||||
const store = createStore({ state })
|
const store = createStore({ state })
|
||||||
@@ -365,6 +387,17 @@ describe('MainMenu.vue', () => {
|
|||||||
|
|
||||||
const ctrlS = new KeyboardEvent('keydown', { key: 's', ctrlKey: true })
|
const ctrlS = new KeyboardEvent('keydown', { key: 's', ctrlKey: true })
|
||||||
const metaS = new KeyboardEvent('keydown', { key: 's', metaKey: true })
|
const metaS = new KeyboardEvent('keydown', { key: 's', metaKey: true })
|
||||||
|
|
||||||
|
// onSave is not called - no tabs open
|
||||||
|
document.dispatchEvent(ctrlS)
|
||||||
|
expect(wrapper.vm.onSave.calledOnce).to.equal(false)
|
||||||
|
document.dispatchEvent(metaS)
|
||||||
|
expect(wrapper.vm.onSave.calledOnce).to.equal(false)
|
||||||
|
|
||||||
|
// Open a tab
|
||||||
|
store.state.currentTab = tab
|
||||||
|
store.state.tabs = [tab]
|
||||||
|
|
||||||
// tab is unsaved and route is /workspace
|
// tab is unsaved and route is /workspace
|
||||||
document.dispatchEvent(ctrlS)
|
document.dispatchEvent(ctrlS)
|
||||||
expect(wrapper.vm.onSave.calledOnce).to.equal(true)
|
expect(wrapper.vm.onSave.calledOnce).to.equal(true)
|
||||||
@@ -394,8 +427,8 @@ describe('MainMenu.vue', () => {
|
|||||||
isSaved: false
|
isSaved: false
|
||||||
}
|
}
|
||||||
const state = {
|
const state = {
|
||||||
currentTab: tab,
|
currentTab: null,
|
||||||
tabs: [tab],
|
tabs: [],
|
||||||
db: {}
|
db: {}
|
||||||
}
|
}
|
||||||
const store = createStore({ state })
|
const store = createStore({ state })
|
||||||
@@ -420,6 +453,17 @@ describe('MainMenu.vue', () => {
|
|||||||
metaKey: true,
|
metaKey: true,
|
||||||
shiftKey: true
|
shiftKey: true
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// onSaveAs is not called - no tabs open
|
||||||
|
document.dispatchEvent(ctrlS)
|
||||||
|
expect(wrapper.vm.onSaveAs.calledOnce).to.equal(false)
|
||||||
|
document.dispatchEvent(metaS)
|
||||||
|
expect(wrapper.vm.onSaveAs.calledOnce).to.equal(false)
|
||||||
|
|
||||||
|
// Open a tab
|
||||||
|
store.state.currentTab = tab
|
||||||
|
store.state.tabs = [tab]
|
||||||
|
|
||||||
// tab is unsaved and route is /workspace
|
// tab is unsaved and route is /workspace
|
||||||
document.dispatchEvent(ctrlS)
|
document.dispatchEvent(ctrlS)
|
||||||
expect(wrapper.vm.onSaveAs.calledOnce).to.equal(true)
|
expect(wrapper.vm.onSaveAs.calledOnce).to.equal(true)
|
||||||
|
|||||||
@@ -23,35 +23,54 @@ describe('chartHelper.js', () => {
|
|||||||
|
|
||||||
it('getOptionsForSave', () => {
|
it('getOptionsForSave', () => {
|
||||||
const state = {
|
const state = {
|
||||||
data: {
|
data: [
|
||||||
foo: {},
|
{
|
||||||
bar: {}
|
foo: {},
|
||||||
},
|
bar: {},
|
||||||
layout: {},
|
selectedpoints: []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
layout: { selections: [{}] },
|
||||||
frames: {}
|
frames: {}
|
||||||
}
|
}
|
||||||
const dataSources = {
|
const dataSources = {
|
||||||
id: [1, 2],
|
id: [1, 2],
|
||||||
name: ['foo', 'bar']
|
name: ['foo', 'bar']
|
||||||
}
|
}
|
||||||
sinon.stub(dereference, 'default')
|
const dereferenceArgs = []
|
||||||
|
sinon.stub(dereference, 'default').callsFake((data, emptySources) => {
|
||||||
|
dereferenceArgs[0] = JSON.stringify(data)
|
||||||
|
dereferenceArgs[1] = JSON.stringify(emptySources)
|
||||||
|
})
|
||||||
sinon.spy(JSON, 'parse')
|
sinon.spy(JSON, 'parse')
|
||||||
|
|
||||||
const ds = chartHelper.getOptionsForSave(state, dataSources)
|
const ds = chartHelper.getOptionsForSave(state, dataSources)
|
||||||
|
|
||||||
expect(dereference.default.calledOnce).to.equal(true)
|
expect(dereference.default.calledOnce).to.equal(true)
|
||||||
|
expect(dereferenceArgs[0]).to.eql(
|
||||||
const args = dereference.default.firstCall.args
|
JSON.stringify([
|
||||||
expect(args[0]).to.eql({
|
{
|
||||||
foo: {},
|
foo: {},
|
||||||
bar: {}
|
bar: {},
|
||||||
})
|
selectedpoints: []
|
||||||
expect(args[1]).to.eql({
|
}
|
||||||
id: [],
|
])
|
||||||
name: []
|
)
|
||||||
})
|
expect(dereferenceArgs[1]).to.eql(
|
||||||
|
JSON.stringify({
|
||||||
|
id: [],
|
||||||
|
name: []
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
expect(ds).to.equal(JSON.parse.returnValues[0])
|
expect(ds).to.equal(JSON.parse.returnValues[0])
|
||||||
|
expect(ds.layout.selections).to.eql([])
|
||||||
|
expect(ds.data).to.eql([
|
||||||
|
{
|
||||||
|
foo: {},
|
||||||
|
bar: {}
|
||||||
|
}
|
||||||
|
])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('getImageDataUrl returns dataUrl', async () => {
|
it('getImageDataUrl returns dataUrl', async () => {
|
||||||
@@ -101,4 +120,32 @@ describe('chartHelper.js', () => {
|
|||||||
'Plotly.newPlot(el, "plotly data", "plotly layout"'
|
'Plotly.newPlot(el, "plotly data", "plotly layout"'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('getRowsByIndexFromDataSources', () => {
|
||||||
|
const dataSources = {
|
||||||
|
id: [1, 2, 3],
|
||||||
|
name: ['Harry', 'Draco', 'Ron'],
|
||||||
|
points: [10, null, 7]
|
||||||
|
}
|
||||||
|
const rows = chartHelper.getRowsByIndexFromDataSources(dataSources, [1, 2])
|
||||||
|
expect(rows).to.eql([
|
||||||
|
{ id: 2, name: 'Draco', points: null },
|
||||||
|
{ id: 3, name: 'Ron', points: 7 }
|
||||||
|
])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('clearSelection', () => {
|
||||||
|
const layout = {
|
||||||
|
selections: [{}],
|
||||||
|
someLayoutField: 1
|
||||||
|
}
|
||||||
|
const data = [
|
||||||
|
{ selectedpoints: [], someField: 1 },
|
||||||
|
{ someField: 2 },
|
||||||
|
{ selectedpoints: [], someField: 3 }
|
||||||
|
]
|
||||||
|
chartHelper.clearSelection(data, layout)
|
||||||
|
expect(layout).to.eql({ selections: [], someLayoutField: 1 })
|
||||||
|
expect(data).to.eql([{ someField: 1 }, { someField: 2 }, { someField: 3 }])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,14 +8,22 @@ describe('_migrations.js', () => {
|
|||||||
id: '123',
|
id: '123',
|
||||||
name: 'foo',
|
name: 'foo',
|
||||||
query: 'SELECT * FROM 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'
|
createdAt: '2021-05-06T11:05:50.877Z'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '456',
|
id: '456',
|
||||||
name: 'bar',
|
name: 'bar',
|
||||||
query: 'SELECT * FROM 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'
|
createdAt: '2021-05-07T11:05:50.877Z'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -26,7 +34,11 @@ describe('_migrations.js', () => {
|
|||||||
name: 'foo',
|
name: 'foo',
|
||||||
query: 'SELECT * FROM foo',
|
query: 'SELECT * FROM foo',
|
||||||
viewType: 'chart',
|
viewType: 'chart',
|
||||||
viewOptions: { here_are: 'foo chart settings' },
|
viewOptions: {
|
||||||
|
data: [{}, {}],
|
||||||
|
layout: { selections: [] },
|
||||||
|
frames: 'foo chart frames'
|
||||||
|
},
|
||||||
createdAt: '2021-05-06T11:05:50.877Z'
|
createdAt: '2021-05-06T11:05:50.877Z'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -34,7 +46,7 @@ describe('_migrations.js', () => {
|
|||||||
name: 'bar',
|
name: 'bar',
|
||||||
query: 'SELECT * FROM bar',
|
query: 'SELECT * FROM bar',
|
||||||
viewType: 'chart',
|
viewType: 'chart',
|
||||||
viewOptions: { here_are: 'bar chart settings' },
|
viewOptions: { data: [{}, {}], layout: {}, frames: 'bar chart frames' },
|
||||||
createdAt: '2021-05-07T11:05:50.877Z'
|
createdAt: '2021-05-07T11:05:50.877Z'
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
@@ -47,7 +59,11 @@ describe('_migrations.js', () => {
|
|||||||
name: 'foo',
|
name: 'foo',
|
||||||
query: 'SELECT * FROM foo',
|
query: 'SELECT * FROM foo',
|
||||||
viewType: 'chart',
|
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'
|
createdAt: '2021-05-06T11:05:50.877Z'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -108,7 +124,11 @@ describe('_migrations.js', () => {
|
|||||||
name: 'foo',
|
name: 'foo',
|
||||||
query: 'SELECT * FROM foo',
|
query: 'SELECT * FROM foo',
|
||||||
viewType: 'chart',
|
viewType: 'chart',
|
||||||
viewOptions: { here_are: 'foo chart settings' },
|
viewOptions: {
|
||||||
|
data: [{}, {}],
|
||||||
|
layout: { selections: [] },
|
||||||
|
frames: 'foo chart frames'
|
||||||
|
},
|
||||||
createdAt: '2021-05-06T11:05:50.877Z'
|
createdAt: '2021-05-06T11:05:50.877Z'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -175,7 +195,11 @@ describe('_migrations.js', () => {
|
|||||||
name: 'foo',
|
name: 'foo',
|
||||||
query: 'SELECT * FROM foo',
|
query: 'SELECT * FROM foo',
|
||||||
viewType: 'chart',
|
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'
|
createdAt: '2021-05-06T11:05:50.877Z'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -238,7 +262,150 @@ describe('_migrations.js', () => {
|
|||||||
name: 'foo',
|
name: 'foo',
|
||||||
query: 'SELECT * FROM foo',
|
query: 'SELECT * FROM foo',
|
||||||
viewType: 'chart',
|
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'
|
createdAt: '2021-05-06T11:05:50.877Z'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
122
tests/views/MainView.spec.js
Normal file
122
tests/views/MainView.spec.js
Normal file
@@ -0,0 +1,122 @@
|
|||||||
|
import { expect } from 'chai'
|
||||||
|
import { mount, flushPromises } from '@vue/test-utils'
|
||||||
|
import actions from '@/store/actions'
|
||||||
|
import mutations from '@/store/mutations'
|
||||||
|
import { createStore } from 'vuex'
|
||||||
|
import MainView from '@/views/MainView.vue'
|
||||||
|
import { routes } from '@/router'
|
||||||
|
import { createRouter, createWebHistory } from 'vue-router'
|
||||||
|
|
||||||
|
describe('MainView.vue', () => {
|
||||||
|
it('Saves inquiry without data', async () => {
|
||||||
|
const state = {
|
||||||
|
db: {},
|
||||||
|
tabs: [],
|
||||||
|
inquiries: []
|
||||||
|
}
|
||||||
|
const store = createStore({ state, actions, mutations })
|
||||||
|
const router = createRouter({
|
||||||
|
history: createWebHistory(),
|
||||||
|
routes: routes
|
||||||
|
})
|
||||||
|
|
||||||
|
router.push('/workspace')
|
||||||
|
await router.isReady()
|
||||||
|
const wrapper = mount(MainView, {
|
||||||
|
global: {
|
||||||
|
stubs: {
|
||||||
|
'router-link': true,
|
||||||
|
teleport: false,
|
||||||
|
'app-diagnostic-info': true,
|
||||||
|
transition: false,
|
||||||
|
schema: true,
|
||||||
|
'run-result': true
|
||||||
|
},
|
||||||
|
plugins: [store, router]
|
||||||
|
},
|
||||||
|
attachTo: document.body
|
||||||
|
})
|
||||||
|
|
||||||
|
await wrapper.find('#create-btn').trigger('click')
|
||||||
|
|
||||||
|
store.state.tabs[1].result = {
|
||||||
|
columns: ['id', 'name'],
|
||||||
|
values: {
|
||||||
|
id: [1, 2],
|
||||||
|
name: ['Harry', 'Drako']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
// Add trace
|
||||||
|
await wrapper
|
||||||
|
.findAllComponents({ name: 'Chart' })[1]
|
||||||
|
.find('button.js-add-button')
|
||||||
|
.wrapperElement.click()
|
||||||
|
|
||||||
|
await flushPromises()
|
||||||
|
|
||||||
|
// Select data for axis x
|
||||||
|
await wrapper
|
||||||
|
.findAll('.field .dropdown-container .Select__indicator')[0]
|
||||||
|
.wrapperElement.dispatchEvent(
|
||||||
|
new MouseEvent('mousedown', { bubbles: true })
|
||||||
|
)
|
||||||
|
await wrapper.findAll('.Select__menu .Select__option')[0].trigger('click')
|
||||||
|
|
||||||
|
// Select data for axis y
|
||||||
|
await wrapper
|
||||||
|
.findAll('.field .dropdown-container .Select__indicator')[2]
|
||||||
|
.wrapperElement.dispatchEvent(
|
||||||
|
new MouseEvent('mousedown', { bubbles: true })
|
||||||
|
)
|
||||||
|
await wrapper.findAll('.Select__menu .Select__option')[1].trigger('click')
|
||||||
|
|
||||||
|
// Click Save in the top menu
|
||||||
|
await wrapper.find('#save-btn').trigger('click')
|
||||||
|
|
||||||
|
// Input inquiry name
|
||||||
|
document.querySelector('.dialog input').value = 'test'
|
||||||
|
document.querySelector('.dialog input').dispatchEvent(
|
||||||
|
new InputEvent('input', {
|
||||||
|
data: 'test'
|
||||||
|
})
|
||||||
|
)
|
||||||
|
|
||||||
|
// Click Save in the dialog
|
||||||
|
document
|
||||||
|
.querySelector('.dialog .dialog-buttons-container button.primary')
|
||||||
|
.click()
|
||||||
|
|
||||||
|
const inquiriesInStore = store.state.inquiries
|
||||||
|
expect(inquiriesInStore.length).to.equal(1)
|
||||||
|
expect(inquiriesInStore[0].createdAt).to.not.be.null
|
||||||
|
expect(inquiriesInStore[0].createdAt).to.not.be.undefined
|
||||||
|
expect(inquiriesInStore[0].updateAt).to.not.be.null
|
||||||
|
expect(inquiriesInStore[0].updatedAt).to.not.be.undefined
|
||||||
|
|
||||||
|
expect(inquiriesInStore[0].id).to.not.be.null
|
||||||
|
expect(inquiriesInStore[0].id).to.not.be.undefined
|
||||||
|
|
||||||
|
expect(inquiriesInStore[0].name).to.equal('test')
|
||||||
|
expect(inquiriesInStore[0].viewType).to.equal('chart')
|
||||||
|
expect(inquiriesInStore[0].viewOptions.data).to.eql([
|
||||||
|
{
|
||||||
|
type: 'scatter',
|
||||||
|
mode: 'markers',
|
||||||
|
x: null,
|
||||||
|
xsrc: 'id',
|
||||||
|
meta: {
|
||||||
|
columnNames: {
|
||||||
|
x: 'id',
|
||||||
|
y: 'name'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
y: null,
|
||||||
|
ysrc: 'name'
|
||||||
|
}
|
||||||
|
])
|
||||||
|
wrapper.unmount()
|
||||||
|
})
|
||||||
|
})
|
||||||
Reference in New Issue
Block a user