-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
XIVY-14730 disable metadata of overwritten variables
Make the metadata read only if the variable is found in the known variables of the required projects.
- Loading branch information
Showing
7 changed files
with
130 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
packages/variable-editor/src/components/variables/detail/DetailContent.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import type { Client, MetaRequestTypes, ProjectVarNode } from '@axonivy/variable-editor-protocol'; | ||
import { waitFor } from '@testing-library/react'; | ||
import { customRenderHook } from '../data/test-utils/test-utils'; | ||
import type { Variable } from '../data/variable'; | ||
import { useOverwrites } from './DetailContent'; | ||
|
||
describe('useOverwrites', () => { | ||
describe('false', () => { | ||
test('in known folder', () => { | ||
const view = customRenderHook(() => useOverwrites(), { | ||
wrapperProps: { client: new ClientMock(), appContext: { variables: variables, selectedVariable: [1, 0] } } | ||
}); | ||
expect(view.result.current).toBeFalsy(); | ||
}); | ||
|
||
test('not in known folder', () => { | ||
const view = customRenderHook(() => useOverwrites(), { | ||
wrapperProps: { client: new ClientMock(), appContext: { variables: variables, selectedVariable: [0] } } | ||
}); | ||
expect(view.result.current).toBeFalsy(); | ||
}); | ||
}); | ||
|
||
describe('true', () => { | ||
test('leaf', async () => { | ||
const view = customRenderHook(() => useOverwrites(), { | ||
wrapperProps: { client: new ClientMock(), appContext: { variables: variables, selectedVariable: [1, 1, 0] } } | ||
}); | ||
await waitFor(() => { | ||
expect(view.result.current).toBeTruthy(); | ||
}); | ||
}); | ||
|
||
test('not leaf', async () => { | ||
const view = customRenderHook(() => useOverwrites(), { | ||
wrapperProps: { client: new ClientMock(), appContext: { variables: variables, selectedVariable: [1, 1] } } | ||
}); | ||
await waitFor(() => { | ||
expect(view.result.current).toBeTruthy(); | ||
}); | ||
}); | ||
}); | ||
}); | ||
|
||
const variables = [ | ||
{ name: 'Variable' }, | ||
{ name: 'Amazon', children: [{ name: 'AmazonVariable' }, { name: 'Comprehend', children: [{ name: 'SecretKey' }] }] } | ||
] as Array<Variable>; | ||
|
||
class ClientMock implements Partial<Client> { | ||
meta<TMeta extends keyof MetaRequestTypes>(): Promise<MetaRequestTypes[TMeta][1]> { | ||
return Promise.resolve({ | ||
children: [{ name: 'Amazon', children: [{ name: 'Comprehend', children: [{ name: 'SecretKey' }, { name: 'AccessKey' }] }] }] | ||
} as ProjectVarNode); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters