evOo-local/apps/web/e2e/sidebar-nav.spec.ts
cynarAI de2a64f070 fix(web): read sidebar trading mode from the bot status API (#80)
The Live Trading control stored its mode in localStorage, so the shell could
claim live money while the bot was in dry-run. Show the Tradingbot status
when TRADING_BOT_URL is set, and an unknown state when it is not.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: cynarAI <cynarAI@users.noreply.github.com>
2026-09-22 22:10:18 +02:00

58 lines
2.4 KiB
TypeScript

/**
* E2E: Sidebar navigation elements.
*
* Verifies the expected sidebar sections appear and that Integrations is gone.
*/
import { expect, test } from "@playwright/test";
import { captureScreenshot, completeOnboarding, signup } from "./helpers";
test.describe.configure({ mode: "serial" });
test("sidebar has expected navigation items and no integrations", async ({ page }) => {
const testInfo = test.info();
const stamp = Date.now();
await signup(page, `snnav-${stamp}@rakazo.test`, "password12", "SnNav");
await completeOnboarding(page);
await expect(page.getByText("Chief").first()).toBeVisible();
const sidebar = page.locator("aside").first();
await captureScreenshot(page, testInfo, "sidebar-nav-before");
// Actual sidebar structure (verified by snapshot):
// - button "Activity" (top action)
// - textbox "Search" (search input)
// - button "Heute" (today)
// - text "Unterhaltungen" (conversations section header)
// - status "Not configured" (trading bot URL unset)
// - NO "Integration(en)" button or text
// Search: it's a textbox, not a button
const searchInput = sidebar.locator('input[placeholder="Search"], textbox[name="Search"]');
await expect(searchInput).toBeVisible({ timeout: 5000 });
// "Heute" (Today)
const todayBtn = sidebar.getByRole("button", { name: "Heute" });
await expect(todayBtn).toBeVisible({ timeout: 5000 });
// "Unterhaltungen" is plain text, not a button
const conversationsText = sidebar.getByText("Unterhaltungen");
await expect(conversationsText).toBeVisible({ timeout: 5000 });
// Trading mode comes from the bot API. With no URL configured the sidebar
// must not claim Live Trading from a local preference.
const tradingStatus = sidebar.getByTestId("trading-mode-status");
await expect(tradingStatus).toBeVisible({ timeout: 5000 });
await expect(tradingStatus).toContainText("Not configured");
await expect(sidebar.getByRole("button", { name: "Live Trading" })).toHaveCount(0);
// No "Integration(en)" button
const integrationBtn = sidebar.getByRole("button", { name: /Integration(en)?/i });
await expect(integrationBtn).toHaveCount(0, { timeout: 5000 });
// No "Integration(en)" text anywhere in sidebar
const integrationText = sidebar.getByText(/Integration(en)?/i);
await expect(integrationText).toHaveCount(0, { timeout: 5000 });
await captureScreenshot(page, testInfo, "sidebar-nav-after");
});