11import { test } from '@playwright/test' ;
22import { NewtabPage } from '../../../integration-tests/new-tab.page.js' ;
33import { OmnibarPage } from './omnibar.page.js' ;
4+ import { CustomizerPage } from '../../customizer/integration-tests/customizer.page.js' ;
45
56test . describe ( 'omnibar widget persistence' , ( ) => {
67 test ( 'remembers input across tabs' , async ( { page } , workerInfo ) => {
@@ -11,14 +12,14 @@ test.describe('omnibar widget persistence', () => {
1112 await omnibar . ready ( ) ;
1213
1314 // first fill
14- await omnibar . input ( { mode : 'search' , value : 'shoes' } ) ;
15+ await omnibar . types ( { mode : 'search' , value : 'shoes' } ) ;
1516
1617 // switch
1718 await omnibar . didSwitchToTab ( '02' , [ '01' , '02' ] ) ;
1819 await omnibar . expectInputValue ( '' ) ;
1920
2021 // second fill
21- await omnibar . input ( { mode : 'search' , value : 'dresses' } ) ;
22+ await omnibar . types ( { mode : 'search' , value : 'dresses' } ) ;
2223
2324 // back to first
2425 await omnibar . didSwitchToTab ( '01' , [ '01' , '02' ] ) ;
@@ -36,7 +37,7 @@ test.describe('omnibar widget persistence', () => {
3637 await omnibar . ready ( ) ;
3738
3839 // first fill
39- await omnibar . input ( { mode : 'search' , value : 'shoes' } ) ;
40+ await omnibar . types ( { mode : 'search' , value : 'shoes' } ) ;
4041 await page . getByRole ( 'tab' , { name : 'Duck.ai' } ) . click ( ) ;
4142
4243 // new tab, should be opened with duck.ai input still visible
@@ -47,4 +48,29 @@ test.describe('omnibar widget persistence', () => {
4748 await omnibar . didSwitchToTab ( '01' , [ '01' , '02' ] ) ;
4849 await omnibar . expectChatValue ( 'shoes' ) ;
4950 } ) ;
51+ test ( 'adjusts mode of other tabs when duck.ai is disabled' , async ( { page } , workerInfo ) => {
52+ const ntp = NewtabPage . create ( page , workerInfo ) ;
53+ const omnibar = new OmnibarPage ( ntp ) ;
54+ const customizer = new CustomizerPage ( ntp ) ;
55+ await ntp . reducedMotion ( ) ;
56+ await ntp . openPage ( { additional : { omnibar : true , tabs : true , 'tabs.debug' : true } } ) ;
57+ await omnibar . ready ( ) ;
58+
59+ // first tab, switch to ai mode
60+ await omnibar . switchMode ( { mode : 'ai' } ) ;
61+
62+ // switch to second tab, should be empty but still on duck.ai
63+ await omnibar . didSwitchToTab ( '02' , [ '01' , '02' ] ) ;
64+ await omnibar . expectValue ( { value : '' , mode : 'ai' } ) ;
65+ await omnibar . types ( { value : 'shoes' , mode : 'ai' } ) ;
66+
67+ // now turn duck.ai off, 'shoes' should remain, but on search mode
68+ await customizer . opensCustomizer ( ) ;
69+ await omnibar . toggleDuckAiButton ( ) . uncheck ( ) ;
70+ await omnibar . expectValue ( { value : 'shoes' , mode : 'search' } ) ;
71+
72+ // back to first tab, should be empty + search
73+ await omnibar . didSwitchToTab ( '01' , [ '01' , '02' ] ) ;
74+ await omnibar . expectValue ( { value : '' , mode : 'search' } ) ;
75+ } ) ;
5076} ) ;
0 commit comments