From c3546ea8567fc29a795e11d1e5303ea46ed596e0 Mon Sep 17 00:00:00 2001
From: Henry Jameson
Date: Tue, 22 Mar 2022 16:40:09 +0200
Subject: fix tests running
---
test/unit/index.js | 7 +++++++
1 file changed, 7 insertions(+)
(limited to 'test')
diff --git a/test/unit/index.js b/test/unit/index.js
index 83a2dcdb..24d2825c 100644
--- a/test/unit/index.js
+++ b/test/unit/index.js
@@ -1,3 +1,10 @@
+import { configureCompat } from 'vue'
+// disable compat for certain features
+configureCompat({
+ COMPONENT_V_MODEL: false,
+ INSTANCE_SET: false,
+ RENDER_FUNCTION: false
+})
// require all test files (files that ends with .spec.js)
const testsContext = require.context('./specs', true, /\.spec$/)
testsContext.keys().forEach(testsContext)
--
cgit v1.2.3-70-g09d2
From c2cf13fc006aa1e513feb99799a8d2df14119eca Mon Sep 17 00:00:00 2001
From: Henry Jameson
Date: Tue, 22 Mar 2022 16:40:45 +0200
Subject: fix richcontent and its tests
---
src/components/rich_content/rich_content.jsx | 7 +-
test/unit/specs/components/rich_content.spec.js | 234 ++++++++++++------------
2 files changed, 124 insertions(+), 117 deletions(-)
(limited to 'test')
diff --git a/src/components/rich_content/rich_content.jsx b/src/components/rich_content/rich_content.jsx
index 97c51189..41e287e4 100644
--- a/src/components/rich_content/rich_content.jsx
+++ b/src/components/rich_content/rich_content.jsx
@@ -1,4 +1,3 @@
-import { h } from 'vue'
import { unescape, flattenDeep } from 'lodash'
import { getTagName, processTextForEmoji, getAttrs } from 'src/services/html_converter/utility.service.js'
import { convertHtmlToTree } from 'src/services/html_converter/html_tree_converter.service.js'
@@ -82,12 +81,12 @@ export default {
}
const renderHashtag = (attrs, children, encounteredTextReverse) => {
- const linkData = getLinkData(attrs, children, tagsIndex++)
+ const { index, ...linkData } = getLinkData(attrs, children, tagsIndex++)
writtenTags.push(linkData)
if (!encounteredTextReverse) {
lastTags.push(linkData)
}
- return
+ return
}
const renderMention = (attrs, children) => {
@@ -235,7 +234,7 @@ export default {
const newChildren = Array.isArray(children)
? [...children].reverse().map(processItemReverse).reverse()
: children
- return
+ return
{ newChildren }
} else {
diff --git a/test/unit/specs/components/rich_content.spec.js b/test/unit/specs/components/rich_content.spec.js
index 30c66a33..a4920867 100644
--- a/test/unit/specs/components/rich_content.spec.js
+++ b/test/unit/specs/components/rich_content.spec.js
@@ -1,8 +1,15 @@
-import { mount, shallowMount, createLocalVue } from '@vue/test-utils'
+import { mount, shallowMount } from '@vue/test-utils'
import RichContent from 'src/components/rich_content/rich_content.jsx'
-const localVue = createLocalVue()
const attentions = []
+const global = {
+ mocks: {
+ '$store': null
+ },
+ stubs: {
+ FAIcon: true
+ }
+}
const makeMention = (who) => {
attentions.push({ statusnet_profile_url: `https://fake.tld/@${who}` })
@@ -11,17 +18,17 @@ const makeMention = (who) => {
const p = (...data) => `${data.join('')}
`
const compwrap = (...data) => `${data.join('')}`
const mentionsLine = (times) => [
- ''
+ '">'
].join('')
describe('RichContent', () => {
it('renders simple post without exploding', () => {
const html = p('Hello world!')
const wrapper = shallowMount(RichContent, {
- localVue,
- propsData: {
+ global,
+ props: {
attentions,
handleLinks: true,
greentext: true,
@@ -30,7 +37,7 @@ describe('RichContent', () => {
}
})
- expect(wrapper.html()).to.eql(compwrap(html))
+ expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(html))
})
it('unescapes everything as needed', () => {
@@ -43,8 +50,8 @@ describe('RichContent', () => {
'Testing \'em all'
].join('')
const wrapper = shallowMount(RichContent, {
- localVue,
- propsData: {
+ global,
+ props: {
attentions,
handleLinks: true,
greentext: true,
@@ -53,7 +60,7 @@ describe('RichContent', () => {
}
})
- expect(wrapper.html()).to.eql(compwrap(expected))
+ expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected))
})
it('replaces mention with mentionsline', () => {
@@ -62,8 +69,8 @@ describe('RichContent', () => {
' how are you doing today?'
)
const wrapper = shallowMount(RichContent, {
- localVue,
- propsData: {
+ global,
+ props: {
attentions,
handleLinks: true,
greentext: true,
@@ -72,7 +79,7 @@ describe('RichContent', () => {
}
})
- expect(wrapper.html()).to.eql(compwrap(p(
+ expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(p(
mentionsLine(1),
' how are you doing today?'
)))
@@ -93,17 +100,17 @@ describe('RichContent', () => {
),
// TODO fix this extra line somehow?
p(
- ''
+ '">'
)
].join('')
const wrapper = shallowMount(RichContent, {
- localVue,
- propsData: {
+ global,
+ props: {
attentions,
handleLinks: true,
greentext: true,
@@ -112,7 +119,7 @@ describe('RichContent', () => {
}
})
- expect(wrapper.html()).to.eql(compwrap(expected))
+ expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected))
})
it('Does not touch links if link handling is disabled', () => {
@@ -130,8 +137,8 @@ describe('RichContent', () => {
].join('\n')
const wrapper = shallowMount(RichContent, {
- localVue,
- propsData: {
+ global,
+ props: {
attentions,
handleLinks: false,
greentext: true,
@@ -154,8 +161,8 @@ describe('RichContent', () => {
].join('\n')
const wrapper = shallowMount(RichContent, {
- localVue,
- propsData: {
+ global,
+ props: {
attentions,
handleLinks: false,
greentext: true,
@@ -174,8 +181,8 @@ describe('RichContent', () => {
].join('\n')
const wrapper = shallowMount(RichContent, {
- localVue,
- propsData: {
+ global,
+ props: {
attentions,
handleLinks: false,
greentext: false,
@@ -191,12 +198,12 @@ describe('RichContent', () => {
const html = p('Ebin :DDDD :spurdo:')
const expected = p(
'Ebin :DDDD ',
- ''
+ ''
)
const wrapper = shallowMount(RichContent, {
- localVue,
- propsData: {
+ global,
+ props: {
attentions,
handleLinks: false,
greentext: false,
@@ -205,15 +212,15 @@ describe('RichContent', () => {
}
})
- expect(wrapper.html()).to.eql(compwrap(expected))
+ expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected))
})
it('Doesn\'t add nonexistent emoji to post', () => {
const html = p('Lol :lol:')
const wrapper = shallowMount(RichContent, {
- localVue,
- propsData: {
+ global,
+ props: {
attentions,
handleLinks: false,
greentext: false,
@@ -222,7 +229,7 @@ describe('RichContent', () => {
}
})
- expect(wrapper.html()).to.eql(compwrap(html))
+ expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(html))
})
it('Greentext + last mentions', () => {
@@ -240,8 +247,8 @@ describe('RichContent', () => {
].join('\n')
const wrapper = shallowMount(RichContent, {
- localVue,
- propsData: {
+ global,
+ props: {
attentions,
handleLinks: true,
greentext: true,
@@ -272,8 +279,8 @@ describe('RichContent', () => {
].join('
')
const wrapper = shallowMount(RichContent, {
- localVue,
- propsData: {
+ global,
+ props: {
attentions,
handleLinks: true,
greentext: true,
@@ -282,7 +289,7 @@ describe('RichContent', () => {
}
})
- expect(wrapper.html()).to.eql(compwrap(expected))
+ expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected))
})
it('buggy example/hashtags', () => {
@@ -300,16 +307,18 @@ describe('RichContent', () => {
'',
'',
'NHCMDUXJPPZ6M3Z2CQ6D2EBRSWGE7MZY.jpg',
- ' ',
- '',
- ' ',
- '',
+ ' ',
+ '#nou',
+ '',
+ ' ',
+ '#screencap',
+ '',
'
'
].join('')
const wrapper = shallowMount(RichContent, {
- localVue,
- propsData: {
+ global,
+ props: {
attentions,
handleLinks: true,
greentext: true,
@@ -318,7 +327,7 @@ describe('RichContent', () => {
}
})
- expect(wrapper.html()).to.eql(compwrap(expected))
+ expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected))
})
it('rich contents of a mention are handled properly', () => {
@@ -342,7 +351,8 @@ describe('RichContent', () => {
p(
'',
'',
- '',
+ '',
+ '',
'',
'https://',
'',
@@ -350,9 +360,10 @@ describe('RichContent', () => {
'',
'',
'',
- '', // v-if placeholder, mentionlink's "new" (i.e. rich) display
+ '',
+ '', // v-if placeholder, mentionlink's "new" (i.e. rich) display
'',
- '', // v-if placeholder, mentionsline's extra mentions and stuff
+ '', // v-if placeholder, mentionsline's extra mentions and stuff
''
),
p(
@@ -361,8 +372,8 @@ describe('RichContent', () => {
].join('')
const wrapper = mount(RichContent, {
- localVue,
- propsData: {
+ global,
+ props: {
attentions,
handleLinks: true,
greentext: true,
@@ -371,76 +382,73 @@ describe('RichContent', () => {
}
})
- expect(wrapper.html()).to.eql(compwrap(expected))
+ expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected))
})
it('rich contents of nested mentions are handled properly', () => {
attentions.push({ statusnet_profile_url: 'lol' })
const html = [
- p(
- '',
- '',
- '',
- 'https://',
- '',
- 'lol.tld/',
- '',
- '',
- '',
- ' ',
- '',
- '',
- 'https://',
- '',
- 'lol.tld/',
- '',
- '',
- '',
- ''
- ),
- p(
- 'Testing'
- )
+ '',
+ '',
+ '',
+ 'https://',
+ '',
+ 'lol.tld/',
+ '',
+ '',
+ '',
+ ' ',
+ '',
+ '',
+ 'https://',
+ '',
+ 'lol.tld/',
+ '',
+ '',
+ '',
+ ' ',
+ '',
+ 'Testing'
].join('')
const expected = [
- p(
- '',
- '',
- '',
- '',
- '',
- 'https://',
- '',
- 'lol.tld/',
- '',
- '',
- '',
- '', // v-if placeholder, mentionlink's "new" (i.e. rich) display
- '',
- '',
- '',
- '',
- 'https://',
- '',
- 'lol.tld/',
- '',
- '',
- '',
- '', // v-if placeholder, mentionlink's "new" (i.e. rich) display
- '',
- '', // v-if placeholder, mentionsline's extra mentions and stuff
- '',
- ''
- ),
+ '',
+ '',
+ '',
+ '',
+ '',
+ '',
+ 'https://',
+ '',
+ 'lol.tld/',
+ '',
+ '',
+ '',
+ '',
+ '', // v-if placeholder, mentionlink's "new" (i.e. rich) display
+ '',
+ '',
+ '',
+ '',
+ '',
+ 'https://',
+ '',
+ 'lol.tld/',
+ '',
+ '',
+ '',
+ '',
+ '', // v-if placeholder, mentionlink's "new" (i.e. rich) display
+ '',
+ '', // v-if placeholder, mentionsline's extra mentions and stuff
+ '',
' ',
- p(
- 'Testing'
- )
+ '',
+ 'Testing'
].join('')
const wrapper = mount(RichContent, {
- localVue,
- propsData: {
+ global,
+ props: {
attentions,
handleLinks: true,
greentext: true,
@@ -449,7 +457,7 @@ describe('RichContent', () => {
}
})
- expect(wrapper.html()).to.eql(compwrap(expected))
+ expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected))
})
it('rich contents of a link are handled properly', () => {
@@ -483,8 +491,8 @@ describe('RichContent', () => {
].join('')
const wrapper = shallowMount(RichContent, {
- localVue,
- propsData: {
+ global,
+ props: {
attentions,
handleLinks: true,
greentext: true,
@@ -493,7 +501,7 @@ describe('RichContent', () => {
}
})
- expect(wrapper.html()).to.eql(compwrap(expected))
+ expect(wrapper.html().replace(/\n/g, '')).to.eql(compwrap(expected))
})
it.skip('[INFORMATIVE] Performance testing, 10 000 simple posts', () => {
@@ -530,8 +538,8 @@ describe('RichContent', () => {
const t0 = performance.now()
const wrapper = mount(TestComponent, {
- localVue,
- propsData: {
+ global,
+ props: {
attentions,
handleLinks,
vhtml
--
cgit v1.2.3-70-g09d2
From 9d7a7e2019601dd1f7877d8fce2a07c5e459941e Mon Sep 17 00:00:00 2001
From: Henry Jameson
Date: Tue, 22 Mar 2022 18:14:56 +0200
Subject: fix emoji input tests
---
src/components/emoji_input/emoji_input.js | 7 ++-
test/unit/specs/components/emoji_input.spec.js | 78 ++++++++++++++------------
2 files changed, 48 insertions(+), 37 deletions(-)
(limited to 'test')
diff --git a/src/components/emoji_input/emoji_input.js b/src/components/emoji_input/emoji_input.js
index 5b51da18..e772bf75 100644
--- a/src/components/emoji_input/emoji_input.js
+++ b/src/components/emoji_input/emoji_input.js
@@ -189,8 +189,11 @@ const EmojiInput = {
img: imageUrl || ''
}))
},
- suggestions (newValue) {
- this.$nextTick(this.resize)
+ suggestions: {
+ handler (newValue) {
+ this.$nextTick(this.resize)
+ },
+ deep: true
}
},
methods: {
diff --git a/test/unit/specs/components/emoji_input.spec.js b/test/unit/specs/components/emoji_input.spec.js
index 045b47fd..6188308e 100644
--- a/test/unit/specs/components/emoji_input.spec.js
+++ b/test/unit/specs/components/emoji_input.spec.js
@@ -1,108 +1,116 @@
-import { shallowMount, createLocalVue } from '@vue/test-utils'
+import { h } from 'vue'
+import { shallowMount } from '@vue/test-utils'
import EmojiInput from 'src/components/emoji_input/emoji_input.vue'
+import vClickOutside from 'click-outside-vue3'
const generateInput = (value, padEmoji = true) => {
- const localVue = createLocalVue()
- localVue.directive('click-outside', () => {})
const wrapper = shallowMount(EmojiInput, {
- propsData: {
- suggest: () => [],
- enableEmojiPicker: true,
- value
- },
- mocks: {
- $store: {
- getters: {
- mergedConfig: {
- padEmoji
+ global: {
+ renderStubDefaultSlot: true,
+ mocks: {
+ $store: {
+ getters: {
+ mergedConfig: {
+ padEmoji
+ }
}
}
+ },
+ stubs: {
+ FAIcon: true
+ },
+ directives: {
+ 'click-outside': vClickOutside
}
},
- slots: {
- default: ''
+ props: {
+ suggest: () => [],
+ enableEmojiPicker: true,
+ modelValue: value
},
- localVue
+ slots: {
+ 'default': () => h('input', '')
+ }
})
- return [wrapper, localVue]
+ return wrapper
}
describe('EmojiInput', () => {
describe('insertion mechanism', () => {
it('inserts string at the end with trailing space', () => {
const initialString = 'Testing'
- const [wrapper] = generateInput(initialString)
+ const wrapper = generateInput(initialString)
const input = wrapper.find('input')
input.setValue(initialString)
wrapper.setData({ caret: initialString.length })
wrapper.vm.insert({ insertion: '(test)', keepOpen: false })
- const inputEvents = wrapper.emitted().input
+ const inputEvents = wrapper.emitted()['update:modelValue']
expect(inputEvents[inputEvents.length - 1][0]).to.eql('Testing (test) ')
})
it('inserts string at the end with trailing space (source has a trailing space)', () => {
const initialString = 'Testing '
- const [wrapper] = generateInput(initialString)
+ const wrapper = generateInput(initialString)
const input = wrapper.find('input')
input.setValue(initialString)
wrapper.setData({ caret: initialString.length })
wrapper.vm.insert({ insertion: '(test)', keepOpen: false })
- const inputEvents = wrapper.emitted().input
+ const inputEvents = wrapper.emitted()['update:modelValue']
expect(inputEvents[inputEvents.length - 1][0]).to.eql('Testing (test) ')
})
it('inserts string at the begginning without leading space', () => {
const initialString = 'Testing'
- const [wrapper] = generateInput(initialString)
+ const wrapper = generateInput(initialString)
const input = wrapper.find('input')
input.setValue(initialString)
wrapper.setData({ caret: 0 })
wrapper.vm.insert({ insertion: '(test)', keepOpen: false })
- const inputEvents = wrapper.emitted().input
+ const inputEvents = wrapper.emitted()['update:modelValue']
expect(inputEvents[inputEvents.length - 1][0]).to.eql('(test) Testing')
})
it('inserts string between words without creating extra spaces', () => {
const initialString = 'Spurdo Sparde'
- const [wrapper] = generateInput(initialString)
+ const wrapper = generateInput(initialString)
const input = wrapper.find('input')
input.setValue(initialString)
wrapper.setData({ caret: 6 })
wrapper.vm.insert({ insertion: ':ebin:', keepOpen: false })
- const inputEvents = wrapper.emitted().input
+ const inputEvents = wrapper.emitted()['update:modelValue']
expect(inputEvents[inputEvents.length - 1][0]).to.eql('Spurdo :ebin: Sparde')
})
it('inserts string between words without creating extra spaces (other caret)', () => {
const initialString = 'Spurdo Sparde'
- const [wrapper] = generateInput(initialString)
+ const wrapper = generateInput(initialString)
const input = wrapper.find('input')
input.setValue(initialString)
wrapper.setData({ caret: 7 })
wrapper.vm.insert({ insertion: ':ebin:', keepOpen: false })
- const inputEvents = wrapper.emitted().input
+ const inputEvents = wrapper.emitted()['update:modelValue']
expect(inputEvents[inputEvents.length - 1][0]).to.eql('Spurdo :ebin: Sparde')
})
it('inserts string without any padding if padEmoji setting is set to false', () => {
const initialString = 'Eat some spam!'
- const [wrapper] = generateInput(initialString, false)
+ const wrapper = generateInput(initialString, false)
const input = wrapper.find('input')
input.setValue(initialString)
wrapper.setData({ caret: initialString.length, keepOpen: false })
wrapper.vm.insert({ insertion: ':spam:' })
- const inputEvents = wrapper.emitted().input
+ const inputEvents = wrapper.emitted()['update:modelValue']
expect(inputEvents[inputEvents.length - 1][0]).to.eql('Eat some spam!:spam:')
})
it('correctly sets caret after insertion at beginning', (done) => {
const initialString = '1234'
- const [wrapper, vue] = generateInput(initialString)
+ const wrapper = generateInput(initialString)
const input = wrapper.find('input')
input.setValue(initialString)
wrapper.setData({ caret: 0 })
wrapper.vm.insert({ insertion: '1234', keepOpen: false })
- vue.nextTick(() => {
+ wrapper.vm.$nextTick(() => {
expect(wrapper.vm.caret).to.eql(5)
done()
})
@@ -110,12 +118,12 @@ describe('EmojiInput', () => {
it('correctly sets caret after insertion at end', (done) => {
const initialString = '1234'
- const [wrapper, vue] = generateInput(initialString)
+ const wrapper = generateInput(initialString)
const input = wrapper.find('input')
input.setValue(initialString)
wrapper.setData({ caret: initialString.length })
wrapper.vm.insert({ insertion: '1234', keepOpen: false })
- vue.nextTick(() => {
+ wrapper.vm.$nextTick(() => {
expect(wrapper.vm.caret).to.eql(10)
done()
})
@@ -123,12 +131,12 @@ describe('EmojiInput', () => {
it('correctly sets caret after insertion if padEmoji setting is set to false', (done) => {
const initialString = '1234'
- const [wrapper, vue] = generateInput(initialString, false)
+ const wrapper = generateInput(initialString, false)
const input = wrapper.find('input')
input.setValue(initialString)
wrapper.setData({ caret: initialString.length })
wrapper.vm.insert({ insertion: '1234', keepOpen: false })
- vue.nextTick(() => {
+ wrapper.vm.$nextTick(() => {
expect(wrapper.vm.caret).to.eql(8)
done()
})
--
cgit v1.2.3-70-g09d2
From e5ae0671ce9f74bc67fea550204c18bad8f39150 Mon Sep 17 00:00:00 2001
From: Henry Jameson
Date: Tue, 22 Mar 2022 18:56:39 +0200
Subject: skip user profile test for now
https://github.com/vuejs/test-utils/issues/1382
---
test/unit/specs/components/user_profile.spec.js | 48 ++++++++++++-------------
1 file changed, 24 insertions(+), 24 deletions(-)
(limited to 'test')
diff --git a/test/unit/specs/components/user_profile.spec.js b/test/unit/specs/components/user_profile.spec.js
index 142db73c..584758f7 100644
--- a/test/unit/specs/components/user_profile.spec.js
+++ b/test/unit/specs/components/user_profile.spec.js
@@ -1,12 +1,9 @@
-import { mount, createLocalVue } from '@vue/test-utils'
-import Vuex from 'vuex'
+import { mount } from '@vue/test-utils'
+import { createStore } from 'vuex'
import UserProfile from 'src/components/user_profile/user_profile.vue'
import backendInteractorService from 'src/services/backend_interactor_service/backend_interactor_service.js'
import { getters } from 'src/modules/users.js'
-const localVue = createLocalVue()
-localVue.use(Vuex)
-
const mutations = {
clearTimeline: () => {}
}
@@ -42,7 +39,7 @@ const extUser = {
screen_name_ui: 'testUser@test.instance'
}
-const externalProfileStore = new Vuex.Store({
+const externalProfileStore = createStore({
mutations,
actions,
getters: testGetters,
@@ -104,7 +101,7 @@ const externalProfileStore = new Vuex.Store({
}
})
-const localProfileStore = new Vuex.Store({
+const localProfileStore = createStore({
mutations,
actions,
getters: testGetters,
@@ -173,17 +170,19 @@ const localProfileStore = new Vuex.Store({
}
})
-describe('UserProfile', () => {
+// https://github.com/vuejs/test-utils/issues/1382
+describe.skip('UserProfile', () => {
it('renders external profile', () => {
const wrapper = mount(UserProfile, {
- localVue,
- store: externalProfileStore,
- mocks: {
- $route: {
- params: { id: 100 },
- name: 'external-user-profile'
- },
- $t: (msg) => msg
+ global: {
+ plugins: [ externalProfileStore ],
+ mocks: {
+ $route: {
+ params: { id: 100 },
+ name: 'external-user-profile'
+ },
+ $t: (msg) => msg
+ }
}
})
@@ -192,14 +191,15 @@ describe('UserProfile', () => {
it('renders local profile', () => {
const wrapper = mount(UserProfile, {
- localVue,
- store: localProfileStore,
- mocks: {
- $route: {
- params: { name: 'testUser' },
- name: 'user-profile'
- },
- $t: (msg) => msg
+ global: {
+ plugins: [ localProfileStore ],
+ mocks: {
+ $route: {
+ params: { name: 'testUser' },
+ name: 'user-profile'
+ },
+ $t: (msg) => msg
+ }
}
})
--
cgit v1.2.3-70-g09d2
From 3250e59266eb552ba3ef120bb7e2465f79340e4f Mon Sep 17 00:00:00 2001
From: Henry Jameson
Date: Tue, 22 Mar 2022 18:56:54 +0200
Subject: fix routes test
---
test/unit/specs/boot/routes.spec.js | 39 ++++++++++++++++---------------------
1 file changed, 17 insertions(+), 22 deletions(-)
(limited to 'test')
diff --git a/test/unit/specs/boot/routes.spec.js b/test/unit/specs/boot/routes.spec.js
index 3673256f..439aefd4 100644
--- a/test/unit/specs/boot/routes.spec.js
+++ b/test/unit/specs/boot/routes.spec.js
@@ -1,45 +1,40 @@
-import Vuex from 'vuex'
import routes from 'src/boot/routes'
-import { createLocalVue } from '@vue/test-utils'
-import VueRouter from 'vue-router'
+import { createRouter, createMemoryHistory } from 'vue-router'
+import { createStore } from 'vuex'
-const localVue = createLocalVue()
-localVue.use(Vuex)
-localVue.use(VueRouter)
-
-const store = new Vuex.Store({
+const store = createStore({
state: {
instance: {}
}
})
describe('routes', () => {
- const router = new VueRouter({
- mode: 'abstract',
+ const router = createRouter({
+ history: createMemoryHistory(),
routes: routes(store)
})
- it('root path', () => {
- router.push('/main/all')
+ it('root path', async () => {
+ await router.push('/main/all')
- const matchedComponents = router.getMatchedComponents()
+ const matchedComponents = router.currentRoute.value.matched
- expect(matchedComponents[0].components.hasOwnProperty('Timeline')).to.eql(true)
+ expect(matchedComponents[0].components.default.components.hasOwnProperty('Timeline')).to.eql(true)
})
- it('user\'s profile', () => {
- router.push('/fake-user-name')
+ it('user\'s profile', async () => {
+ await router.push('/fake-user-name')
- const matchedComponents = router.getMatchedComponents()
+ const matchedComponents = router.currentRoute.value.matched
- expect(matchedComponents[0].components.hasOwnProperty('UserCard')).to.eql(true)
+ expect(matchedComponents[0].components.default.components.hasOwnProperty('UserCard')).to.eql(true)
})
- it('user\'s profile at /users', () => {
- router.push('/users/fake-user-name')
+ it('user\'s profile at /users', async () => {
+ await router.push('/users/fake-user-name')
- const matchedComponents = router.getMatchedComponents()
+ const matchedComponents = router.currentRoute.value.matched
- expect(matchedComponents[0].components.hasOwnProperty('UserCard')).to.eql(true)
+ expect(matchedComponents[0].components.default.components.hasOwnProperty('UserCard')).to.eql(true)
})
})
--
cgit v1.2.3-70-g09d2
From dc8bef7928cb6a5e06a793a78652234276ca6fce Mon Sep 17 00:00:00 2001
From: Henry Jameson
Date: Tue, 29 Mar 2022 00:58:17 +0300
Subject: remove compat build
---
build/webpack.base.conf.js | 8 --------
build/webpack.dev.conf.js | 4 +++-
build/webpack.prod.conf.js | 4 +++-
package.json | 1 -
src/boot/after_store.js | 10 +---------
test/unit/index.js | 7 -------
yarn.lock | 5 -----
7 files changed, 7 insertions(+), 32 deletions(-)
(limited to 'test')
diff --git a/build/webpack.base.conf.js b/build/webpack.base.conf.js
index 65d398c8..d7ff9b9a 100644
--- a/build/webpack.base.conf.js
+++ b/build/webpack.base.conf.js
@@ -35,7 +35,6 @@ module.exports = {
path.join(__dirname, '../node_modules')
],
alias: {
- 'vue': '@vue/compat',
'static': path.resolve(__dirname, '../static'),
'src': path.resolve(__dirname, '../src'),
'assets': path.resolve(__dirname, '../src/assets'),
@@ -62,13 +61,6 @@ module.exports = {
{
test: /\.vue$/,
loader: 'vue-loader',
- options: {
- compilerOptions: {
- compatConfig: {
- MODE: 2
- }
- }
- }
},
{
test: /\.jsx?$/,
diff --git a/build/webpack.dev.conf.js b/build/webpack.dev.conf.js
index 159572ba..4605b93d 100644
--- a/build/webpack.dev.conf.js
+++ b/build/webpack.dev.conf.js
@@ -21,7 +21,9 @@ module.exports = merge(baseWebpackConfig, {
new webpack.DefinePlugin({
'process.env': config.dev.env,
'COMMIT_HASH': JSON.stringify('DEV'),
- 'DEV_OVERRIDES': JSON.stringify(config.dev.settings)
+ 'DEV_OVERRIDES': JSON.stringify(config.dev.settings),
+ '__VUE_OPTIONS_API__': true,
+ '__VUE_PROD_DEVTOOLS__': false
}),
// https://github.com/glenjamin/webpack-hot-middleware#installation--usage
new webpack.HotModuleReplacementPlugin(),
diff --git a/build/webpack.prod.conf.js b/build/webpack.prod.conf.js
index ed11ebad..a67ed2f6 100644
--- a/build/webpack.prod.conf.js
+++ b/build/webpack.prod.conf.js
@@ -36,7 +36,9 @@ var webpackConfig = merge(baseWebpackConfig, {
new webpack.DefinePlugin({
'process.env': env,
'COMMIT_HASH': JSON.stringify(commitHash),
- 'DEV_OVERRIDES': JSON.stringify(undefined)
+ 'DEV_OVERRIDES': JSON.stringify(undefined),
+ '__VUE_OPTIONS_API__': true,
+ '__VUE_PROD_DEVTOOLS__': false
}),
// extract css into its own file
new MiniCssExtractPlugin({
diff --git a/package.json b/package.json
index f9a58b87..1a743c16 100644
--- a/package.json
+++ b/package.json
@@ -35,7 +35,6 @@
"ruffle-mirror": "2021.12.31",
"click-outside-vue3": "4.0.1",
"vue": "^3.1.0",
- "@vue/compat": "^3.1.0",
"vue-i18n": "9.1.9",
"vue-router": "4.0.14",
"vue-template-compiler": "2.6.11",
diff --git a/src/boot/after_store.js b/src/boot/after_store.js
index 87448c8c..76832708 100644
--- a/src/boot/after_store.js
+++ b/src/boot/after_store.js
@@ -1,4 +1,4 @@
-import { createApp, configureCompat } from 'vue'
+import { createApp } from 'vue'
import { createRouter, createWebHistory } from 'vue-router'
import vClickOutside from 'click-outside-vue3'
@@ -15,14 +15,6 @@ import { CURRENT_VERSION } from '../services/theme_data/theme_data.service.js'
import { applyTheme } from '../services/style_setter/style_setter.js'
import FaviconService from '../services/favicon_service/favicon_service.js'
-// disable compat for certain features
-configureCompat({
- ATTR_FALSE_VALUE: false,
- COMPONENT_V_MODEL: false,
- INSTANCE_SET: false,
- RENDER_FUNCTION: false
-})
-
let staticInitialResults = null
const parsedInitialResults = () => {
diff --git a/test/unit/index.js b/test/unit/index.js
index 24d2825c..83a2dcdb 100644
--- a/test/unit/index.js
+++ b/test/unit/index.js
@@ -1,10 +1,3 @@
-import { configureCompat } from 'vue'
-// disable compat for certain features
-configureCompat({
- COMPONENT_V_MODEL: false,
- INSTANCE_SET: false,
- RENDER_FUNCTION: false
-})
// require all test files (files that ends with .spec.js)
const testsContext = require.context('./specs', true, /\.spec$/)
testsContext.keys().forEach(testsContext)
diff --git a/yarn.lock b/yarn.lock
index a1206eff..ca954c04 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1452,11 +1452,6 @@
html-tags "^3.1.0"
svg-tags "^1.0.0"
-"@vue/compat@^3.1.0":
- version "3.2.31"
- resolved "https://registry.yarnpkg.com/@vue/compat/-/compat-3.2.31.tgz#9c8bdf265eeba1777e5edb56cda73581e351a648"
- integrity sha512-hhwJk/SRwpT2OADctj+t7QZCRIgh04AcelGpe6gdj0OxA75xpHnPrG+fmG37U3Z6WDrNHZpGvu2eXBzWXM4OVA==
-
"@vue/compiler-core@3.2.31":
version "3.2.31"
resolved "https://registry.yarnpkg.com/@vue/compiler-core/-/compiler-core-3.2.31.tgz#d38f06c2cf845742403b523ab4596a3fda152e89"
--
cgit v1.2.3-70-g09d2
From 0bb69d7fe026181bb6367ced8a921d0c3a0dc6ba Mon Sep 17 00:00:00 2001
From: Henry Jameson
Date: Tue, 12 Apr 2022 19:04:32 +0300
Subject: fix tests
---
test/unit/specs/components/rich_content.spec.js | 2 --
1 file changed, 2 deletions(-)
(limited to 'test')
diff --git a/test/unit/specs/components/rich_content.spec.js b/test/unit/specs/components/rich_content.spec.js
index a4920867..958fb997 100644
--- a/test/unit/specs/components/rich_content.spec.js
+++ b/test/unit/specs/components/rich_content.spec.js
@@ -308,10 +308,8 @@ describe('RichContent', () => {
'',
'NHCMDUXJPPZ6M3Z2CQ6D2EBRSWGE7MZY.jpg',
' ',
- '#nou',
'',
' ',
- '#screencap',
'',
'
'
].join('')
--
cgit v1.2.3-70-g09d2
From 13cff692f0633bfccb7896e774fcf4820ddbb4c2 Mon Sep 17 00:00:00 2001
From: Tusooa Zhu
Date: Tue, 7 Jun 2022 20:34:08 -0400
Subject: Fix tests
---
test/unit/specs/services/date_utils/date_utils.spec.js | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
(limited to 'test')
diff --git a/test/unit/specs/services/date_utils/date_utils.spec.js b/test/unit/specs/services/date_utils/date_utils.spec.js
index 2d61dbac..bd1efe81 100644
--- a/test/unit/specs/services/date_utils/date_utils.spec.js
+++ b/test/unit/specs/services/date_utils/date_utils.spec.js
@@ -11,30 +11,30 @@ describe('DateUtils', () => {
it('rounds down for past', () => {
const time = Date.now() - 1.8 * DateUtils.HOUR
- expect(DateUtils.relativeTime(time)).to.eql({ num: 1, key: 'time.hour' })
+ expect(DateUtils.relativeTime(time)).to.eql({ num: 1, key: 'time.unit.hours' })
})
it('rounds up for future', () => {
const time = Date.now() + 1.8 * DateUtils.HOUR
- expect(DateUtils.relativeTime(time)).to.eql({ num: 2, key: 'time.hours' })
+ expect(DateUtils.relativeTime(time)).to.eql({ num: 2, key: 'time.unit.hours' })
})
it('uses plural when necessary', () => {
const time = Date.now() - 3.8 * DateUtils.WEEK
- expect(DateUtils.relativeTime(time)).to.eql({ num: 3, key: 'time.weeks' })
+ expect(DateUtils.relativeTime(time)).to.eql({ num: 3, key: 'time.unit.weeks' })
})
it('works with date string', () => {
const time = Date.now() - 4 * DateUtils.MONTH
const dateString = new Date(time).toISOString()
- expect(DateUtils.relativeTime(dateString)).to.eql({ num: 4, key: 'time.months' })
+ expect(DateUtils.relativeTime(dateString)).to.eql({ num: 4, key: 'time.unit.months' })
})
})
describe('relativeTimeShort', () => {
it('returns the short version of the same relative time', () => {
const time = Date.now() + 2 * DateUtils.YEAR
- expect(DateUtils.relativeTimeShort(time)).to.eql({ num: 2, key: 'time.years_short' })
+ expect(DateUtils.relativeTimeShort(time)).to.eql({ num: 2, key: 'time.unit.years_short' })
})
})
})
--
cgit v1.2.3-70-g09d2