Skip to content

Commit 93a7710

Browse files
authored
Force search mode when Duck.ai is disabled in Omnibar (#1895)
1 parent 10ec39c commit 93a7710

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

special-pages/pages/new-tab/app/omnibar/integration-tests/omnibar.page.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff 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

special-pages/pages/new-tab/app/omnibar/integration-tests/omnibar.spec.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff 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);

special-pages/pages/new-tab/app/omnibar/omnibar.service.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)