Skip to content

Commit

Permalink
feat: update backend to support MDS (#190) (#199)
Browse files Browse the repository at this point in the history
* init MDS

Signed-off-by: tygao <tygao@amazon.com>

* update backend to support mds

Signed-off-by: tygao <tygao@amazon.com>

* remove DSM in required plugins

Signed-off-by: tygao <tygao@amazon.com>

* doc: update changelog

Signed-off-by: tygao <tygao@amazon.com>

* test: update tests

Signed-off-by: tygao <tygao@amazon.com>

* update mock context

Signed-off-by: tygao <tygao@amazon.com>

* update core context mock

Signed-off-by: tygao <tygao@amazon.com>

* test: add tests for chat route

Signed-off-by: tygao <tygao@amazon.com>

* use await and update tests

Signed-off-by: tygao <tygao@amazon.com>

* Fix unit tests after getDataSourceQuery change

Signed-off-by: Lin Wang <wonglam@amazon.com>

* remove useless DSM calling in flyout

Signed-off-by: tygao <tygao@amazon.com>

---------

Signed-off-by: tygao <tygao@amazon.com>
Signed-off-by: Lin Wang <wonglam@amazon.com>
Co-authored-by: Lin Wang <wonglam@amazon.com>
(cherry picked from commit 0d6ce86)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

# Conflicts:
#	CHANGELOG.md

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: tygao <tygao@amazon.com>
  • Loading branch information
3 people committed Jun 3, 2024
1 parent fb07dd8 commit b6b9a27
Show file tree
Hide file tree
Showing 31 changed files with 529 additions and 489 deletions.
2 changes: 1 addition & 1 deletion opensearch_dashboards.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
"dataSourceManagement"
],
"configPath": [
"assistant"
"assistant"
]
}
2 changes: 2 additions & 0 deletions public/components/__tests__/chat_window_header_title.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import * as coreContextExports from '../../contexts/core_context';
import { IMessage } from '../../../common/types/chat_saved_object_attributes';

import { ChatWindowHeaderTitle } from '../chat_window_header_title';
import { DataSourceServiceMock } from '../../services/data_source_service.mock';

const setup = ({
messages = [],
Expand All @@ -37,6 +38,7 @@ const setup = ({
}),
reload: jest.fn(),
},
dataSource: new DataSourceServiceMock(),
},
};
useCoreMock.services.http.put.mockImplementation(() => Promise.resolve());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ import {
EditConversationNameModalProps,
} from '../edit_conversation_name_modal';
import { HttpHandler } from '../../../../../src/core/public';
import { DataSourceServiceMock } from '../../services/data_source_service.mock';

const setup = ({ onClose, defaultTitle, conversationId }: EditConversationNameModalProps) => {
const useCoreMock = {
services: coreMock.createStart(),
services: { ...coreMock.createStart(), dataSource: new DataSourceServiceMock() },
};
jest.spyOn(coreContextExports, 'useCore').mockReturnValue(useCoreMock);

Expand Down Expand Up @@ -156,7 +157,10 @@ describe('<EditConversationNameModal />', () => {
expect(useCoreMock.services.http.put).not.toHaveBeenCalled();

fireEvent.click(renderResult.getByTestId('confirmModalConfirmButton'));
expect(useCoreMock.services.http.put).toHaveBeenCalled();

await waitFor(() => {
expect(useCoreMock.services.http.put).toHaveBeenCalled();
});

fireEvent.click(renderResult.getByTestId('confirmModalCancelButton'));

Expand Down
309 changes: 0 additions & 309 deletions public/components/feedback_modal.tsx

This file was deleted.

3 changes: 2 additions & 1 deletion public/contexts/__mocks__/core_context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import { BehaviorSubject } from 'rxjs';
import { coreMock } from '../../../../../src/core/public/mocks';
import { DataSourceServiceMock } from '../../services/data_source_service.mock';

export const useCore = jest.fn(() => {
const useCoreMock = {
Expand All @@ -24,7 +25,7 @@ export const useCore = jest.fn(() => {
load: jest.fn(),
},
conversationLoad: {},
dataSource: {},
dataSource: new DataSourceServiceMock(),
},
};
useCoreMock.services.http.delete.mockReturnValue(Promise.resolve());
Expand Down
1 change: 1 addition & 0 deletions public/contexts/core_context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface AssistantServices extends Required<OpenSearchDashboardsServices
startDeps: AssistantPluginStartDependencies;
conversationLoad: ConversationLoadService;
conversations: ConversationsService;
// This service is maintained in chatbot instead of dataSource exported from core plugin.
dataSource: DataSourceService;
}

Expand Down
Loading

0 comments on commit b6b9a27

Please sign in to comment.