43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
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: '<div>login</div>' },
|
|
name: 'Login',
|
|
path: '/auth/login',
|
|
},
|
|
{
|
|
component: { template: '<div>workflow share</div>' },
|
|
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');
|
|
});
|
|
});
|