@@ -237,19 +237,25 @@ const logSidebarDiagnostics = (): void => {
237237 * yet contain extension items. A one-shot jQuery `.find()` during that gap
238238 * always misses the item, making the outer reload loop retry needlessly.
239239 *
240- * This helper polls the live jQuery element for up to `NAV_ITEM_SETTLE_MS`
240+ * This helper polls the live `#page-sidebar` DOM for up to `NAV_ITEM_SETTLE_MS`
241241 * so that a single page load is enough once the extensions are ready.
242+ *
243+ * `.then()` must allow longer than `defaultCommandTimeout` (10s) while the inner
244+ * `Cypress.Promise` polls for up to `NAV_ITEM_SETTLE_MS` (15s).
242245 */
243246const NAV_ITEM_SETTLE_MS = 15000 ;
244247const NAV_ITEM_POLL_MS = 500 ;
248+ const NAV_ITEM_FIND_TIMEOUT_MS = NAV_ITEM_SETTLE_MS + 5000 ;
245249
246- const findNavItemInSidebar = ( $sidebar : JQuery , navLabel : string ) : Cypress . Chainable < boolean > =>
250+ const findNavItemInSidebar = ( navLabel : string ) : Cypress . Chainable < boolean > =>
247251 cy . wrap ( null , { log : false } ) . then (
252+ { timeout : NAV_ITEM_FIND_TIMEOUT_MS } ,
248253 ( ) =>
249254 new Cypress . Promise < boolean > ( ( resolve ) => {
250255 const deadline = Date . now ( ) + NAV_ITEM_SETTLE_MS ;
251256 const poll = ( ) => {
252- if ( $sidebar . find ( `a:contains("${ navLabel } ")` ) . length > 0 ) {
257+ const $sidebar = Cypress . $ ( '#page-sidebar' ) ;
258+ if ( $sidebar . length > 0 && $sidebar . find ( `a:contains("${ navLabel } ")` ) . length > 0 ) {
253259 resolve ( true ) ;
254260 } else if ( Date . now ( ) >= deadline ) {
255261 resolve ( false ) ;
@@ -278,7 +284,7 @@ const waitForNavItemInSidebar = (navLabel: string): Cypress.Chainable<boolean> =
278284
279285 return appChrome
280286 . findSideBar ( )
281- . then ( ( $sidebar ) => findNavItemInSidebar ( $sidebar , navLabel ) )
287+ . then ( ( ) => findNavItemInSidebar ( navLabel ) )
282288 . then ( ( found ) => {
283289 const elapsedTime = ( ( Date . now ( ) - startTime ) / 1000 ) . toFixed ( 1 ) ;
284290
0 commit comments