diff --git a/src/components/base/form/TextEditor/Custom/Color/ColorMenuBar.vue b/src/components/base/form/TextEditor/Custom/Color/ColorMenuBar.vue deleted file mode 100644 index 95e117572..000000000 --- a/src/components/base/form/TextEditor/Custom/Color/ColorMenuBar.vue +++ /dev/null @@ -1,63 +0,0 @@ - - - - - diff --git a/src/components/base/navigation/ListPaginator.vue b/src/components/base/navigation/ListPaginator.vue deleted file mode 100644 index 836ca8b2a..000000000 --- a/src/components/base/navigation/ListPaginator.vue +++ /dev/null @@ -1,68 +0,0 @@ - - - diff --git a/src/components/onboarding/CompleteProfile/CompleteProfileStep1.vue b/src/components/onboarding/CompleteProfile/CompleteProfileStep1.vue index a30b057af..26255c39a 100644 --- a/src/components/onboarding/CompleteProfile/CompleteProfileStep1.vue +++ b/src/components/onboarding/CompleteProfile/CompleteProfileStep1.vue @@ -161,13 +161,7 @@ :title="$t('profile.drawer_title')" @close="exempleToShow = null" > - + @@ -185,9 +179,9 @@ import { usePatatoids } from '~/composables/usePatatoids' import ProfileEditBlock from '@/components/onboarding/CompleteProfile/ProfileEditBlock.vue' import TipTapEditor from '@/components/base/form/TextEditor/TipTapEditor.vue' +import UserProfilePreview from '@/components/people/UserProfilePreview.vue' import { NULL_CONTENT, SDGS, VALID_NAME_REGEX } from '~/functs/constants' import LoaderSimple from '@/components/base/loader/LoaderSimple.vue' -import UserProfileV2 from '@/components/people/UserProfileV2.vue' import { pictureApiToImageSizes } from '~/functs/imageSizesUtils' import IconImage from '@/components/base/media/IconImage.vue' import BaseDrawer from '@/components/base/BaseDrawer.vue' @@ -204,7 +198,7 @@ export default { ProfileEditBlock, TipTapEditor, BaseDrawer, - UserProfileV2, + UserProfilePreview, LoaderSimple, }, diff --git a/src/components/people/FullProfile/ProfileHeaderV2.vue b/src/components/people/FullProfile/ProfileHeaderV2.vue deleted file mode 100644 index f6d89dd30..000000000 --- a/src/components/people/FullProfile/ProfileHeaderV2.vue +++ /dev/null @@ -1,274 +0,0 @@ - - - - - diff --git a/src/components/people/UserDescriptions.vue b/src/components/people/UserDescriptions.vue deleted file mode 100644 index 5fb71c281..000000000 --- a/src/components/people/UserDescriptions.vue +++ /dev/null @@ -1,92 +0,0 @@ - - - - - diff --git a/src/components/people/UserProfile/UserProjectList.vue b/src/components/people/UserProfile/UserProjectList.vue deleted file mode 100644 index 897aca908..000000000 --- a/src/components/people/UserProfile/UserProjectList.vue +++ /dev/null @@ -1,77 +0,0 @@ - - - - - diff --git a/src/components/people/UserProfile/UserProjectsSearch.vue b/src/components/people/UserProfile/UserProjectsSearch.vue deleted file mode 100644 index f254f0789..000000000 --- a/src/components/people/UserProfile/UserProjectsSearch.vue +++ /dev/null @@ -1,145 +0,0 @@ - - - diff --git a/src/components/people/UserProfilePreview.vue b/src/components/people/UserProfilePreview.vue new file mode 100644 index 000000000..3a95add2c --- /dev/null +++ b/src/components/people/UserProfilePreview.vue @@ -0,0 +1,125 @@ + + + + + diff --git a/src/components/people/UserProfileV2.vue b/src/components/people/UserProfileV2.vue deleted file mode 100644 index 6627d5f26..000000000 --- a/src/components/people/UserProfileV2.vue +++ /dev/null @@ -1,655 +0,0 @@ - - - - - diff --git a/src/components/people/skill/SkillItem.vue b/src/components/people/skill/SkillItem.vue deleted file mode 100644 index 7e3c7ffeb..000000000 --- a/src/components/people/skill/SkillItem.vue +++ /dev/null @@ -1,144 +0,0 @@ - - - diff --git a/src/components/people/skill/SkillItemFull.vue b/src/components/people/skill/SkillItemFull.vue deleted file mode 100644 index 815f690e9..000000000 --- a/src/components/people/skill/SkillItemFull.vue +++ /dev/null @@ -1,390 +0,0 @@ - - - - diff --git a/src/components/people/skill/SkillSummary.vue b/src/components/people/skill/SkillSummary.vue deleted file mode 100644 index 4ef21bcd8..000000000 --- a/src/components/people/skill/SkillSummary.vue +++ /dev/null @@ -1,127 +0,0 @@ - - - - - diff --git a/src/components/people/skill/SkillsEditDrawer.vue b/src/components/people/skill/SkillsEditDrawer.vue deleted file mode 100644 index cf27564b1..000000000 --- a/src/components/people/skill/SkillsEditDrawer.vue +++ /dev/null @@ -1,330 +0,0 @@ - - - - diff --git a/src/components/people/skill/UserSkillsFull.vue b/src/components/people/skill/UserSkillsFull.vue deleted file mode 100644 index cfe5eb214..000000000 --- a/src/components/people/skill/UserSkillsFull.vue +++ /dev/null @@ -1,112 +0,0 @@ - - - - - diff --git a/src/components/profile/modules/Privacy/PrivacyField.vue b/src/components/profile/modules/Privacy/PrivacyField.vue index dbaa6e8f3..d104fb1bf 100644 --- a/src/components/profile/modules/Privacy/PrivacyField.vue +++ b/src/components/profile/modules/Privacy/PrivacyField.vue @@ -26,7 +26,7 @@ const modelValue = defineModel() diff --git a/src/components/resources/ResourceCount.vue b/src/components/resources/ResourceCount.vue deleted file mode 100644 index 1fa564a3d..000000000 --- a/src/components/resources/ResourceCount.vue +++ /dev/null @@ -1,87 +0,0 @@ - - - - - diff --git a/src/components/resources/ResourceDrawer.vue b/src/components/resources/ResourceDrawer.vue deleted file mode 100644 index 7148b4a52..000000000 --- a/src/components/resources/ResourceDrawer.vue +++ /dev/null @@ -1,454 +0,0 @@ - - - - - - - diff --git a/src/components/resources/ResourcesRecap.vue b/src/components/resources/ResourcesRecap.vue deleted file mode 100644 index bf7787055..000000000 --- a/src/components/resources/ResourcesRecap.vue +++ /dev/null @@ -1,67 +0,0 @@ - - - - - diff --git a/src/components/resources/ResourcesTab.vue b/src/components/resources/ResourcesTab.vue deleted file mode 100644 index 38859ea0e..000000000 --- a/src/components/resources/ResourcesTab.vue +++ /dev/null @@ -1,215 +0,0 @@ - - - - - diff --git a/src/pages/MentorshipRespondPage/MentorshipRespondPage.vue b/src/pages/MentorshipRespondPage/MentorshipRespondPage.vue index c2c210632..5989d71fc 100644 --- a/src/pages/MentorshipRespondPage/MentorshipRespondPage.vue +++ b/src/pages/MentorshipRespondPage/MentorshipRespondPage.vue @@ -69,12 +69,10 @@ :title="$t('profile.drawer_title')" @close="profileIsOpened = false" > - diff --git a/src/pages/UserProfilePageV2/Tabs/ProfileBioEditTab.vue b/src/pages/UserProfilePageV2/Tabs/ProfileBioEditTab.vue deleted file mode 100644 index ed6e77876..000000000 --- a/src/pages/UserProfilePageV2/Tabs/ProfileBioEditTab.vue +++ /dev/null @@ -1,141 +0,0 @@ - - - - diff --git a/src/pages/UserProfilePageV2/Tabs/ProfileBioTab.vue b/src/pages/UserProfilePageV2/Tabs/ProfileBioTab.vue deleted file mode 100644 index f8feab47f..000000000 --- a/src/pages/UserProfilePageV2/Tabs/ProfileBioTab.vue +++ /dev/null @@ -1,94 +0,0 @@ - - - - - diff --git a/src/pages/UserProfilePageV2/Tabs/ProfileGeneralEditTab.vue b/src/pages/UserProfilePageV2/Tabs/ProfileGeneralEditTab.vue deleted file mode 100644 index 79b694d4b..000000000 --- a/src/pages/UserProfilePageV2/Tabs/ProfileGeneralEditTab.vue +++ /dev/null @@ -1,497 +0,0 @@ - - - diff --git a/src/pages/UserProfilePageV2/Tabs/ProfileGroupsEditTab.vue b/src/pages/UserProfilePageV2/Tabs/ProfileGroupsEditTab.vue deleted file mode 100644 index 9cf700c27..000000000 --- a/src/pages/UserProfilePageV2/Tabs/ProfileGroupsEditTab.vue +++ /dev/null @@ -1,98 +0,0 @@ - - - diff --git a/src/pages/UserProfilePageV2/Tabs/ProfileGroupsTab.vue b/src/pages/UserProfilePageV2/Tabs/ProfileGroupsTab.vue deleted file mode 100644 index cce156462..000000000 --- a/src/pages/UserProfilePageV2/Tabs/ProfileGroupsTab.vue +++ /dev/null @@ -1,130 +0,0 @@ - - - - - diff --git a/src/pages/UserProfilePageV2/Tabs/ProfilePrivacyEditTab.vue b/src/pages/UserProfilePageV2/Tabs/ProfilePrivacyEditTab.vue deleted file mode 100644 index a6428d626..000000000 --- a/src/pages/UserProfilePageV2/Tabs/ProfilePrivacyEditTab.vue +++ /dev/null @@ -1,364 +0,0 @@ - - - - diff --git a/src/pages/UserProfilePageV2/Tabs/ProfileProjectTab.vue b/src/pages/UserProfilePageV2/Tabs/ProfileProjectTab.vue deleted file mode 100644 index 1846a577c..000000000 --- a/src/pages/UserProfilePageV2/Tabs/ProfileProjectTab.vue +++ /dev/null @@ -1,180 +0,0 @@ - - - - - diff --git a/src/pages/UserProfilePageV2/Tabs/ProfileProjectsEditTab.vue b/src/pages/UserProfilePageV2/Tabs/ProfileProjectsEditTab.vue deleted file mode 100644 index 4b0870dfb..000000000 --- a/src/pages/UserProfilePageV2/Tabs/ProfileProjectsEditTab.vue +++ /dev/null @@ -1,171 +0,0 @@ - - - - - diff --git a/src/pages/UserProfilePageV2/Tabs/ProfileResourcesTab.vue b/src/pages/UserProfilePageV2/Tabs/ProfileResourcesTab.vue deleted file mode 100644 index a7c8b107a..000000000 --- a/src/pages/UserProfilePageV2/Tabs/ProfileResourcesTab.vue +++ /dev/null @@ -1,101 +0,0 @@ - - - diff --git a/src/pages/UserProfilePageV2/Tabs/ProfileSkillTab.vue b/src/pages/UserProfilePageV2/Tabs/ProfileSkillTab.vue deleted file mode 100644 index 3284601f2..000000000 --- a/src/pages/UserProfilePageV2/Tabs/ProfileSkillTab.vue +++ /dev/null @@ -1,101 +0,0 @@ - - - - - diff --git a/src/pages/UserProfilePageV2/Tabs/ProfileSkillsEditTab.vue b/src/pages/UserProfilePageV2/Tabs/ProfileSkillsEditTab.vue deleted file mode 100644 index d1b5bbb9a..000000000 --- a/src/pages/UserProfilePageV2/Tabs/ProfileSkillsEditTab.vue +++ /dev/null @@ -1,355 +0,0 @@ - - - - - diff --git a/src/pages/UserProfilePageV2/Tabs/ProfileSummaryTab.vue b/src/pages/UserProfilePageV2/Tabs/ProfileSummaryTab.vue deleted file mode 100644 index c19524425..000000000 --- a/src/pages/UserProfilePageV2/Tabs/ProfileSummaryTab.vue +++ /dev/null @@ -1,243 +0,0 @@ - - - - - diff --git a/src/pages/UserProfilePageV2/UserProfilePage.vue b/src/pages/UserProfilePageV2/UserProfilePage.vue deleted file mode 100644 index e5335a206..000000000 --- a/src/pages/UserProfilePageV2/UserProfilePage.vue +++ /dev/null @@ -1,60 +0,0 @@ - - - - diff --git a/tests/unit/components/people/UserProfile/UserProjectList.spec.ts b/tests/unit/components/people/UserProfile/UserProjectList.spec.ts deleted file mode 100644 index d0fa53f5b..000000000 --- a/tests/unit/components/people/UserProfile/UserProjectList.spec.ts +++ /dev/null @@ -1,22 +0,0 @@ -import UserProjectList from '~/components/people/UserProfile/UserProjectList.vue' -import { TranslatedProjectFactory } from '~~/tests/factories/project.factory' -import type { OrganizationOutput } from 'shared-projects-frontend/models' -import useOrganizationsStore from '~/stores/useOrganizations' -import { lpiShallowMount } from '~~/tests/helpers/LpiMount' -import { beforeEach, describe, expect, it } from 'vitest' -import pinia from '~/stores' - -describe('UserProjectList.vue', () => { - beforeEach(() => { - const organizationsStore = useOrganizationsStore(pinia) - organizationsStore._current = { code: 'FOOBAR' } as unknown as OrganizationOutput - }) - - it('should render UserProjectList component', () => { - const props = { - projects: TranslatedProjectFactory.generateMany(10), - } - const wrapper = lpiShallowMount(UserProjectList, { props }) - expect(wrapper.exists()).toBe(true) - }) -}) diff --git a/tests/unit/components/people/UserProfileV2.spec.ts b/tests/unit/components/people/UserProfileV2.spec.ts index 38d1e373f..86e94210b 100644 --- a/tests/unit/components/people/UserProfileV2.spec.ts +++ b/tests/unit/components/people/UserProfileV2.spec.ts @@ -1,4 +1,4 @@ -import UserProfileV2 from '~/components/people/UserProfileV2.vue' +import UserProfilePreview from '~/components/people/UserProfilePreview.vue' import { UserFactory } from '~~/tests/factories/user.factory' import { lpiShallowMount } from '~~/tests/helpers/LpiMount' import { flushPromises } from '@vue/test-utils' @@ -26,7 +26,7 @@ const buildParams = (userId: number, showPageLink: boolean) => ({ }, }) -describe('UserProfileV2', () => { +describe('UserProfilePreview', () => { let usersStore const user = UserFactory.generate() const user2 = UserFactory.generate() @@ -44,8 +44,8 @@ describe('UserProfileV2', () => { usersStore.userFromApi = usersStore.userFromToken = user }) - it('should render UserProfileV2 component', () => { - const wrapper = lpiShallowMount(UserProfileV2, buildParams(user.id, false)) + it('should render UserProfilePreview component', () => { + const wrapper = lpiShallowMount(UserProfilePreview, buildParams(user.id, false)) expect(wrapper.exists()).toBeTruthy() }) @@ -54,56 +54,9 @@ describe('UserProfileV2', () => { registerEndpoint(`user/123333/`, () => { throw createError({ statusCode: 404 }) }) - const wrapper = lpiShallowMount(UserProfileV2, buildParams(123333, false)) + const wrapper = lpiShallowMount(UserProfilePreview, buildParams(123333, false)) await flushPromises() expect(wrapper.emitted()['user-not-found']).toBeTruthy() }) - - it('should see that current user is the logged one', async () => { - const wrapper = lpiShallowMount(UserProfileV2, buildParams(null, false)) - const vm: any = wrapper.vm - await flushPromises() - expect(vm.isSelf).toBeTruthy() - }) - - it('should see that current user is not the logged one', async () => { - usersStore.userFromApi = usersStore.userFromToken = user2 - - const wrapper = lpiShallowMount(UserProfileV2, buildParams(user.id, false)) - const vm: any = wrapper.vm - await flushPromises() - expect(vm.isSelf).toBeFalsy() - }) - - it('should allow edition of self profile', async () => { - const wrapper = lpiShallowMount(UserProfileV2, buildParams(null, false)) - const vm: any = wrapper.vm - await flushPromises() - expect(vm.canEditUserOrIsSelf).toBe(true) - }) - - it('should not allow edition of other profile without specific rights', async () => { - const wrapper = lpiShallowMount(UserProfileV2, buildParams(user2.id, false)) - const vm: any = wrapper.vm - await flushPromises() - expect(vm.canEditUserOrIsSelf).toBe(false) - }) - - // it('should display a loader first then the content', async () => { - // let wrapper = lpiShallowMount(UserProfileV2, buildParams(123, false)) - // let vm: any = wrapper.vm - - // expect(vm.isLoading).toBe(true) - // expect(wrapper.find('loader-simple-stub').exists()).toBe(true) - // expect(wrapper.find('profile-header-stub').exists()).toBe(false) - // expect(wrapper.find('profile-tabs-stub').exists()).toBe(false) - - // await flushPromises() - - // expect(vm.isLoading).toBe(false) - // expect(wrapper.find('loader-simple-stub').exists()).toBe(false) - // expect(wrapper.find('profile-header-stub').exists()).toBe(true) - // expect(wrapper.find('profile-tabs-stub').exists()).toBe(true) - // }) }) diff --git a/tests/unit/components/people/skill/SkillsEditDrawer.spec.ts b/tests/unit/components/people/skill/SkillsEditDrawer.spec.ts deleted file mode 100644 index 0620b7bee..000000000 --- a/tests/unit/components/people/skill/SkillsEditDrawer.spec.ts +++ /dev/null @@ -1,102 +0,0 @@ -import SkillsEditDrawer from '~/components/people/skill/SkillsEditDrawer.vue' -import { lpiMount } from '~~/tests/helpers/LpiMount' - -import type { OrganizationOutput } from 'shared-projects-frontend/models' -import useOrganizationsStore from '~/stores/useOrganizations' - -import { userTranslatedFactory } from '~~/tests/factories/user.factory' -import { beforeEach, describe, expect, it, vi } from 'vitest' - -vi.mock('shared-projects-frontend/apis', async (orginalImporter) => ({ - ...(await orginalImporter()), - postUserSkill: vi.fn().mockResolvedValue({}), - getOrgClassificationTags: vi - .fn() - .mockResolvedValue({ results: [{ id: 1 }, { id: 2 }, { id: 3 }] }), - getAllOrgClassifications: vi.fn().mockResolvedValue({ - results: [ - { - id: 123, - slug: 'for-project', - is_enabled_for_projects: true, - is_enabled_for_skills: false, - }, - { - id: 456, - slug: 'for-skill', - is_enabled_for_projects: false, - is_enabled_for_skills: true, - }, - { - id: 789, - slug: 'for-skill-and-project', - is_enabled_for_projects: true, - is_enabled_for_skills: true, - }, - ], - }), -})) - -describe('SkillsEditDrawer.vue', () => { - let wrapper - - beforeEach(() => { - const organizationsStore = useOrganizationsStore() - organizationsStore._current = { - code: 'test', - tags: [], - enabled_projects_tag_classifications: [ - { id: 123, slug: 'for-project' }, - { id: 789, slug: 'for-skill-and-project' }, - ], - enabled_skills_tag_classifications: [ - { id: 456, slug: 'for-skill' }, - { id: 789, slug: 'for-skill-and-project' }, - ], - default_projects_tags: [{ id: 11 }, { id: 12 }, { id: 13 }], - default_skills_tags: [{ id: 21 }, { id: 22 }, { id: 23 }], - } as unknown as OrganizationOutput - wrapper = lpiMount(SkillsEditDrawer, { - props: { - isOpen: true, - type: 'skills', - user: userTranslatedFactory.generate({ id: 1 }), - searchAllMode: true, - }, - }) - }) - - it('renders correctly', () => { - expect(wrapper.exists()).toBe(true) - }) - - it('renders BaseDrawer component', () => { - expect(wrapper.findComponent({ name: 'BaseDrawer' }).exists()).toBe(true) - }) - - it('renders SearchInput component when in add-skill-mode', () => { - expect(wrapper.findComponent({ name: 'search-input' }).exists()).toBe(true) - }) - - it('renders SkillEditor component when in edit-skill-mode', async () => { - await wrapper.setData({ addedTalent: { tag: { id: 1 }, level: 1, level_to_reach: 1 } }) - expect(wrapper.findComponent({ name: 'skill-editor' }).exists()).toBe(true) - }) - - it('emits close event when BaseDrawer close button is clicked', async () => { - await wrapper.findComponent({ name: 'base-drawer' }).vm.$emit('close') - expect(wrapper.emitted().close).toBeTruthy() - }) - - it('emits skill-added event after saving a skill', async () => { - wrapper.setData({ addedTalent: { tag: { id: 1 }, level: 1, level_to_reach: 1 } }) - await wrapper.vm.save() - expect(wrapper.emitted()['skill-added']).toBeTruthy() - }) - - it('sets talent level correctly', async () => { - const talent = { tag: { id: 1 }, level: 1, level_to_reach: 1 } - wrapper.vm.setTalentLevel(talent, 3) - expect(talent.level).toBe(3) - }) -}) diff --git a/tests/unit/components/project/resource/ResourceCount.spec.ts b/tests/unit/components/project/resource/ResourceCount.spec.ts deleted file mode 100644 index fe1ce6d75..000000000 --- a/tests/unit/components/project/resource/ResourceCount.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -import MockComponent from '~~/tests/helpers/MockComponent.vue' -import { lpiMount } from '~~/tests/helpers/LpiMount' - -import ResourceCount from '~/components/resources/ResourceCount.vue' -import { describe, expect, it, vi } from 'vitest' - -const mockRouter = { - push: vi.fn(), -} - -const mockRoute = { - path: '/test1', -} - -describe('ResourceCount.vue', () => { - it('should render component', () => { - const wrapper = lpiMount(ResourceCount, { - props: { - count: 2, - target: 'foo', - }, - router: [{ path: '/:pathMatch(.*)', component: MockComponent }], - global: { - mocks: { - $router: mockRouter, - $route: mockRoute, - }, - }, - }) - expect(wrapper.exists()).toBe(true) - }) -}) diff --git a/tests/unit/components/project/resource/ResourcesRecap.spec.ts b/tests/unit/components/project/resource/ResourcesRecap.spec.ts deleted file mode 100644 index 409bc921c..000000000 --- a/tests/unit/components/project/resource/ResourcesRecap.spec.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { ProjectOutputFactory } from '~~/tests/factories/project.factory' -import ResourcesRecap from '~/components/resources/ResourcesRecap.vue' -import { lpiShallowMount } from '~~/tests/helpers/LpiMount' -import { beforeEach, describe, expect, it } from 'vitest' -import useProjectsStore from '~/stores/useProjects' -import pinia from '~/stores' - -describe('ResourcesRecap.vue', () => { - beforeEach(() => { - const projectsStore = useProjectsStore(pinia) - - projectsStore.project = { - ...ProjectOutputFactory.generate(), - } - }) - it('should render component', () => { - const props = { - target: '/file', - redirect: '/redirect', - files: 0, - links: 0, - } - const wrapper = lpiShallowMount(ResourcesRecap, { props }) - expect(wrapper.exists()).toBe(true) - }) -}) diff --git a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileBioEditTab.spec.ts b/tests/unit/pages/UserProfilePageV2/Tabs/ProfileBioEditTab.spec.ts deleted file mode 100644 index 61958dcf2..000000000 --- a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileBioEditTab.spec.ts +++ /dev/null @@ -1,17 +0,0 @@ -import ProfileBioEditTab from '~/pages/UserProfilePageV2/Tabs/ProfileBioEditTab.vue' -import { lpiMountSuspended } from '~~/tests/helpers/LpiMount' - -import { userTranslatedFactory } from '~~/tests/factories/user.factory' -import { flushPromises } from '@vue/test-utils' -import { describe, expect, it } from 'vitest' - -describe('ProfileBioEditTab.vue', () => { - it('should render component', async () => { - const user = userTranslatedFactory.generate() - const props = { user } - - const wrapper = await lpiMountSuspended(ProfileBioEditTab, { props }) - await flushPromises() - expect(wrapper.exists()).toBe(true) - }) -}) diff --git a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileBioTab.spec.ts b/tests/unit/pages/UserProfilePageV2/Tabs/ProfileBioTab.spec.ts deleted file mode 100644 index 8910a89ca..000000000 --- a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileBioTab.spec.ts +++ /dev/null @@ -1,68 +0,0 @@ -import ProfileBioTab from '~/pages/UserProfilePageV2/Tabs/ProfileBioTab.vue' -import type { OrganizationOutput } from 'shared-projects-frontend/models' -import { userTranslatedFactory } from '~~/tests/factories/user.factory' -import useOrganizationsStore from '~/stores/useOrganizations' -import { lpiShallowMount } from '~~/tests/helpers/LpiMount' -import { flushPromises } from '@vue/test-utils' -import useUsersStore from '~/stores/useUsers' - -import { registerEndpoint } from '@nuxt/test-utils/runtime' -import { beforeEach, describe, expect, it } from 'vitest' - -describe('ProfileBioTab', () => { - let usersStore - beforeEach(() => { - usersStore = useUsersStore() - const user = userTranslatedFactory.generate({ id: 123 }) - registerEndpoint(`user/${user.id}/`, () => user) - usersStore.userFromApi = usersStore.userFromToken = user - - const organizationsStore = useOrganizationsStore() - organizationsStore._current = { id: 'TEST' } as unknown as OrganizationOutput - }) - it('should render ProfileBioTab component', () => { - const wrapper = lpiShallowMount(ProfileBioTab, { - props: { user: userTranslatedFactory.generate() }, - }) - - expect(wrapper.exists()).toBeTruthy() - }) - - it('should see that current user is the logged one', () => { - const user = userTranslatedFactory.generate({ id: 123 }) - usersStore.userFromApi = usersStore.userFromToken = user - const wrapper = lpiShallowMount(ProfileBioTab, { props: { user } }) - const vm: any = wrapper.vm - expect(vm.isCurrentUser).toBeTruthy() - }) - - it('should see that current user is not the logged one', () => { - const user = userTranslatedFactory.generate({ id: 123 }) - const user2 = userTranslatedFactory.generate({ id: 456 }) - - usersStore.userFromApi = usersStore.userFromToken = user2 - - const wrapper = lpiShallowMount(ProfileBioTab, { props: { user } }) - const vm: any = wrapper.vm - expect(vm.isCurrentUser).toBeFalsy() - }) - - it('should display a message if user has no bio set', async () => { - const user = userTranslatedFactory.generate() - user.description = null - const wrapper = lpiShallowMount(ProfileBioTab, { props: { user } }) - - await flushPromises() - expect(wrapper.find('user-descriptions-stub').exists()).toBe(false) - expect(wrapper.find('.empty-field').exists()).toBe(true) - }) - - it('should display bio if user has one', async () => { - const user = userTranslatedFactory.generate() - const wrapper = lpiShallowMount(ProfileBioTab, { props: { user } }) - - await flushPromises() - expect(wrapper.find('user-descriptions-stub').exists()).toBe(true) - expect(wrapper.find('.empty-field').exists()).toBe(false) - }) -}) diff --git a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileGeneralEditTab.spec.ts b/tests/unit/pages/UserProfilePageV2/Tabs/ProfileGeneralEditTab.spec.ts deleted file mode 100644 index b45b4cb52..000000000 --- a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileGeneralEditTab.spec.ts +++ /dev/null @@ -1,17 +0,0 @@ -import ProfileGeneralEditTab from '~/pages/UserProfilePageV2/Tabs/ProfileGeneralEditTab.vue' -import { lpiMountSuspended } from '~~/tests/helpers/LpiMount' - -import { UserFactory } from '~~/tests/factories/user.factory' -import { flushPromises } from '@vue/test-utils' -import { describe, expect, it } from 'vitest' - -describe('ProfileGeneralEditTab.vue', () => { - it('should render component', async () => { - const user = UserFactory.generate() - const props = { user } - - const wrapper = await lpiMountSuspended(ProfileGeneralEditTab, { props }) - await flushPromises() - expect(wrapper.exists()).toBe(true) - }) -}) diff --git a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileGroupsEditTab.spec.ts b/tests/unit/pages/UserProfilePageV2/Tabs/ProfileGroupsEditTab.spec.ts deleted file mode 100644 index d4e0e3a6a..000000000 --- a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileGroupsEditTab.spec.ts +++ /dev/null @@ -1,17 +0,0 @@ -import ProfileGroupsEditTab from '~/pages/UserProfilePageV2/Tabs/ProfileGroupsEditTab.vue' -import { lpiMountSuspended } from '~~/tests/helpers/LpiMount' - -import { userTranslatedFactory } from '~~/tests/factories/user.factory' -import { flushPromises } from '@vue/test-utils' -import { describe, expect, it } from 'vitest' - -describe('ProfileGroupsEditTab.vue', () => { - it('should render component', async () => { - const user = userTranslatedFactory.generate() - const props = { user } - - const wrapper = await lpiMountSuspended(ProfileGroupsEditTab, { props }) - await flushPromises() - expect(wrapper.exists()).toBe(true) - }) -}) diff --git a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileGroupsTab.spec.ts b/tests/unit/pages/UserProfilePageV2/Tabs/ProfileGroupsTab.spec.ts deleted file mode 100644 index 094739f82..000000000 --- a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileGroupsTab.spec.ts +++ /dev/null @@ -1,28 +0,0 @@ -import ProfileGroupsTab from '~/pages/UserProfilePageV2/Tabs/ProfileGroupsTab.vue' -import { userTranslatedFactory } from '~~/tests/factories/user.factory' -import { lpiShallowMount } from '~~/tests/helpers/LpiMount' - -import { beforeEach, describe, expect, it, vi } from 'vitest' - -import type { OrganizationOutput } from 'shared-projects-frontend/models' -import useOrganizationsStore from '~/stores/useOrganizations' -import pinia from '~/stores' -vi.mock('shared-projects-frontend/apis', async (orginalImporter) => ({ - ...(await orginalImporter()), - getGroup: vi.fn().mockResolvedValue({ results: {} }), -})) - -describe('ProfileGroupsTab', () => { - beforeEach(() => { - const organizationsStore = useOrganizationsStore(pinia) - organizationsStore._current = { id: 'TEST' } as unknown as OrganizationOutput - }) - - it('should render ProfileGroupsTab component', () => { - const wrapper = lpiShallowMount(ProfileGroupsTab, { - props: { user: userTranslatedFactory.generate() }, - }) - - expect(wrapper.exists()).toBeTruthy() - }) -}) diff --git a/tests/unit/pages/UserProfilePageV2/Tabs/ProfilePrivacyEditTab.spec.ts b/tests/unit/pages/UserProfilePageV2/Tabs/ProfilePrivacyEditTab.spec.ts deleted file mode 100644 index 49e57d81f..000000000 --- a/tests/unit/pages/UserProfilePageV2/Tabs/ProfilePrivacyEditTab.spec.ts +++ /dev/null @@ -1,17 +0,0 @@ -import ProfilePrivacyEditTab from '~/pages/UserProfilePageV2/Tabs/ProfilePrivacyEditTab.vue' -import { lpiMountSuspended } from '~~/tests/helpers/LpiMount' - -import { UserFactory } from '~~/tests/factories/user.factory' -import { flushPromises } from '@vue/test-utils' -import { describe, expect, it } from 'vitest' - -describe('ProfilePrivacyEditTab.vue', () => { - it('should render component', async () => { - const user = UserFactory.generate() - const props = { user } - - const wrapper = await lpiMountSuspended(ProfilePrivacyEditTab, { props }) - await flushPromises() - expect(wrapper.exists()).toBe(true) - }) -}) diff --git a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileProjectTab.spec.ts b/tests/unit/pages/UserProfilePageV2/Tabs/ProfileProjectTab.spec.ts deleted file mode 100644 index 9a39d130b..000000000 --- a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileProjectTab.spec.ts +++ /dev/null @@ -1,67 +0,0 @@ -import ProfileProjectTab from '~/pages/UserProfilePageV2/Tabs/ProfileProjectTab.vue' -import { userTranslatedFactory } from '~~/tests/factories/user.factory' -import { lpiShallowMount } from '~~/tests/helpers/LpiMount' -import { flushPromises } from '@vue/test-utils' - -import useOrganizationsStore from '~/stores/useOrganizations' -import { beforeEach, describe, expect, it, vi } from 'vitest' -import useUsersStore from '~/stores/useUsers' - -import { OrganizationFactory } from '~~/tests/factories/organization.factory' - -vi.mock('shared-projects-frontend/apis', async (orginalImporter) => ({ - ...(await orginalImporter()), - getUserFollows: vi.fn().mockResolvedValue({ results: [] }), -})) - -describe('ProfileProjectTab', () => { - let usersStore - beforeEach(() => { - usersStore = useUsersStore() - usersStore.userFromApi = usersStore.userFromToken = userTranslatedFactory.generate({ id: 123 }) - const organizationsStore = useOrganizationsStore() - organizationsStore._current = OrganizationFactory.generate() - }) - - it('should render ProfileProjectTab component', () => { - const wrapper = lpiShallowMount(ProfileProjectTab, { - props: { user: userTranslatedFactory.generate() }, - }) - - expect(wrapper.exists()).toBeTruthy() - }) - - it('should display 3 project lists', async () => { - const user = userTranslatedFactory.generate() - const wrapper = lpiShallowMount(ProfileProjectTab, { props: { user } }) - - await flushPromises() - expect(wrapper.findAll('user-projects-search-stub').length).toBe(3) - }) - - it('should not display a create project button if not on self profile', async () => { - const user = userTranslatedFactory.generate() - const wrapper = lpiShallowMount(ProfileProjectTab, { props: { user } }) - const organizationsStore = useOrganizationsStore() - - await flushPromises() - expect(wrapper.find('.create-project').exists()).toBe(false) - - user.roles.push(`organization:#${organizationsStore.current.id}:viewers`) - usersStore.userFromApi = usersStore.userFromToken = user - - await flushPromises() - expect(wrapper.find('.create-project').exists()).toBe(false) - }) - - it('should display a create project button if on self profile and has persimission', async () => { - const user = userTranslatedFactory.generate({ id: 123 }) - const organizationsStore = useOrganizationsStore() - user.roles.push(`organization:#${organizationsStore.current.id}:members`) - usersStore.userFromApi = usersStore.userFromToken = user - const wrapper = lpiShallowMount(ProfileProjectTab, { props: { user } }) - - await flushPromises() - expect(wrapper.find('.create-project').exists()).toBe(true) - }) -}) diff --git a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileProjectsEditTab.spec.ts b/tests/unit/pages/UserProfilePageV2/Tabs/ProfileProjectsEditTab.spec.ts deleted file mode 100644 index 921478af3..000000000 --- a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileProjectsEditTab.spec.ts +++ /dev/null @@ -1,26 +0,0 @@ -import ProfileProjectsEditTab from '~/pages/UserProfilePageV2/Tabs/ProfileProjectsEditTab.vue' -import { lpiMountSuspended } from '~~/tests/helpers/LpiMount' -import { flushPromises } from '@vue/test-utils' - -import { PaginationsFactory } from '~~/tests/factories/paginations.factory' -import { userTranslatedFactory } from '~~/tests/factories/user.factory' -import { ProjectFactory } from '~~/tests/factories/project.factory' -import FollowFactory from '~~/tests/factories/follow.factory' -import { registerEndpoint } from '@nuxt/test-utils/runtime' -import { describe, expect, it } from 'vitest' - -describe('ProfileProjectsEditTab.vue', () => { - it('should render component', async () => { - const user = userTranslatedFactory.generate() - const props = { user } - - registerEndpoint(`user/${user.id}/follow/`, () => FollowFactory.generateMany(5)) - registerEndpoint(`project/`, () => - PaginationsFactory.generate({ results: ProjectFactory.generateMany(10) }) - ) - - const wrapper = await lpiMountSuspended(ProfileProjectsEditTab, { props }) - await flushPromises() - expect(wrapper.exists()).toBe(true) - }) -}) diff --git a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileResourcesTab.spec.ts b/tests/unit/pages/UserProfilePageV2/Tabs/ProfileResourcesTab.spec.ts deleted file mode 100644 index 1df2bae37..000000000 --- a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileResourcesTab.spec.ts +++ /dev/null @@ -1,35 +0,0 @@ -import ProfileResourcesTab from '~/pages/UserProfilePageV2/Tabs/ProfileResourcesTab.vue' -import { lpiMountSuspended } from '~~/tests/helpers/LpiMount' - -import { AttachmentLinkFactory } from '~~/tests/factories/attachment-link.factory' -import { AttachmentFileFactory } from '~~/tests/factories/attachment-file.factory' -import { PaginationsFactory } from '~~/tests/factories/paginations.factory' -import { UserFactory } from '~~/tests/factories/user.factory' -import { registerEndpoint } from '@nuxt/test-utils/runtime' -import { flushPromises } from '@vue/test-utils' -import { describe, expect, it } from 'vitest' - -describe('ProfileResourcesTab.vue', () => { - it('should render component', async () => { - const props = { - user: UserFactory.generate(), - isInEditingMode: false, - onProfileEdited: () => {}, - } - - registerEndpoint(`user/${props.user.id}/link/`, () => { - return PaginationsFactory.generate({ - results: AttachmentLinkFactory.generateMany(10), - }) - }) - registerEndpoint(`user/${props.user.id}/file/`, () => { - return PaginationsFactory.generate({ - results: AttachmentFileFactory.generateMany(10), - }) - }) - - const wrapper = await lpiMountSuspended(ProfileResourcesTab, { props }) - await flushPromises() - expect(wrapper.exists()).toBe(true) - }) -}) diff --git a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileSkillTab.spec.ts b/tests/unit/pages/UserProfilePageV2/Tabs/ProfileSkillTab.spec.ts deleted file mode 100644 index 028e3b8eb..000000000 --- a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileSkillTab.spec.ts +++ /dev/null @@ -1,147 +0,0 @@ -import ProfileSkillTab from '~/pages/UserProfilePageV2/Tabs/ProfileSkillTab.vue' -import { userTranslatedFactory } from '~~/tests/factories/user.factory' -import { lpiMountSuspended } from '~~/tests/helpers/LpiMount' -import useUsersStore from '~/stores/useUsers' - -import { PaginationsFactory } from '~~/tests/factories/paginations.factory' -import UserSkillsFull from '~/components/people/skill/UserSkillsFull.vue' -import type { OrganizationOutput } from 'shared-projects-frontend/models' -import { SkillFactory } from '~~/tests/factories/skill.factory' -import useOrganizationsStore from '~/stores/useOrganizations' -import { registerEndpoint } from '@nuxt/test-utils/runtime' -import EmptyLabel from '~/components/base/EmptyLabel.vue' -import { beforeEach, describe, expect, it } from 'vitest' -import TagFactory from '~~/tests/factories/tag.factory' -import { flushPromises } from '@vue/test-utils' - -const aTag = TagFactory.generate({ title: '123', description: 'abc' }) - -describe('ProfileSkillTab', () => { - let usersStore: ReturnType - beforeEach(() => { - usersStore = useUsersStore() - usersStore.userFromApi = {} - usersStore.userFromToken = {} - const organizationsStore = useOrganizationsStore() - organizationsStore._current = { id: 'TEST', code: 'TEST' } as unknown as OrganizationOutput - const organizationCode = useOrganizationCode() - - registerEndpoint(`organization/${organizationCode}/mentoring/`, () => - PaginationsFactory.generate() - ) - }) - - it.fails('should render ProfileSkillTab component', async () => { - const wrapper = await lpiMountSuspended(ProfileSkillTab, { - props: { user: userTranslatedFactory.generate() }, - }) - expect.poll(() => expect(wrapper.exists()).toBeTruthy()) - expect(false).toBe(true) - }) - - it('should see that current user is the logged one', async () => { - const user = userTranslatedFactory.generate({ id: 123 }) - - registerEndpoint(`user/${user.id}/category-follow/`, () => PaginationsFactory.generate()) - - usersStore.userFromApi = usersStore.userFromToken = user - const wrapper = await lpiMountSuspended(ProfileSkillTab, { props: { user } }) - await flushPromises() - const vm: any = wrapper.vm - expect(vm.isCurrentUser).toBeTruthy() - }) - - it('should see that current user is not the logged one', async () => { - const user = userTranslatedFactory.generate() - const user2 = userTranslatedFactory.generate() - registerEndpoint(`user/${user.id}/category-follow/`, () => PaginationsFactory.generate()) - registerEndpoint(`user/${user2.id}/category-follow/`, () => PaginationsFactory.generate()) - - usersStore.userFromApi = usersStore.userFromToken = user2 - - const wrapper = await lpiMountSuspended(ProfileSkillTab, { props: { user } }) - await flushPromises() - const vm: any = wrapper.vm - expect(vm.isCurrentUser).toBeFalsy() - }) - - it('should display a message if no skill and no hobby', async () => { - const user = userTranslatedFactory.generate() - const user2 = userTranslatedFactory.generate() - - registerEndpoint(`user/${user.id}/category-follow/`, () => PaginationsFactory.generate()) - registerEndpoint(`user/${user2.id}/category-follow/`, () => PaginationsFactory.generate()) - usersStore.userFromApi = usersStore.userFromToken = user2 - - const wrapper = await lpiMountSuspended(ProfileSkillTab, { props: { user } }) - await flushPromises() - expect(wrapper.findComponent(EmptyLabel).exists()).toBe(true) - expect(wrapper.findAllComponents(UserSkillsFull).length).toBe(0) - }) - - it('should display one list if user has skill but no hobby', async () => { - const user = userTranslatedFactory.generate() - const user2 = userTranslatedFactory.generate() - - registerEndpoint(`user/${user.id}/category-follow/`, () => PaginationsFactory.generate()) - registerEndpoint(`user/${user2.id}/category-follow/`, () => PaginationsFactory.generate()) - user.skills = [SkillFactory.generate({ id: 123, type: 'hobby', tag: aTag })] - usersStore.userFromApi = usersStore.userFromToken = user2 - - const wrapper = await lpiMountSuspended(ProfileSkillTab, { props: { user } }) - await flushPromises() - expect(wrapper.findComponent(EmptyLabel).exists()).toBe(false) - expect(wrapper.findAllComponents(UserSkillsFull).length).toBe(1) - }) - - it('should display one list if user has hobbies but no skills', async () => { - const user = userTranslatedFactory.generate() - const user2 = userTranslatedFactory.generate() - - registerEndpoint(`user/${user.id}/category-follow/`, () => PaginationsFactory.generate()) - registerEndpoint(`user/${user2.id}/category-follow/`, () => PaginationsFactory.generate()) - user.skills = [SkillFactory.generate({ id: 123, type: 'hobby', tag: aTag })] - usersStore.userFromApi = usersStore.userFromToken = user2 - - const wrapper = await lpiMountSuspended(ProfileSkillTab, { props: { user } }) - await flushPromises() - expect(wrapper.findComponent(EmptyLabel).exists()).toBe(false) - expect(wrapper.findAllComponents(UserSkillsFull).length).toBe(1) - }) - - it('should display two lists if user has hobbies and skills', async () => { - const user = userTranslatedFactory.generate() - const user2 = userTranslatedFactory.generate() - - registerEndpoint(`user/${user.id}/category-follow/`, () => PaginationsFactory.generate()) - registerEndpoint(`user/${user2.id}/category-follow/`, () => PaginationsFactory.generate()) - user.skills = [ - SkillFactory.generate({ id: 123, type: 'hobby', tag: aTag }), - SkillFactory.generate({ id: 123, type: 'skill', tag: aTag }), - ] - usersStore.userFromApi = usersStore.userFromToken = user2 - - const wrapper = await lpiMountSuspended(ProfileSkillTab, { props: { user } }) - await flushPromises() - expect(wrapper.findComponent(EmptyLabel).exists()).toBe(false) - expect(wrapper.findAllComponents(UserSkillsFull).length).toBe(2) - }) - - it('should display a tip if list are displayed', async () => { - const user = userTranslatedFactory.generate() - const user2 = userTranslatedFactory.generate() - - registerEndpoint(`user/${user.id}/category-follow/`, () => PaginationsFactory.generate()) - registerEndpoint(`user/${user2.id}/category-follow/`, () => PaginationsFactory.generate()) - user.skills = [ - SkillFactory.generate({ id: 123, type: 'hobby', tag: aTag }), - SkillFactory.generate({ id: 123, type: 'skill', tag: aTag }), - ] - usersStore.userFromApi = usersStore.userFromToken = user2 - - const wrapper = await lpiMountSuspended(ProfileSkillTab, { props: { user } }) - await flushPromises() - await wrapper.vm.$nextTick() - expect(wrapper.find('[data-test="skill-levels-help-button"]').exists()).toBe(true) - }) -}) diff --git a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileSkillsEditTab.spec.ts b/tests/unit/pages/UserProfilePageV2/Tabs/ProfileSkillsEditTab.spec.ts deleted file mode 100644 index 816fbc736..000000000 --- a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileSkillsEditTab.spec.ts +++ /dev/null @@ -1,32 +0,0 @@ -import ProfileSkillsEditTab from '~/pages/UserProfilePageV2/Tabs/ProfileSkillsEditTab.vue' -import { lpiMountSuspended } from '~~/tests/helpers/LpiMount' - -import { OrganizationFactory } from '~~/tests/factories/organization.factory' -import { PaginationsFactory } from '~~/tests/factories/paginations.factory' -import { userTranslatedFactory } from '~~/tests/factories/user.factory' -import useOrganizationsStore from '~/stores/useOrganizations' -import { registerEndpoint } from '@nuxt/test-utils/runtime' -import TagFactory from '~~/tests/factories/tag.factory' -import { flushPromises } from '@vue/test-utils' -import { describe, expect, it } from 'vitest' - -describe('ProfileSkillsEditTab.vue', () => { - it('should render component', async () => { - const user = userTranslatedFactory.generate() - const props = { user } - - const organizationStore = useOrganizationsStore() - organizationStore._current = OrganizationFactory.generate() - - const organizationCode = useOrganizationCode() - registerEndpoint(`organization/${organizationCode}/tag-classification/`, () => { - return PaginationsFactory.generate({ - results: TagFactory.generateMany(10), - }) - }) - - const wrapper = await lpiMountSuspended(ProfileSkillsEditTab, { props }) - await flushPromises() - expect(wrapper.exists()).toBe(true) - }) -}) diff --git a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileSummaryTab.spec.ts b/tests/unit/pages/UserProfilePageV2/Tabs/ProfileSummaryTab.spec.ts deleted file mode 100644 index 4b997db7c..000000000 --- a/tests/unit/pages/UserProfilePageV2/Tabs/ProfileSummaryTab.spec.ts +++ /dev/null @@ -1,108 +0,0 @@ -import ProfileSummaryTab from '~/pages/UserProfilePageV2/Tabs/ProfileSummaryTab.vue' -import { lpiMountSuspended, lpiShallowMount } from '~~/tests/helpers/LpiMount' -import { userTranslatedFactory } from '~~/tests/factories/user.factory' -import { flushPromises } from '@vue/test-utils' - -import { beforeEach, describe, expect, it, vi } from 'vitest' - -import { OrganizationFactory } from '~~/tests/factories/organization.factory' -import { PaginationsFactory } from '~~/tests/factories/paginations.factory' -import { ProjectFactory } from '~~/tests/factories/project.factory' -import useOrganizationsStore from '~/stores/useOrganizations' -import { registerEndpoint } from '@nuxt/test-utils/runtime' -import useUsersStore from '~/stores/useUsers' - -describe('ProfileSummaryTab', () => { - let usersStore - - beforeEach(() => { - usersStore = useUsersStore() - const user = userTranslatedFactory.generate({ id: 123 }) - registerEndpoint(`user/${user.id}/`, () => user) - usersStore.userFromApi = usersStore.userFromToken = user - - const organizationsStore = useOrganizationsStore() - organizationsStore._current = OrganizationFactory.generate() - - registerEndpoint(`project/`, () => - PaginationsFactory.generate({ - results: ProjectFactory.generateMany(10), - }) - ) - }) - - it('should render ProfileSummaryTab component', () => { - const user = userTranslatedFactory.generate() - const wrapper = lpiShallowMount(ProfileSummaryTab, { props: { user } }) - - expect(wrapper.exists()).toBeTruthy() - }) - - it('should see that current user is the logged one', () => { - const user = userTranslatedFactory.generate({ id: 123 }) - usersStore.userFromApi = usersStore.userFromToken = user - const wrapper = lpiShallowMount(ProfileSummaryTab, { props: { user } }) - const vm: any = wrapper.vm - expect(vm.isCurrentUser).toBeTruthy() - }) - - it('should see that current user is not the logged one', () => { - const user = userTranslatedFactory.generate({ id: 123 }) - const user2 = userTranslatedFactory.generate({ id: 456 }) - usersStore.userFromApi = usersStore.userFromToken = user2 - - const wrapper = lpiShallowMount(ProfileSummaryTab, { props: { user } }) - const vm: any = wrapper.vm - expect(vm.isCurrentUser).toBeFalsy() - }) - - it('shouldnt display a message if user has no bio set', async () => { - const user = userTranslatedFactory.generate() - user.description = null - const wrapper = lpiShallowMount(ProfileSummaryTab, { props: { user } }) - - await flushPromises() - expect(wrapper.find('user-descriptions-stub').exists()).toBe(false) - }) - - it('should display bio if user has one', async () => { - const user = userTranslatedFactory.generate() - const wrapper = lpiShallowMount(ProfileSummaryTab, { props: { user } }) - - await flushPromises() - expect(wrapper.find('user-descriptions-stub').exists()).toBe(true) - expect(wrapper.find('.empty-field').exists()).toBe(false) - }) - - it('shouldnt display resources', async () => { - const user = userTranslatedFactory.generate() - user.modules.files = user.modules.links = 0 - const wrapper = await lpiMountSuspended(ProfileSummaryTab, { - props: { user }, - global: { - provide: { - tabsLayoutSelectTab: vi.fn(), - }, - }, - }) - - await flushPromises() - expect(wrapper.find('.resources-recap').exists()).toBe(false) - }) - - it('should display resources', async () => { - const user = userTranslatedFactory.generate() - user.modules.files = user.modules.links = 5 - const wrapper = await lpiMountSuspended(ProfileSummaryTab, { - props: { user }, - global: { - provide: { - tabsLayoutSelectTab: vi.fn(), - }, - }, - }) - - await flushPromises() - expect(wrapper.find('.resources-recap').exists()).toBe(true) - }) -}) diff --git a/tests/unit/pages/UserProfilePageV2/Tabs/ResearcherDocumentsTab.spec.ts b/tests/unit/pages/UserProfilePageV2/Tabs/ResearcherDocumentsTab.spec.ts deleted file mode 100644 index 3e02e928b..000000000 --- a/tests/unit/pages/UserProfilePageV2/Tabs/ResearcherDocumentsTab.spec.ts +++ /dev/null @@ -1,66 +0,0 @@ -import ResearcherDocumentsTab from '~/pages/UserProfilePageV2/Tabs/ResearcherDocumentsTab.vue' -import { lpiMountSuspended } from '~~/tests/helpers/LpiMount' - -import { DocumentFactory, ResearcherFactory } from '~~/tests/factories/researcher.factory' -import type { ResearcherDocumentType } from 'shared-projects-frontend/models' -import { PaginationsFactory } from '~~/tests/factories/paginations.factory' -import { UserFactory } from '~~/tests/factories/user.factory' -import { registerEndpoint } from '@nuxt/test-utils/runtime' -import { flushPromises } from '@vue/test-utils' -import { describe, expect, it } from 'vitest' - -describe('ResearcherDocumentsTab.vue', () => { - it('should render component', async () => { - const user = UserFactory.generate({ - researcher: ResearcherFactory.generate(), - }) - const props = { - user, - documentType: 'publications' satisfies ResearcherDocumentType as ResearcherDocumentType, - } - const organizationCode = useOrganizationCode() - - registerEndpoint( - `crisalid/organization/${organizationCode}/researcher/${props.user.researcher.id}/${props.documentType}/analytics/`, - () => { - return { - document_types: { - JournalArticle: 100, - ConferenceAbstract: 10, - ScholarlyPublication: 45, - Book: 10, - }, - years: [ - { year: 2025, total: 10 }, - { year: 2024, total: 3 }, - { year: 2023, total: 13 }, - { year: 2022, total: 130 }, - ], - roles: { - trc: 12, - trl: 19, - tyg: 10, - }, - } - } - ) - - const docWithoutSimilars = DocumentFactory.generate({ - document_type: 'JournalArticle', - similars: 0, - }) - - registerEndpoint( - `crisalid/organization/${organizationCode}/researcher/${props.user.researcher.id}/${props.documentType}/`, - () => { - return PaginationsFactory.generate({ - results: [docWithoutSimilars], - }) - } - ) - - const wrapper = await lpiMountSuspended(ResearcherDocumentsTab, { props }) - await flushPromises() - expect(wrapper.exists()).toBe(true) - }) -}) diff --git a/tests/unit/pages/UserProfilePageV2/Tabs/ResearcherEditDocumentsTab.spec.ts b/tests/unit/pages/UserProfilePageV2/Tabs/ResearcherEditDocumentsTab.spec.ts deleted file mode 100644 index 3836b69f4..000000000 --- a/tests/unit/pages/UserProfilePageV2/Tabs/ResearcherEditDocumentsTab.spec.ts +++ /dev/null @@ -1,18 +0,0 @@ -import ResearcherEditDocumentsTab from '~/pages/UserProfilePageV2/Tabs/ResearcherEditDocumentsTab.vue' -import { lpiMountSuspended } from '~~/tests/helpers/LpiMount' - -import type { ResearcherDocumentType } from 'shared-projects-frontend/models' -import { flushPromises } from '@vue/test-utils' -import { describe, expect, it } from 'vitest' - -describe('ResearcherEditDocumentsTab.vue', () => { - it('should render component', async () => { - const props = { - documentType: 'publications' satisfies ResearcherDocumentType as ResearcherDocumentType, - } - - const wrapper = await lpiMountSuspended(ResearcherEditDocumentsTab, { props }) - await flushPromises() - expect(wrapper.exists()).toBe(true) - }) -}) diff --git a/tests/unit/pages/UserProfilePageV2/UserProfilePage.spec.ts b/tests/unit/pages/UserProfilePageV2/UserProfilePage.spec.ts deleted file mode 100644 index 3204109ea..000000000 --- a/tests/unit/pages/UserProfilePageV2/UserProfilePage.spec.ts +++ /dev/null @@ -1,29 +0,0 @@ -import UserProfilePage from '~/pages/UserProfilePageV2/UserProfilePage.vue' -import { lpiMountSuspended } from '~~/tests/helpers/LpiMount' - -import { UserFactory } from '~~/tests/factories/user.factory' -import { registerEndpoint } from '@nuxt/test-utils/runtime' -import { flushPromises } from '@vue/test-utils' -import { describe, expect, it } from 'vitest' - -describe('UserProfilePage.vue', () => { - it('should render component', async () => { - const user = UserFactory.generate() - const props = { userIdOrSlug: user.id } - - registerEndpoint(`user/${user.id}/`, () => user) - - const wrapper = await lpiMountSuspended(UserProfilePage, { - props, - global: { - mocks: { - $route: { - name: 'ProfileUser', - }, - }, - }, - }) - await flushPromises() - expect(wrapper.exists()).toBe(true) - }) -})