Commit 45a41ff4 authored by Scott Hampton's avatar Scott Hampton

Fix tests and remove extra code

According to MR suggestions, fixing tests
to account for the new polling actions. Also
removed some extra code that wasn't being
used.
parent 51cf09e6
...@@ -3,7 +3,6 @@ import Poll from '~/lib/utils/poll'; ...@@ -3,7 +3,6 @@ import Poll from '~/lib/utils/poll';
import httpStatusCodes from '~/lib/utils/http_status'; import httpStatusCodes from '~/lib/utils/http_status';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import * as types from './mutation_types'; import * as types from './mutation_types';
import { s__ } from '~/locale';
let eTagPoll; let eTagPoll;
...@@ -63,18 +62,14 @@ export const fetchReport = ({ state, dispatch, commit }) => { ...@@ -63,18 +62,14 @@ export const fetchReport = ({ state, dispatch, commit }) => {
}); });
}; };
export const receiveReportSuccess = ({ commit }, response) => { export const receiveReportSuccess = ({ commit }, { status, data }) => {
if (response.status === httpStatusCodes.OK) { if (status === httpStatusCodes.OK) {
const report = response.data; commit(types.RECEIVE_REPORT_SUCCESS, data);
commit(types.RECEIVE_REPORT_SUCCESS, report);
} }
}; };
export const receiveReportError = ({ commit }) => { export const receiveReportError = ({ commit }) => {
commit( commit(types.RECEIVE_REPORT_ERROR);
types.RECEIVE_REPORT_ERROR,
s__('AccessibilityReport|Failed to retrieve accessibility report'),
);
}; };
// prevent babel-plugin-rewire from generating an invalid default during karma tests // prevent babel-plugin-rewire from generating an invalid default during karma tests
......
...@@ -12,10 +12,9 @@ export default { ...@@ -12,10 +12,9 @@ export default {
state.isLoading = false; state.isLoading = false;
state.report = report; state.report = report;
}, },
[types.RECEIVE_REPORT_ERROR](state, message) { [types.RECEIVE_REPORT_ERROR](state) {
state.isLoading = false; state.isLoading = false;
state.hasError = true; state.hasError = true;
state.errorMessage = message;
state.report = {}; state.report = {};
}, },
}; };
...@@ -1063,9 +1063,6 @@ msgstr "" ...@@ -1063,9 +1063,6 @@ msgstr ""
msgid "AccessTokens|reset it" msgid "AccessTokens|reset it"
msgstr "" msgstr ""
msgid "AccessibilityReport|Failed to retrieve accessibility report"
msgstr ""
msgid "AccessibilityReport|Learn More" msgid "AccessibilityReport|Learn More"
msgstr "" msgstr ""
......
...@@ -117,10 +117,9 @@ describe('Grouped accessibility reports app', () => { ...@@ -117,10 +117,9 @@ describe('Grouped accessibility reports app', () => {
it('renders custom accessibility issue body', () => { it('renders custom accessibility issue body', () => {
const issueBody = wrapper.find(AccessibilityIssueBody); const issueBody = wrapper.find(AccessibilityIssueBody);
expect(issueBody.props('issue').name).toEqual(mockReport.new_errors[0].name); expect(issueBody.props('issue').code).toBe(mockReport.new_errors[0].code);
expect(issueBody.props('issue').code).toEqual(mockReport.new_errors[0].code); expect(issueBody.props('issue').message).toBe(mockReport.new_errors[0].message);
expect(issueBody.props('issue').message).toEqual(mockReport.new_errors[0].message); expect(issueBody.props('isNew')).toBe(true);
expect(issueBody.props('isNew')).toEqual(true);
}); });
}); });
}); });
......
...@@ -41,6 +41,8 @@ describe('Accessibility Reports actions', () => { ...@@ -41,6 +41,8 @@ describe('Accessibility Reports actions', () => {
afterEach(() => { afterEach(() => {
mock.restore(); mock.restore();
actions.stopPolling();
actions.clearEtagPoll();
}); });
describe('success', () => { describe('success', () => {
...@@ -81,7 +83,7 @@ describe('Accessibility Reports actions', () => { ...@@ -81,7 +83,7 @@ describe('Accessibility Reports actions', () => {
}); });
describe('receiveReportSuccess', () => { describe('receiveReportSuccess', () => {
it('should commit RECEIVE_REPORT_SUCCESS mutation', done => { it('should commit RECEIVE_REPORT_SUCCESS mutation with 200', done => {
testAction( testAction(
actions.receiveReportSuccess, actions.receiveReportSuccess,
{ status: 200, data: mockReport }, { status: 200, data: mockReport },
...@@ -91,6 +93,17 @@ describe('Accessibility Reports actions', () => { ...@@ -91,6 +93,17 @@ describe('Accessibility Reports actions', () => {
done, done,
); );
}); });
it('should not commit RECEIVE_REPORTS_SUCCESS mutation with 204', done => {
testAction(
actions.receiveReportSuccess,
{ status: 204, data: mockReport },
localState,
[],
[],
done,
);
});
}); });
describe('receiveReportError', () => { describe('receiveReportError', () => {
...@@ -99,7 +112,7 @@ describe('Accessibility Reports actions', () => { ...@@ -99,7 +112,7 @@ describe('Accessibility Reports actions', () => {
actions.receiveReportError, actions.receiveReportError,
null, null,
localState, localState,
[{ type: types.RECEIVE_REPORT_ERROR, payload: 'Failed to retrieve accessibility report' }], [{ type: types.RECEIVE_REPORT_ERROR }],
[], [],
done, done,
); );
......
...@@ -60,11 +60,5 @@ describe('Accessibility Reports mutations', () => { ...@@ -60,11 +60,5 @@ describe('Accessibility Reports mutations', () => {
expect(localState.hasError).toEqual(true); expect(localState.hasError).toEqual(true);
}); });
it('sets errorMessage to given message', () => {
mutations.RECEIVE_REPORT_ERROR(localState, 'message');
expect(localState.errorMessage).toEqual('message');
});
}); });
}); });
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