Skip to content

Commit 114e455

Browse files
committed
add comments
1 parent 5e9e0b2 commit 114e455

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

tests/ui/LHNItemsPresence.tsx

+25-22
Original file line numberDiff line numberDiff line change
@@ -105,83 +105,86 @@ describe('SidebarLinksData', () => {
105105

106106
describe('Report that should be included in the LHN', () => {
107107
it('should display the current active report', async () => {
108+
// When the SidebarLinks are rendered without a specified report ID.
108109
LHNTestUtils.getDefaultRenderedSidebarLinks();
109-
110110
const report = createReport();
111-
111+
// And the Onyx state is initialized with a report.
112112
await initializeState({
113113
[`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`]: report,
114114
});
115-
// check if no other reports are displayed
115+
// Then no other reports should be displayed in the sidebar.
116116
expect(getOptionRows()).toHaveLength(0);
117-
117+
// When the SidebarLinks are rendered again with the current active report ID.
118118
LHNTestUtils.getDefaultRenderedSidebarLinks(report.reportID);
119-
120-
// check if active report is displayed
119+
// Then the active report should be displayed as part of LHN,
121120
expect(getOptionRows()).toHaveLength(1);
122-
// TODO The report is highlighted as the active report.
121+
// And the active report should be highlighted.
122+
// TODO add the proper assertion for the highlighted report.
123123
});
124124

125125
it('should display draft report', async () => {
126+
// When SidebarLinks are rendered initially.
126127
LHNTestUtils.getDefaultRenderedSidebarLinks();
127128
const draftReport = {
128129
...createReport(false, [1, 2], 0),
129130
writeCapability: CONST.REPORT.WRITE_CAPABILITIES.ALL,
130131
};
131-
132+
// And Onyx state is initialized with a draft report.
132133
await initializeState({
133134
[`${ONYXKEYS.COLLECTION.REPORT}${draftReport.reportID}`]: draftReport,
134135
});
135136

136137
await waitForBatchedUpdatesWithAct();
138+
// And a draft message is added to the report.
137139
await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT_DRAFT_COMMENT}${draftReport.reportID}`, 'draft report message');
138-
139-
// check if draft report is displayed
140+
// Then the sidebar should display the draft report.
140141
expect(getDisplayNames()).toHaveLength(1);
141-
// check if draft icon is displayed
142+
// And the draft icon should be shown, indicating there is unsent content.
142143
expect(screen.getByTestId('Pencil Icon')).toBeOnTheScreen();
143144
});
144145

145146
it('should display pinned report', async () => {
147+
// When the SidebarLinks are rendered.
146148
LHNTestUtils.getDefaultRenderedSidebarLinks();
147149
const report = createReport(false);
150+
// And the report is initialized in Onyx.
148151
await initializeState({
149152
[`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`]: report,
150153
});
151-
152-
// report is not pinned
154+
// Then the report should not appear in the sidebar as it is not pinned.
153155
expect(getOptionRows()).toHaveLength(0);
154-
await waitForBatchedUpdatesWithAct();
155156

156-
// pin the report
157+
await waitForBatchedUpdatesWithAct();
158+
// When the report is marked as pinned.
157159
await Onyx.merge(`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`, {isPinned: true});
158-
159-
// report is pinned
160+
// Then the report should appear in the sidebar because it’s pinned.
160161
expect(getOptionRows()).toHaveLength(1);
161-
162-
// TODO The report is indicated as pinned.
162+
// TODO add the proper assertion for the pinned report.
163163
});
164164
});
165165

166166
describe('Report that should NOT be included in the LHN', () => {
167167
it('should not display report with no participants', async () => {
168+
// When the SidebarLinks are rendered.
168169
LHNTestUtils.getDefaultRenderedSidebarLinks();
169170
const report = LHNTestUtils.getFakeReport([]);
170-
171+
// And a report with no participants is initialized in Onyx.
171172
await initializeState({
172173
[`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`]: report,
173174
});
174-
175+
// Then the report should not appear in the sidebar.
175176
expect(getOptionRows()).toHaveLength(0);
176177
});
177178

178179
it('should not display empty chat', async () => {
180+
// When the SidebarLinks are rendered.
179181
LHNTestUtils.getDefaultRenderedSidebarLinks();
180182
const report = LHNTestUtils.getFakeReport([1, 2], 0);
181-
183+
// And a report with no messages is initialized in Onyx
182184
await initializeState({
183185
[`${ONYXKEYS.COLLECTION.REPORT}${report.reportID}`]: report,
184186
});
187+
// Then the empty report should not appear in the sidebar.
185188
expect(getOptionRows()).toHaveLength(0);
186189
});
187190
});

0 commit comments

Comments
 (0)