remove related dispatches

This commit is contained in:
Henry Jameson 2026-08-20 21:00:36 +03:00
commit ae5984d2f1
29 changed files with 260 additions and 236 deletions

View file

@ -1,4 +1,3 @@
import { createTestingPinia } from '@pinia/testing'
import { config } from '@vue/test-utils'
import { createMemoryHistory, createRouter } from 'vue-router'
import VueVirtualScroller from 'vue-virtual-scroller'

View file

@ -3,7 +3,6 @@ import { createTestingPinia } from '@pinia/testing'
createTestingPinia()
import { createMemoryHistory, createRouter } from 'vue-router'
import { createStore } from 'vuex'
import routes from 'src/boot/routes'

View file

@ -2,12 +2,12 @@ import { createTestingPinia } from '@pinia/testing'
import { flushPromises, mount } from '@vue/test-utils'
import { setActivePinia } from 'pinia'
import { nextTick } from 'vue'
import { useUsersStore } from 'src/stores/users.js'
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
import { $t, mountOpts, waitForEvent } from '../../../fixtures/setup_test'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useUsersStore } from 'src/stores/users.js'
const autoSaveOrNot = (caseFn, caseTitle, runFn) => {
caseFn(`${caseTitle} with auto-save`, function () {

View file

@ -1,9 +1,9 @@
import { createTestingPinia } from '@pinia/testing'
import { setActivePinia } from 'pinia'
import { mount, shallowMount } from '@vue/test-utils'
import { mountOpts } from '../../../fixtures/setup_test'
import { setActivePinia } from 'pinia'
import RichContent from 'src/components/rich_content/rich_content.jsx'
import { mountOpts } from '../../../fixtures/setup_test'
const attentions = []
@ -30,15 +30,18 @@ describe('RichContent', () => {
it('renders simple post without exploding', () => {
const html = p('Hello world!')
const wrapper = shallowMount(RichContent, mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}))
const wrapper = shallowMount(
RichContent,
mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}),
)
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(html))
})
@ -46,30 +49,36 @@ describe('RichContent', () => {
it('unescapes everything as needed', () => {
const html = [p('Testing 'em all'), 'Testing 'em all'].join('')
const expected = [p("Testing 'em all"), "Testing 'em all"].join('')
const wrapper = shallowMount(RichContent, mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}))
const wrapper = shallowMount(
RichContent,
mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}),
)
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
})
it('replaces mention with mentionsline', () => {
const html = p(makeMention('John'), ' how are you doing today?')
const wrapper = shallowMount(RichContent, mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}))
const wrapper = shallowMount(
RichContent,
mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}),
)
expect(wrapper.html().replaceAll('\n', '')).to.eql(
compwrap(p(mentionsLine(1), ' how are you doing today?')),
@ -93,15 +102,18 @@ describe('RichContent', () => {
),
].join('')
const wrapper = shallowMount(RichContent, mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}))
const wrapper = shallowMount(
RichContent,
mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}),
)
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
})
@ -128,15 +140,18 @@ describe('RichContent', () => {
].join(''),
].join('\n')
const wrapper = shallowMount(RichContent, mountOpts({
props: {
attentions,
handleLinks: false,
greentext: true,
emoji: [],
html,
},
}))
const wrapper = shallowMount(
RichContent,
mountOpts({
props: {
attentions,
handleLinks: false,
greentext: true,
emoji: [],
html,
},
}),
)
expect(wrapper.html()).to.eql(compwrap(strippedHtml))
})
@ -148,15 +163,18 @@ describe('RichContent', () => {
'<span class="greentext">&gt;any year</span>',
].join('\n')
const wrapper = shallowMount(RichContent, mountOpts({
props: {
attentions,
handleLinks: false,
greentext: true,
emoji: [],
html,
},
}))
const wrapper = shallowMount(
RichContent,
mountOpts({
props: {
attentions,
handleLinks: false,
greentext: true,
emoji: [],
html,
},
}),
)
expect(wrapper.html()).to.eql(compwrap(expected))
})
@ -164,15 +182,18 @@ describe('RichContent', () => {
it('Does not add greentext and cyantext if setting is set to false', () => {
const html = ['&gt;preordering videogames', '&gt;any year'].join('\n')
const wrapper = shallowMount(RichContent, mountOpts({
props: {
attentions,
handleLinks: false,
greentext: false,
emoji: [],
html,
},
}))
const wrapper = shallowMount(
RichContent,
mountOpts({
props: {
attentions,
handleLinks: false,
greentext: false,
emoji: [],
html,
},
}),
)
expect(wrapper.html()).to.eql(compwrap(html))
})
@ -184,15 +205,18 @@ describe('RichContent', () => {
'<anonymous-stub shortcode="spurdo" islocal="true" class="emoji img" src="about:blank" title=":spurdo:" alt=":spurdo:"></anonymous-stub>',
)
const wrapper = shallowMount(RichContent, mountOpts({
props: {
attentions,
handleLinks: false,
greentext: false,
emoji: [{ url: 'about:blank', shortcode: 'spurdo' }],
html,
},
}))
const wrapper = shallowMount(
RichContent,
mountOpts({
props: {
attentions,
handleLinks: false,
greentext: false,
emoji: [{ url: 'about:blank', shortcode: 'spurdo' }],
html,
},
}),
)
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
})
@ -200,15 +224,18 @@ describe('RichContent', () => {
it("Doesn't add nonexistent emoji to post", () => {
const html = p('Lol :lol:')
const wrapper = shallowMount(RichContent, mountOpts({
props: {
attentions,
handleLinks: false,
greentext: false,
emoji: [],
html,
},
}))
const wrapper = shallowMount(
RichContent,
mountOpts({
props: {
attentions,
handleLinks: false,
greentext: false,
emoji: [],
html,
},
}),
)
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(html))
})
@ -227,15 +254,18 @@ describe('RichContent', () => {
'<span class="greentext">&gt;quote</span>',
].join('\n')
const wrapper = shallowMount(RichContent, mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}))
const wrapper = shallowMount(
RichContent,
mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}),
)
expect(wrapper.html()).to.eql(compwrap(expected))
})
@ -249,15 +279,18 @@ describe('RichContent', () => {
].join('<br>')
const expected = ['Bruh', 'Bruh', mentionsLine(3), 'Bruh'].join('<br>')
const wrapper = shallowMount(RichContent, mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}))
const wrapper = shallowMount(
RichContent,
mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}),
)
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
})
@ -284,15 +317,18 @@ describe('RichContent', () => {
' </p>',
].join('')
const wrapper = shallowMount(RichContent, mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}))
const wrapper = shallowMount(
RichContent,
mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}),
)
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
})
@ -330,15 +366,18 @@ describe('RichContent', () => {
p('Testing'),
].join('')
const wrapper = mount(RichContent, mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}))
const wrapper = mount(
RichContent,
mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}),
)
expect(
wrapper
@ -402,15 +441,18 @@ describe('RichContent', () => {
'Testing',
].join('')
const wrapper = mount(RichContent, mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}))
const wrapper = mount(
RichContent,
mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}),
)
expect(
wrapper
@ -450,15 +492,18 @@ describe('RichContent', () => {
'</p>',
].join('')
const wrapper = shallowMount(RichContent, mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}))
const wrapper = shallowMount(
RichContent,
mountOpts({
props: {
attentions,
handleLinks: true,
greentext: true,
emoji: [],
html,
},
}),
)
expect(wrapper.html().replaceAll('\n', '')).to.eql(compwrap(expected))
})
@ -495,13 +540,16 @@ describe('RichContent', () => {
const ptest = (handleLinks, vhtml) => {
const t0 = performance.now()
const wrapper = mount(TestComponent, mountOpts({
props: {
attentions,
handleLinks,
vhtml,
},
}))
const wrapper = mount(
TestComponent,
mountOpts({
props: {
attentions,
handleLinks,
vhtml,
},
}),
)
const t1 = performance.now()

View file

@ -1,8 +1,8 @@
import { setActivePinia } from 'pinia'
import { createTestingPinia } from '@pinia/testing'
import { setActivePinia } from 'pinia'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { useNotificationsStore } from 'src/stores/notifications.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import * as NotificationUtils from 'src/services/notification_utils/notification_utils.js'

View file

@ -85,14 +85,6 @@ const mockStatusNotification = ({
from_profile: user,
})
const DEFAULT_OPTIONS = (method = 'POST') => ({
method,
credentials: 'same-origin',
headers: {
Accept: 'application/json',
},
})
describe('Notifications store', () => {
beforeEach(() => {
vi.useFakeTimers()
@ -328,7 +320,6 @@ describe('Notifications store', () => {
vi.stubGlobal('fetch', mockFetch)
const store = useNotificationsStore()
const mockedNotification = mockStatusNotification()
store.addNewNotifications({
timestamp: 1337,
@ -366,7 +357,6 @@ describe('Notifications store', () => {
vi.stubGlobal('fetch', mockFetch)
const store = useNotificationsStore()
const mockedNotification = mockStatusNotification()
// FormData is weird to test
store.addNewNotifications({