@@ -3,12 +3,13 @@ import { createComponentRenderer } from '@/__tests__/render';
33import { useNodeTypesStore } from '@/app/stores/nodeTypes.store' ;
44import { useProjectsStore } from '@/features/collaboration/projects/projects.store' ;
55import { ExpressionLocalResolveContextSymbol } from '@/app/constants' ;
6+ import { WorkflowDocumentStoreKey } from '@/app/constants/injectionKeys' ;
67import { useWorkflowHelpers } from '@/app/composables/useWorkflowHelpers' ;
78import ResourceLocator from './ResourceLocator.vue' ;
89import { createTestingPinia } from '@pinia/testing' ;
910import userEvent from '@testing-library/user-event' ;
1011import { fireEvent , screen , waitFor } from '@testing-library/vue' ;
11- import { computed } from 'vue' ;
12+ import { computed , shallowRef } from 'vue' ;
1213import { mockedStore } from '@/__tests__/utils' ;
1314import { vi } from 'vitest' ;
1415import {
@@ -482,6 +483,43 @@ describe('ResourceLocator', () => {
482483 expect ( nodeTypesStore . getNodeParameterActionResult ) . not . toHaveBeenCalled ( ) ;
483484 } ) ;
484485
486+ it ( 'falls back to workflow homeProject ID when currentProjectId is not available' , async ( ) => {
487+ const windowOpenSpy = vi . spyOn ( window , 'open' ) ;
488+ projectsStore . currentProjectId = undefined as unknown as string ;
489+ nodeTypesStore . getResourceLocatorResults . mockResolvedValue ( {
490+ results : [ ] ,
491+ paginationToken : null ,
492+ } ) ;
493+
494+ const mockWorkflowDocumentStore = shallowRef ( {
495+ homeProject : { id : 'home-project-456' , name : 'Test Project' , type : 'team' } ,
496+ } ) ;
497+
498+ const { getByTestId } = renderComponent ( {
499+ props : {
500+ modelValue : TEST_MODEL_VALUE ,
501+ parameter : TEST_PARAMETER_URL_REDIRECT ,
502+ path : `parameters.${ TEST_PARAMETER_URL_REDIRECT . name } ` ,
503+ node : TEST_NODE_URL_REDIRECT ,
504+ displayTitle : 'Test Resource Locator' ,
505+ expressionComputedValue : '' ,
506+ } ,
507+ global : {
508+ provide : {
509+ [ WorkflowDocumentStoreKey as symbol ] : mockWorkflowDocumentStore ,
510+ } ,
511+ } ,
512+ } ) ;
513+
514+ await userEvent . click ( getByTestId ( 'rlc-input' ) ) ;
515+ await userEvent . click ( getByTestId ( 'rlc-item-add-resource' ) ) ;
516+
517+ expect ( windowOpenSpy ) . toHaveBeenCalledWith (
518+ '/projects/home-project-456/datatables/new' ,
519+ '_blank' ,
520+ ) ;
521+ } ) ;
522+
485523 it ( 'clears cached resources after URL redirect so fresh data is fetched on re-open' , async ( ) => {
486524 const TEST_ITEMS = [ { name : 'Old Table' , value : 'old-table' } ] ;
487525 const TEST_ITEMS_UPDATED = [
0 commit comments