2022-03-22 16:56:39 +00:00
|
|
|
import { mount } from '@vue/test-utils'
|
|
|
|
import { createStore } from 'vuex'
|
2018-12-15 03:16:44 +00:00
|
|
|
import UserProfile from 'src/components/user_profile/user_profile.vue'
|
|
|
|
import backendInteractorService from 'src/services/backend_interactor_service/backend_interactor_service.js'
|
2018-12-31 01:57:22 +00:00
|
|
|
import { getters } from 'src/modules/users.js'
|
2018-12-15 03:16:44 +00:00
|
|
|
|
|
|
|
const mutations = {
|
2020-11-10 12:28:10 +00:00
|
|
|
clearTimeline: () => {}
|
2018-12-15 03:16:44 +00:00
|
|
|
}
|
|
|
|
|
2019-03-11 00:17:49 +00:00
|
|
|
const actions = {
|
|
|
|
fetchUser: () => {},
|
|
|
|
fetchUserByScreenName: () => {}
|
|
|
|
}
|
|
|
|
|
2018-12-31 01:57:22 +00:00
|
|
|
const testGetters = {
|
2019-10-06 20:28:30 +00:00
|
|
|
findUser: state => getters.findUser(state.users),
|
2022-08-10 16:17:18 +00:00
|
|
|
findUserByName: state => getters.findUserByName(state.users),
|
2020-04-24 15:53:17 +00:00
|
|
|
relationship: state => getters.relationship(state.users),
|
2019-10-06 20:28:30 +00:00
|
|
|
mergedConfig: state => ({
|
|
|
|
colors: '',
|
|
|
|
highlight: {},
|
|
|
|
customTheme: {
|
|
|
|
colors: []
|
|
|
|
}
|
|
|
|
})
|
2018-12-31 01:57:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const localUser = {
|
|
|
|
id: 100,
|
|
|
|
is_local: true,
|
2021-02-26 14:37:46 +00:00
|
|
|
screen_name: 'testUser',
|
|
|
|
screen_name_ui: 'testUser'
|
2018-12-31 01:57:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const extUser = {
|
|
|
|
id: 100,
|
|
|
|
is_local: false,
|
2021-02-26 14:37:46 +00:00
|
|
|
screen_name: 'testUser@test.instance',
|
|
|
|
screen_name_ui: 'testUser@test.instance'
|
2018-12-31 01:57:22 +00:00
|
|
|
}
|
|
|
|
|
2022-03-22 16:56:39 +00:00
|
|
|
const externalProfileStore = createStore({
|
2018-12-15 03:16:44 +00:00
|
|
|
mutations,
|
2019-03-11 00:17:49 +00:00
|
|
|
actions,
|
2018-12-31 01:57:22 +00:00
|
|
|
getters: testGetters,
|
2018-12-15 03:16:44 +00:00
|
|
|
state: {
|
|
|
|
api: {
|
2019-04-28 17:46:01 +00:00
|
|
|
fetchers: {},
|
2018-12-15 03:16:44 +00:00
|
|
|
backendInteractor: backendInteractorService('')
|
|
|
|
},
|
2018-12-16 23:45:40 +00:00
|
|
|
interface: {
|
|
|
|
browserSupport: ''
|
|
|
|
},
|
2018-12-15 03:16:44 +00:00
|
|
|
instance: {
|
|
|
|
hideUserStats: true
|
|
|
|
},
|
|
|
|
statuses: {
|
|
|
|
timelines: {
|
|
|
|
user: {
|
|
|
|
statuses: [],
|
|
|
|
statusesObject: {},
|
|
|
|
faves: [],
|
|
|
|
visibleStatuses: [],
|
|
|
|
visibleStatusesObject: {},
|
|
|
|
newStatusCount: 0,
|
|
|
|
maxId: 0,
|
|
|
|
minVisibleId: 0,
|
|
|
|
loading: false,
|
|
|
|
followers: [],
|
|
|
|
friends: [],
|
|
|
|
viewing: 'statuses',
|
2018-12-31 01:57:22 +00:00
|
|
|
userId: 100,
|
2018-12-15 03:16:44 +00:00
|
|
|
flushMarker: 0
|
2019-01-26 13:51:07 +00:00
|
|
|
},
|
|
|
|
media: {
|
|
|
|
statuses: [],
|
|
|
|
statusesObject: {},
|
|
|
|
faves: [],
|
|
|
|
visibleStatuses: [],
|
|
|
|
visibleStatusesObject: {},
|
|
|
|
newStatusCount: 0,
|
|
|
|
maxId: 0,
|
|
|
|
minVisibleId: 0,
|
|
|
|
loading: false,
|
|
|
|
followers: [],
|
|
|
|
friends: [],
|
|
|
|
viewing: 'statuses',
|
|
|
|
userId: 100,
|
|
|
|
flushMarker: 0
|
2018-12-15 03:16:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
users: {
|
|
|
|
currentUser: {
|
|
|
|
credentials: ''
|
|
|
|
},
|
2019-03-11 00:17:49 +00:00
|
|
|
usersObject: { 100: extUser },
|
2022-08-10 16:17:18 +00:00
|
|
|
usersByNameObject: {},
|
2020-04-21 21:07:01 +00:00
|
|
|
users: [extUser],
|
|
|
|
relationships: {}
|
2018-12-15 03:16:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-03-22 16:56:39 +00:00
|
|
|
const localProfileStore = createStore({
|
2018-12-16 22:53:21 +00:00
|
|
|
mutations,
|
2019-03-11 00:17:49 +00:00
|
|
|
actions,
|
2018-12-31 01:57:22 +00:00
|
|
|
getters: testGetters,
|
2018-12-16 22:53:21 +00:00
|
|
|
state: {
|
|
|
|
api: {
|
2019-04-28 17:46:01 +00:00
|
|
|
fetchers: {},
|
2018-12-16 22:53:21 +00:00
|
|
|
backendInteractor: backendInteractorService('')
|
|
|
|
},
|
2018-12-16 23:45:40 +00:00
|
|
|
interface: {
|
|
|
|
browserSupport: ''
|
|
|
|
},
|
2018-12-16 22:53:21 +00:00
|
|
|
config: {
|
|
|
|
colors: '',
|
2018-12-16 23:45:40 +00:00
|
|
|
highlight: {},
|
|
|
|
customTheme: {
|
|
|
|
colors: []
|
|
|
|
}
|
2018-12-16 22:53:21 +00:00
|
|
|
},
|
|
|
|
instance: {
|
|
|
|
hideUserStats: true
|
|
|
|
},
|
|
|
|
statuses: {
|
|
|
|
timelines: {
|
|
|
|
user: {
|
|
|
|
statuses: [],
|
|
|
|
statusesObject: {},
|
|
|
|
faves: [],
|
|
|
|
visibleStatuses: [],
|
|
|
|
visibleStatusesObject: {},
|
|
|
|
newStatusCount: 0,
|
|
|
|
maxId: 0,
|
|
|
|
minVisibleId: 0,
|
|
|
|
loading: false,
|
|
|
|
followers: [],
|
|
|
|
friends: [],
|
2019-01-26 13:51:07 +00:00
|
|
|
viewing: 'statuses',
|
|
|
|
userId: 100,
|
|
|
|
flushMarker: 0
|
|
|
|
},
|
|
|
|
media: {
|
|
|
|
statuses: [],
|
|
|
|
statusesObject: {},
|
|
|
|
faves: [],
|
|
|
|
visibleStatuses: [],
|
|
|
|
visibleStatusesObject: {},
|
|
|
|
newStatusCount: 0,
|
|
|
|
maxId: 0,
|
|
|
|
minVisibleId: 0,
|
|
|
|
loading: false,
|
|
|
|
followers: [],
|
|
|
|
friends: [],
|
2018-12-16 22:53:21 +00:00
|
|
|
viewing: 'statuses',
|
2018-12-31 01:57:22 +00:00
|
|
|
userId: 100,
|
2018-12-16 22:53:21 +00:00
|
|
|
flushMarker: 0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
users: {
|
|
|
|
currentUser: {
|
|
|
|
credentials: ''
|
|
|
|
},
|
2022-08-10 16:17:18 +00:00
|
|
|
usersObject: { 100: localUser },
|
|
|
|
usersByNameObject: { testuser: localUser },
|
2020-04-21 21:07:01 +00:00
|
|
|
users: [localUser],
|
|
|
|
relationships: {}
|
2018-12-16 22:53:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2022-03-22 16:56:39 +00:00
|
|
|
// https://github.com/vuejs/test-utils/issues/1382
|
|
|
|
describe.skip('UserProfile', () => {
|
2018-12-16 22:53:21 +00:00
|
|
|
it('renders external profile', () => {
|
2018-12-15 03:16:44 +00:00
|
|
|
const wrapper = mount(UserProfile, {
|
2022-03-22 16:56:39 +00:00
|
|
|
global: {
|
2022-07-31 09:35:48 +00:00
|
|
|
plugins: [externalProfileStore],
|
2022-03-22 16:56:39 +00:00
|
|
|
mocks: {
|
|
|
|
$route: {
|
|
|
|
params: { id: 100 },
|
|
|
|
name: 'external-user-profile'
|
|
|
|
},
|
|
|
|
$t: (msg) => msg
|
|
|
|
}
|
2018-12-15 03:16:44 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2018-12-31 01:57:22 +00:00
|
|
|
expect(wrapper.find('.user-screen-name').text()).to.eql('@testUser@test.instance')
|
2018-12-15 03:16:44 +00:00
|
|
|
})
|
2018-12-16 22:53:21 +00:00
|
|
|
|
|
|
|
it('renders local profile', () => {
|
|
|
|
const wrapper = mount(UserProfile, {
|
2022-03-22 16:56:39 +00:00
|
|
|
global: {
|
2022-07-31 09:35:48 +00:00
|
|
|
plugins: [localProfileStore],
|
2022-03-22 16:56:39 +00:00
|
|
|
mocks: {
|
|
|
|
$route: {
|
|
|
|
params: { name: 'testUser' },
|
|
|
|
name: 'user-profile'
|
|
|
|
},
|
|
|
|
$t: (msg) => msg
|
|
|
|
}
|
2018-12-16 22:53:21 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2018-12-31 01:57:22 +00:00
|
|
|
expect(wrapper.find('.user-screen-name').text()).to.eql('@testUser')
|
2018-12-16 22:53:21 +00:00
|
|
|
})
|
2018-12-15 03:16:44 +00:00
|
|
|
})
|