mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 10:08:52 +08:00
Merge branch 'master' of github.com:lana-k/sqliteviz into migrate_to_vue3
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "sqliteviz",
|
"name": "sqliteviz",
|
||||||
"version": "0.25.0",
|
"version": "0.25.1",
|
||||||
"license": "Apache-2.0",
|
"license": "Apache-2.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
19
src/App.vue
19
src/App.vue
@@ -6,10 +6,27 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import storedInquiries from '@/lib/storedInquiries'
|
||||||
import { ModalsContainer } from 'vue-final-modal'
|
import { ModalsContainer } from 'vue-final-modal'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: { ModalsContainer }
|
components: { ModalsContainer },
|
||||||
|
created () {
|
||||||
|
this.$store.commit('setInquiries', storedInquiries.getStoredInquiries())
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
inquiries () {
|
||||||
|
return this.$store.state.inquiries
|
||||||
|
}
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
inquiries: {
|
||||||
|
deep: true,
|
||||||
|
handler () {
|
||||||
|
storedInquiries.updateStorage(this.inquiries)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -36,40 +36,6 @@ export default {
|
|||||||
return inquiryTab.isPredefined || !inquiryTab.name
|
return inquiryTab.isPredefined || !inquiryTab.name
|
||||||
},
|
},
|
||||||
|
|
||||||
save (inquiryTab, newName) {
|
|
||||||
const value = {
|
|
||||||
id: inquiryTab.isPredefined ? nanoid() : inquiryTab.id,
|
|
||||||
query: inquiryTab.query,
|
|
||||||
viewType: inquiryTab.dataView.mode,
|
|
||||||
viewOptions: inquiryTab.dataView.getOptionsForSave(),
|
|
||||||
name: newName || inquiryTab.name
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get inquiries from local storage
|
|
||||||
const myInquiries = this.getStoredInquiries()
|
|
||||||
|
|
||||||
let inquiryIndex
|
|
||||||
// Set createdAt
|
|
||||||
if (newName) {
|
|
||||||
value.createdAt = new Date()
|
|
||||||
} else {
|
|
||||||
inquiryIndex = myInquiries
|
|
||||||
.findIndex(oldInquiry => oldInquiry.id === inquiryTab.id)
|
|
||||||
value.createdAt = myInquiries[inquiryIndex].createdAt
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert in inquiries list
|
|
||||||
if (newName) {
|
|
||||||
myInquiries.push(value)
|
|
||||||
} else {
|
|
||||||
myInquiries[inquiryIndex] = value
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save to local storage
|
|
||||||
this.updateStorage(myInquiries)
|
|
||||||
return value
|
|
||||||
},
|
|
||||||
|
|
||||||
updateStorage (inquiries) {
|
updateStorage (inquiries) {
|
||||||
localStorage.setItem('myInquiries', JSON.stringify({ version: this.version, inquiries }))
|
localStorage.setItem('myInquiries', JSON.stringify({ version: this.version, inquiries }))
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import Tab from '@/lib/tab'
|
import Tab from '@/lib/tab'
|
||||||
|
import { nanoid } from 'nanoid'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
async addTab ({ state }, inquiry = {}) {
|
async addTab ({ state }, inquiry = {}) {
|
||||||
@@ -13,5 +14,69 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return inquiry.id
|
return inquiry.id
|
||||||
|
},
|
||||||
|
async saveInquiry ({ state }, { inquiryTab, newName }) {
|
||||||
|
const value = {
|
||||||
|
id: inquiryTab.isPredefined ? nanoid() : inquiryTab.id,
|
||||||
|
query: inquiryTab.query,
|
||||||
|
viewType: inquiryTab.dataView.mode,
|
||||||
|
viewOptions: inquiryTab.dataView.getOptionsForSave(),
|
||||||
|
name: newName || inquiryTab.name
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get inquiries from local storage
|
||||||
|
const myInquiries = state.inquiries
|
||||||
|
|
||||||
|
// Set createdAt
|
||||||
|
if (newName) {
|
||||||
|
value.createdAt = new Date()
|
||||||
|
} else {
|
||||||
|
var inquiryIndex = myInquiries.findIndex(oldInquiry => oldInquiry.id === inquiryTab.id)
|
||||||
|
value.createdAt = myInquiries[inquiryIndex].createdAt
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert in inquiries list
|
||||||
|
if (newName) {
|
||||||
|
myInquiries.push(value)
|
||||||
|
} else {
|
||||||
|
myInquiries.splice(inquiryIndex, 1, value)
|
||||||
|
}
|
||||||
|
|
||||||
|
return value
|
||||||
|
},
|
||||||
|
addInquiry ({ state }, newInquiry) {
|
||||||
|
state.inquiries.push(newInquiry)
|
||||||
|
},
|
||||||
|
deleteInquiries ({ state, commit }, inquiryIdSet) {
|
||||||
|
state.inquiries = state.inquiries.filter(
|
||||||
|
inquiry => !inquiryIdSet.has(inquiry.id)
|
||||||
|
)
|
||||||
|
|
||||||
|
// Close deleted inquiries if it was opened
|
||||||
|
const tabs = state.tabs
|
||||||
|
let i = tabs.length - 1
|
||||||
|
while (i > -1) {
|
||||||
|
if (inquiryIdSet.has(tabs[i].id)) {
|
||||||
|
commit('deleteTab', tabs[i])
|
||||||
|
}
|
||||||
|
i--
|
||||||
|
}
|
||||||
|
},
|
||||||
|
renameInquiry ({ state, commit }, { inquiryId, newName }) {
|
||||||
|
const renamingInquiry = state.inquiries
|
||||||
|
.find(inquiry => inquiry.id === inquiryId)
|
||||||
|
|
||||||
|
renamingInquiry.name = newName
|
||||||
|
|
||||||
|
// update tab, if renamed inquiry is opened
|
||||||
|
const tab = state.tabs.find(tab => tab.id === renamingInquiry.id)
|
||||||
|
if (tab) {
|
||||||
|
commit('updateTab', {
|
||||||
|
tab,
|
||||||
|
newValues: {
|
||||||
|
name: newName
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,9 @@ export default {
|
|||||||
setPredefinedInquiriesLoaded (state, value) {
|
setPredefinedInquiriesLoaded (state, value) {
|
||||||
state.predefinedInquiriesLoaded = value
|
state.predefinedInquiriesLoaded = value
|
||||||
},
|
},
|
||||||
|
setInquiries (state, value) {
|
||||||
|
state.inquiries = value
|
||||||
|
},
|
||||||
setIsWorkspaceVisible (state, value) {
|
setIsWorkspaceVisible (state, value) {
|
||||||
state.isWorkspaceVisible = value
|
state.isWorkspaceVisible = value
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ export default {
|
|||||||
currentTab: null,
|
currentTab: null,
|
||||||
currentTabId: null,
|
currentTabId: null,
|
||||||
untitledLastIndex: 0,
|
untitledLastIndex: 0,
|
||||||
|
inquiries: [],
|
||||||
predefinedInquiries: [],
|
predefinedInquiries: [],
|
||||||
loadingPredefinedInquiries: false,
|
loadingPredefinedInquiries: false,
|
||||||
predefinedInquiriesLoaded: false,
|
predefinedInquiriesLoaded: false,
|
||||||
|
|||||||
@@ -187,7 +187,6 @@ export default {
|
|||||||
mixins: [tooltipMixin],
|
mixins: [tooltipMixin],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
inquiries: [],
|
|
||||||
filter: null,
|
filter: null,
|
||||||
newName: null,
|
newName: null,
|
||||||
processedInquiryId: null,
|
processedInquiryId: null,
|
||||||
@@ -202,6 +201,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
inquiries () {
|
||||||
|
return this.$store.state.inquiries
|
||||||
|
},
|
||||||
predefinedInquiries () {
|
predefinedInquiries () {
|
||||||
return this.$store.state.predefinedInquiries.map(inquiry => {
|
return this.$store.state.predefinedInquiries.map(inquiry => {
|
||||||
inquiry.isPredefined = true
|
inquiry.isPredefined = true
|
||||||
@@ -267,7 +269,6 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
async created () {
|
async created () {
|
||||||
this.inquiries = storedInquiries.getStoredInquiries()
|
|
||||||
const loadingPredefinedInquiries = this.$store.state.loadingPredefinedInquiries
|
const loadingPredefinedInquiries = this.$store.state.loadingPredefinedInquiries
|
||||||
const predefinedInquiriesLoaded = this.$store.state.predefinedInquiriesLoaded
|
const predefinedInquiriesLoaded = this.$store.state.predefinedInquiriesLoaded
|
||||||
if (!predefinedInquiriesLoaded && !loadingPredefinedInquiries) {
|
if (!predefinedInquiriesLoaded && !loadingPredefinedInquiries) {
|
||||||
@@ -342,31 +343,17 @@ export default {
|
|||||||
this.errorMsg = "Inquiry name can't be empty"
|
this.errorMsg = "Inquiry name can't be empty"
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const processedInquiry = this.inquiries[this.processedInquiryIndex]
|
this.$store.dispatch('renameInquiry', {
|
||||||
processedInquiry.name = this.newName
|
inquiryId: this.processedInquiryId,
|
||||||
this.inquiries[this.processedInquiryIndex] = processedInquiry
|
newName: this.newName
|
||||||
|
})
|
||||||
|
|
||||||
// update inquiries in local storage
|
|
||||||
storedInquiries.updateStorage(this.inquiries)
|
|
||||||
|
|
||||||
// update tab, if renamed inquiry is opened
|
|
||||||
const tab = this.$store.state.tabs
|
|
||||||
.find(tab => tab.id === processedInquiry.id)
|
|
||||||
if (tab) {
|
|
||||||
this.$store.commit('updateTab', {
|
|
||||||
tab,
|
|
||||||
newValues: {
|
|
||||||
name: this.newName
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
// hide dialog
|
// hide dialog
|
||||||
this.$modal.hide('rename')
|
this.$modal.hide('rename')
|
||||||
},
|
},
|
||||||
duplicateInquiry (index) {
|
duplicateInquiry (index) {
|
||||||
const newInquiry = storedInquiries.duplicateInquiry(this.showedInquiries[index])
|
const newInquiry = storedInquiries.duplicateInquiry(this.showedInquiries[index])
|
||||||
this.inquiries.push(newInquiry)
|
this.$store.dispatch('addInquiry', newInquiry)
|
||||||
storedInquiries.updateStorage(this.inquiries)
|
|
||||||
},
|
},
|
||||||
showDeleteDialog (idsSet) {
|
showDeleteDialog (idsSet) {
|
||||||
this.deleteGroup = idsSet.size > 1
|
this.deleteGroup = idsSet.size > 1
|
||||||
@@ -378,39 +365,19 @@ export default {
|
|||||||
deleteInquiry () {
|
deleteInquiry () {
|
||||||
this.$modal.hide('delete')
|
this.$modal.hide('delete')
|
||||||
if (!this.deleteGroup) {
|
if (!this.deleteGroup) {
|
||||||
this.inquiries.splice(this.processedInquiryIndex, 1)
|
this.$store.dispatch('deleteInquiries', new Set().add(this.processedInquiryId))
|
||||||
|
|
||||||
// Close deleted inquiry tab if it was opened
|
|
||||||
const tab = this.$store.state.tabs
|
|
||||||
.find(tab => tab.id === this.processedInquiryId)
|
|
||||||
if (tab) {
|
|
||||||
this.$store.commit('deleteTab', tab)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear checkbox
|
// Clear checkbox
|
||||||
if (this.selectedInquiriesIds.has(this.processedInquiryId)) {
|
if (this.selectedInquiriesIds.has(this.processedInquiryId)) {
|
||||||
this.selectedInquiriesIds.delete(this.processedInquiryId)
|
this.selectedInquiriesIds.delete(this.processedInquiryId)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.inquiries = this.inquiries.filter(
|
this.$store.dispatch('deleteInquiries', this.selectedInquiriesIds)
|
||||||
inquiry => !this.selectedInquiriesIds.has(inquiry.id)
|
|
||||||
)
|
|
||||||
|
|
||||||
// Close deleted inquiries if it was opened
|
|
||||||
const tabs = this.$store.state.tabs
|
|
||||||
let i = tabs.length - 1
|
|
||||||
while (i > -1) {
|
|
||||||
if (this.selectedInquiriesIds.has(tabs[i].id)) {
|
|
||||||
this.$store.commit('deleteTab', tabs[i])
|
|
||||||
}
|
|
||||||
i--
|
|
||||||
}
|
|
||||||
|
|
||||||
// Clear checkboxes
|
// Clear checkboxes
|
||||||
this.selectedInquiriesIds.clear()
|
this.selectedInquiriesIds.clear()
|
||||||
}
|
}
|
||||||
this.selectedInquiriesCount = this.selectedInquiriesIds.size
|
this.selectedInquiriesCount = this.selectedInquiriesIds.size
|
||||||
storedInquiries.updateStorage(this.inquiries)
|
|
||||||
},
|
},
|
||||||
exportToFile (inquiryList, fileName) {
|
exportToFile (inquiryList, fileName) {
|
||||||
storedInquiries.export(inquiryList, fileName)
|
storedInquiries.export(inquiryList, fileName)
|
||||||
@@ -426,8 +393,7 @@ export default {
|
|||||||
importInquiries () {
|
importInquiries () {
|
||||||
storedInquiries.importInquiries()
|
storedInquiries.importInquiries()
|
||||||
.then(importedInquiries => {
|
.then(importedInquiries => {
|
||||||
this.inquiries = this.inquiries.concat(importedInquiries)
|
this.$store.commit('setInquiries', this.inquiries.concat(importedInquiries))
|
||||||
storedInquiries.updateStorage(this.inquiries)
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ export default {
|
|||||||
this.saveInquiry()
|
this.saveInquiry()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
saveInquiry () {
|
async saveInquiry () {
|
||||||
const isNeedName = storedInquiries.isTabNeedName(this.currentInquiry)
|
const isNeedName = storedInquiries.isTabNeedName(this.currentInquiry)
|
||||||
if (isNeedName && !this.name) {
|
if (isNeedName && !this.name) {
|
||||||
this.errorMsg = 'Inquiry name can\'t be empty'
|
this.errorMsg = 'Inquiry name can\'t be empty'
|
||||||
@@ -133,7 +133,10 @@ export default {
|
|||||||
const tabView = this.currentInquiry.view
|
const tabView = this.currentInquiry.view
|
||||||
|
|
||||||
// Save inquiry
|
// Save inquiry
|
||||||
const value = storedInquiries.save(this.currentInquiry, this.name)
|
const value = await this.$store.dispatch('saveInquiry', {
|
||||||
|
inquiryTab: this.currentInquiry,
|
||||||
|
newName: this.name
|
||||||
|
})
|
||||||
|
|
||||||
// Update tab in store
|
// Update tab in store
|
||||||
this.$store.commit('updateTab', {
|
this.$store.commit('updateTab', {
|
||||||
|
|||||||
52
tests/App.spec.js
Normal file
52
tests/App.spec.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import { expect } from 'chai'
|
||||||
|
import sinon from 'sinon'
|
||||||
|
import { shallowMount } from '@vue/test-utils'
|
||||||
|
import Vuex from 'vuex'
|
||||||
|
import App from '@/App'
|
||||||
|
import storedInquiries from '@/lib/storedInquiries'
|
||||||
|
import mutations from '@/store/mutations'
|
||||||
|
|
||||||
|
describe('App.vue', () => {
|
||||||
|
afterEach(() => {
|
||||||
|
sinon.restore()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Gets inquiries', () => {
|
||||||
|
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
||||||
|
{ id: 1 }, { id: 2 }, { id: 3 }
|
||||||
|
])
|
||||||
|
const state = {
|
||||||
|
predefinedInquiries: [],
|
||||||
|
inquiries: []
|
||||||
|
}
|
||||||
|
const store = new Vuex.Store({ state, mutations })
|
||||||
|
shallowMount(App, { store, stubs: ['router-view'] })
|
||||||
|
|
||||||
|
expect(state.inquiries).to.eql([{ id: 1 }, { id: 2 }, { id: 3 }])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Updates inquiries when they change in store', async () => {
|
||||||
|
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
||||||
|
{ id: 1, name: 'foo' }, { id: 2, name: 'baz' }, { id: 3, name: 'bar' }
|
||||||
|
])
|
||||||
|
sinon.spy(storedInquiries, 'updateStorage')
|
||||||
|
|
||||||
|
const state = {
|
||||||
|
predefinedInquiries: [],
|
||||||
|
inquiries: []
|
||||||
|
}
|
||||||
|
const store = new Vuex.Store({ state, mutations })
|
||||||
|
const wrapper = shallowMount(App, { store, stubs: ['router-view'] })
|
||||||
|
|
||||||
|
store.state.inquiries.splice(0, 1, { id: 1, name: 'new foo name' })
|
||||||
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
|
expect(storedInquiries.updateStorage.calledTwice).to.equal(true)
|
||||||
|
|
||||||
|
expect(storedInquiries.updateStorage.args[1][0]).to.eql([
|
||||||
|
{ id: 1, name: 'new foo name' },
|
||||||
|
{ id: 2, name: 'baz' },
|
||||||
|
{ id: 3, name: 'bar' }
|
||||||
|
])
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -342,87 +342,4 @@ describe('storedInquiries.js', () => {
|
|||||||
createdAt: '2020-11-03T14:17:49.524Z'
|
createdAt: '2020-11-03T14:17:49.524Z'
|
||||||
}])
|
}])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('save adds new inquiry in the storage', () => {
|
|
||||||
const now = new Date()
|
|
||||||
const nowPlusMinute = new Date(now.getTime() + 60 * 1000)
|
|
||||||
const tab = {
|
|
||||||
id: 1,
|
|
||||||
query: 'select * from foo',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: [],
|
|
||||||
name: null,
|
|
||||||
dataView: {
|
|
||||||
getOptionsForSave () {
|
|
||||||
return ['chart']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
const value = storedInquiries.save(tab, 'foo')
|
|
||||||
expect(value.id).to.equal(tab.id)
|
|
||||||
expect(value.name).to.equal('foo')
|
|
||||||
expect(value.query).to.equal(tab.query)
|
|
||||||
expect(value.viewOptions).to.eql(['chart'])
|
|
||||||
expect(value).to.have.property('createdAt').which.within(now, nowPlusMinute)
|
|
||||||
const inquiries = storedInquiries.getStoredInquiries()
|
|
||||||
expect(JSON.stringify(inquiries)).to.equal(JSON.stringify([value]))
|
|
||||||
})
|
|
||||||
|
|
||||||
it('save updates existing inquiry in the storage', () => {
|
|
||||||
const tab = {
|
|
||||||
id: 1,
|
|
||||||
query: 'select * from foo',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: [],
|
|
||||||
name: null,
|
|
||||||
dataView: {
|
|
||||||
getOptionsForSave () {
|
|
||||||
return ['chart']
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
const first = storedInquiries.save(tab, 'foo')
|
|
||||||
|
|
||||||
tab.name = 'foo'
|
|
||||||
tab.query = 'select * from foo'
|
|
||||||
storedInquiries.save(tab)
|
|
||||||
const inquiries = storedInquiries.getStoredInquiries()
|
|
||||||
const second = inquiries[0]
|
|
||||||
expect(inquiries).has.lengthOf(1)
|
|
||||||
expect(second.id).to.equal(first.id)
|
|
||||||
expect(second.name).to.equal(first.name)
|
|
||||||
expect(second.query).to.equal(tab.query)
|
|
||||||
expect(second.viewOptions).to.eql(['chart'])
|
|
||||||
expect(new Date(second.createdAt).getTime()).to.equal(first.createdAt.getTime())
|
|
||||||
})
|
|
||||||
|
|
||||||
it("save adds a new inquiry with new id if it's based on predefined inquiry", () => {
|
|
||||||
const now = new Date()
|
|
||||||
const nowPlusMinute = new Date(now.getTime() + 60 * 1000)
|
|
||||||
const tab = {
|
|
||||||
id: 1,
|
|
||||||
query: 'select * from foo',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: [],
|
|
||||||
name: 'foo predefined',
|
|
||||||
dataView: {
|
|
||||||
getOptionsForSave () {
|
|
||||||
return ['chart']
|
|
||||||
}
|
|
||||||
},
|
|
||||||
isPredefined: true
|
|
||||||
}
|
|
||||||
storedInquiries.save(tab, 'foo')
|
|
||||||
|
|
||||||
const inquiries = storedInquiries.getStoredInquiries()
|
|
||||||
expect(inquiries).has.lengthOf(1)
|
|
||||||
expect(inquiries[0]).to.have.property('id').which.not.equal(tab.id)
|
|
||||||
expect(inquiries[0].name).to.equal('foo')
|
|
||||||
expect(inquiries[0].query).to.equal(tab.query)
|
|
||||||
expect(inquiries[0].viewOptions).to.eql(['chart'])
|
|
||||||
expect(new Date(inquiries[0].createdAt)).to.be.within(now, nowPlusMinute)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,7 +1,14 @@
|
|||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import actions from '@/store/actions'
|
import actions from '@/store/actions'
|
||||||
|
import sinon from 'sinon'
|
||||||
|
|
||||||
const { addTab } = actions
|
const {
|
||||||
|
addTab,
|
||||||
|
addInquiry,
|
||||||
|
deleteInquiries,
|
||||||
|
renameInquiry,
|
||||||
|
saveInquiry
|
||||||
|
} = actions
|
||||||
|
|
||||||
describe('actions', () => {
|
describe('actions', () => {
|
||||||
it('addTab adds new blank tab', async () => {
|
it('addTab adds new blank tab', async () => {
|
||||||
@@ -81,4 +88,156 @@ describe('actions', () => {
|
|||||||
expect(state.tabs).to.have.lengthOf(2)
|
expect(state.tabs).to.have.lengthOf(2)
|
||||||
expect(state.untitledLastIndex).to.equal(0)
|
expect(state.untitledLastIndex).to.equal(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('addInquiry', async () => {
|
||||||
|
const state = {
|
||||||
|
inquiries: [1, 2, 3]
|
||||||
|
}
|
||||||
|
|
||||||
|
await addInquiry({ state }, 4)
|
||||||
|
expect(state.inquiries).to.eql([1, 2, 3, 4])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('deleteInquiries', async () => {
|
||||||
|
const state = {
|
||||||
|
inquiries: [{ id: 1 }, { id: 2 }, { id: 3 }],
|
||||||
|
tabs: [{ id: 3 }, { id: 2 }]
|
||||||
|
}
|
||||||
|
const commit = sinon.spy()
|
||||||
|
|
||||||
|
await deleteInquiries({ state, commit }, new Set().add(2))
|
||||||
|
expect(state.inquiries).to.eql([{ id: 1 }, { id: 3 }])
|
||||||
|
expect(commit.calledWith('deleteTab', { id: 2 })).to.equal(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('renameInquiry', async () => {
|
||||||
|
const state = {
|
||||||
|
inquiries: [
|
||||||
|
{ id: 1, name: 'foo' },
|
||||||
|
{ id: 2, name: 'bar' },
|
||||||
|
{ id: 3, name: 'baz' }
|
||||||
|
],
|
||||||
|
tabs: [{ id: 1, name: 'foo' }, { id: 2, name: 'bar' }]
|
||||||
|
}
|
||||||
|
const commit = sinon.spy()
|
||||||
|
|
||||||
|
await renameInquiry({ state, commit }, { inquiryId: 2, newName: 'new name' })
|
||||||
|
expect(state.inquiries).to.eql([
|
||||||
|
{ id: 1, name: 'foo' },
|
||||||
|
{ id: 2, name: 'new name' },
|
||||||
|
{ id: 3, name: 'baz' }
|
||||||
|
])
|
||||||
|
expect(commit.calledWith('updateTab', {
|
||||||
|
tab: { id: 2, name: 'bar' },
|
||||||
|
newValues: {
|
||||||
|
name: 'new name'
|
||||||
|
}
|
||||||
|
})).to.equal(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('saveInquiry adds new inquiry in the storage', async () => {
|
||||||
|
const now = new Date()
|
||||||
|
const nowPlusMinute = new Date(now.getTime() + 60 * 1000)
|
||||||
|
|
||||||
|
const tab = {
|
||||||
|
id: 1,
|
||||||
|
query: 'select * from foo',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: [],
|
||||||
|
name: null,
|
||||||
|
dataView: {
|
||||||
|
getOptionsForSave () {
|
||||||
|
return ['chart']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const state = {
|
||||||
|
inquiries: [],
|
||||||
|
tabs: [tab]
|
||||||
|
}
|
||||||
|
|
||||||
|
const value = await saveInquiry({ state }, {
|
||||||
|
inquiryTab: tab,
|
||||||
|
newName: 'foo'
|
||||||
|
})
|
||||||
|
expect(value.id).to.equal(tab.id)
|
||||||
|
expect(value.name).to.equal('foo')
|
||||||
|
expect(value.query).to.equal(tab.query)
|
||||||
|
expect(value.viewOptions).to.eql(['chart'])
|
||||||
|
expect(value).to.have.property('createdAt').which.within(now, nowPlusMinute)
|
||||||
|
expect(state.inquiries).to.eql([value])
|
||||||
|
})
|
||||||
|
|
||||||
|
it('save updates existing inquiry in the storage', async () => {
|
||||||
|
const tab = {
|
||||||
|
id: 1,
|
||||||
|
query: 'select * from foo',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: [],
|
||||||
|
name: null,
|
||||||
|
dataView: {
|
||||||
|
getOptionsForSave () {
|
||||||
|
return ['chart']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const state = {
|
||||||
|
inquiries: [],
|
||||||
|
tabs: [tab]
|
||||||
|
}
|
||||||
|
|
||||||
|
const first = await saveInquiry({ state }, {
|
||||||
|
inquiryTab: tab,
|
||||||
|
newName: 'foo'
|
||||||
|
})
|
||||||
|
|
||||||
|
tab.name = 'foo'
|
||||||
|
tab.query = 'select * from foo'
|
||||||
|
await saveInquiry({ state }, { inquiryTab: tab })
|
||||||
|
const inquiries = state.inquiries
|
||||||
|
const second = inquiries[0]
|
||||||
|
expect(inquiries).has.lengthOf(1)
|
||||||
|
expect(second.id).to.equal(first.id)
|
||||||
|
expect(second.name).to.equal(first.name)
|
||||||
|
expect(second.query).to.equal(tab.query)
|
||||||
|
expect(second.viewOptions).to.eql(['chart'])
|
||||||
|
expect(new Date(second.createdAt).getTime()).to.equal(first.createdAt.getTime())
|
||||||
|
})
|
||||||
|
|
||||||
|
it("save adds a new inquiry with new id if it's based on predefined inquiry", async () => {
|
||||||
|
const now = new Date()
|
||||||
|
const nowPlusMinute = new Date(now.getTime() + 60 * 1000)
|
||||||
|
const tab = {
|
||||||
|
id: 1,
|
||||||
|
query: 'select * from foo',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: [],
|
||||||
|
name: 'foo predefined',
|
||||||
|
dataView: {
|
||||||
|
getOptionsForSave () {
|
||||||
|
return ['chart']
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isPredefined: true
|
||||||
|
}
|
||||||
|
|
||||||
|
const state = {
|
||||||
|
inquiries: [],
|
||||||
|
tabs: [tab]
|
||||||
|
}
|
||||||
|
|
||||||
|
await saveInquiry({ state }, {
|
||||||
|
inquiryTab: tab,
|
||||||
|
newName: 'foo'
|
||||||
|
})
|
||||||
|
|
||||||
|
const inquiries = state.inquiries
|
||||||
|
expect(inquiries).has.lengthOf(1)
|
||||||
|
expect(inquiries[0]).to.have.property('id').which.not.equal(tab.id)
|
||||||
|
expect(inquiries[0].name).to.equal('foo')
|
||||||
|
expect(inquiries[0].query).to.equal(tab.query)
|
||||||
|
expect(inquiries[0].viewOptions).to.eql(['chart'])
|
||||||
|
expect(new Date(inquiries[0].createdAt)).to.be.within(now, nowPlusMinute)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ const {
|
|||||||
updatePredefinedInquiries,
|
updatePredefinedInquiries,
|
||||||
setDb,
|
setDb,
|
||||||
setLoadingPredefinedInquiries,
|
setLoadingPredefinedInquiries,
|
||||||
setPredefinedInquiriesLoaded
|
setPredefinedInquiriesLoaded,
|
||||||
|
setInquiries
|
||||||
} = mutations
|
} = mutations
|
||||||
|
|
||||||
describe('mutations', () => {
|
describe('mutations', () => {
|
||||||
@@ -360,4 +361,13 @@ describe('mutations', () => {
|
|||||||
setPredefinedInquiriesLoaded(state, true)
|
setPredefinedInquiriesLoaded(state, true)
|
||||||
expect(state.predefinedInquiriesLoaded).to.equal(true)
|
expect(state.predefinedInquiriesLoaded).to.equal(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('setInquiries', () => {
|
||||||
|
const state = {
|
||||||
|
inquiries: []
|
||||||
|
}
|
||||||
|
|
||||||
|
setInquiries(state, [1, 2, 3])
|
||||||
|
expect(state.inquiries).to.eql([1, 2, 3])
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import Vuex from 'vuex'
|
|||||||
import Inquiries from '@/views/Main/Inquiries'
|
import Inquiries from '@/views/Main/Inquiries'
|
||||||
import storedInquiries from '@/lib/storedInquiries'
|
import storedInquiries from '@/lib/storedInquiries'
|
||||||
import mutations from '@/store/mutations'
|
import mutations from '@/store/mutations'
|
||||||
|
import actions from '@/store/actions'
|
||||||
import fu from '@/lib/utils/fileIo'
|
import fu from '@/lib/utils/fileIo'
|
||||||
|
|
||||||
describe('Inquiries.vue', () => {
|
describe('Inquiries.vue', () => {
|
||||||
@@ -14,16 +15,16 @@ describe('Inquiries.vue', () => {
|
|||||||
|
|
||||||
it('Shows start-guide message if there are no saved and predefined inquiries', () => {
|
it('Shows start-guide message if there are no saved and predefined inquiries', () => {
|
||||||
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([])
|
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([])
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([])
|
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: []
|
||||||
}
|
}
|
||||||
const mutations = {
|
const mutations = {
|
||||||
setPredefinedInquiriesLoaded: sinon.stub(),
|
setPredefinedInquiriesLoaded: sinon.stub(),
|
||||||
updatePredefinedInquiries: sinon.stub(),
|
updatePredefinedInquiries: sinon.stub(),
|
||||||
setLoadingPredefinedInquiries: sinon.stub()
|
setLoadingPredefinedInquiries: sinon.stub()
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
const wrapper = shallowMount(Inquiries, { store })
|
const wrapper = shallowMount(Inquiries, { store })
|
||||||
|
|
||||||
expect(wrapper.find('#start-guide').exists()).to.equal(true)
|
expect(wrapper.find('#start-guide').exists()).to.equal(true)
|
||||||
@@ -40,32 +41,32 @@ describe('Inquiries.vue', () => {
|
|||||||
createdAt: '2020-03-08T19:57:56.299Z'
|
createdAt: '2020-03-08T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
name: 'foo',
|
|
||||||
query: '',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: [],
|
|
||||||
createdAt: '2020-11-03T19:57:56.299Z'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
name: 'bar',
|
|
||||||
query: '',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: [],
|
|
||||||
createdAt: '2020-12-04T18:53:56.299Z'
|
|
||||||
}
|
|
||||||
])
|
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: 'foo',
|
||||||
|
query: '',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: [],
|
||||||
|
createdAt: '2020-11-03T19:57:56.299Z'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
name: 'bar',
|
||||||
|
query: '',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: [],
|
||||||
|
createdAt: '2020-12-04T18:53:56.299Z'
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
const wrapper = shallowMount(Inquiries, { store })
|
const wrapper = shallowMount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
expect(wrapper.find('#start-guide').exists()).to.equal(false)
|
expect(wrapper.find('#start-guide').exists()).to.equal(false)
|
||||||
@@ -94,29 +95,30 @@ describe('Inquiries.vue', () => {
|
|||||||
createdAt: '2020-03-08T19:57:56.299Z'
|
createdAt: '2020-03-08T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
name: 'foo',
|
|
||||||
query: '',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: [],
|
|
||||||
createdAt: '2020-11-03T19:57:56.299Z'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
name: 'bar',
|
|
||||||
query: '',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: [],
|
|
||||||
createdAt: '2020-12-04T18:53:56.299Z'
|
|
||||||
}
|
|
||||||
])
|
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: 'foo',
|
||||||
|
query: '',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: [],
|
||||||
|
createdAt: '2020-11-03T19:57:56.299Z'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
name: 'bar',
|
||||||
|
query: '',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: [],
|
||||||
|
createdAt: '2020-12-04T18:53:56.299Z'
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await wrapper.find('#toolbar-search input').setValue('OO')
|
await wrapper.find('#toolbar-search input').setValue('OO')
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
@@ -138,29 +140,30 @@ describe('Inquiries.vue', () => {
|
|||||||
createdAt: '2020-03-08T19:57:56.299Z'
|
createdAt: '2020-03-08T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
name: 'foo',
|
|
||||||
query: '',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: [],
|
|
||||||
createdAt: '2020-11-03T19:57:56.299Z'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 2,
|
|
||||||
name: 'bar',
|
|
||||||
query: '',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: [],
|
|
||||||
createdAt: '2020-12-04T18:53:56.299Z'
|
|
||||||
}
|
|
||||||
])
|
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: 'foo',
|
||||||
|
query: '',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: [],
|
||||||
|
createdAt: '2020-11-03T19:57:56.299Z'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
name: 'bar',
|
||||||
|
query: '',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: [],
|
||||||
|
createdAt: '2020-12-04T18:53:56.299Z'
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await wrapper.find('#toolbar-search input').setValue('baz')
|
await wrapper.find('#toolbar-search input').setValue('baz')
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
@@ -181,24 +184,24 @@ describe('Inquiries.vue', () => {
|
|||||||
createdAt: '2020-03-08T19:57:56.299Z'
|
createdAt: '2020-03-08T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
name: 'foo',
|
|
||||||
query: '',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: [],
|
|
||||||
createdAt: '2020-11-03T19:57:56.299Z'
|
|
||||||
}
|
|
||||||
])
|
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: 'foo',
|
||||||
|
query: '',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: [],
|
||||||
|
createdAt: '2020-11-03T19:57:56.299Z'
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
const wrapper = shallowMount(Inquiries, { store })
|
const wrapper = shallowMount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
const rows = wrapper.findAll('tbody tr')
|
const rows = wrapper.findAll('tbody tr')
|
||||||
@@ -208,26 +211,25 @@ describe('Inquiries.vue', () => {
|
|||||||
|
|
||||||
it('Exports one inquiry', async () => {
|
it('Exports one inquiry', async () => {
|
||||||
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([])
|
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([])
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
name: 'foo',
|
|
||||||
query: '',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: [],
|
|
||||||
createdAt: '2020-11-03T19:57:56.299Z'
|
|
||||||
}
|
|
||||||
])
|
|
||||||
sinon.stub(storedInquiries, 'serialiseInquiries').returns('I am a serialized inquiry')
|
sinon.stub(storedInquiries, 'serialiseInquiries').returns('I am a serialized inquiry')
|
||||||
sinon.stub(fu, 'exportToFile')
|
sinon.stub(fu, 'exportToFile')
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: 'foo',
|
||||||
|
query: '',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: [],
|
||||||
|
createdAt: '2020-11-03T19:57:56.299Z'
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
await wrapper.findComponent({ name: 'ExportIcon' }).find('svg').trigger('click')
|
await wrapper.findComponent({ name: 'ExportIcon' }).find('svg').trigger('click')
|
||||||
expect(fu.exportToFile.calledOnceWith('I am a serialized inquiry', 'foo.json')).to.equals(true)
|
expect(fu.exportToFile.calledOnceWith('I am a serialized inquiry', 'foo.json')).to.equals(true)
|
||||||
@@ -243,7 +245,6 @@ describe('Inquiries.vue', () => {
|
|||||||
viewOptions: [],
|
viewOptions: [],
|
||||||
createdAt: '2020-11-03T19:57:56.299Z'
|
createdAt: '2020-11-03T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([inquiryInStorage])
|
|
||||||
sinon.stub(storedInquiries, 'updateStorage')
|
sinon.stub(storedInquiries, 'updateStorage')
|
||||||
const newInquiry = {
|
const newInquiry = {
|
||||||
id: 2,
|
id: 2,
|
||||||
@@ -255,13 +256,13 @@ describe('Inquiries.vue', () => {
|
|||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'duplicateInquiry').returns(newInquiry)
|
sinon.stub(storedInquiries, 'duplicateInquiry').returns(newInquiry)
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [inquiryInStorage]
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
await wrapper.findComponent({ name: 'CopyIcon' }).find('svg').trigger('click')
|
await wrapper.findComponent({ name: 'CopyIcon' }).find('svg').trigger('click')
|
||||||
|
|
||||||
@@ -271,9 +272,7 @@ describe('Inquiries.vue', () => {
|
|||||||
expect(rows).to.have.lengthOf(2)
|
expect(rows).to.have.lengthOf(2)
|
||||||
expect(rows[1].findAll('td')[0].text()).to.equals('foo copy')
|
expect(rows[1].findAll('td')[0].text()).to.equals('foo copy')
|
||||||
expect(rows[1].findAll('td')[1].text()).to.contains('3 December 2020 20:57')
|
expect(rows[1].findAll('td')[1].text()).to.contains('3 December 2020 20:57')
|
||||||
expect(
|
expect(state.inquiries).to.eql([inquiryInStorage, newInquiry])
|
||||||
storedInquiries.updateStorage.calledOnceWith(sinon.match([inquiryInStorage, newInquiry]))
|
|
||||||
).to.equals(true)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('The copy of the inquiry is not selected if all inquiries were selected before duplication',
|
it('The copy of the inquiry is not selected if all inquiries were selected before duplication',
|
||||||
@@ -287,8 +286,6 @@ describe('Inquiries.vue', () => {
|
|||||||
viewOptions: [],
|
viewOptions: [],
|
||||||
createdAt: '2020-11-03T19:57:56.299Z'
|
createdAt: '2020-11-03T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([inquiryInStorage])
|
|
||||||
sinon.stub(storedInquiries, 'updateStorage')
|
|
||||||
const newInquiry = {
|
const newInquiry = {
|
||||||
id: 2,
|
id: 2,
|
||||||
name: 'foo copy',
|
name: 'foo copy',
|
||||||
@@ -299,13 +296,13 @@ describe('Inquiries.vue', () => {
|
|||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'duplicateInquiry').returns(newInquiry)
|
sinon.stub(storedInquiries, 'duplicateInquiry').returns(newInquiry)
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [inquiryInStorage]
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
await wrapper.findComponent({ ref: 'mainCheckBox' }).find('.checkbox-container')
|
await wrapper.findComponent({ ref: 'mainCheckBox' }).find('.checkbox-container')
|
||||||
.trigger('click')
|
.trigger('click')
|
||||||
@@ -326,11 +323,11 @@ describe('Inquiries.vue', () => {
|
|||||||
viewOptions: [],
|
viewOptions: [],
|
||||||
createdAt: '2020-11-03T19:57:56.299Z'
|
createdAt: '2020-11-03T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([inquiryInStorage])
|
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [],
|
tabs: [],
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [inquiryInStorage]
|
||||||
}
|
}
|
||||||
const actions = { addTab: sinon.stub().resolves(1) }
|
const actions = { addTab: sinon.stub().resolves(1) }
|
||||||
sinon.spy(mutations, 'setCurrentTabId')
|
sinon.spy(mutations, 'setCurrentTabId')
|
||||||
@@ -344,7 +341,6 @@ describe('Inquiries.vue', () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
await wrapper.find('tbody tr').trigger('click')
|
await wrapper.find('tbody tr').trigger('click')
|
||||||
|
|
||||||
@@ -366,42 +362,40 @@ describe('Inquiries.vue', () => {
|
|||||||
createdAt: '2020-03-08T19:57:56.299Z'
|
createdAt: '2020-03-08T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([])
|
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: []
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
expect(wrapper.findComponent({ name: 'RenameIcon' }).exists()).to.equals(false)
|
expect(wrapper.findComponent({ name: 'RenameIcon' }).exists()).to.equals(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Renames an inquiry', async () => {
|
it('Renames an inquiry', async () => {
|
||||||
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([])
|
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([])
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
name: 'foo',
|
|
||||||
query: '',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: [],
|
|
||||||
createdAt: '2020-11-03T19:57:56.299Z'
|
|
||||||
}
|
|
||||||
])
|
|
||||||
sinon.stub(storedInquiries, 'updateStorage')
|
sinon.stub(storedInquiries, 'updateStorage')
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [{ id: 1, name: 'foo' }],
|
tabs: [{ id: 1, name: 'foo' }],
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: 'foo',
|
||||||
|
query: '',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: [],
|
||||||
|
createdAt: '2020-11-03T19:57:56.299Z'
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
// click Rename icon in the grid
|
// click Rename icon in the grid
|
||||||
@@ -421,19 +415,20 @@ describe('Inquiries.vue', () => {
|
|||||||
.findAll('.dialog-buttons-container button').wrappers
|
.findAll('.dialog-buttons-container button').wrappers
|
||||||
.find(button => button.text() === 'Rename')
|
.find(button => button.text() === 'Rename')
|
||||||
.trigger('click')
|
.trigger('click')
|
||||||
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
// check that the name in the grid is changed
|
// check that the name in the grid is changed
|
||||||
expect(wrapper.find('tbody tr td').text()).to.equals('bar')
|
expect(wrapper.find('tbody tr td').text()).to.equals('bar')
|
||||||
|
|
||||||
// check that storage is updated
|
// check that storage is updated
|
||||||
expect(storedInquiries.updateStorage.calledOnceWith(sinon.match([{
|
expect(state.inquiries).to.eql([{
|
||||||
id: 1,
|
id: 1,
|
||||||
name: 'bar',
|
name: 'bar',
|
||||||
query: '',
|
query: '',
|
||||||
viewType: 'chart',
|
viewType: 'chart',
|
||||||
viewOptions: [],
|
viewOptions: [],
|
||||||
createdAt: '2020-11-03T19:57:56.299Z'
|
createdAt: '2020-11-03T19:57:56.299Z'
|
||||||
}]))).to.equals(true)
|
}])
|
||||||
|
|
||||||
// check that coresponding tab also changed the name
|
// check that coresponding tab also changed the name
|
||||||
expect(state.tabs[0].name).to.equals('bar')
|
expect(state.tabs[0].name).to.equals('bar')
|
||||||
@@ -444,26 +439,25 @@ describe('Inquiries.vue', () => {
|
|||||||
|
|
||||||
it('Shows an error if try to rename to empty string', async () => {
|
it('Shows an error if try to rename to empty string', async () => {
|
||||||
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([])
|
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([])
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
name: 'foo',
|
|
||||||
query: '',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: [],
|
|
||||||
createdAt: '2020-11-03T19:57:56.299Z'
|
|
||||||
}
|
|
||||||
])
|
|
||||||
sinon.stub(storedInquiries, 'updateStorage')
|
sinon.stub(storedInquiries, 'updateStorage')
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [{ id: 1, name: 'foo' }],
|
tabs: [{ id: 1, name: 'foo' }],
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: 'foo',
|
||||||
|
query: '',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: [],
|
||||||
|
createdAt: '2020-11-03T19:57:56.299Z'
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
// click Rename icon in the grid
|
// click Rename icon in the grid
|
||||||
@@ -494,7 +488,6 @@ describe('Inquiries.vue', () => {
|
|||||||
viewOptions: [],
|
viewOptions: [],
|
||||||
createdAt: '2020-11-03T19:57:56.299Z'
|
createdAt: '2020-11-03T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([inquiryInStorage])
|
|
||||||
sinon.stub(storedInquiries, 'updateStorage')
|
sinon.stub(storedInquiries, 'updateStorage')
|
||||||
const importedInquiry = {
|
const importedInquiry = {
|
||||||
id: 2,
|
id: 2,
|
||||||
@@ -506,13 +499,13 @@ describe('Inquiries.vue', () => {
|
|||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'importInquiries').resolves([importedInquiry])
|
sinon.stub(storedInquiries, 'importInquiries').resolves([importedInquiry])
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [inquiryInStorage]
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = shallowMount(Inquiries, { store })
|
const wrapper = shallowMount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
// click Import
|
// click Import
|
||||||
@@ -522,9 +515,7 @@ describe('Inquiries.vue', () => {
|
|||||||
expect(rows).to.have.lengthOf(2)
|
expect(rows).to.have.lengthOf(2)
|
||||||
expect(rows[1].findAll('td')[0].text()).to.equals('bar')
|
expect(rows[1].findAll('td')[0].text()).to.equals('bar')
|
||||||
expect(rows[1].findAll('td')[1].text()).to.equals('3 December 2020 20:57')
|
expect(rows[1].findAll('td')[1].text()).to.equals('3 December 2020 20:57')
|
||||||
expect(storedInquiries.updateStorage.calledOnceWith(
|
expect(state.inquiries).to.eql([inquiryInStorage, importedInquiry])
|
||||||
sinon.match([inquiryInStorage, importedInquiry])
|
|
||||||
)).to.equals(true)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Imported inquiries are not selected if master check box was checked', async () => {
|
it('Imported inquiries are not selected if master check box was checked', async () => {
|
||||||
@@ -537,7 +528,6 @@ describe('Inquiries.vue', () => {
|
|||||||
viewOptions: [],
|
viewOptions: [],
|
||||||
createdAt: '2020-11-03T19:57:56.299Z'
|
createdAt: '2020-11-03T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([inquiryInStorage])
|
|
||||||
sinon.stub(storedInquiries, 'updateStorage')
|
sinon.stub(storedInquiries, 'updateStorage')
|
||||||
const importedInquiry = {
|
const importedInquiry = {
|
||||||
id: 2,
|
id: 2,
|
||||||
@@ -549,13 +539,13 @@ describe('Inquiries.vue', () => {
|
|||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'importInquiries').resolves([importedInquiry])
|
sinon.stub(storedInquiries, 'importInquiries').resolves([importedInquiry])
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [inquiryInStorage]
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
// click on master checkbox
|
// click on master checkbox
|
||||||
@@ -570,7 +560,8 @@ describe('Inquiries.vue', () => {
|
|||||||
expect(checkboxes[0].vm.checked).to.equals(true)
|
expect(checkboxes[0].vm.checked).to.equals(true)
|
||||||
expect(checkboxes[1].vm.checked).to.equals(false)
|
expect(checkboxes[1].vm.checked).to.equals(false)
|
||||||
})
|
})
|
||||||
|
expect(storedInquiries.updateStorage.calledOnceWith(
|
||||||
|
sinon.match([inquiryInStorage, importedInquiry])
|
||||||
it('Deletion is not available for predefined inquiries', async () => {
|
it('Deletion is not available for predefined inquiries', async () => {
|
||||||
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([
|
sinon.stub(storedInquiries, 'readPredefinedInquiries').resolves([
|
||||||
{
|
{
|
||||||
@@ -582,16 +573,15 @@ describe('Inquiries.vue', () => {
|
|||||||
createdAt: '2020-03-08T19:57:56.299Z'
|
createdAt: '2020-03-08T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([])
|
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: []
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
expect(wrapper.findComponent({ name: 'DeleteIcon' }).exists()).to.equals(false)
|
expect(wrapper.findComponent({ name: 'DeleteIcon' }).exists()).to.equals(false)
|
||||||
})
|
})
|
||||||
@@ -614,18 +604,17 @@ describe('Inquiries.vue', () => {
|
|||||||
viewOptions: [],
|
viewOptions: [],
|
||||||
createdAt: '2020-11-03T19:57:56.299Z'
|
createdAt: '2020-11-03T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([foo, bar])
|
|
||||||
sinon.stub(storedInquiries, 'updateStorage')
|
sinon.stub(storedInquiries, 'updateStorage')
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [{ id: 1 }, { id: 2 }],
|
tabs: [{ id: 1 }, { id: 2 }],
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [foo, bar]
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
// click Delete icon in the first row of the grid
|
// click Delete icon in the first row of the grid
|
||||||
await wrapper.findComponent({ name: 'DeleteIcon' }).find('svg').trigger('click')
|
await wrapper.findComponent({ name: 'DeleteIcon' }).find('svg').trigger('click')
|
||||||
@@ -651,7 +640,7 @@ describe('Inquiries.vue', () => {
|
|||||||
expect(state.tabs[0].id).to.equals(2)
|
expect(state.tabs[0].id).to.equals(2)
|
||||||
|
|
||||||
// check that storage is updated
|
// check that storage is updated
|
||||||
expect(storedInquiries.updateStorage.calledOnceWith(sinon.match([bar]))).to.equals(true)
|
expect(state.inquiries).to.eql([bar])
|
||||||
|
|
||||||
// check that delete dialog is closed
|
// check that delete dialog is closed
|
||||||
expect(wrapper.find('[data-modal="delete"]').exists()).to.equal(false)
|
expect(wrapper.find('[data-modal="delete"]').exists()).to.equal(false)
|
||||||
@@ -668,25 +657,24 @@ describe('Inquiries.vue', () => {
|
|||||||
createdAt: '2020-03-08T19:57:56.299Z'
|
createdAt: '2020-03-08T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
])
|
])
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
|
||||||
{
|
|
||||||
id: 1,
|
|
||||||
name: 'foo',
|
|
||||||
query: '',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: [],
|
|
||||||
createdAt: '2020-11-03T19:57:56.299Z'
|
|
||||||
}
|
|
||||||
])
|
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [
|
||||||
|
{
|
||||||
|
id: 1,
|
||||||
|
name: 'foo',
|
||||||
|
query: '',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: [],
|
||||||
|
createdAt: '2020-11-03T19:57:56.299Z'
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
expect(wrapper.find('#toolbar-btns-export').isVisible()).to.equal(false)
|
expect(wrapper.find('#toolbar-btns-export').isVisible()).to.equal(false)
|
||||||
@@ -728,26 +716,25 @@ describe('Inquiries.vue', () => {
|
|||||||
viewOptions: [],
|
viewOptions: [],
|
||||||
createdAt: '2020-03-08T19:57:56.299Z'
|
createdAt: '2020-03-08T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([inquiryInStore, {
|
|
||||||
id: 2,
|
|
||||||
name: 'bar',
|
|
||||||
query: '',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: [],
|
|
||||||
createdAt: '2020-03-08T19:57:56.299Z'
|
|
||||||
}])
|
|
||||||
|
|
||||||
sinon.stub(storedInquiries, 'serialiseInquiries').returns('I am a serialized inquiries')
|
sinon.stub(storedInquiries, 'serialiseInquiries').returns('I am a serialized inquiries')
|
||||||
sinon.stub(fu, 'exportToFile')
|
sinon.stub(fu, 'exportToFile')
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [inquiryInStore, {
|
||||||
|
id: 2,
|
||||||
|
name: 'bar',
|
||||||
|
query: '',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: [],
|
||||||
|
createdAt: '2020-03-08T19:57:56.299Z'
|
||||||
|
}]
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
const rows = wrapper.findAll('tbody tr')
|
const rows = wrapper.findAll('tbody tr')
|
||||||
@@ -785,19 +772,18 @@ describe('Inquiries.vue', () => {
|
|||||||
viewOptions: [],
|
viewOptions: [],
|
||||||
createdAt: '2020-03-08T19:57:56.299Z'
|
createdAt: '2020-03-08T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([inquiryInStore])
|
|
||||||
|
|
||||||
sinon.stub(storedInquiries, 'serialiseInquiries').returns('I am a serialized inquiries')
|
sinon.stub(storedInquiries, 'serialiseInquiries').returns('I am a serialized inquiries')
|
||||||
sinon.stub(fu, 'exportToFile')
|
sinon.stub(fu, 'exportToFile')
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [inquiryInStore]
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
await wrapper.findComponent({ ref: 'mainCheckBox' }).find('.checkbox-container')
|
await wrapper.findComponent({ ref: 'mainCheckBox' }).find('.checkbox-container')
|
||||||
@@ -848,19 +834,18 @@ describe('Inquiries.vue', () => {
|
|||||||
viewOptions: [],
|
viewOptions: [],
|
||||||
createdAt: '2020-03-08T19:57:56.299Z'
|
createdAt: '2020-03-08T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([foo, bar, baz])
|
|
||||||
|
|
||||||
sinon.stub(storedInquiries, 'updateStorage')
|
sinon.stub(storedInquiries, 'updateStorage')
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [{ id: 1 }, { id: 2 }, { id: 0 }, { id: 3 }],
|
tabs: [{ id: 1 }, { id: 2 }, { id: 0 }, { id: 3 }],
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [foo, bar, baz]
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
const rows = wrapper.findAll('tbody tr')
|
const rows = wrapper.findAll('tbody tr')
|
||||||
@@ -895,7 +880,7 @@ describe('Inquiries.vue', () => {
|
|||||||
expect(state.tabs[1].id).to.equals(3)
|
expect(state.tabs[1].id).to.equals(3)
|
||||||
|
|
||||||
// check that storage is updated
|
// check that storage is updated
|
||||||
expect(storedInquiries.updateStorage.calledOnceWith(sinon.match([baz]))).to.equals(true)
|
expect(state.inquiries).to.eql([baz])
|
||||||
|
|
||||||
// check that delete dialog is closed
|
// check that delete dialog is closed
|
||||||
expect(wrapper.find('[data-modal="delete"]').exists()).to.equal(false)
|
expect(wrapper.find('[data-modal="delete"]').exists()).to.equal(false)
|
||||||
@@ -927,18 +912,17 @@ describe('Inquiries.vue', () => {
|
|||||||
viewOptions: [],
|
viewOptions: [],
|
||||||
createdAt: '2020-03-08T19:57:56.299Z'
|
createdAt: '2020-03-08T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([foo, bar])
|
|
||||||
sinon.stub(storedInquiries, 'updateStorage')
|
sinon.stub(storedInquiries, 'updateStorage')
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [],
|
tabs: [],
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [foo, bar]
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
const rows = wrapper.findAll('tbody tr')
|
const rows = wrapper.findAll('tbody tr')
|
||||||
@@ -970,7 +954,7 @@ describe('Inquiries.vue', () => {
|
|||||||
expect(wrapper.findAll('tbody tr')[1].find('td').text()).to.equals('bar')
|
expect(wrapper.findAll('tbody tr')[1].find('td').text()).to.equals('bar')
|
||||||
|
|
||||||
// check that storage is updated
|
// check that storage is updated
|
||||||
expect(storedInquiries.updateStorage.calledOnceWith(sinon.match([bar]))).to.equals(true)
|
expect(state.inquiries).to.eql([bar])
|
||||||
|
|
||||||
// check that delete dialog is closed
|
// check that delete dialog is closed
|
||||||
expect(wrapper.find('[data-modal="delete"]').exists()).to.equal(false)
|
expect(wrapper.find('[data-modal="delete"]').exists()).to.equal(false)
|
||||||
@@ -1002,18 +986,17 @@ describe('Inquiries.vue', () => {
|
|||||||
viewOptions: [],
|
viewOptions: [],
|
||||||
createdAt: '2020-03-08T19:57:56.299Z'
|
createdAt: '2020-03-08T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([foo, bar])
|
|
||||||
sinon.stub(storedInquiries, 'updateStorage')
|
sinon.stub(storedInquiries, 'updateStorage')
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [],
|
tabs: [],
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [foo, bar]
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
await wrapper.findComponent({ ref: 'mainCheckBox' }).find('.checkbox-container')
|
await wrapper.findComponent({ ref: 'mainCheckBox' }).find('.checkbox-container')
|
||||||
@@ -1041,7 +1024,7 @@ describe('Inquiries.vue', () => {
|
|||||||
expect(wrapper.findAll('tbody tr')[0].find('td').text()).to.contains('hello_world')
|
expect(wrapper.findAll('tbody tr')[0].find('td').text()).to.contains('hello_world')
|
||||||
|
|
||||||
// check that storage is updated
|
// check that storage is updated
|
||||||
expect(storedInquiries.updateStorage.calledOnceWith(sinon.match([]))).to.equals(true)
|
expect(state.inquiries).to.eql([])
|
||||||
|
|
||||||
// check that delete dialog is closed
|
// check that delete dialog is closed
|
||||||
expect(wrapper.find('[data-modal="delete"]').exists()).to.equal(false)
|
expect(wrapper.find('[data-modal="delete"]').exists()).to.equal(false)
|
||||||
@@ -1065,16 +1048,15 @@ describe('Inquiries.vue', () => {
|
|||||||
viewOptions: [],
|
viewOptions: [],
|
||||||
createdAt: '2020-03-08T19:57:56.299Z'
|
createdAt: '2020-03-08T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([foo, bar])
|
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [foo, bar]
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
const mainCheckBox = wrapper.findComponent({ ref: 'mainCheckBox' })
|
const mainCheckBox = wrapper.findComponent({ ref: 'mainCheckBox' })
|
||||||
@@ -1124,16 +1106,15 @@ describe('Inquiries.vue', () => {
|
|||||||
viewOptions: [],
|
viewOptions: [],
|
||||||
createdAt: '2020-03-08T19:57:56.299Z'
|
createdAt: '2020-03-08T19:57:56.299Z'
|
||||||
}
|
}
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([foo, bar])
|
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: []
|
predefinedInquiries: [],
|
||||||
|
inquiries: [foo, bar]
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
|
|
||||||
const wrapper = mount(Inquiries, { store })
|
const wrapper = mount(Inquiries, { store })
|
||||||
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
await storedInquiries.readPredefinedInquiries.returnValues[0]
|
||||||
await storedInquiries.getStoredInquiries.returnValues[0]
|
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
const mainCheckBox = wrapper.findComponent({ ref: 'mainCheckBox' })
|
const mainCheckBox = wrapper.findComponent({ ref: 'mainCheckBox' })
|
||||||
|
|||||||
@@ -367,16 +367,18 @@ describe('MainMenu.vue', () => {
|
|||||||
const mutations = {
|
const mutations = {
|
||||||
updateTab: sinon.stub()
|
updateTab: sinon.stub()
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const actions = {
|
||||||
|
saveInquiry: sinon.stub().returns({
|
||||||
|
name: 'foo',
|
||||||
|
id: 1,
|
||||||
|
query: 'SELECT * FROM foo',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
const $route = { path: '/workspace' }
|
const $route = { path: '/workspace' }
|
||||||
sinon.stub(storedInquiries, 'isTabNeedName').returns(false)
|
sinon.stub(storedInquiries, 'isTabNeedName').returns(false)
|
||||||
sinon.stub(storedInquiries, 'save').returns({
|
|
||||||
name: 'foo',
|
|
||||||
id: 1,
|
|
||||||
query: 'SELECT * FROM foo',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: []
|
|
||||||
})
|
|
||||||
|
|
||||||
wrapper = mount(MainMenu, {
|
wrapper = mount(MainMenu, {
|
||||||
store,
|
store,
|
||||||
@@ -391,8 +393,11 @@ describe('MainMenu.vue', () => {
|
|||||||
// check that the dialog is closed
|
// check that the dialog is closed
|
||||||
expect(wrapper.find('[data-modal="save"]').exists()).to.equal(false)
|
expect(wrapper.find('[data-modal="save"]').exists()).to.equal(false)
|
||||||
|
|
||||||
// check that the inquiry was saved via storedInquiries.save (newName='')
|
// check that the inquiry was saved via saveInquiry (newName='')
|
||||||
expect(storedInquiries.save.calledOnceWith(state.currentTab, '')).to.equal(true)
|
expect(actions.saveInquiry.calledOnce).to.equal(true)
|
||||||
|
expect(actions.saveInquiry.args[0][1]).to.eql({
|
||||||
|
inquiryTab: state.currentTab, newName: ''
|
||||||
|
})
|
||||||
|
|
||||||
// check that the tab was updated
|
// check that the tab was updated
|
||||||
expect(mutations.updateTab.calledOnceWith(state, sinon.match({
|
expect(mutations.updateTab.calledOnceWith(state, sinon.match({
|
||||||
@@ -428,16 +433,18 @@ describe('MainMenu.vue', () => {
|
|||||||
const mutations = {
|
const mutations = {
|
||||||
updateTab: sinon.stub()
|
updateTab: sinon.stub()
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const actions = {
|
||||||
|
saveInquiry: sinon.stub().returns({
|
||||||
|
name: 'foo',
|
||||||
|
id: 1,
|
||||||
|
query: 'SELECT * FROM foo',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
const $route = { path: '/workspace' }
|
const $route = { path: '/workspace' }
|
||||||
sinon.stub(storedInquiries, 'isTabNeedName').returns(true)
|
sinon.stub(storedInquiries, 'isTabNeedName').returns(true)
|
||||||
sinon.stub(storedInquiries, 'save').returns({
|
|
||||||
name: 'foo',
|
|
||||||
id: 1,
|
|
||||||
query: 'SELECT * FROM foo',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: []
|
|
||||||
})
|
|
||||||
|
|
||||||
wrapper = mount(MainMenu, {
|
wrapper = mount(MainMenu, {
|
||||||
store,
|
store,
|
||||||
@@ -480,16 +487,18 @@ describe('MainMenu.vue', () => {
|
|||||||
const mutations = {
|
const mutations = {
|
||||||
updateTab: sinon.stub()
|
updateTab: sinon.stub()
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const actions = {
|
||||||
|
saveInquiry: sinon.stub().returns({
|
||||||
|
name: 'foo',
|
||||||
|
id: 1,
|
||||||
|
query: 'SELECT * FROM foo',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
const $route = { path: '/workspace' }
|
const $route = { path: '/workspace' }
|
||||||
sinon.stub(storedInquiries, 'isTabNeedName').returns(true)
|
sinon.stub(storedInquiries, 'isTabNeedName').returns(true)
|
||||||
sinon.stub(storedInquiries, 'save').returns({
|
|
||||||
name: 'foo',
|
|
||||||
id: 1,
|
|
||||||
query: 'SELECT * FROM foo',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: []
|
|
||||||
})
|
|
||||||
|
|
||||||
wrapper = mount(MainMenu, {
|
wrapper = mount(MainMenu, {
|
||||||
store,
|
store,
|
||||||
@@ -513,11 +522,17 @@ describe('MainMenu.vue', () => {
|
|||||||
.find(button => button.text() === 'Save')
|
.find(button => button.text() === 'Save')
|
||||||
.trigger('click')
|
.trigger('click')
|
||||||
|
|
||||||
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
// check that the dialog is closed
|
// check that the dialog is closed
|
||||||
expect(wrapper.find('[data-modal="save"]').exists()).to.equal(false)
|
expect(wrapper.find('[data-modal="save"]').exists()).to.equal(false)
|
||||||
|
|
||||||
// check that the inquiry was saved via storedInquiries.save (newName='foo')
|
// check that the inquiry was saved via saveInquiry (newName='foo')
|
||||||
expect(storedInquiries.save.calledOnceWith(state.currentTab, 'foo')).to.equal(true)
|
expect(actions.saveInquiry.calledOnce).to.equal(true)
|
||||||
|
expect(actions.saveInquiry.args[0][1]).to.eql({
|
||||||
|
inquiryTab: state.currentTab,
|
||||||
|
newName: 'foo'
|
||||||
|
})
|
||||||
|
|
||||||
// check that the tab was updated
|
// check that the tab was updated
|
||||||
expect(mutations.updateTab.calledOnceWith(state, sinon.match({
|
expect(mutations.updateTab.calledOnceWith(state, sinon.match({
|
||||||
@@ -562,16 +577,18 @@ describe('MainMenu.vue', () => {
|
|||||||
const mutations = {
|
const mutations = {
|
||||||
updateTab: sinon.stub()
|
updateTab: sinon.stub()
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const actions = {
|
||||||
|
saveInquiry: sinon.stub().returns({
|
||||||
|
name: 'bar',
|
||||||
|
id: 2,
|
||||||
|
query: 'SELECT * FROM foo',
|
||||||
|
viewType: 'chart',
|
||||||
|
viewOptions: []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
const $route = { path: '/workspace' }
|
const $route = { path: '/workspace' }
|
||||||
sinon.stub(storedInquiries, 'isTabNeedName').returns(true)
|
sinon.stub(storedInquiries, 'isTabNeedName').returns(true)
|
||||||
sinon.stub(storedInquiries, 'save').returns({
|
|
||||||
name: 'bar',
|
|
||||||
id: 2,
|
|
||||||
query: 'SELECT * FROM foo',
|
|
||||||
viewType: 'chart',
|
|
||||||
viewOptions: []
|
|
||||||
})
|
|
||||||
|
|
||||||
wrapper = mount(MainMenu, {
|
wrapper = mount(MainMenu, {
|
||||||
store,
|
store,
|
||||||
@@ -598,11 +615,17 @@ describe('MainMenu.vue', () => {
|
|||||||
.find(button => button.text() === 'Save')
|
.find(button => button.text() === 'Save')
|
||||||
.trigger('click')
|
.trigger('click')
|
||||||
|
|
||||||
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
// check that the dialog is closed
|
// check that the dialog is closed
|
||||||
expect(wrapper.find('[data-modal="save"]').exists()).to.equal(false)
|
expect(wrapper.find('[data-modal="save"]').exists()).to.equal(false)
|
||||||
|
|
||||||
// check that the inquiry was saved via storedInquiries.save (newName='bar')
|
// check that the inquiry was saved via saveInquiry (newName='bar')
|
||||||
expect(storedInquiries.save.calledOnceWith(state.currentTab, 'bar')).to.equal(true)
|
expect(actions.saveInquiry.calledOnce).to.equal(true)
|
||||||
|
expect(actions.saveInquiry.args[0][1]).to.eql({
|
||||||
|
inquiryTab: state.currentTab,
|
||||||
|
newName: 'bar'
|
||||||
|
})
|
||||||
|
|
||||||
// check that the tab was updated
|
// check that the tab was updated
|
||||||
expect(mutations.updateTab.calledOnceWith(state, sinon.match({
|
expect(mutations.updateTab.calledOnceWith(state, sinon.match({
|
||||||
@@ -651,15 +674,17 @@ describe('MainMenu.vue', () => {
|
|||||||
const mutations = {
|
const mutations = {
|
||||||
updateTab: sinon.stub()
|
updateTab: sinon.stub()
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, mutations })
|
const actions = {
|
||||||
|
saveInquiry: sinon.stub().returns({
|
||||||
|
name: 'bar',
|
||||||
|
id: 2,
|
||||||
|
query: 'SELECT * FROM foo',
|
||||||
|
chart: []
|
||||||
|
})
|
||||||
|
}
|
||||||
|
const store = new Vuex.Store({ state, mutations, actions })
|
||||||
const $route = { path: '/workspace' }
|
const $route = { path: '/workspace' }
|
||||||
sinon.stub(storedInquiries, 'isTabNeedName').returns(true)
|
sinon.stub(storedInquiries, 'isTabNeedName').returns(true)
|
||||||
sinon.stub(storedInquiries, 'save').returns({
|
|
||||||
name: 'bar',
|
|
||||||
id: 2,
|
|
||||||
query: 'SELECT * FROM foo',
|
|
||||||
chart: []
|
|
||||||
})
|
|
||||||
|
|
||||||
wrapper = mount(MainMenu, {
|
wrapper = mount(MainMenu, {
|
||||||
store,
|
store,
|
||||||
@@ -684,7 +709,7 @@ describe('MainMenu.vue', () => {
|
|||||||
expect(wrapper.find('[data-modal="save"]').exists()).to.equal(false)
|
expect(wrapper.find('[data-modal="save"]').exists()).to.equal(false)
|
||||||
|
|
||||||
// check that the inquiry was not saved via storedInquiries.save
|
// check that the inquiry was not saved via storedInquiries.save
|
||||||
expect(storedInquiries.save.called).to.equal(false)
|
expect(actions.saveInquiry.called).to.equal(false)
|
||||||
|
|
||||||
// check that the tab was not updated
|
// check that the tab was not updated
|
||||||
expect(mutations.updateTab.called).to.equal(false)
|
expect(mutations.updateTab.called).to.equal(false)
|
||||||
|
|||||||
Reference in New Issue
Block a user