forked from microsoft/BotFramework-Composer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: UI implementation for Linting and Validation (microsoft#1518)
* lint ui * update some ui * update some function * update some naming and clean some component * hoist the filter state * convert to es6 module imports of office ui * fix some conflict * fix linting * fix e2e test * add format-message * add e2e test and unit test
- Loading branch information
Showing
14 changed files
with
420 additions
and
59 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
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'); | ||
}); | ||
|
||
}); | ||
}); |
23 changes: 23 additions & 0 deletions
23
Composer/packages/client/__tests__/components/notificationHeader.test.js
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,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'); | ||
}); | ||
}); |
22 changes: 22 additions & 0 deletions
22
Composer/packages/client/__tests__/components/notificationList.test.js
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,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'); | ||
}); | ||
}); |
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
46 changes: 46 additions & 0 deletions
46
Composer/packages/client/src/pages/notifications/NotificationHeader.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,46 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
/** @jsx jsx */ | ||
import { jsx } from '@emotion/core'; | ||
import { Dropdown, IDropdownOption } from 'office-ui-fabric-react/lib/Dropdown'; | ||
import formatMessage from 'format-message'; | ||
import { useMemo } from 'react'; | ||
|
||
import { notificationHeader, notificationHeaderText, dropdownStyles } from './styles'; | ||
|
||
const createOptions = (items: string[]): IDropdownOption[] => { | ||
const defaultOptions: IDropdownOption[] = [ | ||
{ key: formatMessage('Show All Locations'), text: formatMessage('All'), data: '', isSelected: true }, | ||
]; | ||
items.forEach(item => { | ||
return defaultOptions.push({ key: item, text: item, data: item }); | ||
}); | ||
return defaultOptions; | ||
}; | ||
|
||
export interface INotificationHeader { | ||
onChange: (text: string) => void; | ||
items: string[]; | ||
} | ||
|
||
export const NotificationHeader: React.FC<INotificationHeader> = props => { | ||
const { onChange, items } = props; | ||
const options = useMemo(() => { | ||
return createOptions(items); | ||
}, [items]); | ||
|
||
return ( | ||
<div css={notificationHeader}> | ||
<div css={notificationHeaderText}>{formatMessage('Notifications')}</div> | ||
<Dropdown | ||
onChange={(event, option) => { | ||
if (option) onChange(option.data); | ||
}} | ||
options={options} | ||
styles={dropdownStyles} | ||
data-testid="notifications-dropdown" | ||
/> | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.