fix lint and tests

This commit is contained in:
einhornimmond 2025-02-24 17:37:30 +01:00
parent 7344e87c72
commit 472c7598ad
13 changed files with 36 additions and 42 deletions

View File

@ -101,12 +101,13 @@ describe('NavBar', () => {
describe('Navbar Menu', () => {
it('has correct menu items', () => {
const navItems = wrapper.findAll('.nav-item a')
expect(navItems).toHaveLength(7)
expect(navItems).toHaveLength(8)
expect(navItems[0].attributes('href')).toBe('/user')
expect(navItems[1].attributes('href')).toBe('/creation-confirm')
expect(navItems[2].attributes('href')).toBe('/contribution-links')
expect(navItems[3].attributes('href')).toBe('/federation')
expect(navItems[4].attributes('href')).toBe('/statistic')
expect(navItems[4].attributes('href')).toBe('/projectBranding')
expect(navItems[5].attributes('href')).toBe('/statistic')
})
})

View File

@ -32,7 +32,11 @@
<BNavItem to="/federation" :active="isActive('federation')">
{{ $t('navbar.instances') }}
</BNavItem>
<BNavItem to="/projectBranding" :active="isActive('projectBranding')" :title="$t('navbar.projectBrandingTooltip')">
<BNavItem
to="/projectBranding"
:active="isActive('projectBranding')"
:title="$t('navbar.projectBrandingTooltip')"
>
{{ $t('navbar.projectBranding') }}
</BNavItem>
<BNavItem to="/statistic" :active="isActive('statistic')">

View File

@ -56,6 +56,7 @@
"enter_text": "Text eintragen",
"form": "Schöpfungsformular",
"min_characters": "Mindestens 10 Zeichen eingeben",
"reset": "Zurücksetzen",
"select_month": "Monat auswählen",
"select_value": "Betrag auswählen",
"submit_creation": "Schöpfung einreichen",

View File

@ -1,14 +0,0 @@
// TODO: only needed for grace period, before all inputs updated for using veeValidate + yup
export const isLanguageKey = (str) =>
str.match(/^(?!\.)[a-z][a-zA-Z0-9-]*([.][a-z][a-zA-Z0-9-]*)*(?<!\.)$/)
export const translateYupErrorString = (error, t) => {
const type = typeof error
if (type === 'object') {
return t(error.key, error.values)
} else if (type === 'string' && error.length > 0 && isLanguageKey(error)) {
return t(error)
} else {
return error
}
}

View File

@ -1,3 +1,4 @@
import { ProjectBranding } from '@entity/ProjectBranding'
import { SignJWT } from 'jose'
import { IRequestOptions, IRestResponse, RestClient } from 'typed-rest-client'
@ -8,10 +9,9 @@ import { backendLogger as logger } from '@/server/logger'
import { PostUserLoggingView } from './logging/PostUserLogging.view'
import { GetUser } from './model/GetUser'
import { PostUser } from './model/PostUser'
import { Space } from './model/Space'
import { SpacesResponse } from './model/SpacesResponse'
import { UsersResponse } from './model/UsersResponse'
import { Space } from './model/Space'
import { ProjectBranding } from '@entity/ProjectBranding'
/**
* HumHubClient as singleton class

View File

@ -1,8 +1,6 @@
import { ProjectBranding as dbProjectBranding } from '@entity/ProjectBranding'
import { ObjectType, Field, Int } from 'type-graphql'
import { Space } from './Space'
@ObjectType()
export class ProjectBranding {
constructor(projectBranding: dbProjectBranding) {

View File

@ -153,9 +153,9 @@ describe('ContributionMessageResolver', () => {
message: 'Test',
},
})
expect(logger.debug).toBeCalledTimes(4)
expect(logger.debug).toBeCalledTimes(9)
expect(logger.debug).toHaveBeenNthCalledWith(
4,
8,
'use UnconfirmedContributionUserAddMessageRole',
)
expect(mutationResult).toEqual(
@ -351,9 +351,9 @@ describe('ContributionMessageResolver', () => {
},
})
expect(logger.debug).toBeCalledTimes(4)
expect(logger.debug).toBeCalledTimes(8)
expect(logger.debug).toHaveBeenNthCalledWith(
4,
8,
'use UnconfirmedContributionAdminAddMessageRole',
)
@ -386,9 +386,9 @@ describe('ContributionMessageResolver', () => {
},
})
expect(logger.debug).toBeCalledTimes(4)
expect(logger.debug).toBeCalledTimes(8)
expect(logger.debug).toHaveBeenNthCalledWith(
4,
8,
'use UnconfirmedContributionAdminAddMessageRole',
)
@ -404,7 +404,7 @@ describe('ContributionMessageResolver', () => {
})
it('logs the error "ContributionMessage was not sent successfully: Error: missing right ADMIN_CREATE_CONTRIBUTION_MESSAGE for user"', () => {
expect(logger.debug).toBeCalledTimes(4)
expect(logger.debug).toBeCalledTimes(8)
expect(logger.error).toHaveBeenNthCalledWith(
1,
'missing right ADMIN_CREATE_CONTRIBUTION_MESSAGE for user',

View File

@ -5,6 +5,7 @@ import { ApolloServerTestClient } from 'apollo-server-testing'
import { testEnvironment, cleanDB, contributionDateFormatter } from '@test/helpers'
import { CONFIG } from '@/config'
import { userFactory } from '@/seeds/factory/user'
import { login, createContribution, adminCreateContribution } from '@/seeds/graphql/mutations'
import { bibiBloxberg } from '@/seeds/users/bibi-bloxberg'
@ -14,6 +15,8 @@ import { getOpenCreations, getUserCreation } from './creations'
jest.mock('@/password/EncryptorUtils')
CONFIG.HUMHUB_ACTIVE = false
let mutate: ApolloServerTestClient['mutate'], con: Connection
let testEnv: {
mutate: ApolloServerTestClient['mutate']
@ -272,6 +275,7 @@ describe('util/creation', () => {
})
})
})
describe('getOpenCreations', () => {
beforeAll(() => {
// enable Fake timers

View File

@ -22,6 +22,12 @@ vi.mock('@vue/apollo-composable', () => ({
})),
}))
vi.mock('@/composables/useToast', () => ({
useAppToast: vi.fn(() => ({
addToast: vi.fn(),
})),
}))
describe('ContributionListItem', () => {
let wrapper
@ -99,12 +105,6 @@ describe('ContributionListItem', () => {
})
})
describe('date', () => {
it('is equal to createdAt', () => {
expect(wrapper.vm.date).toBe(wrapper.vm.createdAt)
})
})
describe('delete contribution', () => {
describe('edit contribution', () => {
beforeEach(() => {

View File

@ -125,7 +125,7 @@ import ContributionMessagesList from '@/components/ContributionMessages/Contribu
import { listContributionMessages } from '@/graphql/queries'
import { useAppToast } from '@/composables/useToast'
import { useI18n } from 'vue-i18n'
import { useLazyQuery, useQuery } from '@vue/apollo-composable'
import { useLazyQuery } from '@vue/apollo-composable'
import AppAvatar from '@/components/AppAvatar.vue'
const props = defineProps({
@ -201,10 +201,9 @@ const props = defineProps({
},
})
const { toastError, toastSuccess } = useAppToast()
const { toastError } = useAppToast()
const { t } = useI18n()
const inProcess = ref(true)
const messagesGet = ref([])
const visible = ref(false)
@ -224,8 +223,6 @@ const icon = computed(() => {
return 'bell-fill'
})
const date = computed(() => props.createdAt)
const collapseId = computed(() => 'collapse' + String(props.id))
const username = computed(() => ({

View File

@ -34,6 +34,9 @@ vi.mock('@vue/apollo-composable', () => ({
useMutation: () => ({
mutate: mockMutate,
}),
useLazyQuery: () => ({
load: vi.fn(),
}),
}))
describe('Login', () => {

View File

@ -74,7 +74,7 @@ const form = ref({
password: '',
})
const { handleSubmit, meta, values } = useForm({
const { handleSubmit, meta } = useForm({
initialValues: form.value,
})

View File

@ -161,9 +161,9 @@ describe('Vuex store', () => {
const commit = vi.fn()
const state = {}
it('calls nineteen commits', () => {
it('calls twente commits', () => {
logout({ commit, state })
expect(commit).toHaveBeenCalledTimes(19)
expect(commit).toHaveBeenCalledTimes(20)
})
// ... (other logout action tests remain largely the same)