-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Model registry deploy modal has faulty submit button disable detection (
#3209) * working version * addressed comments
- Loading branch information
1 parent
5613032
commit e9c8a33
Showing
2 changed files
with
55 additions
and
1 deletion.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
.../concepts/modelRegistry/apiHooks/__tests__/usePrefillDeployModalFromModelRegistry.spec.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,48 @@ | ||
import { renderHook } from '@testing-library/react'; | ||
import usePrefillDeployModalFromModelRegistry from '~/pages/modelRegistry/screens/RegisteredModels/usePrefillDeployModalFromModelRegistry'; | ||
import { ProjectKind } from '~/k8sTypes'; | ||
import { RegisteredModelDeployInfo } from '~/pages/modelRegistry/screens/RegisteredModels/useRegisteredModelDeployInfo'; | ||
import { mockInferenceServiceModalData } from '~/__mocks__/mockInferenceServiceModalData'; | ||
import { DataConnection } from '~/pages/projects/types'; | ||
|
||
describe('usePrefillDeployModalFromModelRegistry', () => { | ||
const mockProjectContext = { | ||
currentProject: { | ||
apiVersion: 'v1', | ||
kind: 'Project', | ||
metadata: { | ||
name: 'test-project', | ||
namespace: 'test-namespace', | ||
}, | ||
} as ProjectKind, | ||
dataConnections: [] as DataConnection[], | ||
}; | ||
|
||
const data = mockInferenceServiceModalData({}); | ||
|
||
const mockSetCreateData = jest.fn(); | ||
|
||
const mockRegisteredModelDeployInfo: RegisteredModelDeployInfo = { | ||
modelName: 'test-model', | ||
modelArtifactUri: 's3://bucket/path', | ||
modelArtifactStorageKey: 'test-key', | ||
}; | ||
|
||
it('should ensure awsData array never has more than one element per key', () => { | ||
renderHook(() => | ||
usePrefillDeployModalFromModelRegistry( | ||
mockProjectContext, | ||
data, | ||
mockSetCreateData, | ||
mockRegisteredModelDeployInfo, | ||
), | ||
); | ||
|
||
const { awsData } = mockSetCreateData.mock.calls.find(([key]) => key === 'storage')[1]; | ||
|
||
const keys = awsData.map((item: { key: string }) => item.key); | ||
const uniqueKeys = new Set(keys); | ||
|
||
expect(keys.length).toBe(uniqueKeys.size); | ||
}); | ||
}); |
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