-
Notifications
You must be signed in to change notification settings - Fork 377
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into gcox/support-json-schema-files
- Loading branch information
Showing
72 changed files
with
4,668 additions
and
1,474 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
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
67 changes: 67 additions & 0 deletions
67
Composer/packages/client/__tests__/components/createQnAModal.test.tsx
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,67 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
import React from 'react'; | ||
import { fireEvent } from '@bfc/test-utils'; | ||
|
||
import { renderWithRecoil } from '../testUtils/renderWithRecoil'; | ||
import CreateQnAFromUrlModal from '../../src/components/QnA/CreateQnAFromUrlModal'; | ||
import { showCreateQnAFromUrlDialogState, showCreateQnAFromUrlDialogWithScratchState } from '../../src/recoilModel'; | ||
|
||
describe('<CreateQnAFromUrlModal />', () => { | ||
const onDismiss = jest.fn(() => {}); | ||
const onSubmit = jest.fn(() => {}); | ||
const projectId = 'test-create-qna'; | ||
|
||
it('renders <CreateQnAFromUrlModal /> and create from scratch', () => { | ||
const container = renderWithRecoil( | ||
<CreateQnAFromUrlModal | ||
dialogId="test" | ||
projectId={projectId} | ||
qnaFiles={[]} | ||
onDismiss={onDismiss} | ||
onSubmit={onSubmit} | ||
/>, | ||
({ set }) => { | ||
set(showCreateQnAFromUrlDialogState(projectId), true); | ||
set(showCreateQnAFromUrlDialogWithScratchState(projectId), true); | ||
} | ||
); | ||
|
||
const { getByTestId } = container; | ||
const createFromScratchButton = getByTestId('createKnowledgeBaseFromScratch'); | ||
expect(createFromScratchButton).not.toBeNull(); | ||
fireEvent.click(createFromScratchButton); | ||
// actions tobe called | ||
}); | ||
|
||
it('create with name/url and validate the value', () => { | ||
const container = renderWithRecoil( | ||
<CreateQnAFromUrlModal | ||
dialogId="test" | ||
projectId={projectId} | ||
qnaFiles={[]} | ||
onDismiss={onDismiss} | ||
onSubmit={onSubmit} | ||
/>, | ||
() => {} | ||
); | ||
|
||
const { findByText, getByTestId } = container; | ||
const inputName = getByTestId('knowledgeLocationTextField-name') as HTMLInputElement; | ||
fireEvent.change(inputName, { target: { value: 'test' } }); | ||
|
||
const inputUrl = getByTestId('knowledgeLocationTextField-url') as HTMLInputElement; | ||
fireEvent.change(inputUrl, { target: { value: 'test' } }); | ||
|
||
expect(inputUrl.value).toBe('test'); | ||
expect(findByText(/A valid url should start with/)).not.toBeNull(); | ||
fireEvent.change(inputUrl, { target: { value: 'http://test' } }); | ||
|
||
const createKnowledgeButton = getByTestId('createKnowledgeBase'); | ||
expect(createKnowledgeButton).not.toBeNull(); | ||
fireEvent.click(createKnowledgeButton); | ||
expect(onSubmit).toBeCalled(); | ||
expect(onSubmit).toBeCalledWith({ url: 'http://test', name: 'test', multiTurn: false }); | ||
}); | ||
}); |
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.