-
Notifications
You must be signed in to change notification settings - Fork 4k
Remove a call to getReportNameValuePairs when checking if a thread is disabled #63607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
88fb51b
d9cddb5
1dd70c3
050b4a0
6baa0d1
365d037
d2b013f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1234,42 +1234,6 @@ describe('ReportUtils', () => { | |
| expect(shouldDisableThread(reportAction, reportID, false)).toBeTruthy(); | ||
| }); | ||
|
|
||
| it('should disable on deleted and not-thread actions', () => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I refactored this test to be more explicit, like the new archived tests |
||
| const reportAction = { | ||
| message: [ | ||
| { | ||
| translationKey: '', | ||
| type: 'COMMENT', | ||
| html: '', | ||
| text: '', | ||
| isEdited: true, | ||
| }, | ||
| ], | ||
| childVisibleActionCount: 1, | ||
| } as ReportAction; | ||
| expect(shouldDisableThread(reportAction, reportID, false)).toBeFalsy(); | ||
|
|
||
| reportAction.childVisibleActionCount = 0; | ||
| expect(shouldDisableThread(reportAction, reportID, false)).toBeTruthy(); | ||
| }); | ||
|
|
||
| it('should disable on archived reports and not-thread actions', () => { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was a bad test because it wasn't actually testing archived reports. Archived reports would have required doing something with the report NVPs, not the status or state. Then, the test is really only testing the However, since the report wasn't actually archived, the logic falls into the same path as deleted threads since |
||
| Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`, { | ||
| statusNum: CONST.REPORT.STATUS_NUM.CLOSED, | ||
| stateNum: CONST.REPORT.STATE_NUM.APPROVED, | ||
| }) | ||
| .then(() => waitForBatchedUpdates()) | ||
| .then(() => { | ||
| const reportAction = { | ||
| childVisibleActionCount: 1, | ||
| } as ReportAction; | ||
| expect(shouldDisableThread(reportAction, reportID, false)).toBeFalsy(); | ||
|
|
||
| reportAction.childVisibleActionCount = 0; | ||
| expect(shouldDisableThread(reportAction, reportID, false)).toBeTruthy(); | ||
| }); | ||
| }); | ||
|
|
||
| it("should disable on a whisper action and it's neither a report preview nor IOU action", () => { | ||
| const reportAction = { | ||
| actionName: CONST.REPORT.ACTIONS.TYPE.MODIFIED_EXPENSE, | ||
|
|
@@ -1286,6 +1250,186 @@ describe('ReportUtils', () => { | |
| } as ReportAction; | ||
| expect(shouldDisableThread(reportAction, reportID, true)).toBeTruthy(); | ||
| }); | ||
|
|
||
| describe('deleted threads', () => { | ||
| it('should be enabled if the report action is not-deleted and child visible action count is 1', () => { | ||
| // Given a normal report action with one child visible action count | ||
| const reportAction = { | ||
| message: [ | ||
| { | ||
| translationKey: '', | ||
| type: 'COMMENT', | ||
| html: 'test', | ||
| text: 'test', | ||
| }, | ||
| ], | ||
| childVisibleActionCount: 1, | ||
| } as ReportAction; | ||
|
|
||
| // When it's checked to see if the thread should be disabled | ||
| const isThreadDisabled = shouldDisableThread(reportAction, reportID, false); | ||
|
|
||
| // Then the thread should be enabled | ||
| expect(isThreadDisabled).toBeFalsy(); | ||
| }); | ||
|
|
||
| it('should be enabled if the report action is not-deleted and child visible action count is 0', () => { | ||
| // Given a normal report action with zero child visible action count | ||
| const reportAction = { | ||
| message: [ | ||
| { | ||
| translationKey: '', | ||
| type: 'COMMENT', | ||
| html: 'test', | ||
| text: 'test', | ||
| }, | ||
| ], | ||
| childVisibleActionCount: 0, | ||
| } as ReportAction; | ||
|
|
||
| // When it's checked to see if the thread should be disabled | ||
| const isThreadDisabled = shouldDisableThread(reportAction, reportID, false); | ||
|
|
||
| // Then the thread should be enabled | ||
| expect(isThreadDisabled).toBeFalsy(); | ||
| }); | ||
| it('should be enabled if the report action is deleted and child visible action count is 1', () => { | ||
| // Given a normal report action with one child visible action count | ||
| const reportAction = { | ||
| message: [ | ||
| { | ||
| translationKey: '', | ||
| type: 'COMMENT', | ||
| html: '', | ||
| text: '', | ||
| }, | ||
| ], | ||
| childVisibleActionCount: 1, | ||
| } as ReportAction; | ||
|
|
||
| // When it's checked to see if the thread should be disabled | ||
| const isThreadDisabled = shouldDisableThread(reportAction, reportID, false); | ||
|
|
||
| // Then the thread should be enabled | ||
| expect(isThreadDisabled).toBeFalsy(); | ||
| }); | ||
|
|
||
| it('should be disabled if the report action is deleted and child visible action count is 0', () => { | ||
| // Given a normal report action with zero child visible action count | ||
| const reportAction = { | ||
| message: [ | ||
| { | ||
| translationKey: '', | ||
| type: 'COMMENT', | ||
| html: '', | ||
| text: '', | ||
| }, | ||
| ], | ||
| childVisibleActionCount: 0, | ||
| } as ReportAction; | ||
|
|
||
| // When it's checked to see if the thread should be disabled | ||
| const isThreadDisabled = shouldDisableThread(reportAction, reportID, false); | ||
|
|
||
| // Then the thread should be disabled | ||
| expect(isThreadDisabled).toBeTruthy(); | ||
| }); | ||
| }); | ||
|
|
||
| describe('archived report threads', () => { | ||
| it('should be enabled if the report is not-archived and child visible action count is 1', () => { | ||
| // Given a normal report action with one child visible action count | ||
| const reportAction = { | ||
| message: [ | ||
| { | ||
| translationKey: '', | ||
| type: 'COMMENT', | ||
| html: 'test', | ||
| text: 'test', | ||
| }, | ||
| ], | ||
| childVisibleActionCount: 1, | ||
| } as ReportAction; | ||
|
|
||
| // And a report that is not archived | ||
| const isReportArchived = false; | ||
|
|
||
| // When it's checked to see if the thread should be disabled | ||
| const isThreadDisabled = shouldDisableThread(reportAction, reportID, false, isReportArchived); | ||
|
|
||
| // Then the thread should be enabled | ||
| expect(isThreadDisabled).toBeFalsy(); | ||
| }); | ||
| it('should be enabled if the report is not-archived and child visible action count is 0', () => { | ||
| // Given a normal report action with zero child visible action counts | ||
| const reportAction = { | ||
| message: [ | ||
| { | ||
| translationKey: '', | ||
| type: 'COMMENT', | ||
| html: 'test', | ||
| text: 'test', | ||
| }, | ||
| ], | ||
| childVisibleActionCount: 1, | ||
| } as ReportAction; | ||
|
|
||
| // And a report that is not archived | ||
| const isReportArchived = false; | ||
|
|
||
| // When it's checked to see if the thread should be disabled | ||
| const isThreadDisabled = shouldDisableThread(reportAction, reportID, false, isReportArchived); | ||
|
|
||
| // Then the thread should be enabled | ||
| expect(isThreadDisabled).toBeFalsy(); | ||
| }); | ||
| it('should be enabled if the report is archived and child visible action count is 1', () => { | ||
| // Given a normal report action with one child visible action count | ||
| const reportAction = { | ||
| message: [ | ||
| { | ||
| translationKey: '', | ||
| type: 'COMMENT', | ||
| html: 'test', | ||
| text: 'test', | ||
| }, | ||
| ], | ||
| childVisibleActionCount: 1, | ||
| } as ReportAction; | ||
|
|
||
| // And a report that is not archived | ||
| const isReportArchived = true; | ||
|
|
||
| // When it's checked to see if the thread should be disabled | ||
| const isThreadDisabled = shouldDisableThread(reportAction, reportID, false, isReportArchived); | ||
|
|
||
| // Then the thread should be enabled | ||
| expect(isThreadDisabled).toBeFalsy(); | ||
| }); | ||
| it('should be disabled if the report is archived and child visible action count is 0', () => { | ||
| // Given a normal report action with zero child visible action counts | ||
| const reportAction = { | ||
| message: [ | ||
| { | ||
| translationKey: '', | ||
| type: 'COMMENT', | ||
| html: 'test', | ||
| text: 'test', | ||
| }, | ||
| ], | ||
| childVisibleActionCount: 0, | ||
| } as ReportAction; | ||
|
|
||
| // And a report that is not archived | ||
| const isReportArchived = true; | ||
|
|
||
| // When it's checked to see if the thread should be disabled | ||
| const isThreadDisabled = shouldDisableThread(reportAction, reportID, false, isReportArchived); | ||
|
|
||
| // Then the thread should be disabled | ||
| expect(isThreadDisabled).toBeTruthy(); | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| describe('getAllAncestorReportActions', () => { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function was not being referenced anywhere, so I just removed it.