phobos_checkpoint_ui 0.4.0 → 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +5 -1
  3. data/frontend/.gitignore +4 -0
  4. data/frontend/src/actions/events-search.js +11 -11
  5. data/frontend/src/actions/events-search.spec.js +21 -21
  6. data/frontend/src/actions/failures/details.js +42 -0
  7. data/frontend/src/actions/failures/details.spec.js +71 -0
  8. data/frontend/src/actions/failures/overview.js +14 -0
  9. data/frontend/src/actions/failures/overview.spec.js +20 -0
  10. data/frontend/src/actions/failures/retry.js +58 -0
  11. data/frontend/src/actions/failures/retry.spec.js +117 -0
  12. data/frontend/src/actions/failures/search/index.js +76 -0
  13. data/frontend/src/actions/failures/search/index.spec.js +197 -0
  14. data/frontend/src/actions/index.js +24 -5
  15. data/frontend/src/actions/navigation/index.js +5 -0
  16. data/frontend/src/actions/navigation/index.spec.js +21 -0
  17. data/frontend/src/api.js +11 -0
  18. data/frontend/src/components/{event-overview/attribute.js → attribute/index.js} +0 -0
  19. data/frontend/src/components/empty-event/index.js +20 -0
  20. data/frontend/src/components/empty-event/index.spec.js +38 -0
  21. data/frontend/src/components/event-overview/index.js +1 -1
  22. data/frontend/src/components/event-retry-dialog/index.js +1 -1
  23. data/frontend/src/components/failure/error-message.js +19 -0
  24. data/frontend/src/components/failure/error-message.scss +8 -0
  25. data/frontend/src/components/failure/event.scss +3 -0
  26. data/frontend/src/components/failure/index.js +82 -0
  27. data/frontend/src/components/failure/index.spec.js +89 -0
  28. data/frontend/src/components/failure/loading.js +16 -0
  29. data/frontend/src/components/failure/overview/failure-overview.scss +28 -0
  30. data/frontend/src/components/failure/overview/index.js +60 -0
  31. data/frontend/src/components/failure/overview/index.spec.js +71 -0
  32. data/frontend/src/components/failure/overview-dialog/event-overview-dialog.scss +15 -0
  33. data/frontend/src/components/failure/overview-dialog/index.js +90 -0
  34. data/frontend/src/components/failure/retry-dialog/index.js +72 -0
  35. data/frontend/src/components/failure/style.js +16 -0
  36. data/frontend/src/components/failures-list/failures-list.scss +49 -0
  37. data/frontend/src/components/failures-list/index.js +62 -0
  38. data/frontend/src/components/failures-list/index.spec.js +59 -0
  39. data/frontend/src/components/header/index.js +36 -2
  40. data/frontend/src/components/load-more/index.js +22 -0
  41. data/frontend/src/components/load-more/index.spec.js +54 -0
  42. data/frontend/src/components/search-input/index.js +2 -5
  43. data/frontend/src/components/search-input/index.spec.js +6 -6
  44. data/frontend/src/reducers/events.js +2 -2
  45. data/frontend/src/reducers/events.spec.js +4 -4
  46. data/frontend/src/reducers/failures/details/index.js +32 -0
  47. data/frontend/src/reducers/failures/details/index.spec.js +54 -0
  48. data/frontend/src/reducers/failures/index.js +48 -0
  49. data/frontend/src/reducers/failures/index.spec.js +95 -0
  50. data/frontend/src/reducers/index.js +4 -1
  51. data/frontend/src/reducers/index.spec.js +2 -0
  52. data/frontend/src/reducers/xhr-status.js +25 -10
  53. data/frontend/src/reducers/xhr-status.spec.js +65 -15
  54. data/frontend/src/routes.js +6 -2
  55. data/frontend/src/store.js +7 -3
  56. data/frontend/src/views/{event-details.js → events/details/index.js} +0 -0
  57. data/frontend/src/views/{events-search.js → events/search/index.js} +37 -44
  58. data/frontend/src/views/{events-search.scss → events/search/index.scss} +0 -0
  59. data/frontend/src/views/{events-search.spec.js → events/search/index.spec.js} +35 -25
  60. data/frontend/src/views/failures/details/index.js +50 -0
  61. data/frontend/src/views/failures/search/index.js +113 -0
  62. data/frontend/src/views/failures/search/index.scss +24 -0
  63. data/frontend/src/views/failures/search/index.spec.js +106 -0
  64. data/lib/phobos_checkpoint_ui/version.rb +1 -1
  65. data/phobos_checkpoint_ui.gemspec +1 -1
  66. metadata +53 -14
