-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19321 from Expensify/paulogasparsv-exclude-empty-…
…chats-from-lnh Exclude empty chats (with no ADDCOMMENT actions or message drafts) from LNH
- Loading branch information
Showing
4 changed files
with
106 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import wrapOnyxWithWaitForPromisesToResolve from '../utils/wrapOnyxWithWaitForPr | |
import CONST from '../../src/CONST'; | ||
import DateUtils from '../../src/libs/DateUtils'; | ||
import * as Localize from '../../src/libs/Localize'; | ||
import * as Report from '../../src/libs/actions/Report'; | ||
|
||
// Be sure to include the mocked permissions library or else the beta tests won't work | ||
jest.mock('../../src/libs/Permissions'); | ||
|
@@ -72,7 +73,59 @@ describe('Sidebar', () => { | |
); | ||
}); | ||
|
||
it('includes or excludes policy expense chats depending on the beta', () => { | ||
it('excludes an empty chat report', () => { | ||
LHNTestUtils.getDefaultRenderedSidebarLinks(); | ||
|
||
// Given a new report | ||
const report = LHNTestUtils.getFakeReport(['[email protected]', '[email protected]'], 0); | ||
|
||
return ( | ||
waitForPromisesToResolve() | ||
// When Onyx is updated to contain that report | ||
.then(() => | ||
Onyx.multiSet({ | ||
[`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`]: report, | ||
}), | ||
) | ||
|
||
// Then no reports are rendered in the LHN | ||
.then(() => { | ||
const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); | ||
const displayNames = screen.queryAllByLabelText(hintText); | ||
expect(displayNames).toHaveLength(0); | ||
}) | ||
); | ||
}); | ||
|
||
it('includes an empty chat report if it has a draft', () => { | ||
LHNTestUtils.getDefaultRenderedSidebarLinks(); | ||
|
||
// Given a new report | ||
const report = { | ||
...LHNTestUtils.getFakeReport([1, 2], 0), | ||
hasDraft: true, | ||
}; | ||
|
||
return ( | ||
waitForPromisesToResolve() | ||
// When Onyx is updated to contain that report | ||
.then(() => | ||
Onyx.multiSet({ | ||
[`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`]: report, | ||
[ONYXKEYS.PERSONAL_DETAILS_LIST]: LHNTestUtils.fakePersonalDetails, | ||
}), | ||
) | ||
|
||
// Then no reports are rendered in the LHN | ||
.then(() => { | ||
const hintText = Localize.translateLocal('accessibilityHints.chatUserDisplayNames'); | ||
const displayNames = screen.queryAllByLabelText(hintText); | ||
expect(displayNames).toHaveLength(1); | ||
}) | ||
); | ||
}); | ||
|
||
it('includes or excludes policy expensechats depending on the beta', () => { | ||
LHNTestUtils.getDefaultRenderedSidebarLinks(); | ||
|
||
// Given a policy expense report | ||
|
@@ -94,6 +147,9 @@ describe('Sidebar', () => { | |
}), | ||
) | ||
|
||
// When the report has at least one ADDCOMMENT action to be rendered in the LNH | ||
.then(() => Report.addComment(report.reportID, 'Hi, this is a comment')) | ||
|
||
// Then no reports are rendered in the LHN | ||
.then(() => { | ||
const hintText = Localize.translateLocal('accessibilityHints.navigatesToChat'); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters