Skip to content

Commit

Permalink
Merge pull request #1 from microsoft/main
Browse files Browse the repository at this point in the history
New commits
  • Loading branch information
cdonke authored Aug 27, 2020
2 parents d476007 + dde7d88 commit dc94aa3
Show file tree
Hide file tree
Showing 225 changed files with 6,822 additions and 1,384 deletions.
3 changes: 2 additions & 1 deletion Composer/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
"viewportWidth": 1600,
"viewportHeight": 1200,
"defaultCommandTimeout": 8000,
"baseUrl": "http://localhost:3000"
"baseUrl": "http://localhost:3000",
"retries": 2
}
4 changes: 2 additions & 2 deletions Composer/cypress/integration/LuisDeploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ context('Luis Deploy', () => {
cy.url().should('contain', 'language-understanding/all');
cy.route({
method: 'POST',
url: 'api/projects/*/luFiles/publish',
url: 'api/projects/*/build',
status: 200,
response: 'fixture:luPublish/success',
});
Expand All @@ -33,7 +33,7 @@ context('Luis Deploy', () => {

cy.route({
method: 'POST',
url: 'api/projects/*/luFiles/publish',
url: 'api/projects/*/build',
status: 400,
response: 'fixture:luPublish/error',
});
Expand Down
4 changes: 2 additions & 2 deletions Composer/cypress/integration/Onboarding.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ context('Onboarding', () => {
beforeEach(() => {
cy.visit('/home');
cy.createBot('TodoSample', 'Onboarding');

cy.visitPage('Design');
//enable onboarding setting
cy.visitPage('Settings');
cy.findByTestId('ProjectTree').within(() => {
cy.findByText('Application Settings').click();
});
cy.findByLabelText('Onboarding').click();
cy.findByTestId('onboardingToggle').click();
cy.visitPage('Design');
});

Expand Down
1 change: 1 addition & 0 deletions Composer/cypress/integration/SaveAs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ context('Saving As', () => {
});

it('can create a new bot from an existing bot', () => {
cy.visitPage('Design');
cy.findByTestId('LeftNav-CommandBarButtonHome').click();
cy.url().should('contain', 'home');
cy.findByText('Save as').click();
Expand Down
8 changes: 3 additions & 5 deletions Composer/cypress/integration/ToDoBot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
// Licensed under the MIT License.

context('ToDo Bot', () => {
beforeEach(() => {
before(() => {
cy.visit('/home');
cy.createBot('TodoSample');
cy.findByTestId('WelcomeModalCloseIcon').click();
cy.findByText('Yes').click();
});

it('can open the main dialog', () => {
Expand All @@ -19,7 +21,6 @@ context('ToDo Bot', () => {
it('can open the AddToDo dialog', () => {
cy.findByTestId('ProjectTree').within(() => {
cy.findByText('addtodo').click();
cy.findByText('addtodo').click();
});

cy.url().should('contain', 'addtodo');
Expand All @@ -28,7 +29,6 @@ context('ToDo Bot', () => {
it('can open the ClearToDos dialog', () => {
cy.findByTestId('ProjectTree').within(() => {
cy.findByText('cleartodos').click();
cy.findByText('cleartodos').click();
});

cy.url().should('contain', 'cleartodos');
Expand All @@ -37,7 +37,6 @@ context('ToDo Bot', () => {
it('can open the DeleteToDo dialog', () => {
cy.findByTestId('ProjectTree').within(() => {
cy.findByText('deletetodo').click();
cy.findByText('deletetodo').click();
});

cy.url().should('contain', 'deletetodo');
Expand All @@ -46,7 +45,6 @@ context('ToDo Bot', () => {
it('can open the ShowToDos dialog', () => {
cy.findByTestId('ProjectTree').within(() => {
cy.findByText('showtodos').click();
cy.findByText('showtodos').click();
});

cy.url().should('contain', 'showtodos');
Expand Down
2 changes: 1 addition & 1 deletion Composer/cypress/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"baseUrl": "../node_modules",
"target": "es5",
"lib": ["es5", "dom"],
"types": ["cypress", "@types/testing-library__cypress", "./support/commands"]
"types": ["cypress", "@testing-library/cypress", "./support/commands"]
},
"include": ["**/*.ts"]
}
6 changes: 3 additions & 3 deletions Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,18 @@
"@babel/preset-typescript": "^7.9.0",
"@bfc/eslint-plugin-bfcomposer": "*",
"@emotion/babel-preset-css-prop": "^10.0.27",
"@testing-library/cypress": "^6.0.0",
"@testing-library/cypress": "7.0.0-beta.1",
"@typescript-eslint/eslint-plugin": "2.34.0",
"@typescript-eslint/parser": "2.34.0",
"chalk": "^4.0.0",
"concurrently": "^4.1.0",
"coveralls": "^3.1.0",
"cross-env": "^6.0.3",
"cypress": "^4.5.0",
"cypress": "^5.0.0",
"cypress-plugin-tab": "^1.0.5",
"eslint": "7.0.0",
"eslint-config-prettier": "6.11.0",
"eslint-plugin-cypress": "2.10.3",
"eslint-plugin-cypress": "2.11.1",
"eslint-plugin-emotion": "10.0.27",
"eslint-plugin-format-message": "6.2.3",
"eslint-plugin-import": "2.20.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import * as React from 'react';
import { fireEvent } from '@bfc/test-utils';

import { PublishLuisDialog } from '../../../src/components/TestController/publishDialog';
import { PublishDialog } from '../../../src/components/TestController/publishDialog';
import { projectIdState, botNameState, settingsState, dispatcherState } from '../../../src/recoilModel';
import { renderWithRecoil } from '../../testUtils';
jest.useFakeTimers();
Expand All @@ -18,8 +18,10 @@ const luisConfig = {
defaultLanguage: 'en-us',
environment: 'composer',
};
describe('<PublishLuisDialog />', () => {
it('should render the <PublishLuisDialog />', () => {
const config = { subscriptionKey: '12345', qnaRegion: 'westus', ...luisConfig };
const qnaConfig = { subscriptionKey: '12345', endpointKey: '12345', qnaRegion: 'westus' };
describe('<PublishDialog />', () => {
it('should render the <PublishDialog />', () => {
const onDismiss = jest.fn(() => {});
const onPublish = jest.fn(() => {});
const setSettingsMock = jest.fn(() => {});
Expand All @@ -31,16 +33,11 @@ describe('<PublishLuisDialog />', () => {
set(botNameState, 'sampleBot0');
set(settingsState, {
luis: luisConfig,
qna: qnaConfig,
});
};
const { getByText } = renderWithRecoil(
<PublishLuisDialog
isOpen
botName={'sampleBot0'}
config={luisConfig}
onDismiss={onDismiss}
onPublish={onPublish}
/>,
<PublishDialog isOpen botName={'sampleBot0'} config={config} onDismiss={onDismiss} onPublish={onPublish} />,
recoilInitState
);

Expand All @@ -50,14 +47,21 @@ describe('<PublishLuisDialog />', () => {
fireEvent.click(publishButton);
expect(onPublish).toBeCalled();
expect(onPublish).toBeCalledWith({
name: 'sampleBot0',
authoringKey: '12345',
authoringEndpoint: 'testAuthoringEndpoint',
endpointKey: '12345',
endpoint: 'testEndpoint',
authoringRegion: 'westus',
defaultLanguage: 'en-us',
environment: 'composer',
luis: {
name: 'sampleBot0',
authoringKey: '12345',
authoringEndpoint: 'testAuthoringEndpoint',
endpointKey: '12345',
endpoint: 'testEndpoint',
authoringRegion: 'westus',
defaultLanguage: 'en-us',
environment: 'composer',
},
qna: {
subscriptionKey: '12345',
endpointKey: '',
qnaRegion: 'westus',
},
});
});
});
5 changes: 5 additions & 0 deletions Composer/packages/client/__tests__/components/skill.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ const recoilInitState = ({ set }) => {
defaultLanguage: 'en-us',
environment: 'composer',
},
qna: {
subscriptionKey: '12345',
qnaRegion: 'westus',
endpointKey: '',
},
});
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import * as React from 'react';
import { fireEvent, waitFor } from '@bfc/test-utils';

import { TriggerCreationModal } from '../../src/components/ProjectTree/TriggerCreationModal';
import { renderWithRecoil } from '../testUtils';

describe('<TriggerCreationModal/>', () => {
const onSubmitMock = jest.fn();
const onDismissMock = jest.fn();

function renderComponent() {
return renderWithRecoil(
<TriggerCreationModal isOpen dialogId={'todobot'} onDismiss={onDismissMock} onSubmit={onSubmitMock} />
);
}

it('should render the component', () => {
const component = renderComponent();
expect(component.container).toBeDefined();
});

it('hould create a Luis Intent recognized', async () => {
const component = renderComponent();
const triggerType = component.getByTestId('triggerTypeDropDown');
fireEvent.click(triggerType);

const luisOption = component.getByTitle('Intent recognized');
fireEvent.click(luisOption);
const node = await waitFor(() => component.getByTestId('triggerFormSubmit'));
expect(node).toBeDisabled();
});

it('should create a QnA Intent recognized', async () => {
const component = renderComponent();
const triggerType = component.getByTestId('triggerTypeDropDown');
fireEvent.click(triggerType);

const qnaOption = component.getByTitle('QnA Intent recognized');
fireEvent.click(qnaOption);

const node = await waitFor(() => component.getByTestId('triggerFormSubmit'));
expect(node).toBeEnabled();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/* eslint-disable react-hooks/rules-of-hooks */
import React from 'react';

import TableView from '../../../src/pages/knowledge-base/table-view';
import CodeEditor from '../../../src/pages/knowledge-base/code-editor';
import { renderWithRecoil } from '../../testUtils';
import {
projectIdState,
localeState,
dialogsState,
qnaFilesState,
settingsState,
schemasState,
dispatcherState,
} from '../../../src/recoilModel';
import mockProjectResponse from '../../../src/recoilModel/dispatchers/__tests__/mocks/mockProjectResponse.json';

const initialContent = `
# ?question
\`\`\`
answer
\`\`\`
`;

const state = {
projectId: 'test',
dialogs: [{ id: '1' }, { id: '2' }],
locale: 'en-us',
qnaFiles: [
{
id: 'a.en-us',
content: initialContent,
qnaSections: [
{
Questions: [{ content: 'question', id: 1 }],
Answer: 'answer',
uuid: 1,
},
],
},
],
settings: {
defaultLanguage: 'en-us',
languages: ['en-us', 'fr-fr'],
},
};

const updateQnAFileMock = jest.fn();

const initRecoilState = ({ set }) => {
set(projectIdState, state.projectId);
set(localeState, state.locale);
set(dialogsState, state.dialogs);
set(qnaFilesState, state.qnaFiles);
set(settingsState, state.settings);
set(schemasState, mockProjectResponse.schemas);
set(dispatcherState, {
updateQnAFile: updateQnAFileMock,
});
};

describe('QnA page all up view', () => {
it('should render QnA page table view', () => {
const { getByText, getByTestId } = renderWithRecoil(<TableView dialogId={'a'} />, initRecoilState);
getByTestId('table-view');
getByText('question (1)');
getByText('answer');
});

it('should render QnA page code editor', () => {
renderWithRecoil(<CodeEditor dialogId={'a'} />, initRecoilState);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import * as React from 'react';
import { RecoilRoot } from 'recoil';
import { renderHook } from '@bfc/test-utils/lib/hooks';
import { Range, Position } from '@bfc/shared';

import useNotifications from '../../../src/pages/notifications/useNotifications';
import {
Expand Down Expand Up @@ -37,10 +38,7 @@ const state = {
Body: '- test12345 ss',
Entities: [],
Name: 'test',
range: {
endLineNumber: 7,
startLineNumber: 4,
},
range: new Range(new Position(4, 0), new Position(7, 14)),
},
],
diagnostics: [
Expand All @@ -64,7 +62,7 @@ const state = {
{
body: '- ${add(1,2)}',
name: 'bar',
range: { endLineNumber: 0, startLineNumber: 0 },
range: new Range(new Position(0, 0), new Position(2, 14)),
},
],
diagnostics: [
Expand Down
2 changes: 1 addition & 1 deletion Composer/packages/client/__tests__/plugins.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('mergePluginConfigs', () => {
};

// @ts-expect-error
expect(mergePluginConfigs(config1, config2).recognizers).toEqual(['recognizer 1', 'recognizer 2']);
expect(mergePluginConfigs(config1, config2).recognizers).toEqual(['recognizer 2', 'recognizer 1']);
});

it('replaces other arrays', () => {
Expand Down
Loading

0 comments on commit dc94aa3

Please sign in to comment.