Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { signInThroughForm } from '../../../utils/formSignIn';
import {
AppModeExpectation,
assertAppMode,
switchToAiModeViaProfileToggle,
switchToAiModeViaSidebarSwitcher,
} from '../../Utils/appMode';

// The AI sidebar renders two AppModeSwitcher instances (compact rail + expanded
Expand Down Expand Up @@ -57,7 +57,7 @@ const waitForAppMode = async (page: Page, expected: AppModeExpectation) => {

const openSwitcherAsAi = async (page: Page, user: UserClass) => {
await signInThroughForm(page, user);
await switchToAiModeViaProfileToggle(page);
await switchToAiModeViaSidebarSwitcher(page);
await expect(page.getByTestId('ask-sidebar')).toBeVisible();
await page.locator(VISIBLE_SWITCHER_TRIGGER).click();
await expect(page.locator(VISIBLE_SWITCHER_CARD)).toBeVisible();
Expand Down Expand Up @@ -89,7 +89,7 @@ test.describe('AppMode — cross-device sync', { tag: ['@Platform'] }, () => {
test('Preference set in browser A is visible on a fresh login in browser B', async ({
browser,
}) => {
// openSwitcherAsAi (full login + profile-toggle + switcher-open) plus a
// openSwitcherAsAi (full login + sidebar-switch + switcher-open) plus a
// second login on browser B tips past the 60s per-test default under CI
// load. Bump.
test.setTimeout(150_000);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import {
AppModeExpectation,
assertAppMode,
stubTenantDefaultAppMode,
switchToAiModeViaProfileToggle,
switchToAiModeViaSidebarSwitcher,
} from '../../Utils/appMode';

type DefaultAppMode = 'ai' | 'classic' | null;
Expand Down Expand Up @@ -330,7 +330,7 @@ test.describe('AppMode — unified precedence', { tag: ['@Platform'] }, () => {
// Classic; the manual switch overrides for this tab.
await signInThroughForm(page, user);
await waitForAllLoadersToDisappear(page);
await switchToAiModeViaProfileToggle(page);
await switchToAiModeViaSidebarSwitcher(page);
await expect(page.getByTestId('ask-sidebar')).toBeVisible();
await waitForAppMode(page, 'ai');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { expect, test } from '../../../support/fixtures/base';
import { UserClass } from '../../../support/user/UserClass';
import { createNewPage } from '../../../utils/common';
import { signInThroughForm } from '../../../utils/formSignIn';
import { switchToAiModeViaProfileToggle } from '../../Utils/appMode';
import { switchToAiModeViaSidebarSwitcher } from '../../Utils/appMode';

// The AI sidebar renders two AppModeSwitcher instances (compact rail + expanded
// card); `:visible` narrows to whichever is shown without a positional locator.
Expand Down Expand Up @@ -47,7 +47,7 @@ const isAppModePreferenceDelete = (response: Response) =>
*/
const openSwitcherAsAi = async (page: Page, user: UserClass) => {
await signInThroughForm(page, user);
await switchToAiModeViaProfileToggle(page);
await switchToAiModeViaSidebarSwitcher(page);
await expect(page.getByTestId('ask-sidebar')).toBeVisible();
await page.locator(VISIBLE_SWITCHER_TRIGGER).click();
await expect(page.locator(VISIBLE_SWITCHER_CARD)).toBeVisible();
Expand Down Expand Up @@ -81,7 +81,7 @@ test.describe('AppMode — preference round trip', { tag: ['@Platform'] }, () =>
test('Toggle "remember" ON emits a PUT with the typed-union body', async ({
browser,
}) => {
// openSwitcherAsAi = login + profile-toggle + open-switcher: three heavy
// openSwitcherAsAi = login + sidebar-switch + open-switcher: three heavy
// sequential steps that tip past the 60s default under CI load. Bump.
test.setTimeout(EXTENDED_TEST_TIMEOUT);
const context = await browser.newContext();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { waitForAllLoadersToDisappear } from '../../../utils/entity';
import {
assertAppMode,
disableAiAppMode,
switchToAiModeViaProfileToggle,
switchToAiModeViaSidebarSwitcher,
} from '../../Utils/appMode';
import { expect, test } from './fixtures';

Expand Down Expand Up @@ -78,7 +78,7 @@ const simulateAllTabsClosed = (page: Page): Promise<void> =>
);

test.describe('AppMode — resolver behaviour', { tag: ['@Platform'] }, () => {
test('profile-dropdown toggle switches Classic → AI and populates session + hint', async ({
test('sidebar switcher switches Classic → AI and populates session + hint', async ({
page,
}) => {
await disableAiAppMode(page);
Expand All @@ -90,8 +90,8 @@ test.describe('AppMode — resolver behaviour', { tag: ['@Platform'] }, () => {
await assertAppMode(page, 'default');
});

await test.step('Toggle to AI via profile dropdown', async () => {
await switchToAiModeViaProfileToggle(page);
await test.step('Toggle to AI via the sidebar switcher', async () => {
await switchToAiModeViaSidebarSwitcher(page);
await expect(page.getByTestId('ask-sidebar')).toBeVisible();
await assertAppMode(page, 'ai');
});
Expand All @@ -109,7 +109,7 @@ test.describe('AppMode — resolver behaviour', { tag: ['@Platform'] }, () => {
await disableAiAppMode(page);
await page.goto('/my-data', { waitUntil: 'domcontentloaded' });
await waitForAllLoadersToDisappear(page);
await switchToAiModeViaProfileToggle(page);
await switchToAiModeViaSidebarSwitcher(page);
await expect(page.getByTestId('ask-sidebar')).toBeVisible();

await test.step('Reload the tab', async () => {
Expand All @@ -129,7 +129,7 @@ test.describe('AppMode — resolver behaviour', { tag: ['@Platform'] }, () => {
await disableAiAppMode(page);
await page.goto('/my-data', { waitUntil: 'domcontentloaded' });
await waitForAllLoadersToDisappear(page);
await switchToAiModeViaProfileToggle(page);
await switchToAiModeViaSidebarSwitcher(page);
await expect(page.getByTestId('ask-sidebar')).toBeVisible();

// The hint is what carries the mode across tabs — sessionStorage does NOT
Expand All @@ -156,7 +156,7 @@ test.describe('AppMode — resolver behaviour', { tag: ['@Platform'] }, () => {
await disableAiAppMode(page);
await page.goto('/my-data', { waitUntil: 'domcontentloaded' });
await waitForAllLoadersToDisappear(page);
await switchToAiModeViaProfileToggle(page);
await switchToAiModeViaSidebarSwitcher(page);
await expect(page.getByTestId('ask-sidebar')).toBeVisible();

await test.step('Simulate closing every tab (session + hint gone)', async () => {
Expand All @@ -178,7 +178,7 @@ test.describe('AppMode — resolver behaviour', { tag: ['@Platform'] }, () => {
await disableAiAppMode(page);
await page.goto('/my-data', { waitUntil: 'domcontentloaded' });
await waitForAllLoadersToDisappear(page);
await switchToAiModeViaProfileToggle(page);
await switchToAiModeViaSidebarSwitcher(page);
await expect(page.getByTestId('ask-sidebar')).toBeVisible();

const rememberToggle = page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { redirectToHomePage } from '../../utils/common';
import {
disableAiAppMode,
enableAiAppMode,
switchToAiModeViaProfileToggle,
switchToAiModeViaSidebarSwitcher,
} from '../Utils/appMode';

test.use({ storageState: 'playwright/.auth/admin.json' });
Expand Down Expand Up @@ -92,7 +92,7 @@ test.describe(
);
await page.keyboard.press('Escape');

await switchToAiModeViaProfileToggle(page);
await switchToAiModeViaSidebarSwitcher(page);
await expect(root(page)).toHaveClass(/dark-mode/);
expect(await page.evaluate(() => localStorage.getItem('ui-theme'))).toBe(
'dark'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -270,15 +270,15 @@ export const assertAppMode = async (
};

/**
* Switch to AI mode from Classic via the navbar profile-dropdown interface
* toggle — the production control. Opens the dropdown, clicks "AI", and waits
* for the AI shell to settle.
* Switch to AI mode from Classic via the sidebar-footer interface switcher —
* the production control. Opens the switcher, clicks "AI", and waits for the
* AI shell to settle.
*/
export const switchToAiModeViaProfileToggle = async (
export const switchToAiModeViaSidebarSwitcher = async (
Comment thread
Rohit0301 marked this conversation as resolved.
Resolved
page: Page
): Promise<void> => {
await page.getByTestId('dropdown-profile').click();
await page.getByTestId('interface-mode-option-ai').click();
await page.getByTestId('app-mode-switcher-trigger').click();
await page.getByTestId('app-mode-option-ai').click();
await waitForAllLoadersToDisappear(page);
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright 2026 Collate.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import {
AppModeSwitcherTriggerStyle,
AppModeSwitcherVariant,
} from './AppModeSwitcher.types';

export const OPTION_ICON_BOX =
'tw:w-9 tw:h-9 tw:rounded-[10px] tw:bg-utility-blue-50 tw:border tw:border-utility-blue-100 tw:shrink-0';

export const CURRENT_CHECK_CLASS = 'tw:shrink-0 tw:text-fg-brand-primary';

const UNSTYLED_BUTTON =
'tw:flex tw:items-center tw:bg-transparent tw:border-0 tw:cursor-pointer';

// `frame` variants sit inside a core Card, which owns the surface (border, background, radius).
export const TRIGGER_STYLES: Record<
AppModeSwitcherVariant,
AppModeSwitcherTriggerStyle
> = {
inline: {
root: `${UNSTYLED_BUTTON} tw:gap-2.5 tw:w-full tw:p-0 tw:text-left`,
label: 'tw:flex-1 tw:text-sm tw:text-secondary tw:font-medium',
iconSize: 20,
chevron: 'right',
},
pill: {
root: 'tw:flex tw:items-center tw:gap-1 tw:px-2 tw:py-1 tw:bg-utility-blue-50 tw:border tw:border-utility-blue-200 tw:rounded-full tw:cursor-pointer tw:text-left',
label: 'tw:text-[10px] tw:text-utility-blue-700 tw:font-semibold',
iconSize: 12,
chevron: 'up',
},
card: {
root: `${UNSTYLED_BUTTON} tw:gap-2.5 tw:w-full tw:px-3.5 tw:py-2.5 tw:text-left tw:hover:bg-primary_hover`,
label: 'tw:flex-1 tw:text-sm tw:text-primary tw:font-medium',
iconSize: 20,
chevron: 'right',
frame: 'tw:w-full',
},
icon: {
root: `${UNSTYLED_BUTTON} tw:justify-center tw:size-full tw:hover:bg-primary_hover`,
iconSize: 20,
frame: 'tw:size-14',
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ jest.mock('@openmetadata/ui-core-components', () => ({
content,
}: React.PropsWithChildren<{ content: React.ReactNode }>) =>
React.createElement(React.Fragment, null, children, content),
Card: ({
children,
...props
}: React.PropsWithChildren<Record<string, unknown>>) =>
React.createElement('div', props, children),
Box: ({
children,
...props
Expand Down Expand Up @@ -133,6 +138,30 @@ describe('AppModeSwitcher', () => {
expect(getTrigger()).toHaveTextContent('label.classic mode');
});

it('shows the mode as a short pill label in the AI rail', () => {
render(<AppModeSwitcher variant="pill" />);

expect(getTrigger()).toHaveTextContent(/^label\.classic$/);
});

it('shows the full mode sentence on the bordered sidebar card', () => {
render(<AppModeSwitcher variant="card" />);

expect(getTrigger()).toHaveTextContent('label.classic mode');
expect(getTrigger()).not.toHaveAttribute('aria-label');
});

it('names the icon-only trigger for the collapsed sidebar and still opens the switcher', () => {
render(<AppModeSwitcher variant="icon" />);

expect(getTrigger()).toHaveAccessibleName('label.classic mode');
expect(getTrigger()).toHaveTextContent(/^$/);

fireEvent.click(getTrigger());

expect(getCard()).toBeInTheDocument();
});

it('renders both Classic and AI options', () => {
render(<AppModeSwitcher />);

Expand Down
Loading
Loading