diff --git a/frontend/src/components/SessionLogoutTimeout.spec.js b/frontend/src/components/SessionLogoutTimeout.spec.js
index 07d47f9be..fae087ba0 100644
--- a/frontend/src/components/SessionLogoutTimeout.spec.js
+++ b/frontend/src/components/SessionLogoutTimeout.spec.js
@@ -4,7 +4,6 @@ import { nextTick, ref } from 'vue'
import SessionLogoutTimeout from './SessionLogoutTimeout.vue'
import { useLazyQuery } from '@vue/apollo-composable'
import { useStore } from 'vuex'
-import { useModal } from 'bootstrap-vue-next'
// Mock external dependencies
vi.mock('vuex', () => ({
@@ -21,16 +20,21 @@ vi.mock('@vue/apollo-composable', () => ({
// Mock bootstrap-vue-next
const mockHide = vi.fn()
+
vi.mock('bootstrap-vue-next', () => ({
useModal: vi.fn(() => ({
hide: mockHide,
})),
- BModal: { template: '
' },
- BCard: { template: '
' },
- BCardText: { template: '
' },
- BRow: { template: '
' },
- BCol: { template: '
' },
- BButton: { template: '' },
+ BModal: {
+ name: 'BModal',
+ props: ['modelValue'],
+ template: '
',
+ },
+ BCard: { name: 'BCard', template: '
' },
+ BCardText: { name: 'BCardText', template: '
' },
+ BRow: { name: 'BRow', template: '
' },
+ BCol: { name: 'BCol', template: '
' },
+ BButton: { name: 'BButton', template: '' },
}))
const setTokenTime = (seconds) => {
@@ -84,10 +88,9 @@ describe('SessionLogoutTimeout', () => {
})
it('does not show modal when remaining time is more than 75 seconds', async () => {
- wrapper = createWrapper(setTokenTime(76))
- await nextTick()
-
- vi.runOnlyPendingTimers()
+ // 76 don't work, because value will be rounded down with floor, so with running the code time were passing,
+ // and 76 will be rounded down to 75
+ wrapper = createWrapper(setTokenTime(77))
await nextTick()
const modal = wrapper.findComponent({ name: 'BModal' })
@@ -95,7 +98,7 @@ describe('SessionLogoutTimeout', () => {
})
it('emits logout when time expires', async () => {
- wrapper = createWrapper(setTokenTime(1))
+ wrapper = createWrapper(setTokenTime(2))
await nextTick()
vi.runAllTimers()
@@ -162,7 +165,8 @@ describe('SessionLogoutTimeout', () => {
await nextTick()
const warningText = wrapper.find('.text-warning')
- expect(warningText.text()).toContain('65')
+ // second will be rounded with floor
+ expect(warningText.text()).toContain('64')
})
it('shows 00 when time is expired', async () => {
diff --git a/frontend/src/components/SessionLogoutTimeout.vue b/frontend/src/components/SessionLogoutTimeout.vue
index 997a2f2d8..0822ccc0a 100644
--- a/frontend/src/components/SessionLogoutTimeout.vue
+++ b/frontend/src/components/SessionLogoutTimeout.vue
@@ -43,11 +43,11 @@