Skip to content

Commit

Permalink
fix(test): properly mount component
Browse files Browse the repository at this point in the history
Signed-off-by: Elizabeth Danzberger <lizzy7128@tutanota.de>
  • Loading branch information
elzody committed May 8, 2024
1 parent 505b698 commit 8b95831
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 23 deletions.
6 changes: 0 additions & 6 deletions cypress/component/ContentReferenceWidget.cy.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import ContentReferenceWidget from '../../src/views/ContentReferenceWidget.vue'
import store from '../../src/store/store.js'
import data from '../../src/store/data.js'

const richObject = {
id: 1,
Expand Down Expand Up @@ -149,10 +147,6 @@ describe('ContentReferenceWidget', () => {
propsData: {
richObject,
},
store: {
...store,
...data,
},
})
})
})
28 changes: 11 additions & 17 deletions cypress/support/component.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,9 @@
import Vue, { h } from 'vue'
import { mount } from 'cypress/vue2'
import App from '../../src/App.vue'
import store from '../../src/store/store.js'
import data from '../../src/store/data.js'
import Vuex from 'vuex'
import { translate as t, translatePlural as n } from '@nextcloud/l10n'

Vue.mixin({
methods: { t, n },
store: {
...store,
...data,
},
})

const tables = {
0: {
id: 1,
Expand All @@ -37,15 +27,19 @@ const tables = {
}

Cypress.Commands.add('mount', (component, options = {}) => {
// options.store = options.store || { ...store, ...data }
cy.intercept({
method: 'GET',
url: '**/index.php/apps/tables/table',
}, tables)

options.extensions = options.extensions || {}

options.extensions.mixins = options.extensions.mixins || []
options.extensions.mixins.push({
methods: { t, n },
store: {
...store,
...data,
},
})

options.extensions.plugins = options.extensions.plugins || []
options.extensions.plugins.push(Vuex)

return mount(App, { propsData: { tableId: 1 } })
return mount(component, options)
})

0 comments on commit 8b95831

Please sign in to comment.