fix tests
This commit is contained in:
parent
54298927da
commit
ff621d9d80
12 changed files with 78 additions and 63 deletions
|
|
@ -325,7 +325,8 @@ const PostStatusForm = {
|
||||||
},
|
},
|
||||||
hideScopeNotice() {
|
hideScopeNotice() {
|
||||||
return (
|
return (
|
||||||
this.disableNotice || useMergedConfigStore().mergedConfig.hideScopeNotice
|
this.disableNotice ||
|
||||||
|
useMergedConfigStore().mergedConfig.hideScopeNotice
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
pollContentError() {
|
pollContentError() {
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,8 @@ import Popover from '../popover/popover.vue'
|
||||||
|
|
||||||
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 { useSyncConfigStore } from 'src/stores/sync_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 { LOCAL_ONLY_KEYS } from 'src/modules/default_config_state.js'
|
import { LOCAL_ONLY_KEYS } from 'src/modules/default_config_state.js'
|
||||||
import {
|
import {
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
import { useEditStatusStore } from 'src/stores/editStatus.js'
|
import { useEditStatusStore } from 'src/stores/editStatus.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'
|
||||||
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
import { useReportsStore } from 'src/stores/reports.js'
|
import { useReportsStore } from 'src/stores/reports.js'
|
||||||
import { useStatusHistoryStore } from 'src/stores/statusHistory.js'
|
import { useStatusHistoryStore } from 'src/stores/statusHistory.js'
|
||||||
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
|
||||||
|
|
||||||
const PRIVATE_SCOPES = new Set(['private', 'direct'])
|
const PRIVATE_SCOPES = new Set(['private', 'direct'])
|
||||||
const PUBLIC_SCOPES = new Set(['public', 'unlisted'])
|
const PUBLIC_SCOPES = new Set(['public', 'unlisted'])
|
||||||
|
|
|
||||||
|
|
@ -661,8 +661,8 @@ export const SYNC_DEFAULT_CONFIG_DEFINITIONS = {
|
||||||
},
|
},
|
||||||
collapseNav: {
|
collapseNav: {
|
||||||
description: 'Collapse navigation panel to header only',
|
description: 'Collapse navigation panel to header only',
|
||||||
default: false
|
default: false,
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
export const SYNC_DEFAULT_CONFIG = convertDefinitions(
|
export const SYNC_DEFAULT_CONFIG = convertDefinitions(
|
||||||
SYNC_DEFAULT_CONFIG_DEFINITIONS,
|
SYNC_DEFAULT_CONFIG_DEFINITIONS,
|
||||||
|
|
@ -675,12 +675,14 @@ export const THEME_CONFIG_DEFINITIONS = {
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
colors: {
|
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: {},
|
default: {},
|
||||||
},
|
},
|
||||||
// V2
|
// V2
|
||||||
customTheme: {
|
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,
|
default: null,
|
||||||
},
|
},
|
||||||
customThemeSource: {
|
customThemeSource: {
|
||||||
|
|
@ -705,9 +707,7 @@ export const THEME_CONFIG_DEFINITIONS = {
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
export const THEME_CONFIG = convertDefinitions(
|
export const THEME_CONFIG = convertDefinitions(THEME_CONFIG_DEFINITIONS)
|
||||||
THEME_CONFIG_DEFINITIONS,
|
|
||||||
)
|
|
||||||
|
|
||||||
export const makeUndefined = (c) =>
|
export const makeUndefined = (c) =>
|
||||||
Object.fromEntries(Object.keys(c).map((key) => [key, undefined]))
|
Object.fromEntries(Object.keys(c).map((key) => [key, undefined]))
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ import { useInstanceStore } from 'src/stores/instance'
|
||||||
import {
|
import {
|
||||||
LOCAL_DEFAULT_CONFIG,
|
LOCAL_DEFAULT_CONFIG,
|
||||||
LOCAL_DEFAULT_CONFIG_DEFINITIONS,
|
LOCAL_DEFAULT_CONFIG_DEFINITIONS,
|
||||||
validateSetting,
|
|
||||||
makeUndefined,
|
makeUndefined,
|
||||||
|
validateSetting,
|
||||||
} from 'src/modules/default_config_state'
|
} from 'src/modules/default_config_state'
|
||||||
|
|
||||||
export const defaultState = {
|
export const defaultState = {
|
||||||
|
|
@ -57,7 +57,9 @@ export const useLocalConfigStore = defineStore('local_config', {
|
||||||
persist: {
|
persist: {
|
||||||
afterLoad(state) {
|
afterLoad(state) {
|
||||||
return {
|
return {
|
||||||
prefsStorage: state.prefsStorage ?? { ...makeUndefined(LOCAL_DEFAULT_CONFIG) },
|
prefsStorage: state.prefsStorage ?? {
|
||||||
|
...makeUndefined(LOCAL_DEFAULT_CONFIG),
|
||||||
|
},
|
||||||
tempStorage: { ...makeUndefined(LOCAL_DEFAULT_CONFIG) },
|
tempStorage: { ...makeUndefined(LOCAL_DEFAULT_CONFIG) },
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -7,8 +7,8 @@ import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
||||||
import {
|
import {
|
||||||
INSTANCE_DEFAULT_CONFIG,
|
INSTANCE_DEFAULT_CONFIG,
|
||||||
LOCAL_DEFAULT_CONFIG,
|
LOCAL_DEFAULT_CONFIG,
|
||||||
THEME_CONFIG,
|
|
||||||
LOCAL_ONLY_KEYS,
|
LOCAL_ONLY_KEYS,
|
||||||
|
THEME_CONFIG,
|
||||||
} from 'src/modules/default_config_state.js'
|
} from 'src/modules/default_config_state.js'
|
||||||
|
|
||||||
const ROOT_CONFIG = {
|
const ROOT_CONFIG = {
|
||||||
|
|
@ -35,10 +35,7 @@ export const useMergedConfigStore = defineStore('merged_config', {
|
||||||
const getDefault = (k) => instancePrefs[k] ?? ROOT_CONFIG[k]
|
const getDefault = (k) => instancePrefs[k] ?? ROOT_CONFIG[k]
|
||||||
|
|
||||||
const result = Object.fromEntries(
|
const result = Object.fromEntries(
|
||||||
Object.keys(ROOT_CONFIG).map((k) => [
|
Object.keys(ROOT_CONFIG).map((k) => [k, getValue(k) ?? getDefault(k)]),
|
||||||
k,
|
|
||||||
getValue(k) ?? getDefault(k),
|
|
||||||
]),
|
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
},
|
},
|
||||||
|
|
@ -48,10 +45,7 @@ export const useMergedConfigStore = defineStore('merged_config', {
|
||||||
const getDefault = (k) => instancePrefs[k] ?? ROOT_CONFIG[k]
|
const getDefault = (k) => instancePrefs[k] ?? ROOT_CONFIG[k]
|
||||||
|
|
||||||
const result = Object.fromEntries(
|
const result = Object.fromEntries(
|
||||||
Object.keys(ROOT_CONFIG).map((k) => [
|
Object.keys(ROOT_CONFIG).map((k) => [k, getDefault(k)]),
|
||||||
k,
|
|
||||||
getDefault(k),
|
|
||||||
]),
|
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
},
|
},
|
||||||
|
|
@ -65,10 +59,7 @@ export const useMergedConfigStore = defineStore('merged_config', {
|
||||||
tempPrefs[k] ?? localPrefs[k] ?? syncPrefs.simple[k] ?? instancePrefs[k]
|
tempPrefs[k] ?? localPrefs[k] ?? syncPrefs.simple[k] ?? instancePrefs[k]
|
||||||
|
|
||||||
const result = Object.fromEntries(
|
const result = Object.fromEntries(
|
||||||
Object.keys(ROOT_CONFIG).map(([k, value]) => [
|
Object.keys(ROOT_CONFIG).map(([k, value]) => [k, getValue(k)]),
|
||||||
k,
|
|
||||||
getValue(k),
|
|
||||||
]),
|
|
||||||
)
|
)
|
||||||
return result
|
return result
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -24,10 +24,10 @@ import { useLocalConfigStore } from 'src/stores/local_config.js'
|
||||||
|
|
||||||
import { storage } from 'src/lib/storage.js'
|
import { storage } from 'src/lib/storage.js'
|
||||||
import {
|
import {
|
||||||
|
makeUndefined,
|
||||||
ROOT_CONFIG,
|
ROOT_CONFIG,
|
||||||
ROOT_CONFIG_DEFINITIONS,
|
ROOT_CONFIG_DEFINITIONS,
|
||||||
validateSetting,
|
validateSetting,
|
||||||
makeUndefined,
|
|
||||||
} from 'src/modules/default_config_state.js'
|
} from 'src/modules/default_config_state.js'
|
||||||
import { oldDefaultConfigSync } from 'src/modules/old_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) {
|
switch (operation) {
|
||||||
case 'set':
|
case 'set': {
|
||||||
if (path.startsWith('collections')) {
|
if (path.startsWith('collections')) {
|
||||||
return console.error('Illegal operation "set" on a collection')
|
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`,
|
`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
|
break
|
||||||
|
}
|
||||||
case 'unset':
|
case 'unset':
|
||||||
if (path.startsWith('collections')) {
|
if (path.startsWith('collections')) {
|
||||||
return console.error('Illegal operation "unset" on a collection')
|
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')
|
const definition = path.startsWith('simple.muteFilters')
|
||||||
? { default: {} }
|
? { default: {} }
|
||||||
: ROOT_CONFIG_DEFINITIONS[path.split('.')[1]]
|
: ROOT_CONFIG_DEFINITIONS[path.split('.')[1]]
|
||||||
|
|
||||||
const finalValue = validateSetting({
|
const finalValue = validateSetting({
|
||||||
path: path.split('.')[1],
|
path: path.split('.')[1],
|
||||||
|
|
|
||||||
|
|
@ -153,8 +153,9 @@ const _mergeJournal = (...journals) => {
|
||||||
export const _mergeHighlights = (recent, stale) => {
|
export const _mergeHighlights = (recent, stale) => {
|
||||||
if (!stale) return recent
|
if (!stale) return recent
|
||||||
if (!recent) return stale
|
if (!recent) return stale
|
||||||
const { _journal: recentJournal, ...recentData } = recent
|
const { _journal: recentJournal, highlight: recentHighlight } = recent
|
||||||
const { _journal: staleJournal } = stale
|
const { _journal: staleJournal } = stale
|
||||||
|
console.log(recentHighlight)
|
||||||
/** Journal entry format:
|
/** Journal entry format:
|
||||||
* user: user to entry in highlight storage
|
* user: user to entry in highlight storage
|
||||||
* timestamp: timestamp of the change
|
* 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
|
* 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)
|
* to requested one. Intended only to be used with simple preferences (boolean, number)
|
||||||
*/
|
*/
|
||||||
const resultOutput = { ...recentData }
|
const resultHighlight = { ...recentHighlight }
|
||||||
const Journal = _mergeJournal(staleJournal, recentJournal)
|
const Journal = _mergeJournal(staleJournal, recentJournal)
|
||||||
Journal.forEach(({ user, operation, args }) => {
|
Journal.forEach(({ user, operation, args }) => {
|
||||||
if (user.startsWith('_')) {
|
if (user.startsWith('_')) {
|
||||||
|
|
@ -174,16 +175,16 @@ export const _mergeHighlights = (recent, stale) => {
|
||||||
}
|
}
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
case 'set':
|
case 'set':
|
||||||
resultOutput[user] = args[0]
|
resultHighlight[user] = args[0]
|
||||||
break
|
break
|
||||||
case 'unset':
|
case 'unset':
|
||||||
delete resultOutput[user]
|
delete resultHighlight[user]
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
return console.error(`Unknown journal operation: '${operation}'`)
|
return console.error(`Unknown journal operation: '${operation}'`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return { ...resultOutput, _journal: Journal }
|
return { highlight: resultHighlight, _journal: Journal }
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useUserHighlightStore = defineStore('user_highlight', {
|
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.cache._timestamp = Math.min(stale._timestamp, recent._timestamp)
|
||||||
}
|
}
|
||||||
this.highlight = this.cache.highlight
|
this.highlight = this.cache.highlight
|
||||||
this.pushHighlight()
|
|
||||||
},
|
},
|
||||||
pushHighlight({ force = false } = {}) {
|
pushHighlight({ force = false } = {}) {
|
||||||
const needPush = this.dirty || force
|
const needPush = this.dirty || force
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ 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 { $t, mountOpts, waitForEvent } from '../../../fixtures/setup_test'
|
||||||
|
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
|
||||||
const autoSaveOrNot = (caseFn, caseTitle, runFn) => {
|
const autoSaveOrNot = (caseFn, caseTitle, runFn) => {
|
||||||
caseFn(`${caseTitle} with auto-save`, function () {
|
caseFn(`${caseTitle} with auto-save`, function () {
|
||||||
|
|
@ -48,7 +48,7 @@ describe('Draft saving', () => {
|
||||||
'should save when the button is clicked',
|
'should save when the button is clicked',
|
||||||
async (autoSave) => {
|
async (autoSave) => {
|
||||||
const wrapper = mount(PostStatusForm, mountOpts())
|
const wrapper = mount(PostStatusForm, mountOpts())
|
||||||
const store = useSyncConfigStore()
|
const store = useMergedConfigStore()
|
||||||
store.mergedConfig = {
|
store.mergedConfig = {
|
||||||
autoSaveDraft: autoSave,
|
autoSaveDraft: autoSave,
|
||||||
}
|
}
|
||||||
|
|
@ -68,7 +68,7 @@ describe('Draft saving', () => {
|
||||||
it('should auto-save if it is enabled', async function () {
|
it('should auto-save if it is enabled', async function () {
|
||||||
vi.useFakeTimers()
|
vi.useFakeTimers()
|
||||||
const wrapper = mount(PostStatusForm, mountOpts())
|
const wrapper = mount(PostStatusForm, mountOpts())
|
||||||
const store = useSyncConfigStore()
|
const store = useMergedConfigStore()
|
||||||
store.mergedConfig = {
|
store.mergedConfig = {
|
||||||
autoSaveDraft: true,
|
autoSaveDraft: true,
|
||||||
}
|
}
|
||||||
|
|
@ -91,7 +91,7 @@ describe('Draft saving', () => {
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
const store = useSyncConfigStore()
|
const store = useMergedConfigStore()
|
||||||
store.mergedConfig = {
|
store.mergedConfig = {
|
||||||
autoSaveDraft: true,
|
autoSaveDraft: true,
|
||||||
}
|
}
|
||||||
|
|
@ -112,7 +112,7 @@ describe('Draft saving', () => {
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
const store = useSyncConfigStore()
|
const store = useMergedConfigStore()
|
||||||
store.mergedConfig = {
|
store.mergedConfig = {
|
||||||
autoSaveDraft: false,
|
autoSaveDraft: false,
|
||||||
unsavedPostAction: 'save',
|
unsavedPostAction: 'save',
|
||||||
|
|
@ -134,7 +134,7 @@ describe('Draft saving', () => {
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
const store = useSyncConfigStore()
|
const store = useMergedConfigStore()
|
||||||
store.mergedConfig = {
|
store.mergedConfig = {
|
||||||
autoSaveDraft: false,
|
autoSaveDraft: false,
|
||||||
unsavedPostAction: 'discard',
|
unsavedPostAction: 'discard',
|
||||||
|
|
@ -156,7 +156,7 @@ describe('Draft saving', () => {
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
const store = useSyncConfigStore(createTestingPinia())
|
const store = useMergedConfigStore(createTestingPinia())
|
||||||
store.mergedConfig = {
|
store.mergedConfig = {
|
||||||
autoSaveDraft: false,
|
autoSaveDraft: false,
|
||||||
unsavedPostAction: 'confirm',
|
unsavedPostAction: 'confirm',
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ createTestingPinia()
|
||||||
|
|
||||||
import EmojiInput from 'src/components/emoji_input/emoji_input.vue'
|
import EmojiInput from 'src/components/emoji_input/emoji_input.vue'
|
||||||
|
|
||||||
import { useSyncConfigStore } from 'src/stores/sync_config.js'
|
import { useMergedConfigStore } from 'src/stores/merged_config.js'
|
||||||
|
|
||||||
const generateInput = (value, padEmoji = true) => {
|
const generateInput = (value, padEmoji = true) => {
|
||||||
const wrapper = shallowMount(EmojiInput, {
|
const wrapper = shallowMount(EmojiInput, {
|
||||||
|
|
@ -45,7 +45,7 @@ const generateInput = (value, padEmoji = true) => {
|
||||||
|
|
||||||
describe('EmojiInput', () => {
|
describe('EmojiInput', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
const store = useSyncConfigStore(createTestingPinia())
|
const store = useMergedConfigStore(createTestingPinia())
|
||||||
store.mergedConfig = {
|
store.mergedConfig = {
|
||||||
padEmoji: true,
|
padEmoji: true,
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +113,7 @@ describe('EmojiInput', () => {
|
||||||
it('inserts string without any padding if padEmoji setting is set to false', () => {
|
it('inserts string without any padding if padEmoji setting is set to false', () => {
|
||||||
const initialString = 'Eat some spam!'
|
const initialString = 'Eat some spam!'
|
||||||
const wrapper = generateInput(initialString, false)
|
const wrapper = generateInput(initialString, false)
|
||||||
const store = useSyncConfigStore(createTestingPinia())
|
const store = useMergedConfigStore(createTestingPinia())
|
||||||
store.mergedConfig = {
|
store.mergedConfig = {
|
||||||
padEmoji: false,
|
padEmoji: false,
|
||||||
}
|
}
|
||||||
|
|
@ -152,7 +152,7 @@ describe('EmojiInput', () => {
|
||||||
it('correctly sets caret after insertion if padEmoji setting is set to false', async () => {
|
it('correctly sets caret after insertion if padEmoji setting is set to false', async () => {
|
||||||
const initialString = '1234'
|
const initialString = '1234'
|
||||||
const wrapper = generateInput(initialString, false)
|
const wrapper = generateInput(initialString, false)
|
||||||
const store = useSyncConfigStore(createTestingPinia())
|
const store = useMergedConfigStore(createTestingPinia())
|
||||||
store.mergedConfig = {
|
store.mergedConfig = {
|
||||||
padEmoji: false,
|
padEmoji: false,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,6 @@
|
||||||
import { cloneDeep } from 'lodash'
|
import { cloneDeep } from 'lodash'
|
||||||
import { createPinia, setActivePinia } from 'pinia'
|
import { createPinia, setActivePinia } from 'pinia'
|
||||||
|
|
||||||
import { CURRENT_UPDATE_COUNTER } from 'src/components/update_notification/update_notification.js'
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
_getAllFlags,
|
_getAllFlags,
|
||||||
_getRecentData,
|
_getRecentData,
|
||||||
|
|
@ -75,7 +73,7 @@ describe('The SyncConfig store', () => {
|
||||||
_version: VERSION,
|
_version: VERSION,
|
||||||
flagStorage: {
|
flagStorage: {
|
||||||
...defaultState.flagStorage,
|
...defaultState.flagStorage,
|
||||||
updateCounter: CURRENT_UPDATE_COUNTER,
|
updateCounter: 1,
|
||||||
},
|
},
|
||||||
prefsStorage: {
|
prefsStorage: {
|
||||||
...defaultState.prefsStorage,
|
...defaultState.prefsStorage,
|
||||||
|
|
@ -85,7 +83,7 @@ describe('The SyncConfig store', () => {
|
||||||
|
|
||||||
expect(store.flagStorage).to.eql({
|
expect(store.flagStorage).to.eql({
|
||||||
...defaultState.flagStorage,
|
...defaultState.flagStorage,
|
||||||
updateCounter: CURRENT_UPDATE_COUNTER,
|
updateCounter: 1,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -118,7 +116,7 @@ describe('The SyncConfig store', () => {
|
||||||
_version: VERSION,
|
_version: VERSION,
|
||||||
flagStorage: {
|
flagStorage: {
|
||||||
...defaultState.flagStorage,
|
...defaultState.flagStorage,
|
||||||
updateCounter: CURRENT_UPDATE_COUNTER,
|
updateCounter: 1,
|
||||||
},
|
},
|
||||||
prefsStorage: {
|
prefsStorage: {
|
||||||
...defaultState.prefsStorage,
|
...defaultState.prefsStorage,
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ import { createPinia, setActivePinia } from 'pinia'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
_getRecentData,
|
_getRecentData,
|
||||||
_mergePrefs,
|
_mergeHighlights,
|
||||||
_moveItemInArray,
|
_moveItemInArray,
|
||||||
useUserHighlightStore,
|
useUserHighlightStore,
|
||||||
} from 'src/stores/user_highlight.js'
|
} from 'src/stores/user_highlight.js'
|
||||||
|
|
@ -11,6 +11,15 @@ import {
|
||||||
describe('The UserHighlight store', () => {
|
describe('The UserHighlight store', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
setActivePinia(createPinia())
|
setActivePinia(createPinia())
|
||||||
|
window.vuex = {
|
||||||
|
state: {
|
||||||
|
users: {
|
||||||
|
currentUser: {
|
||||||
|
fqn: 'foo@bar.tld',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('mutations', () => {
|
describe('mutations', () => {
|
||||||
|
|
@ -20,23 +29,23 @@ describe('The UserHighlight store', () => {
|
||||||
storage: {},
|
storage: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
it('should initialize storage if none present', () => {
|
it('should initialize storage if none present', async () => {
|
||||||
const store = useUserHighlightStore()
|
const store = useUserHighlightStore()
|
||||||
store.initUserHighlight({ ...user })
|
await store.initUserHighlight({ ...user })
|
||||||
expect(store.cache._timestamp).to.be.a('number')
|
expect(store.cache._timestamp).to.be.a('number')
|
||||||
expect(store.cache.highlight).to.eql({ _journal: [] })
|
expect(store.cache.highlight).to.eql({ _journal: [] })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should initialize storage for new users if none present', () => {
|
it('should initialize storage for new users if none present', async () => {
|
||||||
const store = useUserHighlightStore()
|
const store = useUserHighlightStore()
|
||||||
store.initUserHighlight({ ...user, created_at: new Date() })
|
await store.initUserHighlight({ ...user, created_at: new Date() })
|
||||||
expect(store.cache._timestamp).to.be.a('number')
|
expect(store.cache._timestamp).to.be.a('number')
|
||||||
expect(store.cache.highlight).to.eql({ _journal: [] })
|
expect(store.cache.highlight).to.eql({ _journal: [] })
|
||||||
})
|
})
|
||||||
|
|
||||||
it('should use remote version if local missing', () => {
|
it('should use remote version if local missing', async () => {
|
||||||
const store = useUserHighlightStore()
|
const store = useUserHighlightStore()
|
||||||
store.initUserHighlight(store, user)
|
await store.initUserHighlight(store, user)
|
||||||
expect(store.cache._timestamp).to.be.a('number')
|
expect(store.cache._timestamp).to.be.a('number')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
@ -161,10 +170,10 @@ describe('The UserHighlight store', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('_mergePrefs', () => {
|
describe('_mergeHighlights', () => {
|
||||||
it('should prefer recent and apply journal to it', () => {
|
it('should prefer recent and apply journal to it', () => {
|
||||||
expect(
|
expect(
|
||||||
_mergePrefs(
|
_mergeHighlights(
|
||||||
// RECENT
|
// RECENT
|
||||||
{
|
{
|
||||||
highlight: {
|
highlight: {
|
||||||
|
|
@ -227,7 +236,7 @@ describe('The UserHighlight store', () => {
|
||||||
|
|
||||||
it('should work with objects', () => {
|
it('should work with objects', () => {
|
||||||
expect(
|
expect(
|
||||||
_mergePrefs(
|
_mergeHighlights(
|
||||||
// RECENT
|
// RECENT
|
||||||
{
|
{
|
||||||
highlight: { 'a@test.xyz': { type: 'foo' } },
|
highlight: { 'a@test.xyz': { type: 'foo' } },
|
||||||
|
|
@ -268,7 +277,7 @@ describe('The UserHighlight store', () => {
|
||||||
|
|
||||||
it('should work with unset', () => {
|
it('should work with unset', () => {
|
||||||
expect(
|
expect(
|
||||||
_mergePrefs(
|
_mergeHighlights(
|
||||||
// RECENT
|
// RECENT
|
||||||
{
|
{
|
||||||
highlight: { 'a@test.xyz': { type: 'foo' } },
|
highlight: { 'a@test.xyz': { type: 'foo' } },
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue