Merge remote-tracking branch 'origin/develop' into migrate/vuex-to-pinia
This commit is contained in:
commit
58e18d48df
489 changed files with 31167 additions and 9871 deletions
|
|
@ -74,7 +74,7 @@ describe('The serverSideStorage module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
it('should reset local timestamp to remote if contents are the same', () => {
|
||||
it.only('should reset local timestamp to remote if contents are the same', () => {
|
||||
const state = {
|
||||
...cloneDeep(defaultState),
|
||||
cache: null
|
||||
|
|
@ -176,33 +176,33 @@ describe('The serverSideStorage module', () => {
|
|||
})
|
||||
describe('_getRecentData', () => {
|
||||
it('should handle nulls correctly', () => {
|
||||
expect(_getRecentData(null, null)).to.eql({ recent: null, stale: null, needUpload: true })
|
||||
expect(_getRecentData(null, null, true)).to.eql({ recent: null, stale: null, needUpload: true })
|
||||
})
|
||||
|
||||
it('doesn\'t choke on invalid data', () => {
|
||||
expect(_getRecentData({ a: 1 }, { b: 2 })).to.eql({ recent: null, stale: null, needUpload: true })
|
||||
expect(_getRecentData({ a: 1 }, { b: 2 }, true)).to.eql({ recent: null, stale: null, needUpload: true })
|
||||
})
|
||||
|
||||
it('should prefer the valid non-null correctly, needUpload works properly', () => {
|
||||
const nonNull = { _version: VERSION, _timestamp: 1 }
|
||||
expect(_getRecentData(nonNull, null)).to.eql({ recent: nonNull, stale: null, needUpload: true })
|
||||
expect(_getRecentData(null, nonNull)).to.eql({ recent: nonNull, stale: null, needUpload: false })
|
||||
expect(_getRecentData(nonNull, null, true)).to.eql({ recent: nonNull, stale: null, needUpload: true })
|
||||
expect(_getRecentData(null, nonNull, true)).to.eql({ recent: nonNull, stale: null, needUpload: false })
|
||||
})
|
||||
|
||||
it('should prefer the one with higher timestamp', () => {
|
||||
const a = { _version: VERSION, _timestamp: 1 }
|
||||
const b = { _version: VERSION, _timestamp: 2 }
|
||||
|
||||
expect(_getRecentData(a, b)).to.eql({ recent: b, stale: a, needUpload: false })
|
||||
expect(_getRecentData(b, a)).to.eql({ recent: b, stale: a, needUpload: false })
|
||||
expect(_getRecentData(a, b, true)).to.eql({ recent: b, stale: a, needUpload: false })
|
||||
expect(_getRecentData(b, a, true)).to.eql({ recent: b, stale: a, needUpload: false })
|
||||
})
|
||||
|
||||
it('case where both are same', () => {
|
||||
const a = { _version: VERSION, _timestamp: 3 }
|
||||
const b = { _version: VERSION, _timestamp: 3 }
|
||||
|
||||
expect(_getRecentData(a, b)).to.eql({ recent: b, stale: a, needUpload: false })
|
||||
expect(_getRecentData(b, a)).to.eql({ recent: b, stale: a, needUpload: false })
|
||||
expect(_getRecentData(a, b, true)).to.eql({ recent: b, stale: a, needUpload: false })
|
||||
expect(_getRecentData(b, a, true)).to.eql({ recent: b, stale: a, needUpload: false })
|
||||
})
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -77,24 +77,6 @@ describe('Statuses module', () => {
|
|||
expect(state.timelines.public.newStatusCount).to.equal(0)
|
||||
})
|
||||
|
||||
it('removes statuses by tag on deletion', () => {
|
||||
const state = defaultState()
|
||||
const status = makeMockStatus({ id: '1' })
|
||||
const otherStatus = makeMockStatus({ id: '3' })
|
||||
status.uri = 'xxx'
|
||||
const deletion = makeMockStatus({ id: '2', type: 'deletion' })
|
||||
deletion.text = 'Dolus deleted notice {{tag:gs.smuglo.li,2016-11-18:noticeId=1038007:objectType=note}}.'
|
||||
deletion.uri = 'xxx'
|
||||
|
||||
mutations.addNewStatuses(state, { statuses: [status, otherStatus], showImmediately: true, timeline: 'public' })
|
||||
mutations.addNewStatuses(state, { statuses: [deletion], showImmediately: true, timeline: 'public' })
|
||||
|
||||
expect(state.allStatuses).to.eql([otherStatus])
|
||||
expect(state.timelines.public.statuses).to.eql([otherStatus])
|
||||
expect(state.timelines.public.visibleStatuses).to.eql([otherStatus])
|
||||
expect(state.timelines.public.maxId).to.eql('3')
|
||||
})
|
||||
|
||||
it('does not update the maxId when the noIdUpdate flag is set', () => {
|
||||
const state = defaultState()
|
||||
const status = makeMockStatus({ id: '1' })
|
||||
|
|
@ -315,62 +297,4 @@ describe('Statuses module', () => {
|
|||
expect(state.timelines.user.userId).to.eql(123)
|
||||
})
|
||||
})
|
||||
|
||||
describe('notifications', () => {
|
||||
it('removes a notification when the notice gets removed', () => {
|
||||
const user = { id: '1' }
|
||||
const state = defaultState()
|
||||
const status = makeMockStatus({ id: '1' })
|
||||
const otherStatus = makeMockStatus({ id: '3' })
|
||||
const mentionedStatus = makeMockStatus({ id: '2' })
|
||||
mentionedStatus.attentions = [user]
|
||||
mentionedStatus.uri = 'xxx'
|
||||
otherStatus.attentions = [user]
|
||||
|
||||
const deletion = makeMockStatus({ id: '4', type: 'deletion' })
|
||||
deletion.text = 'Dolus deleted notice {{tag:gs.smuglo.li,2016-11-18:noticeId=1038007:objectType=note}}.'
|
||||
deletion.uri = 'xxx'
|
||||
const newNotificationSideEffects = () => {}
|
||||
mutations.addNewStatuses(state, { statuses: [status, otherStatus], user })
|
||||
mutations.addNewNotifications(
|
||||
state,
|
||||
{
|
||||
notifications: [{
|
||||
from_profile: { id: '2' },
|
||||
id: '998',
|
||||
type: 'mention',
|
||||
status: otherStatus,
|
||||
action: otherStatus,
|
||||
seen: false
|
||||
}],
|
||||
newNotificationSideEffects
|
||||
})
|
||||
|
||||
expect(state.notifications.data.length).to.eql(1)
|
||||
mutations.addNewNotifications(
|
||||
state,
|
||||
{
|
||||
notifications: [{
|
||||
from_profile: { id: '2' },
|
||||
id: '999',
|
||||
type: 'mention',
|
||||
status: mentionedStatus,
|
||||
action: mentionedStatus,
|
||||
seen: false
|
||||
}],
|
||||
newNotificationSideEffects
|
||||
})
|
||||
|
||||
mutations.addNewStatuses(state, { statuses: [mentionedStatus], user })
|
||||
expect(state.allStatuses.length).to.eql(3)
|
||||
expect(state.notifications.data.length).to.eql(2)
|
||||
expect(state.notifications.data[1].status).to.eql(mentionedStatus)
|
||||
expect(state.notifications.data[1].action).to.eql(mentionedStatus)
|
||||
expect(state.notifications.data[1].type).to.eql('mention')
|
||||
|
||||
mutations.addNewStatuses(state, { statuses: [deletion], user })
|
||||
expect(state.allStatuses.length).to.eql(2)
|
||||
expect(state.notifications.data.length).to.eql(1)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue