import { createMemoryHistory, createRouter } from 'vue-router'; import { useAccessStore } from '@easyflow/stores'; import { createPinia, setActivePinia } from 'pinia'; import { beforeEach, describe, expect, it } from 'vitest'; import { createRouterGuard } from '../guard'; describe('public route guard', () => { beforeEach(() => { setActivePinia(createPinia()); }); it('bypasses stale login state for an anonymous workflow share', async () => { const accessStore = useAccessStore(); accessStore.setAccessToken('stale-token'); const router = createRouter({ history: createMemoryHistory(), routes: [ { component: { template: '
login
' }, name: 'Login', path: '/auth/login', }, { component: { template: '
workflow share
' }, meta: { ignoreAccess: true, title: 'Workflow Share' }, name: 'WorkflowShare', path: '/share/workflow', }, ], }); createRouterGuard(router); await router.push('/share/workflow?shareKey=share-key'); await router.isReady(); expect(router.currentRoute.value.name).toBe('WorkflowShare'); expect(router.currentRoute.value.query.shareKey).toBe('share-key'); }); });