This commit is contained in:
Henry Jameson 2026-09-02 17:26:08 +03:00
commit c611788e77
19 changed files with 59 additions and 122 deletions

View file

@ -17,8 +17,11 @@ const CHANGE_EMAIL_URL = '/api/pleroma/change_email'
const CHANGE_PASSWORD_URL = '/api/pleroma/change_password' const CHANGE_PASSWORD_URL = '/api/pleroma/change_password'
const MOVE_ACCOUNT_URL = '/api/pleroma/move_account' const MOVE_ACCOUNT_URL = '/api/pleroma/move_account'
const ALIASES_URL = '/api/pleroma/aliases' const ALIASES_URL = '/api/pleroma/aliases'
const NOTIFICATION_SETTINGS_URL = ({ blockFromStrangers, hideNotificationContents }) => const NOTIFICATION_SETTINGS_URL = ({
`/api/pleroma/notification_settings${paramsString({ blockFromStrangers, hideNotificationContents })}` blockFromStrangers,
hideNotificationContents,
}) =>
`/api/pleroma/notification_settings${paramsString({ blockFromStrangers, hideNotificationContents })}`
export const NOTIFICATION_READ_URL = '/api/v1/pleroma/notifications/read' export const NOTIFICATION_READ_URL = '/api/v1/pleroma/notifications/read'
const MFA_SETTINGS_URL = '/api/pleroma/accounts/mfa' const MFA_SETTINGS_URL = '/api/pleroma/accounts/mfa'

View file

