Skip to content

Commit

Permalink
Merge branch 'master' into liweitian/updateDefaultFolder
Browse files Browse the repository at this point in the history
  • Loading branch information
cwhitten authored Nov 18, 2019
2 parents eb1194c + 4831b79 commit c6468d5
Show file tree
Hide file tree
Showing 221 changed files with 3,586 additions and 2,002 deletions.
10 changes: 7 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
ci:
name: Unit Tests
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- name: Checkout
Expand All @@ -30,7 +31,7 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
- name: yarn install
run: yarn install
run: yarn
working-directory: Composer
- name: yarn build:dev
run: yarn build:dev
Expand All @@ -57,6 +58,7 @@ jobs:
e2e:
name: E2E Tests
runs-on: ubuntu-latest
timeout-minutes: 20

steps:
- name: Checkout
Expand All @@ -73,7 +75,7 @@ jobs:
restore-keys: |
${{ runner.os }}-yarn-
- name: yarn install
run: yarn install
run: yarn
working-directory: Composer
- name: yarn build:prod
run: yarn build:prod
Expand All @@ -95,13 +97,15 @@ jobs:
botproject:
name: BotProject
runs-on: windows-latest
timeout-minutes: 20

steps:
- name: Checkout
uses: actions/checkout@v1
- name: Set Dotnet Version
uses: actions/setup-dotnet@v1
with:
dotnet-version: "2.1.802" # SDK Version to use.
dotnet-version: "3.0.100" # SDK Version to use.
- name: dotnet build
run: dotnet build
working-directory: BotProject/CSharp
Expand Down
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"type": "node",
"request": "attach",
"name": "Server: Attach",
"port": 9229,
"port": 9228,
"sourceMaps": true
}
]
Expand Down
2 changes: 1 addition & 1 deletion BotProject/Templates/CSharp/BotProject.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
<Rule Id="SA1408" Action="Error" />
<Rule Id="SA1410" Action="Error" />
<Rule Id="SA1411" Action="Error" />
<Rule Id="SA1412" Action="Error" />
<Rule Id="SA1412" Action="None" /> <!-- StoreFilesAsUtf8BOM-->
<Rule Id="SA1413" Action="None" /> <!-- UseTrailingCommasInMultiLineInitializers-->
<Rule Id="SA1101" Action="None" /> <!-- PrefixLocalCallsWithThis -->
<Rule Id="SA1129" Action="None" /> <!-- DoNotUseDefaultValueTypeConstructor-->
Expand Down
26 changes: 25 additions & 1 deletion Composer/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ module.exports = {
'plugin:@typescript-eslint/recommended-requiring-type-checking',
'plugin:@typescript-eslint/eslint-recommended',
'prettier/@typescript-eslint',
'plugin:@bfc/bfcomposer/recommended',
],
plugins: ['import', 'notice', 'security'],
plugins: ['import', 'notice', 'security', 'lodash'],
env: {
browser: true,
es6: true,
Expand All @@ -21,6 +22,8 @@ module.exports = {
templateFile: require.resolve('./license.js'),
},
],

