Skip to content

Commit 1c21b9d

Browse files
committed
cleanup tests
1 parent 49407e4 commit 1c21b9d

10 files changed

Lines changed: 87 additions & 72 deletions

File tree

src/api/people.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export async function searchPeopleAdmin(organizationId: OrganizationModel['id'],
6464

6565
export async function searchPeopleByExactMail(email: string, params: object) {
6666
const adaptedParams = params ? _adaptParamsToGetQuery(params) : {}
67-
return await useAPI(`user/get-by-email/${email}/`, { ...adaptedParams, noError: true }) //.data.value
67+
return await useAPI(`user/get-by-email/${email}/`, { ...adaptedParams })
6868
}
6969

7070
export async function patchUser(id: string | number, body: UserPatchModel) {

src/components/people/Account/OtherOrgUserCard.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ export default {
7272
acc['#' + org.id] = org // the # is prefixed to org id in role code
7373
return acc
7474
}, {})
75-
console.log(orgIndex)
7675
this.orgRoles =
7776
user?.roles
7877
.filter((role) => role.match(/^organization:[^:]+:[^:]+$/))

src/components/resources/ResourcesRecap.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,16 @@
2121
<script setup lang="ts">
2222
import SectionHeader from '@/components/base/SectionHeader.vue'
2323
import ResourceCount from '@/components/project/resource/ResourceCount.vue'
24+
import { RouteLocationRaw } from 'vue-router'
2425
2526
const router = useRouter()
2627
2728
const props = withDefaults(
2829
defineProps<{
2930
files?: number
3031
links?: number
31-
target: any
32-
redirect: any
32+
target: RouteLocationRaw
33+
redirect: RouteLocationRaw
3334
}>(),
3435
{ links: 0, files: 0 }
3536
)

src/components/search/FilterTags/TagResults.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,10 @@ export default {
100100
101101
computed: {
102102
pagination() {
103-
if (!this.request) return { total: 0, current: 1 }
103+
if (!this.request) return { total: 0, currentPage: 1 }
104104
return {
105-
currentPage: this.request.current_page,
106-
total: this.request.total_page,
105+
currentPage: this.request.current_page ?? 0,
106+
total: this.request.total_page ?? 0,
107107
previous: this.request.previous,
108108
next: this.request.next,
109109
first: this.request.first,

tests/unit/components/admin/DefaultTagsAdmin.spec.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ vi.mock('@/api/tag-classification.service', () => ({
3131
}),
3232
getAllOrgClassifications: vi.fn().mockResolvedValue({
3333
count: 3,
34+
current_page: 1,
35+
total_page: 1,
36+
previous: null,
37+
next: null,
38+
first: null,
39+
last: null,
3440
results: [
3541
{
3642
id: 123,

tests/unit/components/people/Account/AccountDrawer.spec.ts

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -19,39 +19,39 @@ describe('AccountDrawer', () => {
1919
}
2020
})
2121

22-
// it('AddMode', async () => {
23-
// const email = 'test@protonmail.com'
24-
// registerEndpoint(`user/get-by-email/${email}/`, () => {
25-
// throw createError({ statusCode: 404 })
26-
// })
27-
28-
// const wrapper = await lpiMount(AccountDrawer, { props: defaultProps })
29-
// expect(wrapper.findComponent(ExistingAccountChecker).exists()).toBe(true)
30-
// expect(wrapper.findComponent(AccountLayout).exists()).toBe(false)
31-
// })
22+
it('AddMode', async () => {
23+
const email = 'test@protonmail.com'
24+
registerEndpoint(`user/get-by-email/${email}/`, () => {
25+
throw createError({ statusCode: 404 })
26+
})
27+
28+
const wrapper = await lpiMount(AccountDrawer, { props: defaultProps })
29+
expect(wrapper.findComponent(ExistingAccountChecker).exists()).toBe(true)
30+
expect(wrapper.findComponent(AccountLayout).exists()).toBe(false)
31+
})
3232

33-
// it('AddMode email not exists', async () => {
34-
// const email = 'test@protonmail.com'
35-
// registerEndpoint(`user/get-by-email/${email}/`, () => {
36-
// throw createError({ statusCode: 404 })
37-
// })
33+
it('AddMode email not exists', async () => {
34+
const email = 'test@protonmail.com'
35+
registerEndpoint(`user/get-by-email/${email}/`, () => {
36+
throw createError({ statusCode: 404 })
37+
})
3838

39-
// const wrapper = await lpiMount(AccountDrawer, { props: defaultProps })
39+
const wrapper = await lpiMount(AccountDrawer, { props: defaultProps })
4040

41-
// const input = wrapper.get<HTMLInputElement>('input[type="email"]')
42-
// await input.setValue(email)
41+
const input = wrapper.get<HTMLInputElement>('input[type="email"]')
42+
await input.setValue(email)
4343

44-
// const confirm = wrapper.get<HTMLButtonElement>('[data-test="confirm-button"]')
45-
// await confirm.element.click()
44+
const confirm = wrapper.get<HTMLButtonElement>('[data-test="confirm-button"]')
45+
await confirm.element.click()
4646

47-
// await flushPromises()
47+
await flushPromises()
4848

49-
// expect(wrapper.findComponent(ExistingAccountChecker).exists()).toBe(false)
50-
// expect(wrapper.findComponent(AccountLayout).exists()).toBe(true)
49+
expect(wrapper.findComponent(ExistingAccountChecker).exists()).toBe(false)
50+
expect(wrapper.findComponent(AccountLayout).exists()).toBe(true)
5151

52-
// // email not exists so create user
53-
// expect(wrapper.findComponent(AccountLayout).text()).contain('Create an account')
54-
// })
52+
// email not exists so create user
53+
expect(wrapper.findComponent(AccountLayout).text()).contain('Create an account')
54+
})
5555

5656
it('AddMode email exists', async () => {
5757
const props = {
@@ -73,34 +73,34 @@ describe('AccountDrawer', () => {
7373
await confirm.element.click()
7474

7575
await flushPromises()
76-
// await flushPromises()
76+
await flushPromises()
7777

78-
// expect(wrapper.findComponent(ExistingAccountChecker).exists()).toBe(false)
79-
// expect(wrapper.findComponent(AccountLayout).exists()).toBe(true)
78+
expect(wrapper.findComponent(ExistingAccountChecker).exists()).toBe(false)
79+
expect(wrapper.findComponent(AccountLayout).exists()).toBe(true)
8080

81-
// // email exists so update/add account
82-
// expect(wrapper.findComponent(AccountLayout).text()).contain('Add an account')
81+
// email exists so update/add account
82+
expect(wrapper.findComponent(AccountLayout).text()).contain('Add an account')
8383
})
8484

85-
// it('inviteMode', async () => {
86-
// const props = {
87-
// ...defaultProps,
88-
// isAddMode: false,
89-
// isInviteMode: true,
90-
// selectedUser: UserFactory.generate(),
91-
// }
92-
// const organization = OrganizationOutputFactory.generate()
93-
// registerEndpoint(`user/${props.selectedUser.id}/`, () => props.selectedUser)
94-
// registerEndpoint(`organization/`, () => ({ results: [organization] }))
95-
// const email = props.selectedUser.email
96-
// registerEndpoint(`user/get-by-email/${email}/`, () => {
97-
// throw createError({ statusCode: 404 })
98-
// })
99-
100-
// const wrapper = await lpiMount(AccountDrawer, {
101-
// props,
102-
// })
103-
// expect(wrapper.findComponent(ExistingAccountChecker).exists()).toBe(false)
104-
// expect(wrapper.findComponent(AccountLayout).exists()).toBe(true)
105-
// })
85+
it('inviteMode', async () => {
86+
const props = {
87+
...defaultProps,
88+
isAddMode: false,
89+
isInviteMode: true,
90+
selectedUser: UserFactory.generate(),
91+
}
92+
const organization = OrganizationOutputFactory.generate()
93+
registerEndpoint(`user/${props.selectedUser.id}/`, () => props.selectedUser)
94+
registerEndpoint(`organization/`, () => ({ results: [organization] }))
95+
const email = props.selectedUser.email
96+
registerEndpoint(`user/get-by-email/${email}/`, () => {
97+
throw createError({ statusCode: 404 })
98+
})
99+
100+
const wrapper = await lpiMount(AccountDrawer, {
101+
props,
102+
})
103+
expect(wrapper.findComponent(ExistingAccountChecker).exists()).toBe(false)
104+
expect(wrapper.findComponent(AccountLayout).exists()).toBe(true)
105+
})
106106
})

tests/unit/components/people/Researcher/ResearcherDocumentsTab.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ describe('ResearcherDocumentsTab.vue', () => {
7171
return {
7272
document_types: {
7373
JournalArticle: 100,
74-
Editorial: 10,
75-
Lecture: 45,
76-
Map: 10,
74+
ConferenceAbstract: 10,
75+
ScholarlyPublication: 45,
76+
Book: 10,
7777
},
7878
years: [
7979
{ year: 2025, total: 10 },
@@ -82,9 +82,9 @@ describe('ResearcherDocumentsTab.vue', () => {
8282
{ year: 2022, total: 130 },
8383
],
8484
roles: {
85-
'thesis-advisor': 12,
86-
transcriber: 19,
87-
translator: 10,
85+
trc: 12,
86+
trl: 19,
87+
tyg: 10,
8888
},
8989
}
9090
}

tests/unit/components/project/resource/ResourcesRecap.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ describe('ResourcesRecap.vue', () => {
1616
}
1717
})
1818
it('should render component', () => {
19-
const wrapper = lpiShallowMount(ResourcesRecap, {})
19+
const props = {
20+
target: '/file',
21+
redirect: '/redirect',
22+
}
23+
const wrapper = lpiShallowMount(ResourcesRecap, { props })
2024
expect(wrapper.exists()).toBe(true)
2125
})
2226
})

tests/unit/pages/ProjectPageV2/Tabs/ProjectGoalsTab.spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ import ProjectGoalsTab from '@/pages/ProjectPageV2/Tabs/ProjectGoalsTab.vue'
33

44
import { describe, expect, it, vi } from 'vitest'
55
import { flushPromises } from '@vue/test-utils'
6+
import { TranslatedProjectFactory } from '../../../../factories/project.factory'
67

78
describe('ProjectGoalsTab.vue', () => {
89
it('should render component', async () => {
10+
const project = TranslatedProjectFactory.generate()
911
const wrapper = await lpiMountSuspended(ProjectGoalsTab, {
12+
props: {
13+
project,
14+
},
1015
provide: {
1116
projectLayoutToggleAddModal: vi.fn(),
1217
},

tests/unit/pages/UserProfilePageV2/Tabs/ResearcherDocumentsTab.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ describe('ResearcherDocumentsTab.vue', () => {
2525
return {
2626
document_types: {
2727
JournalArticle: 100,
28-
Editorial: 10,
29-
Lecture: 45,
30-
Map: 10,
28+
ConferenceAbstract: 10,
29+
ScholarlyPublication: 45,
30+
Book: 10,
3131
},
3232
years: [
3333
{ year: 2025, total: 10 },
@@ -36,9 +36,9 @@ describe('ResearcherDocumentsTab.vue', () => {
3636
{ year: 2022, total: 130 },
3737
],
3838
roles: {
39-
'thesis-advisor': 12,
40-
transcriber: 19,
41-
translator: 10,
39+
trc: 12,
40+
trl: 19,
41+
tyg: 10,
4242
},
4343
}
4444
}

0 commit comments

Comments
 (0)