11import { writable } from 'svelte/store' ;
22
3- import { afterEach , describe , expect , it , vi } from 'vitest' ;
3+ import { afterEach , beforeEach , describe , expect , it , vi } from 'vitest' ;
44
55import { base } from '$app/paths' ;
66
77import type {
88 EventSortOrder ,
99 WorkflowViewPreference ,
1010} from '$lib/stores/event-view' ;
11- import { routePrefix } from '$lib/stores/route-prefix' ;
1211
12+ import { initCoreProvider } from './core-provider' ;
1313import {
1414 baseRouteForWorkflow ,
1515 hasParameters ,
@@ -567,31 +567,30 @@ describe('routeFor worker deployment version and serverless routes', () => {
567567describe ( 'routeFor with prefix' , ( ) => {
568568 const prefix = '/projects/my-project' ;
569569
570- afterEach ( ( ) => {
571- routePrefix . set ( '' ) ;
570+ beforeEach ( ( ) => {
571+ initCoreProvider ( {
572+ getAccessToken : async ( ) => '' ,
573+ getRoutePrefix : ( ) => prefix ,
574+ } ) ;
572575 } ) ;
573576
574577 it ( 'should prepend prefix to root route' , ( ) => {
575- routePrefix . set ( prefix ) ;
576578 expect ( routeForNamespaces ( ) ) . toBe ( `${ base } ${ prefix } /namespaces` ) ;
577579 } ) ;
578580
579581 it ( 'should prepend prefix to namespace route' , ( ) => {
580- routePrefix . set ( prefix ) ;
581582 expect ( routeForNamespace ( { namespace : 'default' } ) ) . toBe (
582583 `${ base } ${ prefix } /namespaces/default` ,
583584 ) ;
584585 } ) ;
585586
586587 it ( 'should propagate prefix through leaf functions' , ( ) => {
587- routePrefix . set ( prefix ) ;
588588 expect ( routeForWorkflows ( { namespace : 'default' } ) ) . toBe (
589589 `${ base } ${ prefix } /namespaces/default/workflows` ,
590590 ) ;
591591 } ) ;
592592
593593 it ( 'should propagate prefix through deep leaf functions' , ( ) => {
594- routePrefix . set ( prefix ) ;
595594 expect (
596595 routeForCallStack ( {
597596 namespace : 'default' ,
@@ -602,40 +601,41 @@ describe('routeFor with prefix', () => {
602601 } ) ;
603602
604603 it ( 'should propagate prefix to nexus routes' , ( ) => {
605- routePrefix . set ( prefix ) ;
606604 expect ( routeForNexus ( ) ) . toBe ( `${ base } ${ prefix } /nexus` ) ;
607605 } ) ;
608606
609607 it ( 'should propagate prefix to schedule routes' , ( ) => {
610- routePrefix . set ( prefix ) ;
611608 expect ( routeForSchedules ( { namespace : 'default' } ) ) . toBe (
612609 `${ base } ${ prefix } /namespaces/default/schedules` ,
613610 ) ;
614611 } ) ;
615612
616613 it ( 'should not apply prefix when store is empty' , ( ) => {
617- routePrefix . set ( '' ) ;
614+ initCoreProvider ( {
615+ getAccessToken : async ( ) => '' ,
616+ getRoutePrefix : ( ) => '' ,
617+ } ) ;
618618 expect ( routeForNamespaces ( ) ) . toBe ( `${ base } /namespaces` ) ;
619619 } ) ;
620620
621621 it ( 'should not apply prefix to auth routes' , ( ) => {
622- routePrefix . set ( prefix ) ;
623622 const settings = { auth : { } , baseUrl : 'https://localhost' } ;
624623 const searchParams = new URLSearchParams ( ) ;
625624 const sso = routeForAuthentication ( { settings, searchParams } ) ;
626625 expect ( sso ) . not . toContain ( prefix ) ;
627626 } ) ;
628627
629628 it ( 'should not apply prefix to login page' , ( ) => {
630- routePrefix . set ( prefix ) ;
631629 const login = routeForLoginPage ( '' , false ) ;
632630 expect ( login ) . not . toContain ( prefix ) ;
633631 } ) ;
634632
635633 it ( 'should revert to default behavior when prefix is cleared' , ( ) => {
636- routePrefix . set ( prefix ) ;
637634 expect ( routeForNamespaces ( ) ) . toBe ( `${ base } ${ prefix } /namespaces` ) ;
638- routePrefix . set ( '' ) ;
635+ initCoreProvider ( {
636+ getAccessToken : async ( ) => '' ,
637+ getRoutePrefix : ( ) => '' ,
638+ } ) ;
639639 expect ( routeForNamespaces ( ) ) . toBe ( `${ base } /namespaces` ) ;
640640 } ) ;
641641} ) ;
0 commit comments