Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🐛 fix: Give the Header's Sidebar Toggle Its Own Test Id (#14850)

Danny Avilaaf7e890b14a0
diff --git a/client/src/components/Chat/Header.tsx b/client/src/components/Chat/Header.tsx
index 8e61910622..0d936c89df 100644
--- a/client/src/components/Chat/Header.tsx
+++ b/client/src/components/Chat/Header.tsx
@@ -50,7 +50,7 @@ function Header() {
return (
<div className="absolute top-0 z-10 flex h-[52px] w-full items-center gap-2 bg-gradient-to-b from-presentation via-presentation/70 to-transparent p-2 font-semibold text-text-primary md:from-presentation/80 md:via-presentation/50 2xl:from-presentation/0 2xl:via-transparent">
<div className="flex flex-shrink-0 items-center md:hidden">
- <OpenSidebar />
+ <OpenSidebar testId="header-open-sidebar-button" />
</div>
<div
diff --git a/client/src/components/Chat/Menus/OpenSidebar.tsx b/client/src/components/Chat/Menus/OpenSidebar.tsx
index e8a158a001..8aa47b2b2f 100644
--- a/client/src/components/Chat/Menus/OpenSidebar.tsx
+++ b/client/src/components/Chat/Menus/OpenSidebar.tsx
@@ -9,7 +9,18 @@ import store from '~/store';
export const CLOSE_SIDEBAR_ID = 'close-sidebar-button';
export const OPEN_SIDEBAR_ID = 'open-sidebar-button';
-export default function OpenSidebar({ className }: { className?: string }) {
+/**
+ * `testId` exists because the sidebar rail publishes `open-sidebar-button` for its own
+ * collapsed toggle. Any caller that can stay mounted alongside the rail must claim a
+ * distinct id, or `getByTestId` resolves to two elements.
+ */
+export default function OpenSidebar({
+ className,
+ testId = OPEN_SIDEBAR_ID,
+}: {
+ className?: string;
+ testId?: string;
+}) {
const localize = useLocalize();
const setSidebarExpanded = useSetRecoilState(store.sidebarExpanded);
const tooltipDescription = useShortcutHint('toggleSidebar', localize('com_nav_open_sidebar'));
@@ -32,7 +43,7 @@ export default function OpenSidebar({ className }: { className?: string }) {
id={OPEN_SIDEBAR_ID}
size="icon"
variant="outline"
- data-testid="open-sidebar-button"
+ data-testid={testId}
aria-label={localize('com_nav_open_sidebar')}
aria-expanded={false}
aria-controls="chat-history-nav"
diff --git a/e2e/specs/mock/sidebar.spec.ts b/e2e/specs/mock/sidebar.spec.ts
index 04cc1a6868..4015fcf97d 100644
--- a/e2e/specs/mock/sidebar.spec.ts
+++ b/e2e/specs/mock/sidebar.spec.ts
@@ -159,6 +159,10 @@ test.describe('sidebar conversation grouping', () => {
localStorage.setItem('unifiedSidebarExpanded', JSON.stringify(false)),
);
await page.reload({ timeout: 10000 });
+ // The chat header keeps its own mobile toggle mounted and hides it with CSS, so this
+ // testid belongs to the rail alone — a second holder makes the click below strict-mode
+ // flaky rather than failing outright.
+ await expect(page.getByTestId('open-sidebar-button')).toHaveCount(1);
await expect(page.getByTestId('open-sidebar-button')).toBeVisible();
// Expand: rows first measure during the width animation — the regression window.