diff --git a/src/api/__mocks__/users.js b/src/api/__mocks__/users.js index b5aca6a1..31657293 100644 --- a/src/api/__mocks__/users.js +++ b/src/api/__mocks__/users.js @@ -4,6 +4,10 @@ export let users = [ { active: false, deactivated: true, id: 'abc', nickname: 'john', local: true, external: false, roles: { admin: false, moderator: false }, tags: ['strip_media'] } ] +const userProfile = { avatar: 'avatar.jpg', display_name: 'Allis', nickname: 'allis', id: '2', tags: [], roles: { admin: true, moderator: false }, local: true, external: false } + +const userStatuses = [] + const filterUsers = (str) => { const filters = str.split(',').filter(item => item.length > 0) if (filters.length === 0) { @@ -20,6 +24,10 @@ const filterUsers = (str) => { return applyFilters([], filters, users) } +export async function fetchUser(id, authHost, token) { + return Promise.resolve({ data: userProfile }) +} + export async function fetchUsers(filters, authHost, token, page = 1) { const filteredUsers = filterUsers(filters) return Promise.resolve({ data: { @@ -29,6 +37,10 @@ export async function fetchUsers(filters, authHost, token, page = 1) { }}) } +export async function fetchUserStatuses(id, authHost, godmode, token) { + return Promise.resolve({ data: userStatuses }) +} + export async function getPasswordResetToken(nickname, authHost, token) { return Promise.resolve({ data: { token: 'g05lxnBJQnL', link: 'http://url/api/pleroma/password_reset/g05lxnBJQnL' }}) } diff --git a/src/lang/en.js b/src/lang/en.js index d4893455..13c30906 100644 --- a/src/lang/en.js +++ b/src/lang/en.js @@ -236,11 +236,17 @@ export default { tags: 'Tags', moderator: 'Moderator', admin: 'Admin', - local: 'Local', + local: 'local', + external: 'external', + localUppercase: 'Local', nickname: 'Nickname', - deactivated: 'Deactivated', recentStatuses: 'Recent Statues', - showPrivateStatuses: 'Show private statuses' + showPrivateStatuses: 'Show private statuses', + roles: 'Roles', + activeUppercase: 'Active', + active: 'active', + deactivated: 'deactivated', + noStatuses: 'No statuses to show' }, usersFilter: { inputPlaceholder: 'Select filter', diff --git a/src/views/status/Status.vue b/src/views/status/Status.vue index b33744b1..60fbb610 100644 --- a/src/views/status/Status.vue +++ b/src/views/status/Status.vue @@ -185,54 +185,56 @@ export default { diff --git a/test/views/users/show.test.js b/test/views/users/show.test.js new file mode 100644 index 00000000..b57501c5 --- /dev/null +++ b/test/views/users/show.test.js @@ -0,0 +1,48 @@ +import Vuex from 'vuex' +import { mount, createLocalVue, config } from '@vue/test-utils' +import flushPromises from 'flush-promises' +import Element from 'element-ui' +import UsersShow from '@/views/users/show' +import storeConfig from './store.conf' +import { cloneDeep } from 'lodash' + +config.mocks["$t"] = () => {} + +const localVue = createLocalVue() +localVue.use(Vuex) +localVue.use(Element) + +const $route = { + params: { + id: '2' + } +} + +jest.mock('@/api/nodeInfo') +jest.mock('@/api/users') + +describe('Search and filter users', () => { + let store + + beforeEach(() => { + store = new Vuex.Store(cloneDeep(storeConfig)) + }) + + it('fetches user profile', async (done) => { + const wrapper = mount(UsersShow, { + store, + localVue, + sync: false, + stubs: ['router-link'], + mocks: { + $route + } + }) + + await flushPromises() + expect(wrapper.find('.user-profile-card').isVisible()).toBe(true) + expect(store.state.userProfile.user.nickname).toBe('allis') + expect(store.state.userProfile.user.roles.admin).toBe(true) + done() + }) +}) diff --git a/test/views/users/store.conf.js b/test/views/users/store.conf.js index 77e2b7c8..89a7622a 100644 --- a/test/views/users/store.conf.js +++ b/test/views/users/store.conf.js @@ -1,5 +1,6 @@ import app from '@/store/modules/app' import user from '@/store/modules/user' +import userProfile from '@/store/modules/userProfile' import users from '@/store/modules/users' import getters from '@/store/getters' @@ -7,6 +8,7 @@ export default { modules: { app, user, + userProfile, users }, getters