-
Notifications
You must be signed in to change notification settings - Fork 182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prefill URI connections and fix prefill deploy model form from version #3590
Open
manaswinidas
wants to merge
15
commits into
opendatahub-io:main
Choose a base branch
from
manaswinidas:prefill-uri-connections
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+747
−274
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c7dcbd7
Add autofill modal and button for URI connections
manaswinidas aebc3e7
Porting DataConnection to Connection
manaswinidas dae1edf
Merge with 'main'
manaswinidas 6519eda
Fix prefill for S3 connections and merge with main
manaswinidas eaad6fd
Fix prefill for S3 connections
manaswinidas 99b898e
Fix for prefilling URI connections
manaswinidas f70f3c5
Add alert to prefilled modal and some name changes
manaswinidas ece823b
Fix conflicts
manaswinidas 2ca897c
Add unit tests and UX fixes
manaswinidas 7712f42
Fix unit tests
manaswinidas 9a8ff18
Microcopy fixes
manaswinidas b70fba1
Fix Cypress tests
manaswinidas f2062e6
Fix more Cypress tests
manaswinidas 66c44f8
Remove extra params in tests
manaswinidas 31127fa
Add comments for tech debt and a RegisteredModelLocation type
manaswinidas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
59 changes: 59 additions & 0 deletions
59
frontend/src/concepts/connectionTypes/__tests__/useConnectionType.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,59 @@ | ||
import { act } from 'react'; | ||
import { standardUseFetchState, testHook } from '~/__tests__/unit/testUtils/hooks'; | ||
import { fetchConnectionType } from '~/services/connectionTypesService'; | ||
import { useConnectionType } from '~/concepts/connectionTypes/useConnectionType'; | ||
import { mockConnectionTypeConfigMapObj } from '~/__mocks__/mockConnectionType'; | ||
|
||
jest.mock('~/services/connectionTypesService', () => ({ | ||
fetchConnectionType: jest.fn(), | ||
})); | ||
|
||
const mockFetchConnectionType = jest.mocked(fetchConnectionType); | ||
|
||
describe('useConnectionType', () => { | ||
it('should return connection type config map object when name is given', async () => { | ||
const configMapObjMock = mockConnectionTypeConfigMapObj({ name: 'test-connection-type' }); | ||
mockFetchConnectionType.mockResolvedValue(configMapObjMock); | ||
const renderResult = testHook(useConnectionType)('test-connection-type'); | ||
expect(mockFetchConnectionType).toHaveBeenCalledTimes(1); | ||
expect(renderResult).hookToStrictEqual(standardUseFetchState(undefined, false, undefined)); | ||
expect(renderResult).hookToHaveUpdateCount(1); | ||
|
||
// wait for update | ||
await renderResult.waitForNextUpdate(); | ||
expect(mockFetchConnectionType).toHaveBeenCalledTimes(1); | ||
expect(renderResult).hookToStrictEqual(standardUseFetchState(configMapObjMock, true)); | ||
expect(renderResult).hookToHaveUpdateCount(2); | ||
expect(renderResult).hookToBeStable([false, false, true, true]); | ||
|
||
// refresh | ||
await act(() => renderResult.result.current[3]()); | ||
expect(mockFetchConnectionType).toHaveBeenCalledTimes(2); | ||
expect(renderResult).hookToHaveUpdateCount(3); | ||
expect(renderResult).hookToBeStable([false, true, true, true]); | ||
}); | ||
|
||
it('should handle errors when name is empty', async () => { | ||
mockFetchConnectionType.mockRejectedValue(new Error('No connection type name')); | ||
const renderResult = testHook(useConnectionType)('test'); | ||
expect(renderResult).hookToStrictEqual(standardUseFetchState(undefined)); | ||
expect(renderResult).hookToHaveUpdateCount(1); | ||
// wait for update | ||
await renderResult.waitForNextUpdate(); | ||
expect(renderResult).hookToStrictEqual( | ||
standardUseFetchState(undefined, false, new Error('No connection type name')), | ||
); | ||
expect(mockFetchConnectionType).toHaveBeenCalledTimes(1); | ||
expect(renderResult).hookToHaveUpdateCount(2); | ||
expect(renderResult).hookToBeStable([true, true, false, true]); | ||
// refresh | ||
mockFetchConnectionType.mockRejectedValue(new Error('No connection type name-error2')); | ||
await act(() => renderResult.result.current[3]()); | ||
expect(mockFetchConnectionType).toHaveBeenCalledTimes(2); | ||
expect(renderResult).hookToStrictEqual( | ||
standardUseFetchState(undefined, false, new Error('No connection type name-error2')), | ||
); | ||
expect(renderResult).hookToHaveUpdateCount(3); | ||
expect(renderResult).hookToBeStable([true, true, false, true]); | ||
}); | ||
}); |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: This would be easier for the next person to grok if it was an if / else branch IMO