gloomberb 0.2.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -19
- package/bin/gloomberb +3 -0
- package/package.json +5 -4
- package/patches/@opentui%2Fcore@0.1.90.patch +356 -0
- package/src/app.tsx +1365 -0
- package/src/brokers/sync-broker-instance.test.ts +100 -0
- package/src/brokers/sync-broker-instance.ts +341 -0
- package/src/cli/commands/plugins.ts +173 -0
- package/src/cli/commands/portfolio.ts +210 -0
- package/src/cli/commands/search.ts +120 -0
- package/src/cli/commands/ticker.ts +375 -0
- package/src/cli/commands/watchlist.ts +210 -0
- package/src/cli/context.ts +62 -0
- package/src/cli/errors.ts +13 -0
- package/src/cli/helpers.ts +85 -0
- package/src/cli/index.ts +143 -0
- package/src/cli/ticker-resolution.ts +39 -0
- package/src/cli/types.ts +15 -0
- package/src/cli.test.ts +361 -0
- package/src/components/chart/chart-data.ts +239 -0
- package/src/components/chart/chart-renderer.ts +1199 -0
- package/src/components/chart/chart-types.ts +82 -0
- package/src/components/chart/chart-viewport.ts +21 -0
- package/src/components/chart/chart.test.ts +439 -0
- package/src/components/chart/comparison-chart-data.test.ts +109 -0
- package/src/components/chart/comparison-chart-data.ts +316 -0
- package/src/components/chart/comparison-chart-renderer.test.ts +84 -0
- package/src/components/chart/comparison-chart-renderer.ts +354 -0
- package/src/components/chart/comparison-stock-chart.tsx +1486 -0
- package/src/components/chart/cursor-motion.ts +48 -0
- package/src/components/chart/native/chart-rasterizer.ts +732 -0
- package/src/components/chart/native/kitty-adapter.ts +12 -0
- package/src/components/chart/native/kitty-manager.ts +142 -0
- package/src/components/chart/native/kitty-protocol.ts +110 -0
- package/src/components/chart/native/kitty-support.ts +71 -0
- package/src/components/chart/native/kitty.test.ts +620 -0
- package/src/components/chart/native/renderer-selection.ts +24 -0
- package/src/components/chart/native/surface-manager.ts +225 -0
- package/src/components/chart/native/surface-sync.ts +34 -0
- package/src/components/chart/stock-chart-renderer-switch.test.tsx +165 -0
- package/src/components/chart/stock-chart.test.ts +107 -0
- package/src/components/chart/stock-chart.tsx +1556 -0
- package/src/components/command-bar/__snapshots__/command-bar.test.tsx.snap +137 -0
- package/src/components/command-bar/command-bar.test.tsx +1546 -0
- package/src/components/command-bar/command-bar.tsx +4841 -0
- package/src/components/command-bar/command-registry.ts +269 -0
- package/src/components/command-bar/helpers.test.ts +224 -0
- package/src/components/command-bar/helpers.ts +371 -0
- package/src/components/command-bar/root-shortcuts.ts +158 -0
- package/src/components/command-bar/view-model.test.ts +152 -0
- package/src/components/command-bar/view-model.ts +185 -0
- package/src/components/command-bar/workflow-ops.test.ts +70 -0
- package/src/components/command-bar/workflow-ops.ts +433 -0
- package/src/components/command-bar/workflow-types.ts +127 -0
- package/src/components/detail-feed-view.test.tsx +105 -0
- package/src/components/detail-feed-view.tsx +295 -0
- package/src/components/index.ts +32 -0
- package/src/components/layout/floating-pane.tsx +49 -0
- package/src/components/layout/header.tsx +151 -0
- package/src/components/layout/pane-header.tsx +44 -0
- package/src/components/layout/pane.tsx +49 -0
- package/src/components/layout/pixel-mouse-mode.test.ts +122 -0
- package/src/components/layout/pixel-mouse.test.ts +40 -0
- package/src/components/layout/shell.test.tsx +651 -0
- package/src/components/layout/shell.tsx +1200 -0
- package/src/components/layout/status-bar.test.tsx +173 -0
- package/src/components/layout/status-bar.tsx +138 -0
- package/src/components/markdown-editor.tsx +134 -0
- package/src/components/markdown-text.tsx +218 -0
- package/src/components/onboarding/onboarding-wizard.test.tsx +184 -0
- package/src/components/onboarding/onboarding-wizard.tsx +1365 -0
- package/src/components/pane-settings-dialog.tsx +468 -0
- package/src/components/pane-template-wizard.test.tsx +52 -0
- package/src/components/pane-template-wizard.tsx +199 -0
- package/src/components/price-selector-dialog.tsx +195 -0
- package/src/components/spinner.tsx +2 -0
- package/src/components/tab-bar.tsx +17 -0
- package/src/components/ticker-badge-text.test.tsx +160 -0
- package/src/components/ticker-badge-text.tsx +58 -0
- package/src/components/ticker-badge.tsx +88 -0
- package/src/components/ticker-list-table.tsx +188 -0
- package/src/components/toggle-list.tsx +74 -0
- package/src/components/ui/button.tsx +77 -0
- package/src/components/ui/data-table.tsx +210 -0
- package/src/components/ui/external-link.tsx +22 -0
- package/src/components/ui/fields.tsx +187 -0
- package/src/components/ui/frame.tsx +73 -0
- package/src/components/ui/index.ts +53 -0
- package/src/components/ui/list-view.tsx +166 -0
- package/src/components/ui/loading.tsx +70 -0
- package/src/components/ui/status.tsx +83 -0
- package/src/components/ui/tabs.tsx +47 -0
- package/src/components/ui/toggle.tsx +164 -0
- package/src/components/ui/ui.test.tsx +134 -0
- package/src/data/app-persistence.ts +25 -0
- package/src/data/config-store.test.ts +347 -0
- package/src/data/config-store.ts +507 -0
- package/src/data/plugin-state-store.ts +102 -0
- package/src/data/resource-store.ts +323 -0
- package/src/data/session-store.ts +52 -0
- package/src/data/sqlite-cache.test.ts +103 -0
- package/src/data/sqlite-database.ts +62 -0
- package/src/data/sqlite-json.ts +19 -0
- package/src/data/ticker-repository.ts +45 -0
- package/src/data/ticker-store.ts +46 -0
- package/src/index.tsx +67 -0
- package/src/market-data/coordinator.test.ts +369 -0
- package/src/market-data/coordinator.ts +580 -0
- package/src/market-data/hooks.tsx +234 -0
- package/src/market-data/query-store.ts +28 -0
- package/src/market-data/request-types.test.ts +64 -0
- package/src/market-data/request-types.ts +70 -0
- package/src/market-data/result-types.ts +56 -0
- package/src/market-data/selectors.ts +166 -0
- package/src/market-data/trace.ts +7 -0
- package/src/pane-settings.test.ts +55 -0
- package/src/pane-settings.ts +73 -0
- package/src/plugins/builtin/ai/ask-ai-detail-tab.tsx +350 -0
- package/src/plugins/builtin/ai/gloomberb-cli.ts +70 -0
- package/src/plugins/builtin/ai/index.test.tsx +139 -0
- package/src/plugins/builtin/ai/index.tsx +86 -0
- package/src/plugins/builtin/ai/providers.ts +99 -0
- package/src/plugins/builtin/ai/runner.ts +82 -0
- package/src/plugins/builtin/ai/screener-contract.test.ts +117 -0
- package/src/plugins/builtin/ai/screener-contract.ts +174 -0
- package/src/plugins/builtin/ai/screener-pane.test.tsx +365 -0
- package/src/plugins/builtin/ai/screener-pane.tsx +1161 -0
- package/src/plugins/builtin/ai/settings.ts +79 -0
- package/src/plugins/builtin/ai/ticker-context.ts +64 -0
- package/src/plugins/builtin/ai/utils.ts +71 -0
- package/src/plugins/builtin/ask-ai.test.tsx +258 -0
- package/src/plugins/builtin/ask-ai.tsx +9 -0
- package/src/plugins/builtin/chat-controller.test.ts +217 -0
- package/src/plugins/builtin/chat-controller.ts +340 -0
- package/src/plugins/builtin/chat.test.tsx +451 -0
- package/src/plugins/builtin/chat.tsx +620 -0
- package/src/plugins/builtin/comparison-chart.test.tsx +277 -0
- package/src/plugins/builtin/comparison-chart.tsx +169 -0
- package/src/plugins/builtin/data-providers.ts +16 -0
- package/src/plugins/builtin/debug.tsx +351 -0
- package/src/plugins/builtin/help.test.tsx +110 -0
- package/src/plugins/builtin/help.tsx +281 -0
- package/src/plugins/builtin/layout-manager.tsx +264 -0
- package/src/plugins/builtin/manual-entry.tsx +25 -0
- package/src/plugins/builtin/news.tsx +143 -0
- package/src/plugins/builtin/notes-files.ts +58 -0
- package/src/plugins/builtin/notes.tsx +396 -0
- package/src/plugins/builtin/options-availability.test.tsx +179 -0
- package/src/plugins/builtin/options-availability.ts +158 -0
- package/src/plugins/builtin/options.tsx +364 -0
- package/src/plugins/builtin/portfolio-list/header.tsx +227 -0
- package/src/plugins/builtin/portfolio-list/index.tsx +99 -0
- package/src/plugins/builtin/portfolio-list/metrics.ts +460 -0
- package/src/plugins/builtin/portfolio-list/pane.tsx +533 -0
- package/src/plugins/builtin/portfolio-list/settings.ts +270 -0
- package/src/plugins/builtin/portfolio-list/summary.tsx +270 -0
- package/src/plugins/builtin/portfolio-list/table.tsx +64 -0
- package/src/plugins/builtin/portfolio-list.test.ts +74 -0
- package/src/plugins/builtin/portfolio-list.test.tsx +1164 -0
- package/src/plugins/builtin/portfolio-metrics.test.ts +224 -0
- package/src/plugins/builtin/quote-monitor.test.tsx +114 -0
- package/src/plugins/builtin/sec.tsx +250 -0
- package/src/plugins/builtin/ticker-detail/chart-tab.tsx +43 -0
- package/src/plugins/builtin/ticker-detail/financials-tab.tsx +390 -0
- package/src/plugins/builtin/ticker-detail/index.tsx +80 -0
- package/src/plugins/builtin/ticker-detail/overview-tab.tsx +242 -0
- package/src/plugins/builtin/ticker-detail/pane.tsx +183 -0
- package/src/plugins/builtin/ticker-detail/quote-monitor.tsx +83 -0
- package/src/plugins/builtin/ticker-detail/settings.ts +132 -0
- package/src/plugins/builtin/ticker-detail-chart-tab-switch.test.tsx +193 -0
- package/src/plugins/builtin/ticker-detail.test.tsx +578 -0
- package/src/plugins/builtin/yahoo.ts +18 -0
- package/src/plugins/event-bus.ts +37 -0
- package/src/plugins/ibkr/__snapshots__/trade-tab.test.tsx.snap +35 -0
- package/src/plugins/ibkr/account-cache.test.ts +101 -0
- package/src/plugins/ibkr/account-cache.ts +137 -0
- package/src/plugins/ibkr/broker-adapter.ts +168 -0
- package/src/plugins/ibkr/config.test.ts +68 -0
- package/src/plugins/ibkr/config.ts +262 -0
- package/src/plugins/ibkr/dialogs.tsx +83 -0
- package/src/plugins/ibkr/flex.test.ts +107 -0
- package/src/plugins/ibkr/flex.ts +267 -0
- package/src/plugins/ibkr/fundamental-parser.ts +149 -0
- package/src/plugins/ibkr/gateway-helpers.ts +28 -0
- package/src/plugins/ibkr/gateway-selection.ts +51 -0
- package/src/plugins/ibkr/gateway-service.test.ts +450 -0
- package/src/plugins/ibkr/gateway-service.ts +2228 -0
- package/src/plugins/ibkr/index.test.tsx +183 -0
- package/src/plugins/ibkr/index.tsx +153 -0
- package/src/plugins/ibkr/instance-selection.test.ts +121 -0
- package/src/plugins/ibkr/instance-selection.ts +36 -0
- package/src/plugins/ibkr/price-normalization.test.ts +38 -0
- package/src/plugins/ibkr/price-normalization.ts +59 -0
- package/src/plugins/ibkr/trade-badge.tsx +27 -0
- package/src/plugins/ibkr/trade-tab.test.tsx +225 -0
- package/src/plugins/ibkr/trade-tab.tsx +1050 -0
- package/src/plugins/ibkr/trade-utils.test.ts +175 -0
- package/src/plugins/ibkr/trade-utils.ts +149 -0
- package/src/plugins/ibkr/trading-pane.tsx +438 -0
- package/src/plugins/ibkr/trading-state.test.ts +109 -0
- package/src/plugins/ibkr/trading-state.ts +339 -0
- package/src/plugins/loader.ts +71 -0
- package/src/plugins/pane-manager.test.ts +103 -0
- package/src/plugins/pane-manager.ts +974 -0
- package/src/plugins/plugin-persistence.ts +85 -0
- package/src/plugins/plugin-runtime.test.tsx +185 -0
- package/src/plugins/plugin-runtime.tsx +175 -0
- package/src/plugins/prediction-markets/cache.ts +114 -0
- package/src/plugins/prediction-markets/categories.ts +223 -0
- package/src/plugins/prediction-markets/chart.tsx +512 -0
- package/src/plugins/prediction-markets/columns.ts +133 -0
- package/src/plugins/prediction-markets/controller-data.ts +614 -0
- package/src/plugins/prediction-markets/controller.ts +725 -0
- package/src/plugins/prediction-markets/detail/book.tsx +118 -0
- package/src/plugins/prediction-markets/detail/outcomes.tsx +102 -0
- package/src/plugins/prediction-markets/detail/overview.tsx +73 -0
- package/src/plugins/prediction-markets/detail/pane.tsx +308 -0
- package/src/plugins/prediction-markets/detail/rules.tsx +16 -0
- package/src/plugins/prediction-markets/detail/shared.tsx +29 -0
- package/src/plugins/prediction-markets/detail/trades.tsx +30 -0
- package/src/plugins/prediction-markets/detail.test.tsx +47 -0
- package/src/plugins/prediction-markets/index.tsx +102 -0
- package/src/plugins/prediction-markets/keyboard.ts +64 -0
- package/src/plugins/prediction-markets/launch.test.ts +126 -0
- package/src/plugins/prediction-markets/launch.ts +240 -0
- package/src/plugins/prediction-markets/metrics.ts +311 -0
- package/src/plugins/prediction-markets/navigation.ts +90 -0
- package/src/plugins/prediction-markets/outcome-order.ts +19 -0
- package/src/plugins/prediction-markets/pane.test.tsx +425 -0
- package/src/plugins/prediction-markets/pane.tsx +294 -0
- package/src/plugins/prediction-markets/plugin.test.tsx +570 -0
- package/src/plugins/prediction-markets/rows.ts +229 -0
- package/src/plugins/prediction-markets/services/fetch.ts +97 -0
- package/src/plugins/prediction-markets/services/kalshi-adapter.ts +555 -0
- package/src/plugins/prediction-markets/services/polymarket-adapter.ts +660 -0
- package/src/plugins/prediction-markets/services/polymarket-ws.ts +108 -0
- package/src/plugins/prediction-markets/settings.ts +164 -0
- package/src/plugins/prediction-markets/status.ts +24 -0
- package/src/plugins/prediction-markets/table.tsx +84 -0
- package/src/plugins/prediction-markets/test-helpers.tsx +636 -0
- package/src/plugins/prediction-markets/types.ts +186 -0
- package/src/plugins/registry.ts +633 -0
- package/src/sources/exchange-rates.ts +18 -0
- package/src/sources/gloomberb-cloud.test.ts +199 -0
- package/src/sources/gloomberb-cloud.ts +326 -0
- package/src/sources/provider-errors.ts +19 -0
- package/src/sources/provider-router.test.ts +1476 -0
- package/src/sources/provider-router.ts +1405 -0
- package/src/sources/sec-edgar.test.ts +286 -0
- package/src/sources/sec-edgar.ts +526 -0
- package/src/sources/yahoo-finance.test.ts +14 -0
- package/src/sources/yahoo-finance.ts +1017 -0
- package/src/state/app-activity.test.ts +41 -0
- package/src/state/app-activity.ts +106 -0
- package/src/state/app-bootstrap.test.ts +471 -0
- package/src/state/app-bootstrap.ts +308 -0
- package/src/state/app-context.test.ts +406 -0
- package/src/state/app-context.test.tsx +162 -0
- package/src/state/app-context.tsx +981 -0
- package/src/state/selectors.ts +67 -0
- package/src/state/session-persistence.test.ts +128 -0
- package/src/state/session-persistence.ts +161 -0
- package/src/state/ticker-refresh-queue.test.ts +46 -0
- package/src/state/ticker-refresh-queue.ts +40 -0
- package/src/state/use-inline-tickers.ts +174 -0
- package/src/state/use-quote-streaming.test.ts +37 -0
- package/src/state/use-quote-streaming.test.tsx +70 -0
- package/src/state/use-quote-streaming.ts +80 -0
- package/src/state/use-session-snapshot.ts +84 -0
- package/src/test-support/data-provider.ts +22 -0
- package/src/theme/color-utils.ts +67 -0
- package/src/theme/colors.ts +128 -0
- package/src/theme/themes.test.ts +45 -0
- package/src/theme/themes.ts +491 -0
- package/src/types/broker.ts +105 -0
- package/src/types/config.ts +444 -0
- package/src/types/data-provider.ts +81 -0
- package/src/types/financials.ts +142 -0
- package/src/types/instrument.ts +29 -0
- package/src/types/persistence.ts +21 -0
- package/src/types/plugin.ts +354 -0
- package/src/types/ticker.ts +58 -0
- package/src/types/trading.ts +85 -0
- package/src/updater.test.ts +282 -0
- package/src/updater.ts +303 -0
- package/src/utils/api-client.ts +666 -0
- package/src/utils/ascii-chart.ts +172 -0
- package/src/utils/broker-instances.ts +47 -0
- package/src/utils/cli-output.ts +83 -0
- package/src/utils/currency-units.test.ts +49 -0
- package/src/utils/currency-units.ts +82 -0
- package/src/utils/debug-log.ts +133 -0
- package/src/utils/exchange-rate-map.ts +8 -0
- package/src/utils/format.ts +158 -0
- package/src/utils/fuzzy-search.ts +34 -0
- package/src/utils/market-status.ts +95 -0
- package/src/utils/options.ts +86 -0
- package/src/utils/price-history.ts +39 -0
- package/src/utils/quote-time.test.ts +22 -0
- package/src/utils/quote-time.ts +50 -0
- package/src/utils/sec.test.ts +55 -0
- package/src/utils/sec.ts +45 -0
- package/src/utils/ticker-list.test.ts +22 -0
- package/src/utils/ticker-list.ts +35 -0
- package/src/utils/ticker-metadata.ts +51 -0
- package/src/utils/ticker-search.test.ts +227 -0
- package/src/utils/ticker-search.ts +764 -0
- package/src/utils/ticker-tokenizer.test.ts +48 -0
- package/src/utils/ticker-tokenizer.ts +72 -0
- package/src/version.ts +1 -0
- package/install.mjs +0 -68
|
@@ -0,0 +1,651 @@
|
|
|
1
|
+
import { afterEach, describe, expect, test } from "bun:test";
|
|
2
|
+
import { testRender } from "@opentui/react/test-utils";
|
|
3
|
+
import { DialogProvider } from "@opentui-ui/dialog/react";
|
|
4
|
+
import { act, useReducer } from "react";
|
|
5
|
+
import { AppContext, appReducer, createInitialState } from "../../state/app-context";
|
|
6
|
+
import { cloneLayout, createDefaultConfig } from "../../types/config";
|
|
7
|
+
import type { PluginRegistry } from "../../plugins/registry";
|
|
8
|
+
import { setSharedRegistryForTests } from "../../plugins/registry";
|
|
9
|
+
import { portfolioListPlugin } from "../../plugins/builtin/portfolio-list";
|
|
10
|
+
import { StatusBar } from "./status-bar";
|
|
11
|
+
import { Header } from "./header";
|
|
12
|
+
import { buildNativeWindowState, finalizePaneDragRelease, resolveNativeDockDividers, Shell } from "./shell";
|
|
13
|
+
import type { DataProvider } from "../../types/data-provider";
|
|
14
|
+
import type { Quote } from "../../types/financials";
|
|
15
|
+
import type { TickerRecord } from "../../types/ticker";
|
|
16
|
+
|
|
17
|
+
let testSetup: Awaited<ReturnType<typeof testRender>> | undefined;
|
|
18
|
+
let harnessState: ReturnType<typeof createInitialState> | null = null;
|
|
19
|
+
|
|
20
|
+
afterEach(() => {
|
|
21
|
+
if (testSetup) {
|
|
22
|
+
testSetup.renderer.destroy();
|
|
23
|
+
testSetup = undefined;
|
|
24
|
+
}
|
|
25
|
+
harnessState = null;
|
|
26
|
+
setSharedRegistryForTests(undefined);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
function createShellPluginRegistry(): PluginRegistry {
|
|
30
|
+
return {
|
|
31
|
+
panes: new Map([
|
|
32
|
+
["portfolio-list", {
|
|
33
|
+
id: "portfolio-list",
|
|
34
|
+
name: "Portfolio List",
|
|
35
|
+
component: () => <text>Portfolio Body</text>,
|
|
36
|
+
defaultPosition: "left",
|
|
37
|
+
}],
|
|
38
|
+
["ticker-detail", {
|
|
39
|
+
id: "ticker-detail",
|
|
40
|
+
name: "Ticker Detail",
|
|
41
|
+
component: () => <text>Ticker Detail Body</text>,
|
|
42
|
+
defaultPosition: "right",
|
|
43
|
+
defaultMode: "floating",
|
|
44
|
+
}],
|
|
45
|
+
]),
|
|
46
|
+
paneTemplates: new Map(),
|
|
47
|
+
commands: new Map(),
|
|
48
|
+
tickerActions: new Map(),
|
|
49
|
+
brokers: new Map(),
|
|
50
|
+
allPlugins: new Map(),
|
|
51
|
+
getPluginPaneIds: () => [],
|
|
52
|
+
getPluginPaneTemplateIds: () => [],
|
|
53
|
+
hasPaneSettings: (paneId: string) => paneId === "portfolio-list:main",
|
|
54
|
+
openPaneSettingsFn: () => {},
|
|
55
|
+
openCommandBarFn: () => {},
|
|
56
|
+
updateLayoutFn: () => {},
|
|
57
|
+
hideWidget: () => {},
|
|
58
|
+
} as unknown as PluginRegistry;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function createBrokerPortfolioRegistry(): PluginRegistry {
|
|
62
|
+
const pane = portfolioListPlugin.panes?.[0];
|
|
63
|
+
if (!pane) throw new Error("missing portfolio pane");
|
|
64
|
+
return {
|
|
65
|
+
panes: new Map([["portfolio-list", pane]]),
|
|
66
|
+
paneTemplates: new Map(),
|
|
67
|
+
commands: new Map(),
|
|
68
|
+
tickerActions: new Map(),
|
|
69
|
+
brokers: new Map(),
|
|
70
|
+
allPlugins: new Map([["portfolio-list", portfolioListPlugin]]),
|
|
71
|
+
getPluginPaneIds: () => [],
|
|
72
|
+
getPluginPaneTemplateIds: () => [],
|
|
73
|
+
hasPaneSettings: () => true,
|
|
74
|
+
openPaneSettingsFn: () => {},
|
|
75
|
+
openCommandBarFn: () => {},
|
|
76
|
+
updateLayoutFn: () => {},
|
|
77
|
+
hideWidget: () => {},
|
|
78
|
+
focusPaneFn: () => {},
|
|
79
|
+
pinTickerFn: () => {},
|
|
80
|
+
showPaneFn: () => {},
|
|
81
|
+
getLayoutFn: () => ({ dockRoot: null, instances: [], floating: [] }),
|
|
82
|
+
getTermSizeFn: () => ({ width: 120, height: 40 }),
|
|
83
|
+
Slot: () => null,
|
|
84
|
+
} as unknown as PluginRegistry;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function makeQuote(overrides: Partial<Quote> = {}): Quote {
|
|
88
|
+
return {
|
|
89
|
+
symbol: "AAPL",
|
|
90
|
+
price: 125,
|
|
91
|
+
bid: 124.95,
|
|
92
|
+
ask: 125.05,
|
|
93
|
+
bidSize: 100,
|
|
94
|
+
askSize: 200,
|
|
95
|
+
currency: "USD",
|
|
96
|
+
change: 5,
|
|
97
|
+
changePercent: 4.17,
|
|
98
|
+
previousClose: 120,
|
|
99
|
+
name: "Apple",
|
|
100
|
+
lastUpdated: Date.now(),
|
|
101
|
+
marketState: "REGULAR",
|
|
102
|
+
...overrides,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function makeTicker(overrides: Partial<TickerRecord["metadata"]> = {}): TickerRecord {
|
|
107
|
+
return {
|
|
108
|
+
metadata: {
|
|
109
|
+
ticker: "AAPL",
|
|
110
|
+
exchange: "NASDAQ",
|
|
111
|
+
currency: "USD",
|
|
112
|
+
name: "Apple",
|
|
113
|
+
portfolios: ["broker:ibkr-flex:DU12345"],
|
|
114
|
+
watchlists: [],
|
|
115
|
+
positions: [
|
|
116
|
+
{
|
|
117
|
+
portfolio: "broker:ibkr-flex:DU12345",
|
|
118
|
+
shares: 10,
|
|
119
|
+
avgCost: 100,
|
|
120
|
+
currency: "USD",
|
|
121
|
+
broker: "ibkr",
|
|
122
|
+
brokerInstanceId: "ibkr-flex",
|
|
123
|
+
brokerAccountId: "DU12345",
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
custom: {},
|
|
127
|
+
tags: [],
|
|
128
|
+
...overrides,
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function createHeaderDataProvider(): DataProvider {
|
|
134
|
+
return {
|
|
135
|
+
id: "test",
|
|
136
|
+
name: "Test",
|
|
137
|
+
async getTickerFinancials() {
|
|
138
|
+
return { annualStatements: [], quarterlyStatements: [], priceHistory: [], quote: makeQuote({ symbol: "SPY", name: "SPY" }) };
|
|
139
|
+
},
|
|
140
|
+
async getQuote() {
|
|
141
|
+
return makeQuote({ symbol: "SPY", name: "SPY" });
|
|
142
|
+
},
|
|
143
|
+
async getExchangeRate() {
|
|
144
|
+
return 1;
|
|
145
|
+
},
|
|
146
|
+
async search() {
|
|
147
|
+
return [];
|
|
148
|
+
},
|
|
149
|
+
async getNews() {
|
|
150
|
+
return [];
|
|
151
|
+
},
|
|
152
|
+
async getArticleSummary() {
|
|
153
|
+
return null;
|
|
154
|
+
},
|
|
155
|
+
async getPriceHistory() {
|
|
156
|
+
return [];
|
|
157
|
+
},
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
function HeaderHarness({
|
|
162
|
+
updateAvailable = null,
|
|
163
|
+
updateCheckInProgress = false,
|
|
164
|
+
updateNotice = null,
|
|
165
|
+
}: {
|
|
166
|
+
updateAvailable?: ReturnType<typeof createInitialState>["updateAvailable"];
|
|
167
|
+
updateCheckInProgress?: boolean;
|
|
168
|
+
updateNotice?: string | null;
|
|
169
|
+
}) {
|
|
170
|
+
const initialState = createInitialState(createDefaultConfig("/tmp/gloomberb-header-test"));
|
|
171
|
+
initialState.updateAvailable = updateAvailable;
|
|
172
|
+
initialState.updateCheckInProgress = updateCheckInProgress;
|
|
173
|
+
initialState.updateNotice = updateNotice;
|
|
174
|
+
const [state, dispatch] = useReducer(appReducer, initialState);
|
|
175
|
+
|
|
176
|
+
return (
|
|
177
|
+
<AppContext value={{ state, dispatch }}>
|
|
178
|
+
<Header />
|
|
179
|
+
</AppContext>
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function BrokerShellHarness({ pluginRegistry }: { pluginRegistry: PluginRegistry }) {
|
|
184
|
+
const config = createDefaultConfig("/tmp/gloomberb-shell-broker-test");
|
|
185
|
+
const portfolioId = "broker:ibkr-flex:DU12345";
|
|
186
|
+
const layout = {
|
|
187
|
+
dockRoot: { kind: "pane" as const, instanceId: "portfolio-list:main" },
|
|
188
|
+
instances: [{
|
|
189
|
+
instanceId: "portfolio-list:main",
|
|
190
|
+
paneId: "portfolio-list",
|
|
191
|
+
binding: { kind: "none" as const },
|
|
192
|
+
params: { collectionId: portfolioId },
|
|
193
|
+
}],
|
|
194
|
+
floating: [],
|
|
195
|
+
};
|
|
196
|
+
const initialState = createInitialState({
|
|
197
|
+
...config,
|
|
198
|
+
brokerInstances: [{
|
|
199
|
+
id: "ibkr-flex",
|
|
200
|
+
brokerType: "ibkr",
|
|
201
|
+
label: "Flex",
|
|
202
|
+
connectionMode: "flex",
|
|
203
|
+
config: { connectionMode: "flex", flex: { token: "token", queryId: "query" } },
|
|
204
|
+
enabled: true,
|
|
205
|
+
}],
|
|
206
|
+
portfolios: [
|
|
207
|
+
...config.portfolios,
|
|
208
|
+
{
|
|
209
|
+
id: portfolioId,
|
|
210
|
+
name: "Flex DU12345",
|
|
211
|
+
currency: "USD",
|
|
212
|
+
brokerId: "ibkr",
|
|
213
|
+
brokerInstanceId: "ibkr-flex",
|
|
214
|
+
brokerAccountId: "DU12345",
|
|
215
|
+
},
|
|
216
|
+
],
|
|
217
|
+
layout,
|
|
218
|
+
layouts: [{ name: "Default", layout: cloneLayout(layout) }],
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
initialState.gridlockTipVisible = true;
|
|
222
|
+
initialState.focusedPaneId = "portfolio-list:main";
|
|
223
|
+
initialState.paneState["portfolio-list:main"] = {
|
|
224
|
+
collectionId: portfolioId,
|
|
225
|
+
cursorSymbol: "AAPL",
|
|
226
|
+
cashDrawerExpanded: false,
|
|
227
|
+
};
|
|
228
|
+
initialState.brokerAccounts = {
|
|
229
|
+
"ibkr-flex": [{
|
|
230
|
+
accountId: "DU12345",
|
|
231
|
+
name: "DU12345",
|
|
232
|
+
currency: "USD",
|
|
233
|
+
source: "flex",
|
|
234
|
+
updatedAt: new Date(2026, 2, 27).getTime(),
|
|
235
|
+
totalCashValue: -50000,
|
|
236
|
+
settledCash: -45000,
|
|
237
|
+
netLiquidation: 125000,
|
|
238
|
+
cashBalances: [
|
|
239
|
+
{ currency: "USD", quantity: -50000, baseValue: -50000, baseCurrency: "USD" },
|
|
240
|
+
],
|
|
241
|
+
}],
|
|
242
|
+
};
|
|
243
|
+
initialState.tickers = new Map([["AAPL", makeTicker()]]);
|
|
244
|
+
initialState.financials = new Map([["AAPL", { annualStatements: [], quarterlyStatements: [], priceHistory: [], quote: makeQuote() }]]);
|
|
245
|
+
|
|
246
|
+
const [state, dispatch] = useReducer(appReducer, initialState);
|
|
247
|
+
harnessState = state;
|
|
248
|
+
|
|
249
|
+
return (
|
|
250
|
+
<AppContext value={{ state, dispatch }}>
|
|
251
|
+
<box flexDirection="column">
|
|
252
|
+
<Header dataProvider={createHeaderDataProvider()} />
|
|
253
|
+
<Shell pluginRegistry={pluginRegistry} />
|
|
254
|
+
<StatusBar />
|
|
255
|
+
</box>
|
|
256
|
+
</AppContext>
|
|
257
|
+
);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
describe("Header", () => {
|
|
261
|
+
test("shows the self-update shortcut for standalone binaries", async () => {
|
|
262
|
+
testSetup = await testRender(
|
|
263
|
+
<HeaderHarness updateAvailable={{
|
|
264
|
+
version: "0.3.0",
|
|
265
|
+
tagName: "v0.3.0",
|
|
266
|
+
downloadUrl: "https://example.com/gloomberb",
|
|
267
|
+
publishedAt: "2026-04-01T00:00:00.000Z",
|
|
268
|
+
updateAction: { kind: "self" },
|
|
269
|
+
}} />,
|
|
270
|
+
{ width: 120, height: 2 },
|
|
271
|
+
);
|
|
272
|
+
|
|
273
|
+
await testSetup.renderOnce();
|
|
274
|
+
const frame = testSetup.captureCharFrame();
|
|
275
|
+
|
|
276
|
+
expect(frame).toContain("v0.3.0 available");
|
|
277
|
+
expect(frame).toContain("press u to update");
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
test("shows the manual npm command when self-update is disabled", async () => {
|
|
281
|
+
testSetup = await testRender(
|
|
282
|
+
<HeaderHarness updateAvailable={{
|
|
283
|
+
version: "0.3.0",
|
|
284
|
+
tagName: "v0.3.0",
|
|
285
|
+
downloadUrl: "https://example.com/gloomberb",
|
|
286
|
+
publishedAt: "2026-04-01T00:00:00.000Z",
|
|
287
|
+
updateAction: { kind: "manual", command: "npm install -g gloomberb@latest" },
|
|
288
|
+
}} />,
|
|
289
|
+
{ width: 120, height: 2 },
|
|
290
|
+
);
|
|
291
|
+
|
|
292
|
+
await testSetup.renderOnce();
|
|
293
|
+
const frame = testSetup.captureCharFrame();
|
|
294
|
+
|
|
295
|
+
expect(frame).toContain("v0.3.0 available");
|
|
296
|
+
expect(frame).toContain("run npm install -g gloomberb@latest");
|
|
297
|
+
expect(frame).not.toContain("press u to update");
|
|
298
|
+
});
|
|
299
|
+
|
|
300
|
+
test("shows update check progress and notices", async () => {
|
|
301
|
+
testSetup = await testRender(
|
|
302
|
+
<HeaderHarness updateCheckInProgress />,
|
|
303
|
+
{ width: 120, height: 2 },
|
|
304
|
+
);
|
|
305
|
+
|
|
306
|
+
await testSetup.renderOnce();
|
|
307
|
+
expect(testSetup.captureCharFrame()).toContain("Checking for updates...");
|
|
308
|
+
|
|
309
|
+
testSetup.renderer.destroy();
|
|
310
|
+
|
|
311
|
+
testSetup = await testRender(
|
|
312
|
+
<HeaderHarness updateNotice="Already on v0.3.1" />,
|
|
313
|
+
{ width: 120, height: 2 },
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
await testSetup.renderOnce();
|
|
317
|
+
expect(testSetup.captureCharFrame()).toContain("Already on v0.3.1");
|
|
318
|
+
});
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
describe("Shell", () => {
|
|
322
|
+
test("uses the live floating preview rect for native occluders", () => {
|
|
323
|
+
const state = buildNativeWindowState(
|
|
324
|
+
["portfolio-list:main"],
|
|
325
|
+
[
|
|
326
|
+
{
|
|
327
|
+
paneId: "ticker-detail:main",
|
|
328
|
+
rect: { x: 8, y: 2, width: 36, height: 12 },
|
|
329
|
+
zIndex: 75,
|
|
330
|
+
},
|
|
331
|
+
],
|
|
332
|
+
{
|
|
333
|
+
paneId: "ticker-detail:main",
|
|
334
|
+
rect: { x: 20, y: 6, width: 36, height: 12 },
|
|
335
|
+
},
|
|
336
|
+
{ open: false, width: 120, contentHeight: 40 },
|
|
337
|
+
);
|
|
338
|
+
|
|
339
|
+
expect(state.paneLayers).toEqual([
|
|
340
|
+
{ paneId: "portfolio-list:main", zIndex: 0 },
|
|
341
|
+
{ paneId: "ticker-detail:main", zIndex: 75 },
|
|
342
|
+
]);
|
|
343
|
+
expect(state.occluders).toEqual([
|
|
344
|
+
{
|
|
345
|
+
id: "ticker-detail:main",
|
|
346
|
+
paneId: "ticker-detail:main",
|
|
347
|
+
rect: { x: 20, y: 7, width: 36, height: 12 },
|
|
348
|
+
zIndex: 75,
|
|
349
|
+
},
|
|
350
|
+
]);
|
|
351
|
+
});
|
|
352
|
+
|
|
353
|
+
test("ignores docked drag previews when building native occluders", () => {
|
|
354
|
+
const state = buildNativeWindowState(
|
|
355
|
+
["portfolio-list:main"],
|
|
356
|
+
[
|
|
357
|
+
{
|
|
358
|
+
paneId: "ticker-detail:main",
|
|
359
|
+
rect: { x: 8, y: 2, width: 36, height: 12 },
|
|
360
|
+
zIndex: 75,
|
|
361
|
+
},
|
|
362
|
+
],
|
|
363
|
+
{
|
|
364
|
+
paneId: "portfolio-list:secondary",
|
|
365
|
+
rect: { x: 20, y: 6, width: 36, height: 12 },
|
|
366
|
+
},
|
|
367
|
+
{ open: false, width: 120, contentHeight: 40 },
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
expect(state.occluders).toEqual([
|
|
371
|
+
{
|
|
372
|
+
id: "ticker-detail:main",
|
|
373
|
+
paneId: "ticker-detail:main",
|
|
374
|
+
rect: { x: 8, y: 3, width: 36, height: 12 },
|
|
375
|
+
zIndex: 75,
|
|
376
|
+
},
|
|
377
|
+
]);
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
test("adds transient drag overlays as global native occluders", () => {
|
|
381
|
+
const state = buildNativeWindowState(
|
|
382
|
+
["portfolio-list:main"],
|
|
383
|
+
[],
|
|
384
|
+
null,
|
|
385
|
+
{ open: false, width: 120, contentHeight: 40 },
|
|
386
|
+
[
|
|
387
|
+
{
|
|
388
|
+
id: "dock-preview:snap",
|
|
389
|
+
rect: { x: 0, y: 0, width: 60, height: 20 },
|
|
390
|
+
zIndex: 96,
|
|
391
|
+
},
|
|
392
|
+
],
|
|
393
|
+
);
|
|
394
|
+
|
|
395
|
+
expect(state.occluders).toEqual([
|
|
396
|
+
{
|
|
397
|
+
id: "dock-preview:snap",
|
|
398
|
+
paneId: null,
|
|
399
|
+
rect: { x: 0, y: 1, width: 60, height: 20 },
|
|
400
|
+
zIndex: 96,
|
|
401
|
+
},
|
|
402
|
+
]);
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
test("adds dock dividers as global native occluders", () => {
|
|
406
|
+
const state = buildNativeWindowState(
|
|
407
|
+
["left:main", "right:main"],
|
|
408
|
+
[],
|
|
409
|
+
null,
|
|
410
|
+
{ open: false, width: 120, contentHeight: 40 },
|
|
411
|
+
[],
|
|
412
|
+
[{
|
|
413
|
+
path: [],
|
|
414
|
+
axis: "horizontal",
|
|
415
|
+
bounds: { x: 0, y: 0, width: 120, height: 40 },
|
|
416
|
+
ratio: 0.5,
|
|
417
|
+
rect: { x: 59, y: 0, width: 1, height: 40 },
|
|
418
|
+
}],
|
|
419
|
+
);
|
|
420
|
+
|
|
421
|
+
expect(state.occluders).toEqual([
|
|
422
|
+
{
|
|
423
|
+
id: "dock-divider:root",
|
|
424
|
+
paneId: null,
|
|
425
|
+
rect: { x: 59, y: 1, width: 1, height: 40 },
|
|
426
|
+
zIndex: 1,
|
|
427
|
+
},
|
|
428
|
+
]);
|
|
429
|
+
});
|
|
430
|
+
|
|
431
|
+
test("uses the live divider preview rect for dock divider occluders", () => {
|
|
432
|
+
const state = buildNativeWindowState(
|
|
433
|
+
["left:main", "right:main"],
|
|
434
|
+
[],
|
|
435
|
+
null,
|
|
436
|
+
{ open: false, width: 120, contentHeight: 40 },
|
|
437
|
+
[],
|
|
438
|
+
resolveNativeDockDividers(
|
|
439
|
+
[{
|
|
440
|
+
path: [],
|
|
441
|
+
axis: "horizontal",
|
|
442
|
+
bounds: { x: 0, y: 0, width: 120, height: 40 },
|
|
443
|
+
ratio: 0.5,
|
|
444
|
+
rect: { x: 59, y: 0, width: 1, height: 40 },
|
|
445
|
+
}],
|
|
446
|
+
{
|
|
447
|
+
pathKey: "",
|
|
448
|
+
rect: { x: 71, y: 0, width: 1, height: 40 },
|
|
449
|
+
ratio: 0.6,
|
|
450
|
+
},
|
|
451
|
+
),
|
|
452
|
+
);
|
|
453
|
+
|
|
454
|
+
expect(state.occluders).toEqual([
|
|
455
|
+
{
|
|
456
|
+
id: "dock-divider:root",
|
|
457
|
+
paneId: null,
|
|
458
|
+
rect: { x: 71, y: 1, width: 1, height: 40 },
|
|
459
|
+
zIndex: 1,
|
|
460
|
+
},
|
|
461
|
+
]);
|
|
462
|
+
});
|
|
463
|
+
|
|
464
|
+
test("opens the pane menu when clicking the docked header action area", async () => {
|
|
465
|
+
const config = createDefaultConfig("/tmp/gloomberb-shell-test");
|
|
466
|
+
const mainPane = config.layout.instances.find((instance) => instance.instanceId === "portfolio-list:main");
|
|
467
|
+
if (!mainPane) throw new Error("missing default portfolio pane");
|
|
468
|
+
|
|
469
|
+
const singlePaneLayout = {
|
|
470
|
+
dockRoot: { kind: "pane" as const, instanceId: "portfolio-list:main" },
|
|
471
|
+
instances: [{ ...mainPane }],
|
|
472
|
+
floating: [],
|
|
473
|
+
};
|
|
474
|
+
const nextConfig = {
|
|
475
|
+
...config,
|
|
476
|
+
layout: cloneLayout(singlePaneLayout),
|
|
477
|
+
layouts: [{ name: "Default", layout: cloneLayout(singlePaneLayout) }],
|
|
478
|
+
};
|
|
479
|
+
const state = createInitialState(nextConfig);
|
|
480
|
+
const pluginRegistry = createShellPluginRegistry();
|
|
481
|
+
|
|
482
|
+
testSetup = await testRender(
|
|
483
|
+
<AppContext value={{ state, dispatch: () => {} }}>
|
|
484
|
+
<DialogProvider dialogOptions={{ style: { backgroundColor: "#000000", borderColor: "#ffffff", borderStyle: "single" } }}>
|
|
485
|
+
<Shell pluginRegistry={pluginRegistry} />
|
|
486
|
+
</DialogProvider>
|
|
487
|
+
</AppContext>,
|
|
488
|
+
{ width: 40, height: 10 },
|
|
489
|
+
);
|
|
490
|
+
|
|
491
|
+
await testSetup.renderOnce();
|
|
492
|
+
await act(async () => {
|
|
493
|
+
await testSetup!.mockMouse.click(37, 1);
|
|
494
|
+
});
|
|
495
|
+
await testSetup.renderOnce();
|
|
496
|
+
|
|
497
|
+
expect(testSetup.captureCharFrame()).toContain("Settings");
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
test("keeps the cash drawer and gridlock tip on distinct click rows in the full app layout", async () => {
|
|
501
|
+
const pluginRegistry = createBrokerPortfolioRegistry();
|
|
502
|
+
const layoutUpdates: unknown[] = [];
|
|
503
|
+
const toasts: string[] = [];
|
|
504
|
+
pluginRegistry.getLayoutFn = () => harnessState?.config.layout ?? { dockRoot: null, instances: [], floating: [] };
|
|
505
|
+
pluginRegistry.updateLayoutFn = (layout) => { layoutUpdates.push(layout); };
|
|
506
|
+
pluginRegistry.showToastFn = (message: string) => { toasts.push(message); };
|
|
507
|
+
setSharedRegistryForTests(pluginRegistry);
|
|
508
|
+
|
|
509
|
+
testSetup = await testRender(
|
|
510
|
+
<DialogProvider dialogOptions={{ style: { backgroundColor: "#000000", borderColor: "#ffffff", borderStyle: "single" } }}>
|
|
511
|
+
<BrokerShellHarness pluginRegistry={pluginRegistry} />
|
|
512
|
+
</DialogProvider>,
|
|
513
|
+
{ width: 100, height: 24 },
|
|
514
|
+
);
|
|
515
|
+
|
|
516
|
+
await act(async () => {
|
|
517
|
+
await testSetup!.renderOnce();
|
|
518
|
+
await testSetup!.renderOnce();
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
const lines = testSetup.captureCharFrame().split("\n");
|
|
522
|
+
const cashRow = lines.findIndex((line) => line.includes("Cash & Margin"));
|
|
523
|
+
const cashCol = lines[cashRow]?.indexOf("Cash & Margin") ?? -1;
|
|
524
|
+
const gridlockRow = lines.findIndex((line) => line.includes("Gridlock All"));
|
|
525
|
+
const gridlockCol = lines[gridlockRow]?.indexOf("Gridlock All") ?? -1;
|
|
526
|
+
|
|
527
|
+
expect(cashRow).toBeGreaterThanOrEqual(0);
|
|
528
|
+
expect(cashCol).toBeGreaterThanOrEqual(0);
|
|
529
|
+
expect(gridlockRow).toBeGreaterThanOrEqual(0);
|
|
530
|
+
expect(gridlockCol).toBeGreaterThanOrEqual(0);
|
|
531
|
+
expect(gridlockRow).toBeGreaterThan(cashRow);
|
|
532
|
+
|
|
533
|
+
await act(async () => {
|
|
534
|
+
await testSetup!.mockMouse.click(gridlockCol + 1, gridlockRow);
|
|
535
|
+
await testSetup!.renderOnce();
|
|
536
|
+
await testSetup!.renderOnce();
|
|
537
|
+
});
|
|
538
|
+
|
|
539
|
+
expect(harnessState?.paneState["portfolio-list:main"]?.cashDrawerExpanded).toBe(false);
|
|
540
|
+
expect(layoutUpdates.length).toBe(1);
|
|
541
|
+
expect(toasts).toEqual(["Retiled all panes"]);
|
|
542
|
+
});
|
|
543
|
+
|
|
544
|
+
test("shows the gridlock tip after snapping a pane to a half screen", () => {
|
|
545
|
+
const config = createDefaultConfig("/tmp/gloomberb-shell-snap-test");
|
|
546
|
+
const snapLayout = cloneLayout(config.layout);
|
|
547
|
+
snapLayout.dockRoot = { kind: "pane", instanceId: "portfolio-list:main" };
|
|
548
|
+
snapLayout.floating = [{ instanceId: "ticker-detail:main", x: 8, y: 2, width: 36, height: 12, zIndex: 75 }];
|
|
549
|
+
|
|
550
|
+
const result = finalizePaneDragRelease(
|
|
551
|
+
snapLayout,
|
|
552
|
+
"ticker-detail:main",
|
|
553
|
+
{ x: 8, y: 2, width: 36, height: 12 },
|
|
554
|
+
{ kind: "snap", position: "left", rect: { x: 0, y: 0, width: 50, height: 22 } },
|
|
555
|
+
);
|
|
556
|
+
|
|
557
|
+
expect(result.shouldShowGridlockTip).toBe(true);
|
|
558
|
+
expect(result.nextLayout.floating[0]).toEqual(expect.objectContaining({
|
|
559
|
+
instanceId: "ticker-detail:main",
|
|
560
|
+
x: 0,
|
|
561
|
+
y: 0,
|
|
562
|
+
width: 50,
|
|
563
|
+
height: 22,
|
|
564
|
+
}));
|
|
565
|
+
});
|
|
566
|
+
|
|
567
|
+
test("closes the focused docked pane with Ctrl+W", async () => {
|
|
568
|
+
const config = createDefaultConfig("/tmp/gloomberb-shell-test");
|
|
569
|
+
const mainPane = config.layout.instances.find((instance) => instance.instanceId === "portfolio-list:main");
|
|
570
|
+
if (!mainPane) throw new Error("missing default portfolio pane");
|
|
571
|
+
|
|
572
|
+
const singlePaneLayout = {
|
|
573
|
+
dockRoot: { kind: "pane" as const, instanceId: "portfolio-list:main" },
|
|
574
|
+
instances: [{ ...mainPane }],
|
|
575
|
+
floating: [],
|
|
576
|
+
};
|
|
577
|
+
const state = {
|
|
578
|
+
...createInitialState({
|
|
579
|
+
...config,
|
|
580
|
+
layout: cloneLayout(singlePaneLayout),
|
|
581
|
+
layouts: [{ name: "Default", layout: cloneLayout(singlePaneLayout) }],
|
|
582
|
+
}),
|
|
583
|
+
focusedPaneId: "portfolio-list:main",
|
|
584
|
+
};
|
|
585
|
+
const actions: Array<any> = [];
|
|
586
|
+
|
|
587
|
+
testSetup = await testRender(
|
|
588
|
+
<AppContext value={{ state, dispatch: (action) => actions.push(action) }}>
|
|
589
|
+
<DialogProvider dialogOptions={{ style: { backgroundColor: "#000000", borderColor: "#ffffff", borderStyle: "single" } }}>
|
|
590
|
+
<Shell pluginRegistry={createShellPluginRegistry()} />
|
|
591
|
+
</DialogProvider>
|
|
592
|
+
</AppContext>,
|
|
593
|
+
{ width: 40, height: 10 },
|
|
594
|
+
);
|
|
595
|
+
|
|
596
|
+
await testSetup.renderOnce();
|
|
597
|
+
await act(async () => {
|
|
598
|
+
testSetup!.mockInput.pressKey("w", { ctrl: true });
|
|
599
|
+
await testSetup!.renderOnce();
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
const updateLayout = actions.find((action) => action.type === "UPDATE_LAYOUT");
|
|
603
|
+
expect(actions).toContainEqual({ type: "PUSH_LAYOUT_HISTORY" });
|
|
604
|
+
expect(updateLayout?.layout.instances).toEqual([]);
|
|
605
|
+
expect(updateLayout?.layout.floating).toEqual([]);
|
|
606
|
+
expect(updateLayout?.layout.dockRoot).toBeNull();
|
|
607
|
+
});
|
|
608
|
+
|
|
609
|
+
test("closes the focused floating pane with Ctrl+W", async () => {
|
|
610
|
+
const config = createDefaultConfig("/tmp/gloomberb-shell-test");
|
|
611
|
+
const mainPane = config.layout.instances.find((instance) => instance.instanceId === "portfolio-list:main");
|
|
612
|
+
const detailPane = config.layout.instances.find((instance) => instance.instanceId === "ticker-detail:main");
|
|
613
|
+
if (!mainPane || !detailPane) throw new Error("missing default panes");
|
|
614
|
+
|
|
615
|
+
const mixedLayout = {
|
|
616
|
+
dockRoot: { kind: "pane" as const, instanceId: "portfolio-list:main" },
|
|
617
|
+
instances: [{ ...mainPane }, { ...detailPane }],
|
|
618
|
+
floating: [{ instanceId: "ticker-detail:main", x: 4, y: 2, width: 30, height: 8 }],
|
|
619
|
+
};
|
|
620
|
+
const state = {
|
|
621
|
+
...createInitialState({
|
|
622
|
+
...config,
|
|
623
|
+
layout: cloneLayout(mixedLayout),
|
|
624
|
+
layouts: [{ name: "Default", layout: cloneLayout(mixedLayout) }],
|
|
625
|
+
}),
|
|
626
|
+
focusedPaneId: "ticker-detail:main",
|
|
627
|
+
};
|
|
628
|
+
const actions: Array<any> = [];
|
|
629
|
+
|
|
630
|
+
testSetup = await testRender(
|
|
631
|
+
<AppContext value={{ state, dispatch: (action) => actions.push(action) }}>
|
|
632
|
+
<DialogProvider dialogOptions={{ style: { backgroundColor: "#000000", borderColor: "#ffffff", borderStyle: "single" } }}>
|
|
633
|
+
<Shell pluginRegistry={createShellPluginRegistry()} />
|
|
634
|
+
</DialogProvider>
|
|
635
|
+
</AppContext>,
|
|
636
|
+
{ width: 40, height: 12 },
|
|
637
|
+
);
|
|
638
|
+
|
|
639
|
+
await testSetup.renderOnce();
|
|
640
|
+
await act(async () => {
|
|
641
|
+
testSetup!.mockInput.pressKey("w", { ctrl: true });
|
|
642
|
+
await testSetup!.renderOnce();
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
const updateLayout = actions.find((action) => action.type === "UPDATE_LAYOUT");
|
|
646
|
+
expect(actions).toContainEqual({ type: "PUSH_LAYOUT_HISTORY" });
|
|
647
|
+
expect(updateLayout?.layout.instances.map((instance: { instanceId: string }) => instance.instanceId)).toEqual(["portfolio-list:main"]);
|
|
648
|
+
expect(updateLayout?.layout.floating).toEqual([]);
|
|
649
|
+
expect(updateLayout?.layout.dockRoot).toEqual({ kind: "pane", instanceId: "portfolio-list:main" });
|
|
650
|
+
});
|
|
651
|
+
});
|