diff --git a/src/CONST.js b/src/CONST.js index e5b6657ebddd..403e62e639bc 100755 --- a/src/CONST.js +++ b/src/CONST.js @@ -711,6 +711,12 @@ const CONST = { // There's a limit of 60k characters in Auth - https://github.com/Expensify/Auth/blob/198d59547f71fdee8121325e8bc9241fc9c3236a/auth/lib/Request.h#L28 MAX_COMMENT_LENGTH: 60000, + + ONYX: { + METHOD: { + MERGE: 'merge', + }, + }, }; export default CONST; diff --git a/src/components/InlineSystemMessage.js b/src/components/InlineSystemMessage.js index 9f3b124db8e8..0b6645fe255b 100644 --- a/src/components/InlineSystemMessage.js +++ b/src/components/InlineSystemMessage.js @@ -9,7 +9,11 @@ import Icon from './Icon'; const propTypes = { /** Error to display */ - message: PropTypes.string.isRequired, + message: PropTypes.string, +}; + +const defaultProps = { + message: '', }; const InlineSystemMessage = (props) => { @@ -25,5 +29,6 @@ const InlineSystemMessage = (props) => { }; InlineSystemMessage.propTypes = propTypes; +InlineSystemMessage.defaultProps = defaultProps; InlineSystemMessage.displayName = 'InlineSystemMessage'; export default InlineSystemMessage; diff --git a/src/libs/DateUtils.js b/src/libs/DateUtils.js index 791bd9e8c81c..256c9938f805 100644 --- a/src/libs/DateUtils.js +++ b/src/libs/DateUtils.js @@ -115,21 +115,38 @@ function startCurrentDateUpdater() { }); } -/* - * Updates user's timezone, if their timezone is set to automatic and - * is different from current timezone +/** + * @returns {Object} */ -function updateTimezone() { +function getCurrentTimezone() { const currentTimezone = moment.tz.guess(true); if (timezone.automatic && timezone.selected !== currentTimezone) { - PersonalDetails.setPersonalDetails({timezone: {...timezone, selected: currentTimezone}}); + return {...timezone, selected: currentTimezone}; } + return timezone; } /* - * Returns a version of updateTimezone function throttled by 5 minutes + * Updates user's timezone, if their timezone is set to automatic and + * is different from current timezone + */ +function updateTimezone() { + PersonalDetails.setPersonalDetails({timezone: getCurrentTimezone()}); +} + +// Used to throttle updates to the timezone when necessary +let lastUpdatedTimezoneTime = moment(); + +/** + * @returns {Boolean} */ -const throttledUpdateTimezone = _.throttle(() => updateTimezone(), 1000 * 60 * 5); +function canUpdateTimezone() { + return lastUpdatedTimezoneTime.isBefore(moment().subtract(5, 'minutes')); +} + +function setTimezoneUpdated() { + lastUpdatedTimezoneTime = moment(); +} /** * @namespace DateUtils @@ -139,8 +156,10 @@ const DateUtils = { timestampToDateTime, startCurrentDateUpdater, updateTimezone, - throttledUpdateTimezone, getLocalMomentFromTimestamp, + getCurrentTimezone, + canUpdateTimezone, + setTimezoneUpdated, }; export default DateUtils; diff --git a/src/libs/actions/Report.js b/src/libs/actions/Report.js index f529931b5c80..fff484b3e81c 100644 --- a/src/libs/actions/Report.js +++ b/src/libs/actions/Report.js @@ -9,7 +9,6 @@ import * as Pusher from '../Pusher/pusher'; import LocalNotification from '../Notification/LocalNotification'; import PushNotification from '../Notification/PushNotification'; import * as PersonalDetails from './PersonalDetails'; -import * as User from './User'; import Navigation from '../Navigation/Navigation'; import * as ActiveClientManager from '../ActiveClientManager'; import Visibility from '../Visibility'; @@ -27,6 +26,7 @@ import * as ReportActions from './ReportActions'; import Growl from '../Growl'; import * as Localize from '../Localize'; import PusherUtils from '../PusherUtils'; +import DateUtils from '../DateUtils'; let currentUserEmail; let currentUserAccountID; @@ -534,54 +534,6 @@ function updateReportActionMessage(reportID, sequenceNumber, message) { }); } -/** - * Updates a report in the store with a new report action - * - * @param {Number} reportID - * @param {Object} reportAction - * @param {String} [notificationPreference] On what cadence the user would like to be notified - */ -function updateReportWithNewAction( - reportID, - reportAction, - notificationPreference = CONST.REPORT.NOTIFICATION_PREFERENCE.ALWAYS, -) { - const messageHtml = reportAction.actionName === CONST.REPORT.ACTIONS.TYPE.RENAMED - ? lodashGet(reportAction, 'originalMessage.html', '') - : lodashGet(reportAction, ['message', 0, 'html'], ''); - - const parser = new ExpensiMark(); - const messageText = parser.htmlToText(messageHtml); - - const updatedReportObject = { - // Always merge the reportID into Onyx. If the report doesn't exist in Onyx yet, then all the rest of the data will be filled out by handleReportChanged - reportID, - maxSequenceNumber: reportAction.sequenceNumber, - notificationPreference, - lastMessageTimestamp: reportAction.timestamp, - lastMessageText: ReportUtils.formatReportLastMessageText(messageText), - lastActorEmail: reportAction.actorEmail, - }; - - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, updatedReportObject); - - const reportActionsToMerge = {}; - if (reportAction.clientID) { - // Remove the optimistic action from the report since we are about to replace it - // with the real one (which has the true sequenceNumber) - reportActionsToMerge[reportAction.clientID] = null; - } - - // Add the action into Onyx - reportActionsToMerge[reportAction.sequenceNumber] = { - ...reportAction, - isAttachment: ReportUtils.isReportMessageAttachment(lodashGet(reportAction, ['message', 0], {})), - loading: false, - }; - - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, reportActionsToMerge); -} - /** * Get the private pusher channel name for a Report. * @@ -606,13 +558,6 @@ function subscribeToUserEvents() { return; } - // Live-update a report's actions when a 'report comment' event is received. - PusherUtils.subscribeToPrivateUserChannelEvent( - Pusher.TYPE.REPORT_COMMENT, - currentUserAccountID, - pushJSON => updateReportWithNewAction(pushJSON.reportID, pushJSON.reportAction, pushJSON.notificationPreference), - ); - // Live-update a report's actions when an 'edit comment' event is received. PusherUtils.subscribeToPrivateUserChannelEvent(Pusher.TYPE.REPORT_COMMENT_EDIT, currentUserAccountID, @@ -623,9 +568,9 @@ function subscribeToUserEvents() { * Setup reportComment push notification callbacks. */ function subscribeToReportCommentPushNotifications() { - PushNotification.onReceived(PushNotification.TYPE.REPORT_COMMENT, ({reportID, reportAction}) => { + PushNotification.onReceived(PushNotification.TYPE.REPORT_COMMENT, ({reportID, onyxData}) => { Log.info('[Report] Handled event sent by Airship', false, {reportID}); - updateReportWithNewAction(reportID, reportAction); + Onyx.update(onyxData); }); // Open correct report when push notification is clicked @@ -903,7 +848,7 @@ function fetchAllReports( * @param {String} text * @param {File} [file] */ -function addAction(reportID, text, file) { +function addComment(reportID, text, file) { // For comments shorter than 10k chars, convert the comment from MD into HTML because that's how it is stored in the database // For longer comments, skip parsing and display plaintext for performance reasons. It takes over 40s to parse a 100k long string!! const parser = new ExpensiMark(); @@ -921,12 +866,12 @@ function addAction(reportID, text, file) { : parser.htmlToText(htmlForNewComment); // Update the report in Onyx to have the new sequence number - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, { + const optimisticReport = { maxSequenceNumber: newSequenceNumber, lastMessageTimestamp: moment().unix(), lastMessageText: ReportUtils.formatReportLastMessageText(textForNewComment), lastActorEmail: currentUserEmail, - }); + }; // Generate a clientID so we can save the optimistic action to storage with the clientID as key. Later, we will // remove the optimistic action when we add the real action created in the server. We do this because it's not @@ -942,12 +887,10 @@ function addAction(reportID, text, file) { // Store the optimistic action ID on the report the comment was added to. It will be removed later when refetching // report actions in order to clear out any stuck actions (i.e. actions where the client never received a Pusher // event, for whatever reason, from the server with the new action data - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, { - optimisticReportActionIDs: [...(optimisticReportActionIDs[reportID] || []), optimisticReportActionID], - }); + optimisticReport.optimisticReportActionIDs = [...(optimisticReportActionIDs[reportID] || []), optimisticReportActionID]; // Optimistically add the new comment to the store before waiting to save it to the server - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, { + const optimisticReportActions = { [optimisticReportActionID]: { actionName: CONST.REPORT.ACTIONS.TYPE.ADDCOMMENT, actorEmail: currentUserEmail, @@ -976,41 +919,70 @@ function addAction(reportID, text, file) { isFirstItem: false, isAttachment, attachmentInfo, - loading: true, + isLoading: true, shouldShow: true, }, - }); + }; - DeprecatedAPI.Report_AddComment({ + const parameters = { reportID, file, reportComment: commentText, clientID: optimisticReportActionID, - persist: true, - }) - .then((response) => { - if (response.jsonCode === 408) { - Growl.error(Localize.translateLocal('reportActionCompose.fileUploadFailed')); - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, { - [optimisticReportActionID]: null, - }); - console.error(response.message); - return; - } - - if (response.jsonCode === 666 && reportID === conciergeChatReportID) { - Growl.error(Localize.translateLocal('reportActionCompose.blockedFromConcierge')); - Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, { - [optimisticReportActionID]: null, - }); + }; - // The fact that the API is returning this error means the BLOCKED_FROM_CONCIERGE nvp in the user details has changed since the last time we checked, so let's update - User.getUserDetails(); - return; - } + const optimisticData = [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, + value: optimisticReport, + }, + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, + value: optimisticReportActions, + }, + ]; - updateReportWithNewAction(reportID, response.reportAction); + // Update the timezone if it's been 5 minutes from the last time the user added a comment + if (DateUtils.canUpdateTimezone()) { + const timezone = DateUtils.getCurrentTimezone(); + parameters.timezone = JSON.stringify(timezone); + optimisticData.push({ + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.MY_PERSONAL_DETAILS, + value: {timezone}, }); + optimisticData.push({ + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: ONYXKEYS.PERSONAL_DETAILS, + value: {[currentUserEmail]: timezone}, + }); + DateUtils.setTimezoneUpdated(); + } + + API.write(isAttachment ? 'AddAttachment' : 'AddComment', parameters, { + optimisticData, + failureData: [ + { + onyxMethod: CONST.ONYX.METHOD.MERGE, + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`, + value: { + [optimisticReportActionID]: { + isLoading: false, + }, + }, + }, + ], + }); +} + +/** + * @param {Number} reportID + * @param {Object} file + */ +function addAttachment(reportID, file) { + addComment(reportID, '', file); } /** @@ -1521,7 +1493,8 @@ export { fetchChatReportsByIDs, fetchIOUReportByID, fetchIOUReportByIDAndUpdateChatReport, - addAction, + addComment, + addAttachment, updateLastReadActionID, updateNotificationPreference, setNewMarkerPosition, diff --git a/src/libs/actions/ReportActions.js b/src/libs/actions/ReportActions.js index d613b4045e56..a069aa6b115c 100644 --- a/src/libs/actions/ReportActions.js +++ b/src/libs/actions/ReportActions.js @@ -34,7 +34,7 @@ Onyx.connect({ const reportID = CollectionUtils.extractCollectionItemID(key); const actionsArray = _.toArray(actions); reportActions[reportID] = actionsArray; - const mostRecentNonLoadingActionIndex = _.findLastIndex(actionsArray, action => !action.loading); + const mostRecentNonLoadingActionIndex = _.findLastIndex(actionsArray, action => !action.isLoading); const mostRecentAction = actionsArray[mostRecentNonLoadingActionIndex]; if (!mostRecentAction || _.isUndefined(mostRecentAction.sequenceNumber)) { return; diff --git a/src/pages/home/ReportScreen.js b/src/pages/home/ReportScreen.js index 4b4faa4d7013..bc2d299c1536 100644 --- a/src/pages/home/ReportScreen.js +++ b/src/pages/home/ReportScreen.js @@ -146,7 +146,7 @@ class ReportScreen extends React.Component { * @param {String} text */ onSubmitComment(text) { - Report.addAction(getReportID(this.props.route), text); + Report.addComment(getReportID(this.props.route), text); } /** diff --git a/src/pages/home/report/ReportActionCompose.js b/src/pages/home/report/ReportActionCompose.js index a48ef025fa0a..24be05efec76 100755 --- a/src/pages/home/report/ReportActionCompose.js +++ b/src/pages/home/report/ReportActionCompose.js @@ -36,7 +36,6 @@ import ReportActionComposeFocusManager from '../../../libs/ReportActionComposeFo import participantPropTypes from '../../../components/participantPropTypes'; import ParticipantLocalTime from './ParticipantLocalTime'; import {withPersonalDetails} from '../../../components/OnyxProvider'; -import DateUtils from '../../../libs/DateUtils'; import * as User from '../../../libs/actions/User'; import Tooltip from '../../../components/Tooltip'; import EmojiPickerButton from '../../../components/EmojiPicker/EmojiPickerButton'; @@ -448,8 +447,6 @@ class ReportActionCompose extends React.Component { return; } - DateUtils.throttledUpdateTimezone(); - this.props.onSubmit(trimmedComment); this.updateComment(''); this.setTextInputShouldClear(true); @@ -498,7 +495,7 @@ class ReportActionCompose extends React.Component { headerTitle={this.props.translate('reportActionCompose.sendAttachment')} onConfirm={(file) => { this.submitForm(); - Report.addAction(this.props.reportID, '', file); + Report.addAttachment(this.props.reportID, file); this.setTextInputShouldClear(false); }} > diff --git a/src/pages/home/report/ReportActionItem.js b/src/pages/home/report/ReportActionItem.js index ac04ba8a5e5b..10e5b58de3cb 100644 --- a/src/pages/home/report/ReportActionItem.js +++ b/src/pages/home/report/ReportActionItem.js @@ -24,8 +24,10 @@ import canUseTouchScreen from '../../../libs/canUseTouchscreen'; import MiniReportActionContextMenu from './ContextMenu/MiniReportActionContextMenu'; import * as ReportActionContextMenu from './ContextMenu/ReportActionContextMenu'; import * as ContextMenuActions from './ContextMenu/ContextMenuActions'; -import {withReportActionsDrafts} from '../../../components/OnyxProvider'; +import {withNetwork, withReportActionsDrafts} from '../../../components/OnyxProvider'; import RenameAction from '../../../components/ReportActionItem/RenameAction'; +import InlineSystemMessage from '../../../components/InlineSystemMessage'; +import styles from '../../../styles/styles'; const propTypes = { /** The ID of the report this action is on. */ @@ -173,7 +175,7 @@ class ReportActionItem extends Component { hovered || this.state.isContextMenuActive || this.props.draftMessage, - this.props.action.isPending || this.props.action.error, + (this.props.network.isOffline && this.props.action.isLoading) || this.props.action.error, )} > {!this.props.displayAsGroup @@ -202,6 +204,9 @@ class ReportActionItem extends Component { )} + + + ); } @@ -211,6 +216,7 @@ ReportActionItem.defaultProps = defaultProps; export default compose( withWindowDimensions, + withNetwork(), withReportActionsDrafts({ propName: 'draftMessage', transformValue: (drafts, props) => { diff --git a/src/pages/home/report/ReportActionItemMessage.js b/src/pages/home/report/ReportActionItemMessage.js index c1eb02a8326d..fd6bb82fa023 100644 --- a/src/pages/home/report/ReportActionItemMessage.js +++ b/src/pages/home/report/ReportActionItemMessage.js @@ -22,7 +22,7 @@ const propTypes = { }; const ReportActionItemMessage = (props) => { - const isUnsent = props.network.isOffline && props.action.loading; + const isUnsent = props.network.isOffline && props.action.isLoading; return ( @@ -32,7 +32,7 @@ const ReportActionItemMessage = (props) => { fragment={fragment} isAttachment={props.action.isAttachment} attachmentInfo={props.action.attachmentInfo} - loading={props.action.loading} + loading={props.action.isLoading} /> ))} diff --git a/src/pages/home/report/ReportActionItemSingle.js b/src/pages/home/report/ReportActionItemSingle.js index bc3c0ddcab38..80a1bc991905 100644 --- a/src/pages/home/report/ReportActionItemSingle.js +++ b/src/pages/home/report/ReportActionItemSingle.js @@ -92,7 +92,7 @@ const ReportActionItemSingle = (props) => { fragment={fragment} tooltipText={props.action.actorEmail} isAttachment={props.action.isAttachment} - isLoading={props.action.loading} + isLoading={props.action.isLoading} isSingleLine /> ))} diff --git a/src/pages/home/report/reportActionPropTypes.js b/src/pages/home/report/reportActionPropTypes.js index c4400d36c3ab..d752047cbb97 100644 --- a/src/pages/home/report/reportActionPropTypes.js +++ b/src/pages/home/report/reportActionPropTypes.js @@ -24,9 +24,8 @@ export default { IOUTransactionID: PropTypes.string, }), - /** If the reportAction is pending, that means we have not yet sent the Report_AddComment command to the server. - This should most often occur when the client is offline. */ - isPending: PropTypes.bool, + /** Whether we have received a response back from the server */ + isLoading: PropTypes.bool, /** Error message that's come back from the server. */ error: PropTypes.string, diff --git a/src/styles/StyleUtils.js b/src/styles/StyleUtils.js index ab37cbe68b72..fe7113bb6314 100644 --- a/src/styles/StyleUtils.js +++ b/src/styles/StyleUtils.js @@ -387,10 +387,10 @@ function getLoginPagePromoStyle() { * Generate the styles for the ReportActionItem wrapper view. * * @param {Boolean} [isHovered] - * @param {Boolean} [isPending] + * @param {Boolean} [isLoading] * @returns {Object} */ -function getReportActionItemStyle(isHovered = false, isPending = false) { +function getReportActionItemStyle(isHovered = false, isLoading = false) { return { display: 'flex', justifyContent: 'space-between', @@ -399,7 +399,7 @@ function getReportActionItemStyle(isHovered = false, isPending = false) { // Warning: Setting this to a non-transparent color will cause unread indicator to break on Android : colors.transparent, - opacity: isPending ? 0.5 : 1, + opacity: isLoading ? 0.5 : 1, cursor: 'default', }; } diff --git a/src/styles/styles.js b/src/styles/styles.js index 493333605ff1..ee43aa1482eb 100644 --- a/src/styles/styles.js +++ b/src/styles/styles.js @@ -1839,6 +1839,10 @@ const styles = { ...{borderRadius: variables.componentBorderRadiusSmall}, }, + reportActionSystemMessageContainer: { + marginLeft: 42, + }, + reportDetailsTitleContainer: { ...flex.dFlex, ...flex.flexColumn, @@ -2567,7 +2571,7 @@ const styles = { color: themeColors.textSupporting, fontSize: variables.fontSizeLabel, fontFamily: fontFamily.GTA, - marginLeft: 4, + marginLeft: 6, }, }; diff --git a/tests/README.md b/tests/README.md index a166fd22b5f4..1ed12dad161f 100644 --- a/tests/README.md +++ b/tests/README.md @@ -60,7 +60,7 @@ describe('actions/Report', () => { })); // When we add a new action to that report - addAction(REPORT_ID, 'Hello!'); + Report.addComment(REPORT_ID, 'Hello!'); return waitForPromisesToResolve() .then(() => { const action = reportActions[ACTION_ID]; @@ -69,7 +69,7 @@ describe('actions/Report', () => { // the comment we left and it will be in a loading state because // it's an "optimistic comment" expect(action.message[0].text).toBe('Hello!'); - expect(action.loading).toBe(true); + expect(action.isPending).toBe(true); }); }); }); diff --git a/tests/actions/ReportTest.js b/tests/actions/ReportTest.js index 6af615bf866b..99c2b0fb0e8e 100644 --- a/tests/actions/ReportTest.js +++ b/tests/actions/ReportTest.js @@ -14,6 +14,7 @@ import waitForPromisesToResolve from '../utils/waitForPromisesToResolve'; import * as TestHelper from '../utils/TestHelper'; import Log from '../../src/libs/Log'; import * as PersistedRequests from '../../src/libs/actions/PersistedRequests'; +import * as User from '../../src/libs/actions/User'; describe('actions/Report', () => { beforeAll(() => { @@ -76,7 +77,7 @@ describe('actions/Report', () => { // Set up Onyx with some test user data return TestHelper.signInWithTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN) .then(() => { - Report.subscribeToUserEvents(); + User.subscribeToUserEvents(); return waitForPromisesToResolve(); }) .then(() => TestHelper.fetchPersonalDetailsForTestUser(TEST_USER_ACCOUNT_ID, TEST_USER_LOGIN, { @@ -90,7 +91,7 @@ describe('actions/Report', () => { .then(() => { // This is a fire and forget response, but once it completes we should be able to verify that we // have an "optimistic" report action in Onyx. - Report.addAction(REPORT_ID, 'Testing a comment'); + Report.addComment(REPORT_ID, 'Testing a comment'); return waitForPromisesToResolve(); }) .then(() => { @@ -98,19 +99,35 @@ describe('actions/Report', () => { // Store the generated clientID so that we can send it with our mock Pusher update clientID = resultAction.sequenceNumber; - expect(resultAction.message).toEqual(REPORT_ACTION.message); expect(resultAction.person).toEqual(REPORT_ACTION.person); - expect(resultAction.loading).toEqual(true); - }) - .then(() => { + expect(resultAction.isLoading).toEqual(true); + // We subscribed to the Pusher channel above and now we need to simulate a reportComment action // Pusher event so we can verify that action was handled correctly and merged into the reportActions. const channel = Pusher.getChannel(`${CONST.PUSHER.PRIVATE_USER_CHANNEL_PREFIX}1${CONFIG.PUSHER.SUFFIX}`); - channel.emit(Pusher.TYPE.REPORT_COMMENT, { - reportID: REPORT_ID, - reportAction: {...REPORT_ACTION, clientID}, - }); + channel.emit(Pusher.TYPE.ONYX_API_UPDATE, [ + { + onyxMethod: 'merge', + key: `${ONYXKEYS.COLLECTION.REPORT}${REPORT_ID}`, + value: { + reportID: REPORT_ID, + maxSequenceNumber: 1, + notificationPreference: 'always', + lastMessageTimestamp: 0, + lastMessageText: 'Testing a comment', + lastActorEmail: TEST_USER_LOGIN, + }, + }, + { + onyxMethod: 'merge', + key: `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${REPORT_ID}`, + value: { + [clientID]: null, + [ACTION_ID]: _.without(resultAction, 'loading'), + }, + }, + ]); // Once a reportComment event is emitted to the Pusher channel we should see the comment get processed // by the Pusher callback and added to the storage so we must wait for promises to resolve again and @@ -124,7 +141,7 @@ describe('actions/Report', () => { const resultAction = reportActions[ACTION_ID]; // Verify that our action is no longer in the loading state - expect(resultAction.loading).toEqual(false); + expect(resultAction.isLoading).not.toBeDefined(); }); }); @@ -180,7 +197,7 @@ describe('actions/Report', () => { } // And leave a comment on a report - Report.addAction(REPORT_ID, 'Testing a comment'); + Report.addComment(REPORT_ID, 'Testing a comment'); // Then we should expect that there is on persisted request expect(PersistedRequests.getAll().length).toBe(1); @@ -189,10 +206,10 @@ describe('actions/Report', () => { return waitForPromisesToResolve(); }) .then(() => { - // THEN only ONE call to Report_AddComment will happen + // THEN only ONE call to AddComment will happen const URL_ARGUMENT_INDEX = 0; - const reportAddCommentCalls = _.filter(global.fetch.mock.calls, callArguments => callArguments[URL_ARGUMENT_INDEX].includes('Report_AddComment')); - expect(reportAddCommentCalls.length).toBe(1); + const addCommentCalls = _.filter(global.fetch.mock.calls, callArguments => callArguments[URL_ARGUMENT_INDEX].includes('AddComment')); + expect(addCommentCalls.length).toBe(1); }); }); });