Commit 896cf465 authored by Maxime Chaillet's avatar Maxime Chaillet

test that getEvents() is called when user clicks the refresh button.

parent 38f7cf50
......@@ -116,7 +116,7 @@ class Event extends React.Component {
<LazyContentEvent event={event} />
{event.events && this.state.collapsed ? <Label style={{ color: "blue", backgroundColor: "white", cursor: "pointer" }} onClick={this.handleClick} >.... {event.events.length} command lines more</Label> : null}
</td>
<td classNmae='eventActionBox' style={{ width: '50px', border: 0 }}>
<td className='eventActionBox' style={{ width: '50px', border: 0 }}>
<Button bsStyle="link" bsSize="small" style={{ padding: '0px' }} onClick={() => this.props.onEventClicked(event)}>
<Glyphicon glyph={getPreviousVersionNumber(event) === 0 ? 'plus' : 'edit'} style={{ width: '40px', position: 'static' }} />
</Button>
......
......@@ -72,18 +72,18 @@ class EventListMenu extends React.Component {
<Navbar.Collapse>
<Nav>
{/* <NavItem eventKey={2} href="#" className="logbookNavItem" > */}
<DropdownButton id='dropdownbuttonId' onClick={(e) => { e.stopPropagation() }}
bsStyle={'primary'}
title={'View'}
bsSize='small'>
<MenuItem eventKey="1" onSelect={() => setView(DOC_VIEW)} > {view === DOC_VIEW ? <Radio checked> Classic (user's commented logs)</Radio> : <Radio checked={false}> Classic (user's commented logs)</Radio>} </MenuItem>
<MenuItem eventKey="2" onSelect={() => setView(LIST_VIEW)} > {view === LIST_VIEW ? <Radio checked> Full (all logs)</Radio> : <Radio checked={false}> Full (all logs)</Radio>} </MenuItem>
<MenuItem divider />
<MenuItem eventKey="3" onSelect={() => this.sortByDate(SORT_EVENTS_FROM_OLDEST)} > {getCurrentlyPressedSortButton() === SORT_EVENTS_FROM_OLDEST ? <Radio checked> Oldest log on top</Radio> : <Radio checked={false}> Oldest log on top</Radio>} </MenuItem>
<MenuItem eventKey="4" onSelect={() => this.sortByDate(SORT_EVENTS_FROM_YOUNGEST)} > {getCurrentlyPressedSortButton() === SORT_EVENTS_FROM_YOUNGEST ? <Radio checked> Latest log on top</Radio> : <Radio checked={false}> Latest log on top</Radio>} </MenuItem>
</DropdownButton>
{/* </NavItem> */}
<NavItem eventKey={2} href="#" className="logbookNavItem" >
<DropdownButton id='dropdownbuttonId' onClick={(e) => { e.stopPropagation() }}
bsStyle={'primary'}
title={'View'}
bsSize='small'>
<MenuItem eventKey="1" onSelect={() => setView(DOC_VIEW)} > {view === DOC_VIEW ? <Radio checked> Classic (user's commented logs)</Radio> : <Radio checked={false}> Classic (user's commented logs)</Radio>} </MenuItem>
<MenuItem eventKey="2" onSelect={() => setView(LIST_VIEW)} > {view === LIST_VIEW ? <Radio checked> Full (all logs)</Radio> : <Radio checked={false}> Full (all logs)</Radio>} </MenuItem>
<MenuItem divider />
<MenuItem eventKey="3" onSelect={() => this.sortByDate(SORT_EVENTS_FROM_OLDEST)} > {getCurrentlyPressedSortButton() === SORT_EVENTS_FROM_OLDEST ? <Radio checked> Oldest log on top</Radio> : <Radio checked={false}> Oldest log on top</Radio>} </MenuItem>
<MenuItem eventKey="4" onSelect={() => this.sortByDate(SORT_EVENTS_FROM_YOUNGEST)} > {getCurrentlyPressedSortButton() === SORT_EVENTS_FROM_YOUNGEST ? <Radio checked> Latest log on top</Radio> : <Radio checked={false}> Latest log on top</Radio>} </MenuItem>
</DropdownButton>
</NavItem>
<NavItem eventKey={3} href={getPDF(sessionId, investigationId, selectionFilter)} target='_blank' className="logbookNavItem" >
<EventListMenuButton text='PDF' glyph='download' tooltipText='Download as PDF' isEnabled={!(isNewEventVisible === undefined || isNewEventVisible === true || numberOfMatchingEventsFound === 0)} />
</NavItem>
......
#nav-dropdown-menu {
padding: 0px;
color: white;
}
@media screen and (min-height: 768px) {
.dropdown {
margin-top: 8px;
}
}
\ No newline at end of file
......@@ -24,7 +24,7 @@ import PeriodicRefresher from './PeriodicRefresher.js';
* This class represents the event container component. It's role is to retrieve events from the server asynchronuously.
* Also, it is connected to redux and retrieves user data and sessionId.
*/
class LogbookContainer extends React.Component {
export class LogbookContainer extends React.Component {
constructor(props) {
super(props);
......@@ -71,7 +71,6 @@ class LogbookContainer extends React.Component {
}
if (this.isAppProperlyConfigured()) {
debugger;
return (
<div style={{ marginBottom: '40px' }}>
<OverlayBox open={this.state.errorMessage ? true : false} onClose={() => { this.setState({ errorMessage: null }) }} classNames={{ modal: 'userMessageModalClass', closeButton: 'userMessageCloseButton' }}>
......@@ -211,7 +210,6 @@ class LogbookContainer extends React.Component {
*/
getEvents(offset, selectionFilter, isEventCountRequestNeeded, sortingFilter) {
const { investigationId, user } = this.props;
sortingFilter = sortingFilter || GUI_CONFIG().DEFAULT_SORTING_FILTER;
if (!selectionFilter) {
// there is not selectionfilter as parameter when the user has clicked on a page
......
......@@ -11,7 +11,7 @@ import promise from "redux-promise-middleware"
import { LOGGED_IN } from '../../src/constants/ActionTypes';
import { GUI_CONFIG } from '../../src/config/gui.config';
jest.mock("../../src/config/gui.config");
import LogbookContainer from '../../src/containers/Logbook/LogbookContainer';
import LogbookContainer, {LogbookContainer as LogbookContainerNoConnect} from '../../src/containers/Logbook/LogbookContainer';
const IORequestModule = require('../../src/containers/Logbook/IORequests')
const resources = require('./resources/NewlyAvailableEventsDialogue.resource.js');
......@@ -46,6 +46,25 @@ describe("NewlyAvailableEventsDialogue integration tests", () => {
/>)
};
it('calls getEvents when the user clicks the refresh icon on the NewlyAvailableEventsDialogue', () => {
IORequestModule.getEventsByInvestigationId = jest.fn((sessionId, investigationId, limit, offset, selectionFilter, sortingFilter, onSuccess, onError) => {
onSuccess(resources.refreshEventList.serverResponse1);
});
IORequestModule.getEventCountByInvestigationId = jest.fn((investigationId, sessionId, selectionFilter, onSuccess, onEventsReceptionFailure) => {
onSuccess(resources.refreshEventList.serverResponse2);
});
const mockedGetEvents = jest.spyOn(LogbookContainerNoConnect.prototype,'getEvents');
const wrapper = getWrapper();
wrapper.update();
expect(mockedGetEvents).toHaveBeenCalledTimes(1); //called by component will mount
wrapper.find('EventListMenu').find('NewlyAvailableEventsDialogue').find('Glyphicon').simulate('click');
wrapper.update()
expect(mockedGetEvents).toHaveBeenCalledTimes(2);
})
it('refreshes the event list when the user clicks the refresh icon on the NewlyAvailableEventsDialogue', () => {
IORequestModule.getEventsByInvestigationId = jest.fn((sessionId, investigationId, limit, offset, selectionFilter, sortingFilter, onSuccess, onError) => {
onSuccess(resources.refreshEventList.serverResponse1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment