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-23 23:14:17 +02:00
parent 6fbddb69bb
commit 62786e7dda
3 changed files with 75 additions and 24 deletions

View File

@@ -59,7 +59,7 @@
<icon-button <icon-button
v-if="mode !== 'pivot'" v-if="mode !== 'pivot'"
ref="viewNodeOrEdgeBtn" ref="viewDetailsBtn"
tooltip="View details" tooltip="View details"
tooltipPosition="top-left" tooltipPosition="top-left"
:active="viewValuePanelVisible" :active="viewValuePanelVisible"

View File

@@ -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
) )

View File

@@ -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)