@ -5,9 +5,9 @@ import Gallery from 'src/components/gallery/gallery.vue'
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue' import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
import StatusContent from 'src/components/status_content/status_content.vue' import StatusContent from 'src/components/status_content/status_content.vue'
import { useDraftsStore } from 'src/stores/drafts.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js' import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useStatusesStore } from 'src/stores/statuses.js' import { useStatusesStore } from 'src/stores/statuses.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { library } from '@fortawesome/fontawesome-svg-core' import { library } from '@fortawesome/fontawesome-svg-core'
import { faPollH } from '@fortawesome/free-solid-svg-icons' import { faPollH } from '@fortawesome/free-solid-svg-icons'
@ -92,9 +92,11 @@ const Draft = {
this.showingConfirmDialog = true this.showingConfirmDialog = true
}, },
doAbandon() { doAbandon() {
useDraftsStore().abandonDraft(this.draft.id).then(() => { useDraftsStore()
this.hideConfirmDialog() .abandonDraft(this.draft.id)
}) .then(() => {
this.hideConfirmDialog()
})
}, },
hideConfirmDialog() { hideConfirmDialog() {
this.showingConfirmDialog = false this.showingConfirmDialog = false

View file

@ -1,9 +1,10 @@
import { defineAsyncComponent } from 'vue' import { defineAsyncComponent } from 'vue'
import { useDraftsStore } from 'src/stores/drafts.js'
import Draft from 'src/components/draft/draft.vue' import Draft from 'src/components/draft/draft.vue'
import List from 'src/components/list/list.vue' import List from 'src/components/list/list.vue'
import { useDraftsStore } from 'src/stores/drafts.js'
const Drafts = { const Drafts = {
components: { components: {
Draft, Draft,
@ -27,7 +28,8 @@ const Drafts = {
this.showingConfirmDialog = true this.showingConfirmDialog = true
}, },
doAbandonAll() { doAbandonAll() {
useDraftsStore().abandonAllDrafts() useDraftsStore()
.abandonAllDrafts()
.then(() => this.hideConfirmDialog()) .then(() => this.hideConfirmDialog())
}, },
hideConfirmDialog() { hideConfirmDialog() {

View file

@ -4,11 +4,11 @@ import { routeTo } from 'src/components/navigation/navigation.js'
import OptionalRouterLink from 'src/components/optional_router_link/optional_router_link.vue' import OptionalRouterLink from 'src/components/optional_router_link/optional_router_link.vue'
import { useAnnouncementsStore } from 'src/stores/announcements.js' import { useAnnouncementsStore } from 'src/stores/announcements.js'
import { useChatsStore } from 'src/stores/chats.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { useFollowRequestsStore } from 'src/stores/follow_requests.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js' import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { useUsersStore } from 'src/stores/users.js' import { useUsersStore } from 'src/stores/users.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { useChatsStore } from 'src/stores/chats.js'
import { useFollowRequestsStore } from 'src/stores/follow_requests.js'
import { library } from '@fortawesome/fontawesome-svg-core' import { library } from '@fortawesome/fontawesome-svg-core'
import { faThumbtack } from '@fortawesome/free-solid-svg-icons' import { faThumbtack } from '@fortawesome/free-solid-svg-icons'

View file

@ -24,6 +24,7 @@ import { findOffset } from '../../services/offset_finder/offset_finder.service.j
import genRandomSeed from '../../services/random_seed/random_seed.service.js' import genRandomSeed from '../../services/random_seed/random_seed.service.js'
import statusPoster from '../../services/status_poster/status_poster.service.js' import statusPoster from '../../services/status_poster/status_poster.service.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { useEmojiStore } from 'src/stores/emoji.js' import { useEmojiStore } from 'src/stores/emoji.js'
import { useInstanceStore } from 'src/stores/instance.js' import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
@ -32,7 +33,6 @@ import { useMediaViewerStore } from 'src/stores/media_viewer.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js' import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js' import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { useUsersStore } from 'src/stores/users.js' import { useUsersStore } from 'src/stores/users.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { pollFormToMasto } from 'src/services/poll/poll.service.js' import { pollFormToMasto } from 'src/services/poll/poll.service.js'

View file

@ -8,8 +8,8 @@ import { useAdminSettingsStore } from 'src/stores/admin_settings.js'
import { useInterfaceStore } from 'src/stores/interface.js' import { useInterfaceStore } from 'src/stores/interface.js'
import { useLocalConfigStore } from 'src/stores/local_config.js' import { useLocalConfigStore } from 'src/stores/local_config.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js' import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { useProfileConfigStore } from 'src/stores/profile_config.js' import { useProfileConfigStore } from 'src/stores/profile_config.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
export default { export default {
components: { components: {
@ -413,7 +413,8 @@ export default {
hardReset() { hardReset() {
switch (this.realSource) { switch (this.realSource) {
case 'admin': case 'admin':
return useAdminSettingsStore().resetAdminSetting({ path: this.path }) return useAdminSettingsStore()
.resetAdminSetting({ path: this.path })
.then(() => { .then(() => {
this.draft = this.state this.draft = this.state
}) })

View file

@ -16,8 +16,8 @@ import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.j
import { useInterfaceStore } from 'src/stores/interface.js' import { useInterfaceStore } from 'src/stores/interface.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js' import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useOAuthStore } from 'src/stores/oauth.js' import { useOAuthStore } from 'src/stores/oauth.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { useProfileConfigStore } from 'src/stores/profile_config.js' import { useProfileConfigStore } from 'src/stores/profile_config.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { useUsersStore } from 'src/stores/users.js' import { useUsersStore } from 'src/stores/users.js'
import { updateProfile } from 'src/api/user.js' import { updateProfile } from 'src/api/user.js'

View file

@ -7,6 +7,7 @@ import { unseenNotifications } from '../../services/notification_utils/notificat
import { useAnnouncementsStore } from 'src/stores/announcements' import { useAnnouncementsStore } from 'src/stores/announcements'
import { useChatsStore } from 'src/stores/chats.js' import { useChatsStore } from 'src/stores/chats.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { useFollowRequestsStore } from 'src/stores/follow_requests.js' import { useFollowRequestsStore } from 'src/stores/follow_requests.js'
import { useInstanceStore } from 'src/stores/instance.js' import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
@ -14,7 +15,6 @@ import { useInterfaceStore } from 'src/stores/interface'
import { useMergedConfigStore } from 'src/stores/merged_config.js' import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useShoutStore } from 'src/stores/shout' import { useShoutStore } from 'src/stores/shout'
import { useUsersStore } from 'src/stores/users.js' import { useUsersStore } from 'src/stores/users.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { library } from '@fortawesome/fontawesome-svg-core' import { library } from '@fortawesome/fontawesome-svg-core'
import { import {

View file

@ -1,11 +1,7 @@
import { cloneDeep, each, get, merge, set } from 'lodash' import { cloneDeep, get, set } from 'lodash'
import { storage } from './storage.js' import { storage } from './storage.js'
import { useInterfaceStore } from 'src/stores/interface'
let loaded = false
const defaultReducer = (state, paths) => const defaultReducer = (state, paths) =>
paths.length === 0 paths.length === 0
? state ? state
@ -14,15 +10,6 @@ const defaultReducer = (state, paths) =>
return substate return substate
}, {}) }, {})
const saveImmedeatelyActions = [
'markNotificationsAsSeen',
'setHighlight',
'setOption',
'setClientData',
'setToken',
'clearToken',
]
const defaultStorage = (() => { const defaultStorage = (() => {
return storage return storage
})() })()

View file

@ -33,10 +33,6 @@ const i18n = createI18n({
messages.setLanguage(i18n.global, currentLocale) messages.setLanguage(i18n.global, currentLocale)
const persistedStateOptions = {
paths: ['oauth', 'config'],
}
;(async () => { ;(async () => {
const isFox = Math.floor(Math.random() * 2) > 0 ? '_fox' : '' const isFox = Math.floor(Math.random() * 2) > 0 ? '_fox' : ''

View file

@ -1,4 +1,5 @@
import { defineStore } from 'pinia' import { defineStore } from 'pinia'
import { storage } from 'src/lib/storage.js' import { storage } from 'src/lib/storage.js'
const storageKey = 'pleroma-fe-drafts' const storageKey = 'pleroma-fe-drafts'
@ -18,13 +19,13 @@ const storageKey = 'pleroma-fe-drafts'
const getStorageData = async () => await storage.getItem(storageKey) const getStorageData = async () => await storage.getItem(storageKey)
const saveDraftToStorage = async (draft) => { const saveDraftToStorage = async (draft) => {
const currentData = await getStorageData() ?? {} const currentData = (await getStorageData()) ?? {}
currentData[draft.id] = JSON.parse(JSON.stringify(draft)) currentData[draft.id] = JSON.parse(JSON.stringify(draft))
await storage.setItem(storageKey, currentData) await storage.setItem(storageKey, currentData)
} }
const deleteDraftFromStorage = async (ids) => { const deleteDraftFromStorage = async (ids) => {
const currentData = await getStorageData() ?? {} const currentData = (await getStorageData()) ?? {}
ids.forEach((id) => { ids.forEach((id) => {
delete currentData[id] delete currentData[id]
}) })
@ -33,7 +34,7 @@ const deleteDraftFromStorage = async (ids) => {
export const useDraftsStore = defineStore('drafts', { export const useDraftsStore = defineStore('drafts', {
state: () => ({ state: () => ({
drafts: new Map() drafts: new Map(),
}), }),
getters: { getters: {
draftsByTypeAndRefId(state) { draftsByTypeAndRefId(state) {
@ -71,5 +72,5 @@ export const useDraftsStore = defineStore('drafts', {
ids.forEach((id) => this.abandonDraft(id)) ids.forEach((id) => this.abandonDraft(id))
await deleteDraftFromStorage(ids) await deleteDraftFromStorage(ids)
}, },
} },
}) })

View file

@ -97,7 +97,9 @@ export const settingsMap = {
} }
export const defaultState = () => ({ export const defaultState = () => ({
config: Object.fromEntries(Object.keys(settingsMap).map((key) => [key, null])) config: Object.fromEntries(
Object.keys(settingsMap).map((key) => [key, null]),
),
}) })
export const useProfileConfigStore = defineStore('profileConfig', { export const useProfileConfigStore = defineStore('profileConfig', {

View file

@ -5,6 +5,7 @@ import { defineStore } from 'pinia'
import { useAnnouncementsStore } from 'src/stores/announcements.js' import { useAnnouncementsStore } from 'src/stores/announcements.js'
import { useBookmarkFoldersStore } from 'src/stores/bookmark_folders.js' import { useBookmarkFoldersStore } from 'src/stores/bookmark_folders.js'
import { useChatsStore } from 'src/stores/chats.js' import { useChatsStore } from 'src/stores/chats.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { useEmojiStore } from 'src/stores/emoji.js' import { useEmojiStore } from 'src/stores/emoji.js'
import { useFollowRequestsStore } from 'src/stores/follow_requests.js' import { useFollowRequestsStore } from 'src/stores/follow_requests.js'
import { useInstanceStore } from 'src/stores/instance.js' import { useInstanceStore } from 'src/stores/instance.js'
@ -14,14 +15,13 @@ import { useListsStore } from 'src/stores/lists.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js' import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useNotificationsStore } from 'src/stores/notifications.js' import { useNotificationsStore } from 'src/stores/notifications.js'
import { useOAuthStore } from 'src/stores/oauth.js' import { useOAuthStore } from 'src/stores/oauth.js'
import { useProfileConfigStore } from 'src/stores/profile_config.js'
import { useShoutStore } from 'src/stores/shout.js' import { useShoutStore } from 'src/stores/shout.js'
import { useStatusesStore } from 'src/stores/statuses.js' import { useStatusesStore } from 'src/stores/statuses.js'
import { useStreamingStore } from 'src/stores/streaming.js' import { useStreamingStore } from 'src/stores/streaming.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js' import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { useProfileConfigStore } from 'src/stores/profile_config.js'
import { useTimelinesStore } from 'src/stores/timelines.js' import { useTimelinesStore } from 'src/stores/timelines.js'
import { useUserHighlightStore } from 'src/stores/user_highlight.js' import { useUserHighlightStore } from 'src/stores/user_highlight.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { revokeToken } from 'src/api/oauth.js' import { revokeToken } from 'src/api/oauth.js'
import { import {

View file

@ -5,26 +5,15 @@ import VueVirtualScroller from 'vue-virtual-scroller'
import RichContent from 'src/components/rich_content/rich_content.jsx' import RichContent from 'src/components/rich_content/rich_content.jsx'
import Status from 'src/components/status/status.vue' import Status from 'src/components/status/status.vue'
import StillImage from 'src/components/still-image/still-image.vue' import StillImage from 'src/components/still-image/still-image.vue'
import makeMockStore from './mock_store'
import routes from 'src/boot/routes' import routes from 'src/boot/routes'
export const $t = (msg) => msg export const $t = (msg) => msg
const $i18n = { t: (msg) => msg } const $i18n = { t: (msg) => msg }
const applyAfterStore = (store, afterStore) => { const getDefaultOpts = () => ({
afterStore(store)
return store
}
const getDefaultOpts = ({
afterStore = () => {
/* no-op */
},
} = {}) => ({
global: { global: {
plugins: [ plugins: [
applyAfterStore(makeMockStore(), afterStore),
VueVirtualScroller, VueVirtualScroller,
createRouter({ createRouter({
history: createMemoryHistory(), history: createMemoryHistory(),
@ -87,9 +76,8 @@ const customBehaviors = () => {
config.plugins.VueWrapper.install(customBehaviors) config.plugins.VueWrapper.install(customBehaviors)
export const mountOpts = (allOpts = {}) => { export const mountOpts = (opts = {}) => {
const { afterStore, ...opts } = allOpts const defaultOpts = getDefaultOpts()
const defaultOpts = getDefaultOpts({ afterStore })
const mergedOpts = { const mergedOpts = {
...opts, ...opts,
global: { global: {

View file

@ -1,10 +1,10 @@
import { createTestingPinia } from '@pinia/testing' import { createTestingPinia } from '@pinia/testing'
import { flushPromises, mount } from '@vue/test-utils' import { flushPromises, mount } from '@vue/test-utils'
import { setActivePinia } from 'pinia' import { setActivePinia } from 'pinia'
import { $t, mountOpts, waitForEvent } from 'test/fixtures/setup_test.js'
import { nextTick } from 'vue' import { nextTick } from 'vue'
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue' 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 { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useUsersStore } from 'src/stores/users.js' import { useUsersStore } from 'src/stores/users.js'

View file

@ -1,10 +1,10 @@
import { createTestingPinia } from '@pinia/testing' import { createTestingPinia } from '@pinia/testing'
import { mount } from '@vue/test-utils' import { mount } from '@vue/test-utils'
import { setActivePinia } from 'pinia' import { setActivePinia } from 'pinia'
import { mountOpts } from 'test/fixtures/setup_test.js'
import { vi } from 'vitest' import { vi } from 'vitest'
import PostStatusForm from 'src/components/post_status_form/post_status_form.vue' import PostStatusForm from 'src/components/post_status_form/post_status_form.vue'
import { mountOpts } from '../../../fixtures/setup_test'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js' import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js' import { useMergedConfigStore } from 'src/stores/merged_config.js'

View file

@ -1,9 +1,9 @@
import { createTestingPinia } from '@pinia/testing' import { createTestingPinia } from '@pinia/testing'
import { mount, shallowMount } from '@vue/test-utils' import { mount, shallowMount } from '@vue/test-utils'
import { setActivePinia } from 'pinia' import { setActivePinia } from 'pinia'
import { mountOpts } from 'test/fixtures/setup_test.js'
import RichContent from 'src/components/rich_content/rich_content.jsx' import RichContent from 'src/components/rich_content/rich_content.jsx'
import { mountOpts } from '../../../fixtures/setup_test'
const attentions = [] const attentions = []

View file

@ -37,10 +37,7 @@ describe('The SyncConfig store', () => {
it('should initialize storage if none present', async () => { it('should initialize storage if none present', async () => {
const store = useSyncConfigStore() const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data store.pushSyncConfig = vi.fn()
store.pushSyncConfig = () => {
/* no-op */
}
await store.initSyncConfig({ ...user }) await store.initSyncConfig({ ...user })
expect(store.cache._version).to.eql(VERSION) expect(store.cache._version).to.eql(VERSION)
expect(store.cache._timestamp).to.be.a('number') expect(store.cache._timestamp).to.be.a('number')
@ -50,10 +47,7 @@ describe('The SyncConfig store', () => {
it('should initialize storage with proper flags for new users if none present', async () => { it('should initialize storage with proper flags for new users if none present', async () => {
const store = useSyncConfigStore() const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data store.pushSyncConfig = vi.fn()
store.pushSyncConfig = () => {
/* no-op */
}
await store.initSyncConfig({ ...user, created_at: new Date() }) await store.initSyncConfig({ ...user, created_at: new Date() })
expect(store.cache._version).to.eql(VERSION) expect(store.cache._version).to.eql(VERSION)
expect(store.cache._timestamp).to.be.a('number') expect(store.cache._timestamp).to.be.a('number')
@ -63,10 +57,7 @@ describe('The SyncConfig store', () => {
it('should merge flags even if remote timestamp is older', async () => { it('should merge flags even if remote timestamp is older', async () => {
const store = useSyncConfigStore() const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data store.pushSyncConfig = vi.fn()
store.pushSyncConfig = () => {
/* no-op */
}
store.cache = { store.cache = {
_timestamp: Date.now(), _timestamp: Date.now(),
_version: VERSION, _version: VERSION,
@ -96,10 +87,7 @@ describe('The SyncConfig store', () => {
it('should trim journal to 500 entries', async () => { it('should trim journal to 500 entries', async () => {
const store = useSyncConfigStore() const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data store.pushSyncConfig = vi.fn()
store.pushSyncConfig = () => {
/* no-op */
}
store.cache = { store.cache = {
_timestamp: Date.now(), _timestamp: Date.now(),
_version: VERSION, _version: VERSION,
@ -138,10 +126,7 @@ describe('The SyncConfig store', () => {
it('should reset local timestamp to remote if contents are the same', async () => { it('should reset local timestamp to remote if contents are the same', async () => {
const store = useSyncConfigStore() const store = useSyncConfigStore()
store.cache = null store.cache = null
// PushSyncConfig is very simple but uses vuex to push data store.pushSyncConfig = vi.fn()
store.pushSyncConfig = () => {
/* no-op */
}
await store.initSyncConfig({ await store.initSyncConfig({
...user, ...user,
@ -161,10 +146,7 @@ describe('The SyncConfig store', () => {
it('should use remote version if local missing', async () => { it('should use remote version if local missing', async () => {
const store = useSyncConfigStore() const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data store.pushSyncConfig = vi.fn()
store.pushSyncConfig = () => {
/* no-op */
}
await store.initSyncConfig(store, user) await store.initSyncConfig(store, user)
expect(store.cache._version).to.eql(VERSION) expect(store.cache._version).to.eql(VERSION)
expect(store.cache._timestamp).to.be.a('number') expect(store.cache._timestamp).to.be.a('number')
@ -208,9 +190,7 @@ describe('The SyncConfig store', () => {
}) })
vi.spyOn(storage, 'setItem').mockResolvedValue() vi.spyOn(storage, 'setItem').mockResolvedValue()
const store = useSyncConfigStore() const store = useSyncConfigStore()
store.pushSyncConfig = () => { store.pushSyncConfig = vi.fn()
/* no-op */
}
await store.initSyncConfig({ await store.initSyncConfig({
...user, ...user,
@ -240,9 +220,7 @@ describe('The SyncConfig store', () => {
}) })
vi.spyOn(storage, 'setItem').mockResolvedValue() vi.spyOn(storage, 'setItem').mockResolvedValue()
const store = useSyncConfigStore() const store = useSyncConfigStore()
store.pushSyncConfig = () => { store.pushSyncConfig = vi.fn()
/* no-op */
}
await store.initSyncConfig({ await store.initSyncConfig({
...user, ...user,
@ -282,9 +260,7 @@ describe('The SyncConfig store', () => {
vi.spyOn(storage, 'setItem').mockResolvedValue() vi.spyOn(storage, 'setItem').mockResolvedValue()
const store = useSyncConfigStore() const store = useSyncConfigStore()
const setPreference = vi.spyOn(store, 'setPreference') const setPreference = vi.spyOn(store, 'setPreference')
store.pushSyncConfig = () => { store.pushSyncConfig = vi.fn()
/* no-op */
}
await store.initSyncConfig({ await store.initSyncConfig({
...user, ...user,
@ -318,9 +294,7 @@ describe('The SyncConfig store', () => {
}) })
vi.spyOn(storage, 'setItem').mockResolvedValue() vi.spyOn(storage, 'setItem').mockResolvedValue()
const store = useSyncConfigStore() const store = useSyncConfigStore()
store.pushSyncConfig = () => { store.pushSyncConfig = vi.fn()
/* no-op */
}
await store.initSyncConfig({ await store.initSyncConfig({
...user, ...user,
@ -357,9 +331,7 @@ describe('The SyncConfig store', () => {
const localStore = useLocalConfigStore() const localStore = useLocalConfigStore()
localStore.set({ path: 'fontInterface', value: 'Current interface' }) localStore.set({ path: 'fontInterface', value: 'Current interface' })
const store = useSyncConfigStore() const store = useSyncConfigStore()
store.pushSyncConfig = () => { store.pushSyncConfig = vi.fn()
/* no-op */
}
await store.initSyncConfig({ ...user }) await store.initSyncConfig({ ...user })
@ -372,10 +344,7 @@ describe('The SyncConfig store', () => {
describe('setPreference', () => { describe('setPreference', () => {
it('should set preference and update journal log accordingly', () => { it('should set preference and update journal log accordingly', () => {
const store = useSyncConfigStore() const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data store.pushSyncConfig = vi.fn()
store.pushSyncConfig = () => {
/* no-op */
}
store.setPreference({ path: 'simple.palette', value: '1' }) store.setPreference({ path: 'simple.palette', value: '1' })
expect(store.prefsStorage.simple.palette).to.eql('1') expect(store.prefsStorage.simple.palette).to.eql('1')
expect(store.prefsStorage._journal).to.have.length(1) expect(store.prefsStorage._journal).to.have.length(1)
@ -390,10 +359,7 @@ describe('The SyncConfig store', () => {
it('should keep journal to a minimum', () => { it('should keep journal to a minimum', () => {
const store = useSyncConfigStore() const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data store.pushSyncConfig = vi.fn()
store.pushSyncConfig = () => {
/* no-op */
}
store.setPreference({ path: 'simple.palette', value: 1 }) store.setPreference({ path: 'simple.palette', value: 1 })
store.setPreference({ path: 'simple.palette', value: 2 }) store.setPreference({ path: 'simple.palette', value: 2 })
store.addCollectionPreference({ path: 'collections.palette', value: 2 }) store.addCollectionPreference({ path: 'collections.palette', value: 2 })
@ -423,10 +389,7 @@ describe('The SyncConfig store', () => {
it('should remove duplicate entries from journal', () => { it('should remove duplicate entries from journal', () => {
const store = useSyncConfigStore() const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data store.pushSyncConfig = vi.fn()
store.pushSyncConfig = () => {
/* no-op */
}
store.setPreference({ path: 'simple.palette', value: 1 }) store.setPreference({ path: 'simple.palette', value: 1 })
store.setPreference({ path: 'simple.palette', value: 1 }) store.setPreference({ path: 'simple.palette', value: 1 })
store.addCollectionPreference({ path: 'collections.palette', value: 2 }) store.addCollectionPreference({ path: 'collections.palette', value: 2 })
@ -440,10 +403,7 @@ describe('The SyncConfig store', () => {
// TODO We need a proper test for object-based stores // TODO We need a proper test for object-based stores
it.skip('should remove depth = 3 set/unset entries from journal', () => { it.skip('should remove depth = 3 set/unset entries from journal', () => {
const store = useSyncConfigStore() const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data store.pushSyncConfig = vi.fn()
store.pushSyncConfig = () => {
/* no-op */
}
store.setPreference({ path: 'simple.fontInput', value: 'test' }) store.setPreference({ path: 'simple.fontInput', value: 'test' })
store.unsetPreference({ path: 'simple.fontInput' }) store.unsetPreference({ path: 'simple.fontInput' })
store.updateCache(store, { username: 'test' }) store.updateCache(store, { username: 'test' })
@ -455,10 +415,7 @@ describe('The SyncConfig store', () => {
it('should not allow unsetting depth <= 2', () => { it('should not allow unsetting depth <= 2', () => {
const store = useSyncConfigStore() const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data store.pushSyncConfig = vi.fn()
store.pushSyncConfig = () => {
/* no-op */
}
store.setPreference({ path: 'simple.object.foo', value: 1 }) store.setPreference({ path: 'simple.object.foo', value: 1 })
expect(() => store.unsetPreference({ path: 'simple' })).to.throw() expect(() => store.unsetPreference({ path: 'simple' })).to.throw()
expect(() => expect(() =>
@ -468,10 +425,7 @@ describe('The SyncConfig store', () => {
it('should not allow (un)setting depth > 3', () => { it('should not allow (un)setting depth > 3', () => {
const store = useSyncConfigStore() const store = useSyncConfigStore()
// PushSyncConfig is very simple but uses vuex to push data store.pushSyncConfig = vi.fn()
store.pushSyncConfig = () => {
/* no-op */
}
store.setPreference({ path: 'simple.object', value: {} }) store.setPreference({ path: 'simple.object', value: {} })
expect(() => expect(() =>
store.setPreference({ path: 'simple.object.lv3', value: 1 }), store.setPreference({ path: 'simple.object.lv3', value: 1 }),

View file

@ -120,6 +120,7 @@ export default defineConfig(async ({ mode, command }) => {
const swDest = 'sw-pleroma.js' const swDest = 'sw-pleroma.js'
const alias = { const alias = {
src: '/src', src: '/src',
test: '/test',
components: '/src/components', components: '/src/components',
...(mode === 'test' ? { vue: 'vue/dist/vue.esm-bundler.js' } : {}), ...(mode === 'test' ? { vue: 'vue/dist/vue.esm-bundler.js' } : {}),
} }