fix some frontend tests

This commit is contained in:
einhornimmond 2025-02-24 14:00:57 +01:00
parent ca628319f9
commit 4c8aea0d3e
2 changed files with 21 additions and 7 deletions

View File

@ -1,5 +1,6 @@
import { describe, it, expect, beforeEach, vi } from 'vitest'
import { mount } from '@vue/test-utils'
import { createStore } from 'vuex'
import AuthLayout from './AuthLayout'
import {
BAvatar,
@ -39,6 +40,19 @@ vi.mock('@/config', () => ({
describe('AuthLayout', () => {
let wrapper
const createVuexStore = () => {
return createStore({
state: {
project: '',
},
actions: {
project: vi.fn(),
},
mutations: {
project: vi.fn(),
},
})
}
const createWrapper = () => {
return mount(AuthLayout, {
@ -54,6 +68,7 @@ describe('AuthLayout', () => {
BImg,
BPopover,
},
plugins: [createVuexStore()],
mocks: {
$i18n: {
locale: 'en',
@ -97,17 +112,16 @@ describe('AuthLayout', () => {
expect(wrapper.find('nav#sidenav-main').exists()).toBe(false)
})
it('has LanguageSwitch2', () => {
expect(wrapper.findComponent({ name: 'LanguageSwitch2' }).exists()).toBe(true)
})
it('displays the community name', () => {
expect(wrapper.find('.h1').text()).toBe('Test Community')
})
it('test size in setTextSize', async () => {
const mockEl = { style: {} }
vi.spyOn(document, 'querySelector').mockReturnValue(mockEl)
await wrapper.vm.setTextSize(0.85)
expect(wrapper.vm.$refs.pageFontSize.$el.style.fontSize).toBe('0.85rem')
expect(mockEl.style.fontSize).toBe('0.85rem')
})
})
@ -115,6 +129,7 @@ describe('AuthLayout', () => {
beforeEach(() => {
wrapper = mount(AuthLayout, {
global: {
plugins: [createVuexStore()],
mocks: {
$i18n: {
locale: 'en',

View File

@ -43,7 +43,7 @@
<BAvatar src="/img/brand/gradido_coin_128x128.png" size="6rem" />
</BCol>
</BRow>
<BCard ref="pageFontSize" no-body class="border-0 mt-4 gradido-custom-background">
<BCard no-body class="border-0 mt-4 gradido-custom-background page-font-size">
<BRow class="p-4">
<BCol cols="10">
<language-switch-2 class="ms-3" />
@ -131,7 +131,6 @@ onMounted(async () => {
const urlParams = new URLSearchParams(window.location.search)
const projectValue = urlParams.get('project')
if (projectValue) {
console.log('project value: ', projectValue)
load()
store.commit('project', projectValue)
} else {