@@ -27,11 +27,11 @@ describe('<SearchInput />', () => {
27
27
  store = mockStore({})
28
28
 
29
29
  props = {
30
- onSearch: jasmine.createSpy('onSearch'),
31
30
  onChangeFilterType: jasmine.createSpy('onChangeFilterType'),
32
31
  onChangeFilterValue: jasmine.createSpy('onChangeFilterValue'),
33
- isFetchingEvents: false,
32
+ triggerSearch: jasmine.createSpy('triggerSearch'),
34
33
 
34
+ isFetchingEvents: false,
35
35
  filterType: 'entity_id',
36
36
  filterValue: '12345'
37
37
  }
@@ -44,13 +44,13 @@ describe('<SearchInput />', () => {
44
44
  expect(props.onChangeFilterValue).toHaveBeenCalledWith('new-value')
45
45
  })
46
46
 
47
- it('calls onSearch when ENTER is pressed in the textfield', () => {
47
+ it('calls triggerSearch when ENTER is pressed in the textfield', () => {
48
48
  component.find('input').simulate('keyDown', { keyCode: ENTER_KEY })
49
- expect(props.onSearch).toHaveBeenCalled()
49
+ expect(props.triggerSearch).toHaveBeenCalled()
50
50
  })
51
51
 
52
- it('calls onSearch when the search button is pressed', () => {
52
+ it('calls triggerSearch when the search button is pressed', () => {
53
53
  component.find('button').simulate('click')
54
- expect(props.onSearch).toHaveBeenCalled()
54
+ expect(props.triggerSearch).toHaveBeenCalled()
55
55
  })
56
56
  })
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  EVENT_SHOW_OVERVIEW,
3
3
  EVENT_HIDE_OVERVIEW,
4
- RECEIVE_SEARCH_RESULTS,
4
+ RECEIVE_EVENTS_SEARCH_RESULTS,
5
5
  EVENT_SHOW_RETRY,
6
6
  EVENT_HIDE_RETRY,
7
7
  RECEIVE_EVENT_RETRY,
@@ -25,7 +25,7 @@ export default (state = [], action) => {
25
25
  case EVENT_HIDE_OVERVIEW:
26
26
  return patchEvent(state, action, { overviewVisible: false, error: null })
27
27
 
28
- case RECEIVE_SEARCH_RESULTS:
28
+ case RECEIVE_EVENTS_SEARCH_RESULTS:
29
29
  return action.offset <= 0
30
30
  ? action.events
31
31
  : state.concat(action.events)
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  EVENT_SHOW_OVERVIEW,
3
3
  EVENT_HIDE_OVERVIEW,
4
- RECEIVE_SEARCH_RESULTS,
4
+ RECEIVE_EVENTS_SEARCH_RESULTS,
5
5
  EVENT_SHOW_RETRY,
6
6
  EVENT_HIDE_RETRY,
7
7
  RECEIVE_EVENT_RETRY,
@@ -29,11 +29,11 @@ describe('reducers/events', () => {
29
29
  })
30
30
  })
31
31
 
32
- describe('for RECEIVE_SEARCH_RESULTS', () => {
32
+ describe('for RECEIVE_EVENTS_SEARCH_RESULTS', () => {
33
33
  describe('when offset less or equal to 0', () => {
34
34
  it('overrides events with action events', () => {
35
35
  const currentState = [{ id: 1 }, { id: 2 }, { id: 3 }]
36
- const action = { type: RECEIVE_SEARCH_RESULTS, offset: 0, events: [{ id: 4 }] }
36
+ const action = { type: RECEIVE_EVENTS_SEARCH_RESULTS, offset: 0, events: [{ id: 4 }] }
37
37
  const expectedState = [{ id: 4 }]
38
38
  expect(reducer(currentState, action)).toEqual(expectedState)
39
39
  })
@@ -42,7 +42,7 @@ describe('reducers/events', () => {
42
42
  describe('when offset is greater than 0', () => {
43
43
  it('add the new events to state', () => {
44
44
  const currentState = [{ id: 1 }, { id: 2 }, { id: 3 }]
45
- const action = { type: RECEIVE_SEARCH_RESULTS, offset: 1, events: [{ id: 4 }] }
45
+ const action = { type: RECEIVE_EVENTS_SEARCH_RESULTS, offset: 1, events: [{ id: 4 }] }
46
46
  const expectedState = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }]
47
47
  expect(reducer(currentState, action)).toEqual(expectedState)
48
48
  })
@@ -0,0 +1,32 @@
1
+ import {
2
+ FAILURE_SHOW_RETRY,
3
+ FAILURE_HIDE_RETRY,
4
+ FAILURE_HIDE_OVERVIEW,
5
+ RECEIVE_FAILURE_DETAILS
6
+ } from 'actions'
7
+
8
+ function patchFailure (state, action, params) {
9
+ if (state.id === action.failure.id) {
10
+ return Object.assign(state, params)
11
+ }
12
+ return state
13
+ }
14
+
15
+ export default (state = {}, action) => {
16
+ switch (action.type) {
17
+ case FAILURE_SHOW_RETRY:
18
+ return patchFailure(state, action, { retryVisible: true })
19
+
20
+ case FAILURE_HIDE_RETRY:
21
+ return patchFailure(state, action, { retryVisible: false })
22
+
23
+ case FAILURE_HIDE_OVERVIEW:
24
+ return {}
25
+
26
+ case RECEIVE_FAILURE_DETAILS:
27
+ return action.failure
28
+
29
+ default:
30
+ return state
31
+ }
32
+ }
@@ -0,0 +1,54 @@
1
+ import {
2
+ FAILURE_SHOW_RETRY,
3
+ FAILURE_HIDE_RETRY,
4
+ FAILURE_HIDE_OVERVIEW,
5
+ RECEIVE_FAILURE_DETAILS
6
+ } from 'actions'
7
+
8
+ import reducer from 'reducers/failures/details'
9
+
10
+ describe('reducers/failures/details', () => {
11
+ describe('for FAILURE_SHOW_RETRY', () => {
12
+ it('sets retryVisible to true', () => {
13
+ const currentState = { id: 1 }
14
+ const action = { type: FAILURE_SHOW_RETRY, failure: { id: 1 } }
15
+ const expectedState = { id: 1, retryVisible: true }
16
+ expect(reducer(currentState, action)).toEqual(expectedState)
17
+ })
18
+ })
19
+
20
+ describe('for FAILURE_HIDE_RETRY', () => {
21
+ it('sets retryVisible to false', () => {
22
+ const currentState = { id: 1 }
23
+ const action = { type: FAILURE_HIDE_RETRY, failure: { id: 1 } }
24
+ const expectedState = { id: 1, retryVisible: false }
25
+ expect(reducer(currentState, action)).toEqual(expectedState)
26
+ })
27
+ })
28
+
29
+ describe('for FAILURE_HIDE_OVERVIEW', () => {
30
+ it('erases the state', () => {
31
+ const currentState = { id: 1 }
32
+ const action = { type: FAILURE_HIDE_OVERVIEW, failure: { id: 1 } }
33
+ const expectedState = { }
34
+ expect(reducer(currentState, action)).toEqual(expectedState)
35
+ })
36
+ })
37
+
38
+ describe('for RECEIVE_FAILURE_DETAILS', () => {
39
+ it('replaces the state', () => {
40
+ const currentState = { id: 1 }
41
+ const action = { type: RECEIVE_FAILURE_DETAILS, failure: { id: 2 } }
42
+ const expectedState = { id: 2 }
43
+ expect(reducer(currentState, action)).toEqual(expectedState)
44
+ })
45
+ })
46
+
47
+ describe('for default', () => {
48
+ it('returns the currentState', () => {
49
+ const currentState = { current: true }
50
+ const action = { type: 'another' }
51
+ expect(reducer(currentState, action)).toEqual(currentState)
52
+ })
53
+ })
54
+ })
@@ -0,0 +1,48 @@
1
+ import {
2
+ FAILURE_SHOW_OVERVIEW,
3
+ FAILURE_HIDE_OVERVIEW,
4
+ RECEIVE_FAILURES_SEARCH_RESULTS,
5
+ FAILURE_SHOW_RETRY,
6
+ FAILURE_HIDE_RETRY,
7
+ RECEIVE_FAILURE_RETRY,
8
+ REQUEST_FAILURE_RETRY_FAILED
9
+ } from 'actions'
10
+
11
+ function patchFailure (state, action, params) {
12
+ return state.map((failure) => {
13
+ if (failure.id === action.failure.id) {
14
+ return Object.assign({}, failure, params)
15
+ }
16
+ return failure
17
+ })
18
+ }
19
+
20
+ export default (state = [], action) => {
21
+ switch (action.type) {
22
+ case FAILURE_SHOW_OVERVIEW:
23
+ return patchFailure(state, action, { overviewVisible: true })
24
+
25
+ case FAILURE_HIDE_OVERVIEW:
26
+ return patchFailure(state, action, { overviewVisible: false, error: null })
27
+
28
+ case RECEIVE_FAILURES_SEARCH_RESULTS:
29
+ return action.offset <= 0
30
+ ? action.failures
31
+ : state.concat(action.failures)
32
+
33
+ case FAILURE_SHOW_RETRY:
34
+ return patchFailure(state, action, { retryVisible: true })
35
+
36
+ case FAILURE_HIDE_RETRY:
37
+ return patchFailure(state, action, { retryVisible: false, error: null })
38
+
39
+ case RECEIVE_FAILURE_RETRY:
40
+ return patchFailure(state, action, { acknowledged: action.acknowledged, error: null })
41
+
42
+ case REQUEST_FAILURE_RETRY_FAILED:
43
+ return patchFailure(state, action, { error: action.error })
44
+
45
+ default:
46
+ return state
47
+ }
48
+ }
@@ -0,0 +1,95 @@
1
+ import {
2
+ FAILURE_SHOW_OVERVIEW,
3
+ FAILURE_HIDE_OVERVIEW,
4
+ RECEIVE_FAILURES_SEARCH_RESULTS,
5
+ FAILURE_SHOW_RETRY,
6
+ FAILURE_HIDE_RETRY,
7
+ RECEIVE_FAILURE_RETRY,
8
+ REQUEST_FAILURE_RETRY_FAILED
9
+ } from 'actions'
10
+
11
+ import reducer from 'reducers/failures'
12
+
13
+ describe('reducers/failures', () => {
14
+ describe('for FAILURE_SHOW_OVERVIEW', () => {
15
+ it('sets overviewVisible for the specific event to true', () => {
16
+ const currentState = [{ id: 1 }, { id: 2 }, { id: 3 }]
17
+ const action = { type: FAILURE_SHOW_OVERVIEW, failure: { id: 2 } }
18
+ const expectedState = [{ id: 1 }, { id: 2, overviewVisible: true }, { id: 3 }]
19
+ expect(reducer(currentState, action)).toEqual(expectedState)
20
+ })
21
+ })
22
+
23
+ describe('for FAILURE_HIDE_OVERVIEW', () => {
24
+ it('sets overviewVisible to false and erase errors for a specific', () => {
25
+ const currentState = [{ id: 1 }, { id: 2, overviewVisible: true }, { id: 3 }]
26
+ const action = { type: FAILURE_HIDE_OVERVIEW, failure: { id: 2 } }
27
+ const expectedState = [{ id: 1 }, { id: 2, overviewVisible: false, error: null }, { id: 3 }]
28
+ expect(reducer(currentState, action)).toEqual(expectedState)
29
+ })
30
+ })
31
+
32
+ describe('for RECEIVE_FAILURES_SEARCH_RESULTS', () => {
33
+ describe('when offset less or equal to 0', () => {
34
+ it('overrides failures with action failures', () => {
35
+ const currentState = [{ id: 1 }, { id: 2 }, { id: 3 }]
36
+ const action = { type: RECEIVE_FAILURES_SEARCH_RESULTS, offset: 0, failures: [{ id: 4 }] }
37
+ const expectedState = [{ id: 4 }]
38
+ expect(reducer(currentState, action)).toEqual(expectedState)
39
+ })
40
+ })
41
+
42
+ describe('when offset is greater than 0', () => {
43
+ it('add the new failures to state', () => {
44
+ const currentState = [{ id: 1 }, { id: 2 }, { id: 3 }]
45
+ const action = { type: RECEIVE_FAILURES_SEARCH_RESULTS, offset: 1, failures: [{ id: 4 }] }
46
+ const expectedState = [{ id: 1 }, { id: 2 }, { id: 3 }, { id: 4 }]
47
+ expect(reducer(currentState, action)).toEqual(expectedState)
48
+ })
49
+ })
50
+ })
51
+
52
+ describe('for FAILURE_SHOW_RETRY', () => {
53
+ it('sets retryVisible for the specific event to true', () => {
54
+ const currentState = [{ id: 1 }, { id: 2 }, { id: 3 }]
55
+ const action = { type: FAILURE_SHOW_RETRY, failure: { id: 2 } }
56
+ const expectedState = [{ id: 1 }, { id: 2, retryVisible: true }, { id: 3 }]
57
+ expect(reducer(currentState, action)).toEqual(expectedState)
58
+ })
59
+ })
60
+
61
+ describe('for FAILURE_HIDE_RETRY', () => {
62
+ it('sets retryVisible to false and erase errors for a specific', () => {
63
+ const currentState = [{ id: 1 }, { id: 2, retryVisible: true }, { id: 3 }]
64
+ const action = { type: FAILURE_HIDE_RETRY, failure: { id: 2 } }
65
+ const expectedState = [{ id: 1 }, { id: 2, retryVisible: false, error: null }, { id: 3 }]
66
+ expect(reducer(currentState, action)).toEqual(expectedState)
67
+ })
68
+ })
69
+
70
+ describe('for RECEIVE_FAILURE_RETRY', () => {
71
+ it('sets acknowledged and erase errors for a specific', () => {
72
+ const currentState = [{ id: 1 }, { id: 2 }, { id: 3 }]
73
+ const action = { type: RECEIVE_FAILURE_RETRY, failure: { id: 2 }, acknowledged: true }
74
+ const expectedState = [{ id: 1 }, { id: 2, acknowledged: true, error: null }, { id: 3 }]
75
+ expect(reducer(currentState, action)).toEqual(expectedState)
76
+ })
77
+ })
78
+
79
+ describe('for REQUEST_FAILURE_RETRY_FAILED', () => {
80
+ it('sets error for a specific', () => {
81
+ const currentState = [{ id: 1 }, { id: 2 }, { id: 3 }]
82
+ const action = { type: REQUEST_FAILURE_RETRY_FAILED, failure: { id: 2 }, error: 'some error' }
83
+ const expectedState = [{ id: 1 }, { id: 2, error: 'some error' }, { id: 3 }]
84
+ expect(reducer(currentState, action)).toEqual(expectedState)
85
+ })
86
+ })
87
+
88
+ describe('for default', () => {
89
+ it('returns the currentState', () => {
90
+ const currentState = { current: true }
91
+ const action = { type: 'another' }
92
+ expect(reducer(currentState, action)).toEqual(currentState)
93
+ })
94
+ })
95
+ })
@@ -2,7 +2,9 @@ import { combineReducers } from 'redux'
2
2
  import { routerReducer } from 'react-router-redux'
3
3
 
4
4
  import events from 'reducers/events'
5
+ import failures from 'reducers/failures'
5
6
  import eventDetails from 'reducers/event-details'
7
+ import failureDetails from 'reducers/failures/details'
6
8
  import eventsFilters from 'reducers/events-filters'
7
9
  import xhrStatus from 'reducers/xhr-status'
8
10
  import flashMessages from 'reducers/flash-messages'
@@ -12,7 +14,8 @@ export default combineReducers({
12
14
  flashMessages,
13
15
  eventsFilters,
14
16
  eventDetails,
17
+ failureDetails,
15
18
  events,
16
-
19
+ failures,
17
20
  routing: routerReducer
18
21
  })
@@ -13,7 +13,9 @@ describe('reducers', () => {
13
13
  flashMessages: [],
14
14
  eventsFilters: { type: 'entity_id' },
15
15
  eventDetails: {},
16
+ failureDetails: {},
16
17
  events: [],
18
+ failures: [],
17
19
  routing: { locationBeforeTransitions: null }
18
20
  })
19
21
  })
@@ -1,9 +1,14 @@
1
1
  import {
2
- REQUEST_SEARCH_RESULTS,
3
- RECEIVE_SEARCH_RESULTS,
4
- REQUEST_SEARCH_RESULTS_FAILED,
5
- LOAD_MORE_SEARCH_RESULTS,
6
- TRIGGER_SEARCH,
2
+ REQUEST_EVENTS_SEARCH_RESULTS,
3
+ RECEIVE_EVENTS_SEARCH_RESULTS,
4
+ REQUEST_EVENTS_SEARCH_RESULTS_FAILED,
5
+ LOAD_MORE_EVENTS_SEARCH_RESULTS,
6
+ TRIGGER_EVENTS_SEARCH,
7
+ REQUEST_FAILURES_SEARCH_RESULTS,
8
+ RECEIVE_FAILURES_SEARCH_RESULTS,
9
+ REQUEST_FAILURES_SEARCH_RESULTS_FAILED,
10
+ LOAD_MORE_FAILURES_SEARCH_RESULTS,
11
+ TRIGGER_FAILURES_SEARCH,
7
12
  REQUEST_EVENT_RETRY,
8
13
  RECEIVE_EVENT_RETRY,
9
14
  REQUEST_EVENT_RETRY_FAILED,
@@ -21,29 +26,39 @@ const initialState = {
21
26
 
22
27
  export default (state = initialState, action) => {
23
28
  switch (action.type) {
24
- case TRIGGER_SEARCH:
29
+ case TRIGGER_FAILURES_SEARCH:
30
+ case TRIGGER_EVENTS_SEARCH:
25
31
  return Object.assign({}, state, {
26
32
  currentEventsOffset: 0,
27
33
  lastEventsLoadSize: 0
28
34
  })
29
35
 
30
- case REQUEST_SEARCH_RESULTS:
36
+ case REQUEST_FAILURES_SEARCH_RESULTS:
37
+ case REQUEST_EVENTS_SEARCH_RESULTS:
31
38
  return Object.assign({}, state, {
32
39
  isFetchingEvents: true
33
40
  })
34
41
 
35
- case RECEIVE_SEARCH_RESULTS:
42
+ case RECEIVE_FAILURES_SEARCH_RESULTS:
43
+ return Object.assign({}, state, {
44
+ isFetchingEvents: false,
45
+ lastEventsLoadSize: action.failures.length
46
+ })
47
+
48
+ case RECEIVE_EVENTS_SEARCH_RESULTS:
36
49
  return Object.assign({}, state, {
37
50
  isFetchingEvents: false,
38
51
  lastEventsLoadSize: action.events.length
39
52
  })
40
53
 
41
- case REQUEST_SEARCH_RESULTS_FAILED:
54
+ case REQUEST_FAILURES_SEARCH_RESULTS_FAILED:
55
+ case REQUEST_EVENTS_SEARCH_RESULTS_FAILED:
42
56
  return Object.assign({}, state, {
43
57
  isFetchingEvents: false
44
58
  })
45
59
 
46
- case LOAD_MORE_SEARCH_RESULTS:
60
+ case LOAD_MORE_FAILURES_SEARCH_RESULTS:
61
+ case LOAD_MORE_EVENTS_SEARCH_RESULTS:
47
62
  return Object.assign({}, state, {
48
63
  currentEventsOffset: action.offset
49
64
  })
@@ -1,9 +1,14 @@
1
1
  import {
2
- TRIGGER_SEARCH,
3
- REQUEST_SEARCH_RESULTS,
4
- RECEIVE_SEARCH_RESULTS,
5
- REQUEST_SEARCH_RESULTS_FAILED,
6
- LOAD_MORE_SEARCH_RESULTS,
2
+ TRIGGER_EVENTS_SEARCH,
3
+ REQUEST_EVENTS_SEARCH_RESULTS,
4
+ RECEIVE_EVENTS_SEARCH_RESULTS,
5
+ REQUEST_EVENTS_SEARCH_RESULTS_FAILED,
6
+ LOAD_MORE_EVENTS_SEARCH_RESULTS,
7
+ TRIGGER_FAILURES_SEARCH,
8
+ REQUEST_FAILURES_SEARCH_RESULTS,
9
+ RECEIVE_FAILURES_SEARCH_RESULTS,
10
+ REQUEST_FAILURES_SEARCH_RESULTS_FAILED,
11
+ LOAD_MORE_FAILURES_SEARCH_RESULTS,
7
12
  REQUEST_EVENT_RETRY,
8
13
  RECEIVE_EVENT_RETRY,
9
14
  REQUEST_EVENT_RETRY_FAILED
@@ -12,46 +17,91 @@ import {
12
17
  import reducer from 'reducers/xhr-status'
13
18
 
14
19
  describe('reducers/xhr-status', () => {
15
- describe('for TRIGGER_SEARCH', () => {
20
+ describe('for TRIGGER_EVENTS_SEARCH', () => {
16
21
  it('resets currentEventsOffset and lastEventsLoadSize', () => {
17
22
  const currentState = { currentEventsOffset: 5, lastEventsLoadSize: 10 }
18
- const action = { type: TRIGGER_SEARCH }
23
+ const action = { type: TRIGGER_EVENTS_SEARCH }
19
24
  const expectedState = { currentEventsOffset: 0, lastEventsLoadSize: 0 }
20
25
  expect(reducer(currentState, action)).toEqual(expectedState)
21
26
  })
22
27
  })
23
28
 
24
- describe('for REQUEST_SEARCH_RESULTS', () => {
29
+ describe('for TRIGGER_FAILURES_SEARCH', () => {
30
+ it('resets currentEventsOffset and lastEventsLoadSize', () => {
31
+ const currentState = { currentEventsOffset: 5, lastEventsLoadSize: 10 }
32
+ const action = { type: TRIGGER_FAILURES_SEARCH }
33
+ const expectedState = { currentEventsOffset: 0, lastEventsLoadSize: 0 }
34
+ expect(reducer(currentState, action)).toEqual(expectedState)
35
+ })
36
+ })
37
+
38
+ describe('for REQUEST_EVENTS_SEARCH_RESULTS', () => {
39
+ it('enables isFetchingEvents', () => {
40
+ const currentState = { isFetchingEvents: false }
41
+ const action = { type: REQUEST_EVENTS_SEARCH_RESULTS }
42
+ const expectedState = { isFetchingEvents: true }
43
+ expect(reducer(currentState, action)).toEqual(expectedState)
44
+ })
45
+ })
46
+
47
+ describe('for REQUEST_FAILURES_SEARCH_RESULTS', () => {
25
48
  it('enables isFetchingEvents', () => {
26
49
  const currentState = { isFetchingEvents: false }
27
- const action = { type: REQUEST_SEARCH_RESULTS }
50
+ const action = { type: REQUEST_FAILURES_SEARCH_RESULTS }
28
51
  const expectedState = { isFetchingEvents: true }
29
52
  expect(reducer(currentState, action)).toEqual(expectedState)
30
53
  })
31
54
  })
32
55
 
33
- describe('for RECEIVE_SEARCH_RESULTS', () => {
56
+ describe('for RECEIVE_EVENTS_SEARCH_RESULTS', () => {
34
57
  it('disables isFetchingEvents and keep the load size', () => {
35
58
  const currentState = { isFetchingEvents: true }
36
- const action = { type: RECEIVE_SEARCH_RESULTS, events: ['A', 'B', 'C'] }
59
+ const action = { type: RECEIVE_EVENTS_SEARCH_RESULTS, events: ['A', 'B', 'C'] }
37
60
  const expectedState = { isFetchingEvents: false, lastEventsLoadSize: 3 }
38
61
  expect(reducer(currentState, action)).toEqual(expectedState)
39
62
  })
40
63
  })
41
64
 
42
- describe('for REQUEST_SEARCH_RESULTS_FAILED', () => {
65
+ describe('for RECEIVE_FAILURES_SEARCH_RESULTS', () => {
66
+ it('disables isFetchingEvents and keep the load size', () => {
67
+ const currentState = { isFetchingEvents: true }
68
+ const action = { type: RECEIVE_FAILURES_SEARCH_RESULTS, failures: ['A', 'B', 'C'] }
69
+ const expectedState = { isFetchingEvents: false, lastEventsLoadSize: 3 }
70
+ expect(reducer(currentState, action)).toEqual(expectedState)
71
+ })
72
+ })
73
+
74
+ describe('for REQUEST_EVENTS_SEARCH_RESULTS_FAILED', () => {
43
75
  it('disables isFetchingEvents', () => {
44
76
  const currentState = { isFetchingEvents: true }
45
- const action = { type: REQUEST_SEARCH_RESULTS_FAILED }
77
+ const action = { type: REQUEST_EVENTS_SEARCH_RESULTS_FAILED }
46
78
  const expectedState = { isFetchingEvents: false }
47
79
  expect(reducer(currentState, action)).toEqual(expectedState)
48
80
  })
49
81
  })
50
82
 
51
- describe('for LOAD_MORE_SEARCH_RESULTS', () => {
83
+ describe('for REQUEST_FAILURES_SEARCH_RESULTS_FAILED', () => {
84
+ it('disables isFetchingEvents', () => {
85
+ const currentState = { isFetchingEvents: true }
86
+ const action = { type: REQUEST_FAILURES_SEARCH_RESULTS_FAILED }
87
+ const expectedState = { isFetchingEvents: false }
88
+ expect(reducer(currentState, action)).toEqual(expectedState)
89
+ })
90
+ })
91
+
92
+ describe('for LOAD_MORE_EVENTS_SEARCH_RESULTS', () => {
93
+ it('updates currentEventsOffset', () => {
94
+ const currentState = { currentEventsOffset: 0 }
95
+ const action = { type: LOAD_MORE_EVENTS_SEARCH_RESULTS, offset: 3 }
96
+ const expectedState = { currentEventsOffset: 3 }
97
+ expect(reducer(currentState, action)).toEqual(expectedState)
98
+ })
99
+ })
100
+
101
+ describe('for LOAD_MORE_FAILURES_SEARCH_RESULTS', () => {
52
102
  it('updates currentEventsOffset', () => {
53
103
  const currentState = { currentEventsOffset: 0 }
54
- const action = { type: LOAD_MORE_SEARCH_RESULTS, offset: 3 }
104
+ const action = { type: LOAD_MORE_FAILURES_SEARCH_RESULTS, offset: 3 }
55
105
  const expectedState = { currentEventsOffset: 3 }
56
106
  expect(reducer(currentState, action)).toEqual(expectedState)
57
107
  })
@@ -4,8 +4,10 @@ import { syncHistoryWithStore } from 'react-router-redux'
4
4
 
5
5
  import store from 'store'
6
6
  import Layout from 'views/layout'
7
- import EventsSearch from 'views/events-search'
8
- import EventDetails from 'views/event-details'
7
+ import EventsSearch from 'views/events/search'
8
+ import EventDetails from 'views/events/details'
9
+ import FailuresSearch from 'views/failures/search'
10
+ import FailureDetails from 'views/failures/details'
9
11
 
10
12
  export const history = syncHistoryWithStore(browserHistory, store)
11
13
 
@@ -15,6 +17,8 @@ export default (
15
17
  <IndexRedirect to='/events' />
16
18
  <Route path='/events' component={EventsSearch} />
17
19
  <Route path='/events/:id' component={EventDetails} />
20
+ <Route path='/failures' component={FailuresSearch} />
21
+ <Route path='/failures/:id' component={FailureDetails} />
18
22
  </Route>
19
23
  </Router>
20
24
  )
@@ -1,13 +1,17 @@
1
1
  import { createStore, applyMiddleware, compose } from 'redux'
2
+ import { routerMiddleware } from 'react-router-redux'
3
+ import { browserHistory } from 'react-router'
2
4
  import thunkMiddleware from 'redux-thunk'
3
5
 
4
- import reducer from 'reducers'
6
+ import reducers from 'reducers'
7
+
8
+ const browserMiddleware = routerMiddleware(browserHistory)
5
9
 
6
10
  const store = createStore(
7
- reducer,
11
+ reducers,
8
12
  {}, // initial state
9
13
  compose(
10
- applyMiddleware(thunkMiddleware), // for async actions
14
+ applyMiddleware(thunkMiddleware, browserMiddleware), // for async actions
11
15
  window.devToolsExtension ? window.devToolsExtension() : (f) => f
12
16
  )
13
17
  )