// typescript
'@typescript-eslint/ban-ts-ignore': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/interface-name-prefix': 'off',
Expand Down Expand Up @@ -54,6 +57,27 @@ module.exports = {
'security/detect-possible-timing-attacks': 'error',
'security/detect-pseudoRandomBytes': 'error',
'security/detect-unsafe-regex': 'error',

// lodash
'lodash/callback-binding': 'error',
'lodash/collection-method-value': 'error',
'lodash/collection-return': 'error',
'lodash/no-double-unwrap': 'error',
'lodash/no-extra-args': 'error',
'lodash/no-unbound-this': 'error',
'lodash/unwrap': 'error',
'lodash/identity-shorthand': 'error',
'lodash/import-scope': ['error', 'method'],
'lodash/matches-prop-shorthand': 'error',
'lodash/matches-shorthand': 'error',
'lodash/path-style': 'error',
'lodash/prefer-compact': 'error',
'lodash/prefer-flat-map': 'error',
'lodash/prefer-immutable-method': 'error',
'lodash/prefer-map': 'error',
'lodash/prefer-reject': 'error',
'lodash/preferred-alias': 'error',
'lodash/prop-shorthand': 'error',
},
overrides: [
{
Expand Down
8 changes: 7 additions & 1 deletion Composer/.eslintrc.react.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
extends: ['./.eslintrc.js', 'plugin:react/recommended'],
plugins: ['react-hooks', 'format-message'],
plugins: ['react-hooks', 'format-message', 'emotion'],
settings: {
react: {
version: '16.9.0',
Expand All @@ -14,17 +14,23 @@ module.exports = {
},
},
rules: {
// format message
'format-message/literal-pattern': 'error',
'format-message/no-invalid-pattern': 'error',
'format-message/no-missing-params': ['error', { allowNonLiteral: false }],

// react hooks
'react-hooks/exhaustive-deps': 'off',
'react-hooks/rules-of-hooks': 'error',

// react
'react/display-name': 'off',
'react/no-danger': 'error',
'react/no-deprecated': 'warn',
'react/prop-types': 'warn',

// emotion
'emotion/jsx-import': 'error',
},
overrides: [
{
Expand Down
2 changes: 1 addition & 1 deletion Composer/cypress/integration/LGPage.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ context('check language generation page', () => {
cy.get('@switchButton').click();

// nav to Main dialog
cy.get('.dialogNavTree button[title="__TestTodoSample.Main"]').click();
cy.get('.dialogNavTree a[title="__TestTodoSample.Main"]').click();
cy.wait(300);

// dialog filter, edit mode button is disabled.
Expand Down
25 changes: 25 additions & 0 deletions Composer/cypress/integration/NotificationPage.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/// <reference types="Cypress" />

context('check notifications page', () => {
beforeEach(() => {
cy.visit(Cypress.env('COMPOSER_URL'));
cy.createBot('TodoSample');
});

it('can show lg syntax error ', () => {
cy.visitPage("Bot Responses");
// left nav tree
cy.contains('TodoSample.Main');
cy.contains('All');

cy.get('.toggleEditMode button').click();
cy.get('textarea').type('test lg syntax error');

cy.visitPage("Notifications");

cy.get('[data-testid="notifications-table-view"]').within(() => {
cy.getByText('common.lg').should('exist');
});

});
});
9 changes: 9 additions & 0 deletions Composer/cypress/integration/Onboarding.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ context('onboarding', () => {
cy.get('input[data-testid="NewDialogName"]').type('__TestOnboarding');
cy.get('input[data-testid="NewDialogName"]').type('{enter}');
cy.wait(2000);

//enable onboarding setting
cy.visitPage("Settings");
cy.wait(2000);
cy.get('[data-testid="ProjectTree"]').within(() => {
cy.get('[title="Onboarding"]').click();
});
cy.get('button[data-testid="onboardingToggle"]').click();
cy.visitPage("Design Flow");
});

it('walk through product tour teaching bubbles', () => {
Expand Down
4 changes: 4 additions & 0 deletions Composer/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,7 @@ Cypress.Commands.add('addEventHandler', handler => {
}
cy.get(`[data-testid="triggerFormSubmit"]`).click();
});

Cypress.Commands.add('visitPage', (page) => {
cy.get(`[data-testid="LeftNav-CommandBarButton${page}"]`).click();
});
3 changes: 3 additions & 0 deletions Composer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@babel/preset-env": "7.3.0",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
"@bfc/eslint-plugin-bfcomposer": "*",
"@emotion/babel-preset-css-prop": "^10.0.17",
"@typescript-eslint/eslint-plugin": "2.6.0",
"@typescript-eslint/parser": "2.6.0",
Expand All @@ -72,9 +73,11 @@
"cypress-testing-library": "^3.0.1",
"eslint": "^5.15.1",
"eslint-config-prettier": "^4.1.0",
"eslint-plugin-emotion": "^10.0.14",
"eslint-plugin-format-message": "^6.2.3",
"eslint-plugin-import": "^2.16.0",
"eslint-plugin-jsx-a11y": "6.1.2",
"eslint-plugin-lodash": "^6.0.0",
"eslint-plugin-notice": "^0.7.8",
"eslint-plugin-prettier": "^3.0.1",
"eslint-plugin-react": "7.12.4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,38 @@ const ProblemChild = () => {
};

describe('<ErrorBoundary/>', () => {
let consoleErrorStub, consoleLogStub;

beforeEach(() => {
consoleErrorStub = jest.spyOn(console, 'error').mockImplementation(() => {});
consoleLogStub = jest.spyOn(console, 'log').mockImplementation(() => {});
});

afterEach(() => {
consoleErrorStub.mockRestore();
consoleLogStub.mockRestore();
});

it('should just render the children if error not occur', () => {
ErrorBoundary.contextType = Store;
const { container, debug } = render(
const { container } = render(
<ErrorBoundary>
<div>test</div>
</ErrorBoundary>
);
debug();
expect(container).toHaveTextContent('test');
});

it('all the components will not crash with ErrorBoundary even child compoent throw a error', () => {
ErrorBoundary.contextType = Store;
const { container, debug } = render(
const { container } = render(
<div>
<ErrorBoundary>
<ProblemChild />
</ErrorBoundary>
<div> will not crash</div>
</div>
);
debug();
expect(container).toHaveTextContent('will not crash');
});

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

import * as React from 'react';
import { fireEvent, render } from 'react-testing-library';

import { NotificationHeader } from '../../src/pages/notifications/NotificationHeader';

describe('<NotificationHeader/>', () => {
const items = ['test1', 'test2', 'test3'];
it('should render the NotificationHeader', () => {
const mockOnChange = jest.fn(() => null);
const { container } = render(<NotificationHeader items={items} onChange={mockOnChange} />);

expect(container).toHaveTextContent('Notifications');
expect(container).toHaveTextContent('All');
const dropdown = container.querySelector('[data-testid="notifications-dropdown"]');
fireEvent.click(dropdown);
const test = document.querySelector('.ms-Dropdown-callout');
expect(test).toHaveTextContent('test1');
expect(test).toHaveTextContent('test2');
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import * as React from 'react';
import { render } from 'react-testing-library';

import { NotificationList } from '../../src/pages/notifications/NotificationList';

describe('<NotificationList/>', () => {
const items = [
{ type: 'Error', location: 'test1', message: 'error1' },
{ type: 'Warning', location: 'test2', message: 'error2' },
{ type: 'Error', location: 'test3', message: 'error3' },
];
it('should render the NotificationList', () => {
const { container } = render(<NotificationList items={items} />);

expect(container).toHaveTextContent('test1');
expect(container).toHaveTextContent('test2');
expect(container).toHaveTextContent('test3');
});
});
Loading

0 comments on commit c6468d5

Please sign in to comment.