fix tests

This commit is contained in:
Henry Jameson 2026-03-25 15:38:31 +02:00
commit ff621d9d80
12 changed files with 78 additions and 63 deletions

View file

@ -325,7 +325,8 @@ const PostStatusForm = {
},
hideScopeNotice() {
return (
this.disableNotice || useMergedConfigStore().mergedConfig.hideScopeNotice
this.disableNotice ||
useMergedConfigStore().mergedConfig.hideScopeNotice
)
},
pollContentError() {

View file

@ -10,8 +10,8 @@ import Popover from '../popover/popover.vue'
import { useInterfaceStore } from 'src/stores/interface.js'
import { useLocalConfigStore } from 'src/stores/local_config.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { LOCAL_ONLY_KEYS } from 'src/modules/default_config_state.js'
import {

View file

@ -1,9 +1,9 @@
import { useEditStatusStore } from 'src/stores/editStatus.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useInstanceCapabilitiesStore } from 'src/stores/instance_capabilities.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
import { useReportsStore } from 'src/stores/reports.js'
import { useStatusHistoryStore } from 'src/stores/statusHistory.js'
import { useMergedConfigStore } from 'src/stores/merged_config.js'
const PRIVATE_SCOPES = new Set(['private', 'direct'])
const PUBLIC_SCOPES = new Set(['public', 'unlisted'])

View file

@ -661,8 +661,8 @@ export const SYNC_DEFAULT_CONFIG_DEFINITIONS = {
},
collapseNav: {
description: 'Collapse navigation panel to header only',
default: false
}
default: false,
},
}
export const SYNC_DEFAULT_CONFIG = convertDefinitions(
SYNC_DEFAULT_CONFIG_DEFINITIONS,
@ -675,12 +675,14 @@ export const THEME_CONFIG_DEFINITIONS = {
default: null,
},
colors: {
description: 'VERY old theme store, just colors of V1, probably not even used anymore',
description:
'VERY old theme store, just colors of V1, probably not even used anymore',
default: {},
},
// V2
customTheme: {
description: '"Snapshot", previously was used as actual theme store for V2 so it\'s still used in case of PleromaFE downgrade event.',
description:
'"Snapshot", previously was used as actual theme store for V2 so it\'s still used in case of PleromaFE downgrade event.',
default: null,
},
customThemeSource: {
@ -705,9 +707,7 @@ export const THEME_CONFIG_DEFINITIONS = {
default: null,
},
}
export const THEME_CONFIG = convertDefinitions(
THEME_CONFIG_DEFINITIONS,
)
export const THEME_CONFIG = convertDefinitions(THEME_CONFIG_DEFINITIONS)
export const makeUndefined = (c) =>
Object.fromEntries(Object.keys(c).map((key) => [key, undefined]))

View file

@ -7,8 +7,8 @@ import { useInstanceStore } from 'src/stores/instance'
import {
LOCAL_DEFAULT_CONFIG,
LOCAL_DEFAULT_CONFIG_DEFINITIONS,
validateSetting,
makeUndefined,
validateSetting,
} from 'src/modules/default_config_state'
export const defaultState = {
@ -57,7 +57,9 @@ export const useLocalConfigStore = defineStore('local_config', {
persist: {
afterLoad(state) {
return {
prefsStorage: state.prefsStorage ?? { ...makeUndefined(LOCAL_DEFAULT_CONFIG) },
prefsStorage: state.prefsStorage ?? {
...makeUndefined(LOCAL_DEFAULT_CONFIG),
},
tempStorage: { ...makeUndefined(LOCAL_DEFAULT_CONFIG) },
}
},

View file

@ -7,8 +7,8 @@ import { useSyncConfigStore } from 'src/stores/sync_config.js'
import {
INSTANCE_DEFAULT_CONFIG,
LOCAL_DEFAULT_CONFIG,
THEME_CONFIG,
LOCAL_ONLY_KEYS,
THEME_CONFIG,
} from 'src/modules/default_config_state.js'
const ROOT_CONFIG = {
@ -35,10 +35,7 @@ export const useMergedConfigStore = defineStore('merged_config', {
const getDefault = (k) => instancePrefs[k] ?? ROOT_CONFIG[k]
const result = Object.fromEntries(
Object.keys(ROOT_CONFIG).map((k) => [
k,
getValue(k) ?? getDefault(k),
]),
Object.keys(ROOT_CONFIG).map((k) => [k, getValue(k) ?? getDefault(k)]),
)
return result
},
@ -48,10 +45,7 @@ export const useMergedConfigStore = defineStore('merged_config', {
const getDefault = (k) => instancePrefs[k] ?? ROOT_CONFIG[k]
const result = Object.fromEntries(
Object.keys(ROOT_CONFIG).map((k) => [
k,
getDefault(k),
]),
Object.keys(ROOT_CONFIG).map((k) => [k, getDefault(k)]),
)
return result
},
@ -65,10 +59,7 @@ export const useMergedConfigStore = defineStore('merged_config', {
tempPrefs[k] ?? localPrefs[k] ?? syncPrefs.simple[k] ?? instancePrefs[k]
const result = Object.fromEntries(
Object.keys(ROOT_CONFIG).map(([k, value]) => [
k,
getValue(k),
]),
Object.keys(ROOT_CONFIG).map(([k, value]) => [k, getValue(k)]),
)
return result
},

View file

@ -24,10 +24,10 @@ import { useLocalConfigStore } from 'src/stores/local_config.js'
import { storage } from 'src/lib/storage.js'
import {
makeUndefined,
ROOT_CONFIG,
ROOT_CONFIG_DEFINITIONS,
validateSetting,
makeUndefined,
} from 'src/modules/default_config_state.js'
import { oldDefaultConfigSync } from 'src/modules/old_default_config_state.js'
@ -297,7 +297,7 @@ export const _mergePrefs = (recent, stale) => {
)
}
switch (operation) {
case 'set':
case 'set': {
if (path.startsWith('collections')) {
return console.error('Illegal operation "set" on a collection')
}
@ -306,8 +306,22 @@ export const _mergePrefs = (recent, stale) => {
`Calling set on depth <= 1 (path: ${path}) is not allowed`,
)
}
set(resultOutput, path, args[0])
const definition = path.startsWith('simple.muteFilters')
? { default: {} }
: ROOT_CONFIG_DEFINITIONS[path.split('.')[1]]
const finalValue = validateSetting({
path: path.split('.')[1],
value: args[0],
definition,
throwError: false,
defaultState: ROOT_CONFIG,
})
set(resultOutput, path, finalValue)
break
}
case 'unset':
if (path.startsWith('collections')) {
return console.error('Illegal operation "unset" on a collection')
@ -488,8 +502,8 @@ export const useSyncConfigStore = defineStore('sync_config', {
}
const definition = path.startsWith('simple.muteFilters')
? { default: {} }
: ROOT_CONFIG_DEFINITIONS[path.split('.')[1]]
? { default: {} }
: ROOT_CONFIG_DEFINITIONS[path.split('.')[1]]
const finalValue = validateSetting({
path: path.split('.')[1],

View file

@ -153,8 +153,9 @@ const _mergeJournal = (...journals) => {
export const _mergeHighlights = (recent, stale) => {
if (!stale) return recent
if (!recent) return stale
const { _journal: recentJournal, ...recentData } = recent
const { _journal: recentJournal, highlight: recentHighlight } = recent
const { _journal: staleJournal } = stale
console.log(recentHighlight)
/** Journal entry format:
* user: user to entry in highlight storage
* timestamp: timestamp of the change
@ -164,7 +165,7 @@ export const _mergeHighlights = (recent, stale) => {
* currently only supported operation type is "set" which just sets the value
* to requested one. Intended only to be used with simple preferences (boolean, number)
*/
const resultOutput = { ...recentData }
const resultHighlight = { ...recentHighlight }
const Journal = _mergeJournal(staleJournal, recentJournal)
Journal.forEach(({ user, operation, args }) => {
if (user.startsWith('_')) {
@ -174,16 +175,16 @@ export const _mergeHighlights = (recent, stale) => {
}
switch (operation) {
case 'set':
resultOutput[user] = args[0]
resultHighlight[user] = args[0]
break
case 'unset':
delete resultOutput[user]
delete resultHighlight[user]
break
default:
return console.error(`Unknown journal operation: '${operation}'`)
}
})
return { ...resultOutput, _journal: Journal }
return { highlight: resultHighlight, _journal: Journal }
}
export const useUserHighlightStore = defineStore('user_highlight', {
@ -333,7 +334,6 @@ export const useUserHighlightStore = defineStore('user_highlight', {
this.cache._timestamp = Math.min(stale._timestamp, recent._timestamp)
}
this.highlight = this.cache.highlight
this.pushHighlight()
},
pushHighlight({ force = false } = {}) {
const needPush = this.dirty || force