Skip to content

Commit 1f08c9c

Browse files
Merge pull request #130 from blackjackkent/development
Hotfix v1.0.1
2 parents cc570ad + 77e275c commit 1f08c9c

14 files changed

Lines changed: 185 additions & 108 deletions

File tree

src/display/views/help/Help.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,5 @@ const Help = (props) => {
6060

6161
Help.propTypes = propTypes;
6262
export default connect(mapStateToProps, {
63-
setActiveHelpTab: actions.setActiveHelpTab,
6463
submitContactForm: actions.submitContactForm
6564
})(Help);

src/display/views/help/__tests__/Help.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ jest.mock('../../../shared/static/StaticDropdownNav', () => 'StaticDropdownNav')
2727
// #endregion mocks
2828

2929
const createTestProps = propOverrides => ({
30-
setActiveHelpTab: jest.fn(),
3130
submitContactForm: jest.fn(),
3231
match: {
3332
url: '/help/tab1',

src/display/views/settings/Settings.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,5 @@ const Settings = (props) => {
6868
Settings.propTypes = propTypes;
6969
export default connect(mapStateToProps, {
7070
submitUserChangePassword: actions.submitUserChangePassword,
71-
setActiveSettingsTab: actions.setActiveSettingsTab,
7271
submitUserAccountInfo: actions.submitUserAccountInfo
7372
})(Settings);

src/display/views/settings/__tests__/Settings.spec.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ jest.mock('../../../shared/static/StaticDropdownNav', () => 'StaticDropdownNav')
2525
// #endregion mocks
2626

2727
const createTestProps = propOverrides => ({
28-
setActiveSettingsTab: jest.fn(),
2928
submitUserChangePassword: jest.fn(),
3029
submitUserAccountInfo: jest.fn(),
3130
match: {

src/infrastructure/sagas/public/__tests__/fetchPublicThreadsStatusSaga.spec.js

Lines changed: 4 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import { SagaTestWrapper } from '../../../../../config/tests/helpers.unit';
77
global.TUMBLR_CLIENT_BASE_URL = 'http://test-site/';
88

99
const responseItems = [];
10-
const myTurnResponseItems = [];
11-
const theirTurnResponseItems = [];
12-
const queuedResponseItems = [];
1310

1411
const initResponseData = () => {
1512
for (let i = 0; i < 5; i++) {
@@ -20,17 +17,10 @@ const initResponseData = () => {
2017
isQueued: j % 2 === 0
2118
};
2219
responseItems.push(responseItem);
23-
if (responseItem.isQueued) {
24-
queuedResponseItems.push(responseItem);
25-
} else if (responseItem.isCallingCharactersTurn) {
26-
myTurnResponseItems.push(responseItem);
27-
} else {
28-
theirTurnResponseItems.push(responseItem);
29-
}
3020
}
3121
}
3222
};
33-
const getInitialAction = (turnFilter) => {
23+
const getInitialAction = () => {
3424
const requests = [];
3525
for (let i = 0; i < 5; i++) {
3626
for (let j = 0; j < 10; j++) {
@@ -44,10 +34,7 @@ const getInitialAction = (turnFilter) => {
4434
return {
4535
type: actions.FETCH_PUBLIC_THREADS_STATUS,
4636
data: {
47-
threadStatusRequestJson: JSON.stringify(requests),
48-
view: {
49-
turnFilter
50-
}
37+
threadStatusRequestJson: JSON.stringify(requests)
5138
}
5239
};
5340
};
@@ -69,7 +56,7 @@ beforeAll(() => {
6956
initResponseData();
7057
});
7158
describe('saga behavior', () => {
72-
it('puts five empty chunks and success if no turn filter provided', () => {
59+
it('puts five chunks and success', () => {
7360
const saga = new SagaTestWrapper(fetchPublicThreadsStatusSaga);
7461
const action = getInitialAction();
7562
setupSaga(saga);
@@ -78,67 +65,13 @@ describe('saga behavior', () => {
7865
const { effects } = result;
7966
expect(effects.put).toHaveLength(6);
8067
for (let i = 0; i < 5; i++) {
81-
expect(effects.put[i].PUT.action.data).toEqual([]);
68+
expect(effects.put[i].PUT.action.data).toHaveLength(10);
8269
}
8370
expect(effects.put[5].PUT.action.type).toEqual(
8471
actions.FETCHED_PUBLIC_THREADS_STATUS_SUCCESS
8572
);
8673
});
8774
});
88-
it('puts filtered chunks and success if turn filter is my turn', () => {
89-
const saga = new SagaTestWrapper(fetchPublicThreadsStatusSaga);
90-
const action = getInitialAction({ includeMyTurn: true });
91-
setupSaga(saga);
92-
return saga.execute(action)
93-
.then((result) => {
94-
const { effects } = result;
95-
expect(effects.put).toHaveLength(6);
96-
expect(effects.put[0].PUT.action.data).toHaveLength(5);
97-
expect(effects.put[1].PUT.action.data).toHaveLength(0);
98-
expect(effects.put[2].PUT.action.data).toHaveLength(5);
99-
expect(effects.put[3].PUT.action.data).toHaveLength(0);
100-
expect(effects.put[4].PUT.action.data).toHaveLength(5);
101-
expect(effects.put[5].PUT.action.type).toEqual(
102-
actions.FETCHED_PUBLIC_THREADS_STATUS_SUCCESS
103-
);
104-
});
105-
});
106-
it('puts filtered chunks and success if turn filter is their turn', () => {
107-
const saga = new SagaTestWrapper(fetchPublicThreadsStatusSaga);
108-
const action = getInitialAction({ includeTheirTurn: true });
109-
setupSaga(saga);
110-
return saga.execute(action)
111-
.then((result) => {
112-
const { effects } = result;
113-
expect(effects.put).toHaveLength(6);
114-
expect(effects.put[0].PUT.action.data).toHaveLength(0);
115-
expect(effects.put[1].PUT.action.data).toHaveLength(5);
116-
expect(effects.put[2].PUT.action.data).toHaveLength(0);
117-
expect(effects.put[3].PUT.action.data).toHaveLength(5);
118-
expect(effects.put[4].PUT.action.data).toHaveLength(0);
119-
expect(effects.put[5].PUT.action.type).toEqual(
120-
actions.FETCHED_PUBLIC_THREADS_STATUS_SUCCESS
121-
);
122-
});
123-
});
124-
it('puts filtered chunks and success if turn filter is queue', () => {
125-
const saga = new SagaTestWrapper(fetchPublicThreadsStatusSaga);
126-
const action = getInitialAction({ includeQueued: true });
127-
setupSaga(saga);
128-
return saga.execute(action)
129-
.then((result) => {
130-
const { effects } = result;
131-
expect(effects.put).toHaveLength(6);
132-
expect(effects.put[0].PUT.action.data).toHaveLength(5);
133-
expect(effects.put[1].PUT.action.data).toHaveLength(5);
134-
expect(effects.put[2].PUT.action.data).toHaveLength(5);
135-
expect(effects.put[3].PUT.action.data).toHaveLength(5);
136-
expect(effects.put[4].PUT.action.data).toHaveLength(5);
137-
expect(effects.put[5].PUT.action.type).toEqual(
138-
actions.FETCHED_PUBLIC_THREADS_STATUS_SUCCESS
139-
);
140-
});
141-
});
14275
it('should dispatch general failure on pre-chunk exception', () => {
14376
const saga = new SagaTestWrapper(fetchPublicThreadsStatusSaga);
14477
saga.expectPut({

src/infrastructure/sagas/public/fetchPublicThreadsStatusSaga.js

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ import {
22
takeLatest, put, call, all
33
} from 'redux-saga/effects';
44
import axios from 'axios';
5-
6-
import filters from '../../constants/filters';
75
import {
86
FETCH_PUBLIC_THREADS_STATUS,
97
fetchedPublicThreadsStatusSuccess,
@@ -12,21 +10,11 @@ import {
1210
fetchedPublicThreadsStatusChunkFailure
1311
} from '../../actions';
1412

15-
function* fetchPublicThreadsStatusChunk(chunk, view) {
13+
function* fetchPublicThreadsStatusChunk(chunk) {
1614
try {
1715
const response = yield call(axios.post, `${TUMBLR_CLIENT_BASE_URL}api/thread`, chunk);
1816
const threads = response.data;
19-
let result = [];
20-
if (view.turnFilter && view.turnFilter.includeMyTurn) {
21-
result = result.concat(threads.filter(filters.MY_TURN));
22-
}
23-
if (view.turnFilter && view.turnFilter.includeTheirTurn) {
24-
result = result.concat(threads.filter(filters.THEIR_TURN));
25-
}
26-
if (view.turnFilter && view.turnFilter.includeQueued) {
27-
result = result.concat(threads.filter(filters.QUEUED));
28-
}
29-
yield put(fetchedPublicThreadsStatusChunkSuccess(result));
17+
yield put(fetchedPublicThreadsStatusChunkSuccess(threads));
3018
} catch (e) {
3119
yield put(fetchedPublicThreadsStatusChunkFailure());
3220
}
@@ -40,7 +28,7 @@ function* fetchPublicThreadsStatus(action) {
4028
chunks.push(requests.slice(i, i + 10));
4129
}
4230
const tasks = [];
43-
chunks.map(c => tasks.push(call(fetchPublicThreadsStatusChunk, c, action.data.view)));
31+
chunks.map(c => tasks.push(call(fetchPublicThreadsStatusChunk, c)));
4432
yield all(tasks);
4533
yield put(fetchedPublicThreadsStatusSuccess());
4634
} catch (e) {

src/infrastructure/sagas/threads/__tests__/fetchActiveThreadsStatusSaga.spec.js

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import { SagaTestWrapper } from '../../../../../config/tests/helpers.unit';
77
global.TUMBLR_CLIENT_BASE_URL = 'http://test-site/';
88

99
const responseItems = [];
10-
const myTurnResponseItems = [];
11-
const theirTurnResponseItems = [];
12-
const queuedResponseItems = [];
1310

1411
const initResponseData = () => {
1512
for (let i = 0; i < 5; i++) {
@@ -20,13 +17,6 @@ const initResponseData = () => {
2017
isQueued: j % 2 === 0
2118
};
2219
responseItems.push(responseItem);
23-
if (responseItem.isQueued) {
24-
queuedResponseItems.push(responseItem);
25-
} else if (responseItem.isCallingCharactersTurn) {
26-
myTurnResponseItems.push(responseItem);
27-
} else {
28-
theirTurnResponseItems.push(responseItem);
29-
}
3020
}
3121
}
3222
};

src/infrastructure/selectors/common/__tests__/commonState.spec.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
getAllArchivedThreadStatus,
66
getFilteredTag,
77
getPublicThreadFilter,
8+
getPublicThreadsView,
89
getAllPublicThreads,
910
getAllPublicThreadStatus,
1011
getAllCharacters,
@@ -112,6 +113,20 @@ describe('getAllPublicThreads', () => {
112113
expect(result).toHaveLength(3);
113114
});
114115
});
116+
describe('getPublicThreadsView', () => {
117+
it('should return view from publicThreads state', () => {
118+
// Arrange
119+
const state = {
120+
publicThreads: {
121+
view: { id: '12345' }
122+
}
123+
};
124+
// Act
125+
const result = getPublicThreadsView(state);
126+
// Assert
127+
expect(result.id).toBe('12345');
128+
});
129+
});
115130
describe('getAllPublicThreadStatus', () => {
116131
it('should return public threads status from state', () => {
117132
// Arrange
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import filterPublicStatusesByTurnFilter from '../filterPublicStatusesByTurnFilter';
2+
3+
const getStatuses = () => [
4+
// two my turn
5+
{ threadId: 1, isCallingCharactersTurn: true, isQueued: false },
6+
{ threadId: 2, isCallingCharactersTurn: true, isQueued: false },
7+
// three their turn
8+
{ threadId: 3, isCallingCharactersTurn: false, isQueued: false },
9+
{ threadId: 4, isCallingCharactersTurn: false, isQueued: false },
10+
{ threadId: 5, isCallingCharactersTurn: false, isQueued: false },
11+
// four queued
12+
{ threadId: 6, isCallingCharactersTurn: true, isQueued: true },
13+
{ threadId: 7, isCallingCharactersTurn: false, isQueued: true },
14+
{ threadId: 8, isCallingCharactersTurn: true, isQueued: true },
15+
{ threadId: 9, isCallingCharactersTurn: false, isQueued: true },
16+
// three archived
17+
{ threadId: 10, isCallingCharactersTurn: false, isQueued: false },
18+
{ threadId: 11, isCallingCharactersTurn: true, isQueued: false },
19+
{ threadId: 12, isCallingCharactersTurn: false, isQueued: true }
20+
];
21+
const getThreads = () => [
22+
{ threadId: 1 },
23+
{ threadId: 2 },
24+
{ threadId: 3 },
25+
{ threadId: 4 },
26+
{ threadId: 5 },
27+
{ threadId: 6 },
28+
{ threadId: 7 },
29+
{ threadId: 8 },
30+
{ threadId: 9 },
31+
{ threadId: 10, isArchived: true },
32+
{ threadId: 11, isArchived: true },
33+
{ threadId: 12, isArchived: true }
34+
];
35+
36+
describe('behavior', () => {
37+
it('should return empty array if no turn filter', () => {
38+
// Arrange
39+
const view = { id: '12345' };
40+
// Act
41+
const result = filterPublicStatusesByTurnFilter(getStatuses(), getThreads(), view);
42+
// Assert
43+
expect(result).toHaveLength(0);
44+
});
45+
it('should return empty array if no properties on turn filter', () => {
46+
// Arrange
47+
const view = { id: '12345', turnFilter: {} };
48+
// Act
49+
const result = filterPublicStatusesByTurnFilter(getStatuses(), getThreads(), view);
50+
// Assert
51+
expect(result).toHaveLength(0);
52+
});
53+
it('should return my turn threads', () => {
54+
// Arrange
55+
const view = { id: '12345', turnFilter: { includeMyTurn: true } };
56+
// Act
57+
const result = filterPublicStatusesByTurnFilter(getStatuses(), getThreads(), view);
58+
// Assert
59+
expect(result).toHaveLength(2);
60+
});
61+
it('should return their turn threads', () => {
62+
// Arrange
63+
const view = { id: '12345', turnFilter: { includeTheirTurn: true } };
64+
// Act
65+
const result = filterPublicStatusesByTurnFilter(getStatuses(), getThreads(), view);
66+
// Assert
67+
expect(result).toHaveLength(3);
68+
});
69+
it('should return queued threads', () => {
70+
// Arrange
71+
const view = { id: '12345', turnFilter: { includeQueued: true } };
72+
// Act
73+
const result = filterPublicStatusesByTurnFilter(getStatuses(), getThreads(), view);
74+
// Assert
75+
expect(result).toHaveLength(4);
76+
});
77+
it('should return archived threads', () => {
78+
// Arrange
79+
const view = { id: '12345', turnFilter: { includeArchived: true } };
80+
// Act
81+
const result = filterPublicStatusesByTurnFilter(getStatuses(), getThreads(), view);
82+
// Assert
83+
expect(result).toHaveLength(3);
84+
});
85+
it('should return combination', () => {
86+
// Arrange
87+
const view = { id: '12345', turnFilter: { includeArchived: true, includeQueued: true, includeTheirTurn: true } };
88+
// Act
89+
const result = filterPublicStatusesByTurnFilter(getStatuses(), getThreads(), view);
90+
// Assert
91+
expect(result).toHaveLength(10);
92+
});
93+
});

src/infrastructure/selectors/common/commonState.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export const getAllArchivedThreadStatus = state => state.archivedThreadsStatus;
55
export const getFilteredTag = state => (state.threadFilter ? state.threadFilter.filteredTag : null);
66
export const getPublicThreadFilter = state => state.publicThreadFilter;
77
export const getAllPublicThreads = state => state.publicThreads.threads;
8+
export const getPublicThreadsView = state => state.publicThreads.view;
89
export const getAllPublicThreadStatus = state => state.publicThreadsStatus;
910
export const getAllCharacters = state => state.characters;
1011
export const getNews = state => state.news;

0 commit comments

Comments
 (0)