@@ -162,14 +162,18 @@ class LongPressMenuTest {
162162 var dismissedCount = 0
163163 setLongPressMenu(
164164 onDismissRequest = { dismissedCount + = 1 },
165- longPressable = getLongPressable(uploader = " A " , uploaderUrl = " https://example.com " ),
165+ longPressable = getLongPressable(uploader = " UpLoAdEr " ),
166166 longPressActions = listOf (ShowChannelDetails .buildAction { pressedCount + = 1 }),
167167 actionArrangement = listOf ()
168168 )
169169
170+ // although ShowChannelDetails is not in the actionArrangement set in user settings (and
171+ // thus the action will not appear in the menu), the LongPressMenu "knows" how to open a
172+ // channel because the longPressActions that can be performed contain ShowChannelDetails,
173+ // therefore the channel name is made clickable in the header
170174 composeRule.onNodeWithText(R .string.show_channel_details, substring = true )
171175 .assertDoesNotExist()
172- composeRule.onNodeWithText(" A " , substring = true )
176+ composeRule.onNodeWithText(" UpLoAdEr " , substring = true )
173177 .assertIsDisplayed()
174178 composeRule.onNodeWithTag(" ShowChannelDetails" )
175179 .performClick()
@@ -183,11 +187,13 @@ class LongPressMenuTest {
183187 var dismissedCount = 0
184188 setLongPressMenu(
185189 onDismissRequest = { dismissedCount + = 1 },
186- longPressable = getLongPressable(uploader = null , uploaderUrl = " https://example.com " ),
190+ longPressable = getLongPressable(uploader = null ),
187191 longPressActions = listOf (ShowChannelDetails .buildAction { pressedCount + = 1 }),
188192 actionArrangement = listOf ()
189193 )
190194
195+ // if the uploader name is not present, we use "Show channel details" as the text for the
196+ // channel opening link in the header
191197 composeRule.onNodeWithText(R .string.show_channel_details, substring = true )
192198 .assertIsDisplayed()
193199 composeRule.onNodeWithTag(" ShowChannelDetails" )
@@ -198,41 +204,26 @@ class LongPressMenuTest {
198204
199205 @Test
200206 fun testShowChannelDetails3 () {
201- var pressedCount = 0
202- var dismissedCount = 0
203207 setLongPressMenu(
204- onDismissRequest = { dismissedCount + = 1 },
205- longPressable = getLongPressable(uploader = null , uploaderUrl = null ),
206- longPressActions = listOf (ShowChannelDetails .buildAction { pressedCount + = 1 }),
207- actionArrangement = listOf ()
208- )
209-
210- composeRule.onNodeWithText(R .string.show_channel_details, substring = true )
211- .assertIsDisplayed()
212- composeRule.onNodeWithTag(" ShowChannelDetails" )
213- .performClick()
214- composeRule.waitUntil { dismissedCount == 1 }
215- assertEquals(1 , pressedCount)
216- }
217-
218- @Test
219- fun testShowChannelDetails4 () {
220- setLongPressMenu(
221- longPressable = getLongPressable(uploader = " A" , uploaderUrl = " https://example.com" ),
208+ longPressable = getLongPressable(uploader = " UpLoAdEr" ),
222209 longPressActions = listOf (),
223210 actionArrangement = listOf ()
224211 )
212+ // the longPressActions that can be performed do not contain ShowChannelDetails, so the
213+ // LongPressMenu cannot "know" how to open channel details
225214 composeRule.onNodeWithTag(" ShowChannelDetails" )
226215 .assertHasNoClickAction()
227216 }
228217
229218 @Test
230- fun testShowChannelDetails5 () {
219+ fun testShowChannelDetails4 () {
231220 setLongPressMenu(
232- longPressable = getLongPressable(uploader = " A " , uploaderUrl = " https://example.com " ),
221+ longPressable = getLongPressable(uploader = " UpLoAdEr " ),
233222 longPressActions = listOf (ShowChannelDetails .buildAction {}),
234223 actionArrangement = listOf (ShowChannelDetails )
235224 )
225+ // a ShowChannelDetails button is already present among the actions,
226+ // so the channel name isn't clickable in the header
236227 composeRule.onNodeWithTag(" ShowChannelDetails" )
237228 .assertHasNoClickAction()
238229 }
0 commit comments