File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed
special-pages/pages/new-tab/app/omnibar Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,10 @@ export class OmnibarPage {
6969 return this . context ( ) . getByRole ( 'button' , { name : 'Close' } ) ;
7070 }
7171
72+ root ( ) {
73+ return this . context ( ) . locator ( '[data-mode]' ) ;
74+ }
75+
7276 /**
7377 * @param {number } count
7478 */
@@ -132,6 +136,13 @@ export class OmnibarPage {
132136 }
133137 }
134138
139+ /**
140+ * @param {'search' | 'ai' } mode
141+ */
142+ async expectDataMode ( mode ) {
143+ await expect ( this . root ( ) ) . toHaveAttribute ( 'data-mode' , mode ) ;
144+ }
145+
135146 /**
136147 * @param {string } method
137148 * @param {number } count
Original file line number Diff line number Diff line change @@ -280,6 +280,29 @@ test.describe('omnibar widget', () => {
280280 await expect ( omnibar . tabList ( ) ) . toHaveCount ( 0 ) ;
281281 } ) ;
282282
283+ test ( 'forces mode to search when Duck.ai is disabled while in ai mode' , async ( { page } , workerInfo ) => {
284+ const ntp = NewtabPage . create ( page , workerInfo ) ;
285+ const omnibar = new OmnibarPage ( ntp ) ;
286+ await ntp . reducedMotion ( ) ;
287+
288+ await ntp . openPage ( { additional : { omnibar : true } } ) ;
289+ await omnibar . ready ( ) ;
290+
291+ // Switch to AI mode
292+ await omnibar . aiTab ( ) . click ( ) ;
293+ await omnibar . expectMode ( 'ai' ) ;
294+
295+ // Disable Duck.ai via Customize panel
296+ await omnibar . customizeButton ( ) . click ( ) ;
297+ await omnibar . toggleDuckAiButton ( ) . click ( ) ;
298+
299+ // Mode should be forced back to search since tab switcher is now hidden
300+ await omnibar . expectDataMode ( 'search' ) ;
301+
302+ // Tab selector should be gone
303+ await expect ( omnibar . tabList ( ) ) . toHaveCount ( 0 ) ;
304+ } ) ;
305+
283306 test ( 'hiding Omnibar widget hides Duck.ai toggle' , async ( { page } , workerInfo ) => {
284307 const ntp = NewtabPage . create ( page , workerInfo ) ;
285308 const omnibar = new OmnibarPage ( ntp ) ;
Original file line number Diff line number Diff line change @@ -74,6 +74,8 @@ export class OmnibarService {
7474 return {
7575 ...old ,
7676 enableAi,
77+ // Force mode to 'search' when Duck.ai is disabled to prevent getting stuck in 'ai' mode
78+ mode : enableAi ? old . mode : 'search' ,
7779 } ;
7880 } ) ;
7981 }
You can’t perform that action at this time.
0 commit comments