Skip to content

Commit 93cd138

Browse files
authored
Merge pull request #1 from lucferbux/enable-shared-library
2 parents 5160e78 + 5749071 commit 93cd138

File tree

142 files changed

+10762
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+10762
-1
lines changed

README.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,23 @@
11
# kubeflow-ui-essentials
2-
A place for Kubeflow common UI code
2+
## Overview
3+
4+
`kubeflow-ui-essentials` is a library designed to provide common UI components and utilities for the Kubeflow ecosystem. This library follows a modular architecture to ensure reusability and maintainability across various Kubeflow repositories. The library is versioned to facilitate consistent updates and integration.
5+
6+
## Folder Structure
7+
8+
The repository contains the following files:
9+
10+
- **api**: Contains the API utilities for the Kubeflow UI components.
11+
- **components**: Contains the reusable UI components for the Kubeflow UI.
12+
- **hooks**: Contains the custom hooks for the Kubeflow UI components.
13+
- **utilities**: Contains the utility functions for the Kubeflow UI components.
14+
- **context**: Contains the context providers for the Kubeflow UI components.
15+
- **style**: Contains the global styles for the Kubeflow UI components.
16+
17+
## Contributing
18+
19+
We welcome contributions to the project. Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file for more information.
20+
21+
## License
22+
23+
This project is licensed under the Apache License 2.0. See the [LICENSE](LICENSE) file for details.

api/__tests__/errorUtils.spec.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { NotReadyError } from '~/shared/utilities/useFetchState';
2+
import { APIError } from '~/shared/api/types';
3+
import { handleRestFailures } from '~/shared/api/errorUtils';
4+
import { mockRegisteredModel } from '~/__mocks__/mockRegisteredModel';
5+
import { mockBFFResponse } from '~/__mocks__/utils';
6+
7+
describe('handleRestFailures', () => {
8+
it('should successfully return registered models', async () => {
9+
const modelRegistryMock = mockRegisteredModel({});
10+
const result = await handleRestFailures(Promise.resolve(mockBFFResponse(modelRegistryMock)));
11+
expect(result.data).toStrictEqual(modelRegistryMock);
12+
});
13+
14+
it('should handle and throw model registry errors', async () => {
15+
const statusMock: APIError = {
16+
error: {
17+
code: '',
18+
message: 'error',
19+
},
20+
};
21+
22+
await expect(handleRestFailures(Promise.resolve(statusMock))).rejects.toThrow('error');
23+
});
24+
25+
it('should handle common state errors ', async () => {
26+
await expect(handleRestFailures(Promise.reject(new NotReadyError('error')))).rejects.toThrow(
27+
'error',
28+
);
29+
});
30+
31+
it('should handle other errors', async () => {
32+
await expect(handleRestFailures(Promise.reject(new Error('error')))).rejects.toThrow(
33+
'Error communicating with server',
34+
);
35+
});
36+
});

0 commit comments

Comments
 (0)