@@ -105,83 +105,86 @@ describe('SidebarLinksData', () => {
105
105
106
106
describe ( 'Report that should be included in the LHN' , ( ) => {
107
107
it ( 'should display the current active report' , async ( ) => {
108
+ // When the SidebarLinks are rendered without a specified report ID.
108
109
LHNTestUtils . getDefaultRenderedSidebarLinks ( ) ;
109
-
110
110
const report = createReport ( ) ;
111
-
111
+ // And the Onyx state is initialized with a report.
112
112
await initializeState ( {
113
113
[ `${ ONYXKEYS . COLLECTION . REPORT } ${ report . reportID } ` ] : report ,
114
114
} ) ;
115
- // check if no other reports are displayed
115
+ // Then no other reports should be displayed in the sidebar.
116
116
expect ( getOptionRows ( ) ) . toHaveLength ( 0 ) ;
117
-
117
+ // When the SidebarLinks are rendered again with the current active report ID.
118
118
LHNTestUtils . getDefaultRenderedSidebarLinks ( report . reportID ) ;
119
-
120
- // check if active report is displayed
119
+ // Then the active report should be displayed as part of LHN,
121
120
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.
123
123
} ) ;
124
124
125
125
it ( 'should display draft report' , async ( ) => {
126
+ // When SidebarLinks are rendered initially.
126
127
LHNTestUtils . getDefaultRenderedSidebarLinks ( ) ;
127
128
const draftReport = {
128
129
...createReport ( false , [ 1 , 2 ] , 0 ) ,
129
130
writeCapability : CONST . REPORT . WRITE_CAPABILITIES . ALL ,
130
131
} ;
131
-
132
+ // And Onyx state is initialized with a draft report.
132
133
await initializeState ( {
133
134
[ `${ ONYXKEYS . COLLECTION . REPORT } ${ draftReport . reportID } ` ] : draftReport ,
134
135
} ) ;
135
136
136
137
await waitForBatchedUpdatesWithAct ( ) ;
138
+ // And a draft message is added to the report.
137
139
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.
140
141
expect ( getDisplayNames ( ) ) . toHaveLength ( 1 ) ;
141
- // check if draft icon is displayed
142
+ // And the draft icon should be shown, indicating there is unsent content.
142
143
expect ( screen . getByTestId ( 'Pencil Icon' ) ) . toBeOnTheScreen ( ) ;
143
144
} ) ;
144
145
145
146
it ( 'should display pinned report' , async ( ) => {
147
+ // When the SidebarLinks are rendered.
146
148
LHNTestUtils . getDefaultRenderedSidebarLinks ( ) ;
147
149
const report = createReport ( false ) ;
150
+ // And the report is initialized in Onyx.
148
151
await initializeState ( {
149
152
[ `${ ONYXKEYS . COLLECTION . REPORT } ${ report . reportID } ` ] : report ,
150
153
} ) ;
151
-
152
- // report is not pinned
154
+ // Then the report should not appear in the sidebar as it is not pinned.
153
155
expect ( getOptionRows ( ) ) . toHaveLength ( 0 ) ;
154
- await waitForBatchedUpdatesWithAct ( ) ;
155
156
156
- // pin the report
157
+ await waitForBatchedUpdatesWithAct ( ) ;
158
+ // When the report is marked as pinned.
157
159
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.
160
161
expect ( getOptionRows ( ) ) . toHaveLength ( 1 ) ;
161
-
162
- // TODO The report is indicated as pinned.
162
+ // TODO add the proper assertion for the pinned report.
163
163
} ) ;
164
164
} ) ;
165
165
166
166
describe ( 'Report that should NOT be included in the LHN' , ( ) => {
167
167
it ( 'should not display report with no participants' , async ( ) => {
168
+ // When the SidebarLinks are rendered.
168
169
LHNTestUtils . getDefaultRenderedSidebarLinks ( ) ;
169
170
const report = LHNTestUtils . getFakeReport ( [ ] ) ;
170
-
171
+ // And a report with no participants is initialized in Onyx.
171
172
await initializeState ( {
172
173
[ `${ ONYXKEYS . COLLECTION . REPORT } ${ report . reportID } ` ] : report ,
173
174
} ) ;
174
-
175
+ // Then the report should not appear in the sidebar.
175
176
expect ( getOptionRows ( ) ) . toHaveLength ( 0 ) ;
176
177
} ) ;
177
178
178
179
it ( 'should not display empty chat' , async ( ) => {
180
+ // When the SidebarLinks are rendered.
179
181
LHNTestUtils . getDefaultRenderedSidebarLinks ( ) ;
180
182
const report = LHNTestUtils . getFakeReport ( [ 1 , 2 ] , 0 ) ;
181
-
183
+ // And a report with no messages is initialized in Onyx
182
184
await initializeState ( {
183
185
[ `${ ONYXKEYS . COLLECTION . REPORT } ${ report . reportID } ` ] : report ,
184
186
} ) ;
187
+ // Then the empty report should not appear in the sidebar.
185
188
expect ( getOptionRows ( ) ) . toHaveLength ( 0 ) ;
186
189
} ) ;
187
190
} ) ;
0 commit comments