Merge branch 'mastoapi/user-stuff' into shigusegubu
* mastoapi/user-stuff: whoops レインせんぱいにサンキュー fix embedded relationship card parsing actually use embedded relationship if it's present instead of filtering nulls, let's just not have them in the first place fixed tests, review fixes, now storing local users with downcase screen name for better compatibility fix error some test fixes, disabled one test for now since logic now is even more async in general attempt at fixing switching to user TL fix reply-to marker, also whoops console log revert some stuff, turns out it's actually breaking. Fixed some local user things Since BE doesn't support fetching user by screen name over MastoAPI we'll gonna just fetching it over QvitterAPI real quick :DDDDDDDDD switch to mastoapi for user timeline Partially transitioned user data to MastoAPI. Added support for fetching relationship data. Upgraded code to be more resilient to nulls caused by missing data in either APIs
This commit is contained in:
commit
c0908e238f
13 changed files with 153 additions and 107 deletions
|
|
@ -12,9 +12,13 @@ const mutations = {
|
|||
setError: () => {}
|
||||
}
|
||||
|
||||
const actions = {
|
||||
fetchUser: () => {},
|
||||
fetchUserByScreenName: () => {}
|
||||
}
|
||||
|
||||
const testGetters = {
|
||||
userByName: state => getters.userByName(state.users),
|
||||
userById: state => getters.userById(state.users)
|
||||
findUser: state => getters.findUser(state.users)
|
||||
}
|
||||
|
||||
const localUser = {
|
||||
|
|
@ -31,6 +35,7 @@ const extUser = {
|
|||
|
||||
const externalProfileStore = new Vuex.Store({
|
||||
mutations,
|
||||
actions,
|
||||
getters: testGetters,
|
||||
state: {
|
||||
api: {
|
||||
|
|
@ -89,7 +94,7 @@ const externalProfileStore = new Vuex.Store({
|
|||
currentUser: {
|
||||
credentials: ''
|
||||
},
|
||||
usersObject: [extUser],
|
||||
usersObject: { 100: extUser },
|
||||
users: [extUser]
|
||||
}
|
||||
}
|
||||
|
|
@ -97,6 +102,7 @@ const externalProfileStore = new Vuex.Store({
|
|||
|
||||
const localProfileStore = new Vuex.Store({
|
||||
mutations,
|
||||
actions,
|
||||
getters: testGetters,
|
||||
state: {
|
||||
api: {
|
||||
|
|
@ -155,7 +161,7 @@ const localProfileStore = new Vuex.Store({
|
|||
currentUser: {
|
||||
credentials: ''
|
||||
},
|
||||
usersObject: [localUser],
|
||||
usersObject: { 100: localUser, 'testuser': localUser },
|
||||
users: [localUser]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,40 +34,31 @@ describe('The users module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('getUserByName', () => {
|
||||
describe('findUser', () => {
|
||||
it('returns user with matching screen_name', () => {
|
||||
const user = { screen_name: 'Guy', id: '1' }
|
||||
const state = {
|
||||
users: [
|
||||
{ screen_name: 'Guy', id: '1' }
|
||||
]
|
||||
usersObject: {
|
||||
1: user,
|
||||
guy: user
|
||||
}
|
||||
}
|
||||
const name = 'Guy'
|
||||
const expected = { screen_name: 'Guy', id: '1' }
|
||||
expect(getters.userByName(state)(name)).to.eql(expected)
|
||||
expect(getters.findUser(state)(name)).to.eql(expected)
|
||||
})
|
||||
|
||||
it('returns user with matching screen_name with different case', () => {
|
||||
const state = {
|
||||
users: [
|
||||
{ screen_name: 'guy', id: '1' }
|
||||
]
|
||||
}
|
||||
const name = 'Guy'
|
||||
const expected = { screen_name: 'guy', id: '1' }
|
||||
expect(getters.userByName(state)(name)).to.eql(expected)
|
||||
})
|
||||
})
|
||||
|
||||
describe('getUserById', () => {
|
||||
it('returns user with matching id', () => {
|
||||
const user = { screen_name: 'Guy', id: '1' }
|
||||
const state = {
|
||||
users: [
|
||||
{ screen_name: 'Guy', id: '1' }
|
||||
]
|
||||
usersObject: {
|
||||
1: user,
|
||||
guy: user
|
||||
}
|
||||
}
|
||||
const id = '1'
|
||||
const expected = { screen_name: 'Guy', id: '1' }
|
||||
expect(getters.userById(state)(id)).to.eql(expected)
|
||||
expect(getters.findUser(state)(id)).to.eql(expected)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue