Skip to content
Snippets Groups Projects
Commit 7ea16bec authored by Eline Evje's avatar Eline Evje
Browse files

Merge branch 'dev' into enhancement/implement-account-number-to-config

parents 730a5dbe 9005e7a9
Branches enhancement/implement-account-number-to-config
No related tags found
3 merge requests!66Final merge,!36Enhancement/implement account number to config,!4Pipeline fix
Pipeline #280406 passed
<template>
<button @click="openModal" class="text-nowrap">Endre avatar</button>
<div
v-if="isModalOpen"
class="fixed inset-0 bg-black bg-opacity-50 flex justify-center items-center z-50"
>
<div class="bg-white p-6 rounded-lg shadow-lg max-w-[80vh] h-auto w-full text-center">
<h2 class="title">Endre avatar</h2>
<div class="avatar-container flex flex-row justify-between items-center my-8">
<button @click="cycleArray('prev')"></button>
<div class="flex flex-row items-center justify-around">
<img :src="previousAvatar" alt="avatar" class="avatar h-16 w-16" />
<div class="border-4 rounded-full border-green-600 p-8 mx-4">
<img :src="currentAvatar" alt="avatar" class="avatar h-40 w-40" />
</div>
<img :src="nextAvatar" alt="avatar" class="avatar h-16 w-16" />
</div>
<button @click="cycleArray('next')"></button>
</div>
<button @click="saveAvatar" class="save-button">Lagre</button>
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const isModalOpen = ref(false)
const avatars = [
'src/assets/coffee.png',
'src/assets/head.png',
'src/assets/nose.png',
'src/assets/penger.png',
'src/assets/pig.png'
]
let currentAvatarIndex = 0
const openModal = () => {
isModalOpen.value = !isModalOpen.value
}
const nextAvatar = ref(avatars[(currentAvatarIndex + 1) % avatars.length])
const currentAvatar = ref(avatars[currentAvatarIndex])
const previousAvatar = ref(avatars[(currentAvatarIndex - 1 + avatars.length) % avatars.length])
const cycleArray = (direction: string) => {
if (direction === 'prev') {
currentAvatarIndex = (currentAvatarIndex - 1 + avatars.length) % avatars.length
console.log(currentAvatarIndex)
currentAvatar.value = avatars[currentAvatarIndex]
previousAvatar.value = avatars[(currentAvatarIndex - 1 + avatars.length) % avatars.length]
nextAvatar.value = avatars[(currentAvatarIndex + 1) % avatars.length]
} else {
currentAvatarIndex = (currentAvatarIndex + 1) % avatars.length
currentAvatar.value = avatars[currentAvatarIndex]
previousAvatar.value = avatars[(currentAvatarIndex - 1 + avatars.length) % avatars.length]
nextAvatar.value = avatars[(currentAvatarIndex + 1) % avatars.length]
}
}
const saveAvatar = () => {
localStorage.setItem('avatar', currentAvatar.value)
isModalOpen.value = false
}
</script>
import { mount, VueWrapper } from '@vue/test-utils'
import NavBar from '@/components/NavBarComponent.vue'
import router from '@/router'
import { createPinia, setActivePinia } from 'pinia'
import { describe, it, expect, beforeEach, vi } from 'vitest'
vi.stubGlobal('scrollTo', vi.fn())
describe('NavBar Routing', () => {
let wrapper: VueWrapper<any>
beforeEach(async () => {
const pinia = createPinia()
setActivePinia(pinia)
wrapper = mount(NavBar, {
global: {
plugins: [router, pinia]
}
})
await router.push('/')
await router.isReady()
})
it('renders without errors', () => {
expect(wrapper.exists()).toBe(true)
})
it('displays correct active route for home link on full screen', async () => {
global.innerWidth = 1200
await router.push('/hjem')
await router.isReady()
expect(wrapper.find('.router-link-exact-active').exists()).toBe(true)
})
it('displays correct active route for goals link on full screen', async () => {
global.innerWidth = 1200
await router.push('/sparemaal')
await router.isReady()
expect(wrapper.find('.router-link-exact-active').exists()).toBe(true)
})
it('displays correct active route for challenges link on full screen', async () => {
global.innerWidth = 1200
await router.push('/spareutfordringer')
await router.isReady()
expect(wrapper.find('.router-link-exact-active').exists()).toBe(true)
})
it('displays correct active route for profile link on full screen', async () => {
global.innerWidth = 1200
await router.push('/profil')
await router.isReady()
expect(wrapper.find('.router-link-exact-active').exists()).toBe(true)
})
it('displays correct active route for home link when the hamburger menu is open', async () => {
global.innerWidth = 1000
wrapper.vm.hamburgerOpen = true
await wrapper.vm.$nextTick()
await router.push('/hjem')
await router.isReady()
expect(wrapper.find('.router-link-exact-active').exists()).toBe(true)
})
it('displays correct active route for goals link when the hamburger menu is open', async () => {
global.innerWidth = 1000
wrapper.vm.hamburgerOpen = true
await wrapper.vm.$nextTick()
await router.push('/sparemaal')
await router.isReady()
expect(wrapper.find('.router-link-exact-active').exists()).toBe(true)
})
it('displays correct active route for challenges link when the hamburger menu is open', async () => {
global.innerWidth = 1000
wrapper.vm.hamburgerOpen = true
await wrapper.vm.$nextTick()
await router.push('/spareutfordringer')
await router.isReady()
expect(wrapper.find('.router-link-exact-active').exists()).toBe(true)
})
it('displays correct active route for profile link when the hamburger menu is open', async () => {
global.innerWidth = 1000
wrapper.vm.hamburgerOpen = true
await wrapper.vm.$nextTick()
await router.push('/profil')
await router.isReady()
expect(wrapper.find('.router-link-exact-active').exists()).toBe(true)
})
})
......@@ -91,16 +91,11 @@ const canResetPassword = computed(() => {
const resetPassword = async () => {
isModalOpen.value = true
const resetPasswordDTO = {
resetID: resetID.value,
userID: userID.value,
newPassword: newPassword.value
}
try {
await axios.post('http://localhost:8080/forgotPassword/resetPassword', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(resetPasswordDTO)
resetID: resetID.value,
userID: userID.value,
newPassword: newPassword.value
})
} catch (error) {
const err = error as Error
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment