gloomberb 0.1.0 → 0.3.1
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/LICENSE +25 -0
- package/README.md +68 -121
- package/bin/gloomberb +3 -0
- package/package.json +13 -4
- package/patches/@opentui%2Fcore@0.1.90.patch +356 -0
- package/src/app.tsx +1330 -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 +1524 -0
- package/src/components/command-bar/command-bar.tsx +4823 -0
- package/src/components/command-bar/command-registry.ts +261 -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 +129 -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 +625 -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/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 +310 -0
- package/src/data/config-store.ts +469 -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 +71 -0
- package/src/pane-settings.ts +73 -0
- package/src/plugins/builtin/ai/ask-ai-detail-tab.tsx +338 -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 +436 -0
- package/src/plugins/builtin/portfolio-list/pane.tsx +533 -0
- package/src/plugins/builtin/portfolio-list/settings.ts +280 -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 +153 -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 +132 -0
- package/src/state/app-context.tsx +969 -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 +434 -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 +162 -0
- package/src/updater.ts +247 -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 -69
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { appReducer, createInitialState, resolveCollectionForPane, resolveTickerForPane } from "./app-context";
|
|
3
|
+
import { cloneLayout, createDefaultConfig, createPaneInstance } from "../types/config";
|
|
4
|
+
import type { AppSessionSnapshot } from "./session-persistence";
|
|
5
|
+
import { buildBrokerPortfolioId } from "../utils/broker-instances";
|
|
6
|
+
|
|
7
|
+
describe("resolveTickerForPane", () => {
|
|
8
|
+
test("uses a portfolio pane cursor for inspector follow panes", () => {
|
|
9
|
+
const config = createDefaultConfig("/tmp/gloomberb-test");
|
|
10
|
+
const state = createInitialState(config);
|
|
11
|
+
|
|
12
|
+
state.paneState["portfolio-list:main"] = {
|
|
13
|
+
collectionId: "main",
|
|
14
|
+
cursorSymbol: "AAPL",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
expect(resolveTickerForPane(state, "portfolio-list:main")).toBe("AAPL");
|
|
18
|
+
expect(resolveTickerForPane(state, "ticker-detail:main")).toBe("AAPL");
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
test("uses fixed ticker bindings for pinned panes", () => {
|
|
22
|
+
const config = createDefaultConfig("/tmp/gloomberb-test");
|
|
23
|
+
const instance = createPaneInstance("ticker-detail", {
|
|
24
|
+
instanceId: "ticker-detail:msft",
|
|
25
|
+
binding: { kind: "fixed", symbol: "MSFT" },
|
|
26
|
+
});
|
|
27
|
+
config.layout.instances.push(instance);
|
|
28
|
+
config.layout.floating.push({
|
|
29
|
+
instanceId: instance.instanceId,
|
|
30
|
+
x: 0,
|
|
31
|
+
y: 0,
|
|
32
|
+
width: 40,
|
|
33
|
+
height: 12,
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const state = createInitialState(config);
|
|
37
|
+
expect(resolveTickerForPane(state, instance.instanceId)).toBe("MSFT");
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test("hydrates remembered pane-local tab and sort state from the previous session", () => {
|
|
41
|
+
const config = createDefaultConfig("/tmp/gloomberb-test");
|
|
42
|
+
const sessionSnapshot: AppSessionSnapshot = {
|
|
43
|
+
paneState: {
|
|
44
|
+
"portfolio-list:main": {
|
|
45
|
+
collectionId: "watchlist",
|
|
46
|
+
collectionSorts: {
|
|
47
|
+
watchlist: { columnId: "change_pct", direction: "desc" },
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
"ticker-detail:main": {
|
|
51
|
+
activeTabId: "financials",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
focusedPaneId: "ticker-detail:main",
|
|
55
|
+
activePanel: "right",
|
|
56
|
+
statusBarVisible: true,
|
|
57
|
+
openPaneIds: ["portfolio-list:main", "ticker-detail:main"],
|
|
58
|
+
hydrationTargets: [],
|
|
59
|
+
exchangeCurrencies: ["USD"],
|
|
60
|
+
savedAt: Date.now(),
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const state = createInitialState(config, sessionSnapshot);
|
|
64
|
+
|
|
65
|
+
expect(state.paneState["portfolio-list:main"]).toEqual({
|
|
66
|
+
collectionId: "watchlist",
|
|
67
|
+
cursorSymbol: null,
|
|
68
|
+
collectionSorts: {
|
|
69
|
+
watchlist: { columnId: "change_pct", direction: "desc" },
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
expect(state.paneState["ticker-detail:main"]).toEqual({
|
|
73
|
+
activeTabId: "financials",
|
|
74
|
+
});
|
|
75
|
+
expect(state.focusedPaneId).toBe("ticker-detail:main");
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("preserves broker portfolio selection until broker portfolios are restored", () => {
|
|
79
|
+
const config = createDefaultConfig("/tmp/gloomberb-test");
|
|
80
|
+
const brokerPortfolioId = buildBrokerPortfolioId("ibkr-live", "DU12345");
|
|
81
|
+
const sessionSnapshot: AppSessionSnapshot = {
|
|
82
|
+
paneState: {
|
|
83
|
+
"portfolio-list:main": {
|
|
84
|
+
collectionId: brokerPortfolioId,
|
|
85
|
+
cursorSymbol: "AAPL",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
focusedPaneId: "portfolio-list:main",
|
|
89
|
+
activePanel: "left",
|
|
90
|
+
statusBarVisible: true,
|
|
91
|
+
openPaneIds: ["portfolio-list:main", "ticker-detail:main"],
|
|
92
|
+
hydrationTargets: [],
|
|
93
|
+
exchangeCurrencies: ["USD"],
|
|
94
|
+
savedAt: Date.now(),
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const initial = createInitialState(config, sessionSnapshot);
|
|
98
|
+
|
|
99
|
+
expect(initial.paneState["portfolio-list:main"]).toEqual({
|
|
100
|
+
collectionId: brokerPortfolioId,
|
|
101
|
+
cursorSymbol: "AAPL",
|
|
102
|
+
});
|
|
103
|
+
expect(resolveCollectionForPane(initial, "portfolio-list:main")).toBe(brokerPortfolioId);
|
|
104
|
+
expect(resolveCollectionForPane(initial, "ticker-detail:main")).toBe(brokerPortfolioId);
|
|
105
|
+
|
|
106
|
+
const nextConfig = {
|
|
107
|
+
...config,
|
|
108
|
+
portfolios: [
|
|
109
|
+
...config.portfolios,
|
|
110
|
+
{
|
|
111
|
+
id: brokerPortfolioId,
|
|
112
|
+
name: "IBKR DU12345",
|
|
113
|
+
currency: "USD",
|
|
114
|
+
brokerId: "ibkr",
|
|
115
|
+
brokerInstanceId: "ibkr-live",
|
|
116
|
+
brokerAccountId: "DU12345",
|
|
117
|
+
},
|
|
118
|
+
],
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const next = appReducer(initial, { type: "SET_CONFIG", config: nextConfig });
|
|
122
|
+
|
|
123
|
+
expect(next.paneState["portfolio-list:main"]).toEqual({
|
|
124
|
+
collectionId: brokerPortfolioId,
|
|
125
|
+
cursorSymbol: "AAPL",
|
|
126
|
+
});
|
|
127
|
+
expect(resolveCollectionForPane(next, "portfolio-list:main")).toBe(brokerPortfolioId);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
test("falls back for unknown non-broker collection ids", () => {
|
|
131
|
+
const config = createDefaultConfig("/tmp/gloomberb-test");
|
|
132
|
+
const sessionSnapshot: AppSessionSnapshot = {
|
|
133
|
+
paneState: {
|
|
134
|
+
"portfolio-list:main": {
|
|
135
|
+
collectionId: "missing-collection",
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
focusedPaneId: "portfolio-list:main",
|
|
139
|
+
activePanel: "left",
|
|
140
|
+
statusBarVisible: true,
|
|
141
|
+
openPaneIds: ["portfolio-list:main", "ticker-detail:main"],
|
|
142
|
+
hydrationTargets: [],
|
|
143
|
+
exchangeCurrencies: ["USD"],
|
|
144
|
+
savedAt: Date.now(),
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
const state = createInitialState(config, sessionSnapshot);
|
|
148
|
+
|
|
149
|
+
expect(state.paneState["portfolio-list:main"]).toEqual({
|
|
150
|
+
collectionId: "main",
|
|
151
|
+
cursorSymbol: null,
|
|
152
|
+
});
|
|
153
|
+
expect(resolveCollectionForPane(state, "portfolio-list:main")).toBe("main");
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
describe("broker account cache", () => {
|
|
158
|
+
test("stores broker accounts by instance id", () => {
|
|
159
|
+
const state = createInitialState(createDefaultConfig("/tmp/gloomberb-test"));
|
|
160
|
+
const next = appReducer(state, {
|
|
161
|
+
type: "SET_BROKER_ACCOUNTS",
|
|
162
|
+
instanceId: "ibkr-flex",
|
|
163
|
+
accounts: [{ accountId: "DU12345", name: "DU12345", totalCashValue: 10 }],
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
expect(next.brokerAccounts).toEqual({
|
|
167
|
+
"ibkr-flex": [{ accountId: "DU12345", name: "DU12345", totalCashValue: 10 }],
|
|
168
|
+
});
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
test("preserves cached broker accounts across unrelated config updates", () => {
|
|
172
|
+
const config = createDefaultConfig("/tmp/gloomberb-test");
|
|
173
|
+
config.brokerInstances.push({
|
|
174
|
+
id: "ibkr-flex",
|
|
175
|
+
brokerType: "ibkr",
|
|
176
|
+
label: "Flex",
|
|
177
|
+
connectionMode: "flex",
|
|
178
|
+
config: { connectionMode: "flex", flex: { token: "t", queryId: "q" } },
|
|
179
|
+
enabled: true,
|
|
180
|
+
});
|
|
181
|
+
const state = appReducer(createInitialState(config), {
|
|
182
|
+
type: "SET_BROKER_ACCOUNTS",
|
|
183
|
+
instanceId: "ibkr-flex",
|
|
184
|
+
accounts: [{ accountId: "DU12345", name: "DU12345", totalCashValue: 10 }],
|
|
185
|
+
});
|
|
186
|
+
|
|
187
|
+
const next = appReducer(state, { type: "SET_CONFIG", config: { ...config, theme: "amber" } });
|
|
188
|
+
|
|
189
|
+
expect(next.brokerAccounts).toEqual(state.brokerAccounts);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
test("clears cached broker accounts when the broker instance is removed", () => {
|
|
193
|
+
const config = createDefaultConfig("/tmp/gloomberb-test");
|
|
194
|
+
config.brokerInstances.push({
|
|
195
|
+
id: "ibkr-flex",
|
|
196
|
+
brokerType: "ibkr",
|
|
197
|
+
label: "Flex",
|
|
198
|
+
connectionMode: "flex",
|
|
199
|
+
config: { connectionMode: "flex", flex: { token: "t", queryId: "q" } },
|
|
200
|
+
enabled: true,
|
|
201
|
+
});
|
|
202
|
+
const state = appReducer(createInitialState(config), {
|
|
203
|
+
type: "SET_BROKER_ACCOUNTS",
|
|
204
|
+
instanceId: "ibkr-flex",
|
|
205
|
+
accounts: [{ accountId: "DU12345", name: "DU12345", totalCashValue: 10 }],
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
const next = appReducer(state, {
|
|
209
|
+
type: "SET_CONFIG",
|
|
210
|
+
config: { ...config, brokerInstances: [] },
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
expect(next.brokerAccounts).toEqual({});
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
describe("quote merging", () => {
|
|
218
|
+
test("does not overwrite live broker quotes with cloud updates", () => {
|
|
219
|
+
const config = createDefaultConfig("/tmp/gloomberb-test");
|
|
220
|
+
const initial = createInitialState(config);
|
|
221
|
+
initial.financials.set("AAPL", {
|
|
222
|
+
annualStatements: [],
|
|
223
|
+
quarterlyStatements: [],
|
|
224
|
+
priceHistory: [],
|
|
225
|
+
quote: {
|
|
226
|
+
symbol: "AAPL",
|
|
227
|
+
providerId: "ibkr",
|
|
228
|
+
price: 201,
|
|
229
|
+
currency: "USD",
|
|
230
|
+
change: 1,
|
|
231
|
+
changePercent: 0.5,
|
|
232
|
+
lastUpdated: Date.now(),
|
|
233
|
+
dataSource: "live",
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
const next = appReducer(initial, {
|
|
238
|
+
type: "MERGE_QUOTE",
|
|
239
|
+
symbol: "AAPL",
|
|
240
|
+
quote: {
|
|
241
|
+
symbol: "AAPL",
|
|
242
|
+
providerId: "gloomberb-cloud",
|
|
243
|
+
price: 199,
|
|
244
|
+
currency: "USD",
|
|
245
|
+
change: -1,
|
|
246
|
+
changePercent: -0.5,
|
|
247
|
+
lastUpdated: Date.now(),
|
|
248
|
+
dataSource: "live",
|
|
249
|
+
},
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
expect(next.financials.get("AAPL")?.quote?.price).toBe(201);
|
|
253
|
+
expect(next.financials.get("AAPL")?.quote?.providerId).toBe("ibkr");
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
test("merges cloud quotes into existing fundamentals without wiping them", () => {
|
|
257
|
+
const config = createDefaultConfig("/tmp/gloomberb-test");
|
|
258
|
+
const initial = createInitialState(config);
|
|
259
|
+
initial.financials.set("AAPL", {
|
|
260
|
+
annualStatements: [],
|
|
261
|
+
quarterlyStatements: [],
|
|
262
|
+
priceHistory: [],
|
|
263
|
+
profile: { description: "Apple" },
|
|
264
|
+
fundamentals: { trailingPE: 30 },
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
const next = appReducer(initial, {
|
|
268
|
+
type: "MERGE_QUOTE",
|
|
269
|
+
symbol: "AAPL",
|
|
270
|
+
quote: {
|
|
271
|
+
symbol: "AAPL",
|
|
272
|
+
providerId: "gloomberb-cloud",
|
|
273
|
+
price: 200,
|
|
274
|
+
currency: "USD",
|
|
275
|
+
change: 2,
|
|
276
|
+
changePercent: 1,
|
|
277
|
+
lastUpdated: Date.now(),
|
|
278
|
+
dataSource: "live",
|
|
279
|
+
},
|
|
280
|
+
});
|
|
281
|
+
|
|
282
|
+
expect(next.financials.get("AAPL")?.profile?.description).toBe("Apple");
|
|
283
|
+
expect(next.financials.get("AAPL")?.fundamentals?.trailingPE).toBe(30);
|
|
284
|
+
expect(next.financials.get("AAPL")?.quote?.price).toBe(200);
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
test("preserves existing bid ask when a streaming quote only updates last price", () => {
|
|
288
|
+
const config = createDefaultConfig("/tmp/gloomberb-test");
|
|
289
|
+
const initial = createInitialState(config);
|
|
290
|
+
initial.financials.set("AAPL", {
|
|
291
|
+
annualStatements: [],
|
|
292
|
+
quarterlyStatements: [],
|
|
293
|
+
priceHistory: [],
|
|
294
|
+
quote: {
|
|
295
|
+
symbol: "AAPL",
|
|
296
|
+
providerId: "gloomberb-cloud",
|
|
297
|
+
price: 200,
|
|
298
|
+
currency: "USD",
|
|
299
|
+
change: 2,
|
|
300
|
+
changePercent: 1,
|
|
301
|
+
bid: 199.95,
|
|
302
|
+
ask: 200.05,
|
|
303
|
+
bidSize: 10,
|
|
304
|
+
askSize: 12,
|
|
305
|
+
lastUpdated: Date.now() - 1000,
|
|
306
|
+
dataSource: "delayed",
|
|
307
|
+
},
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
const next = appReducer(initial, {
|
|
311
|
+
type: "MERGE_QUOTE",
|
|
312
|
+
symbol: "AAPL",
|
|
313
|
+
quote: {
|
|
314
|
+
symbol: "AAPL",
|
|
315
|
+
providerId: "gloomberb-cloud",
|
|
316
|
+
price: 201,
|
|
317
|
+
currency: "USD",
|
|
318
|
+
change: 3,
|
|
319
|
+
changePercent: 1.5,
|
|
320
|
+
lastUpdated: Date.now(),
|
|
321
|
+
dataSource: "live",
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
expect(next.financials.get("AAPL")?.quote?.price).toBe(201);
|
|
326
|
+
expect(next.financials.get("AAPL")?.quote?.bid).toBe(199.95);
|
|
327
|
+
expect(next.financials.get("AAPL")?.quote?.ask).toBe(200.05);
|
|
328
|
+
expect(next.financials.get("AAPL")?.quote?.bidSize).toBe(10);
|
|
329
|
+
expect(next.financials.get("AAPL")?.quote?.askSize).toBe(12);
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
test("ignores same-currency quotes that differ by a likely 100x unit mismatch", () => {
|
|
333
|
+
const config = createDefaultConfig("/tmp/gloomberb-test");
|
|
334
|
+
const initial = createInitialState(config);
|
|
335
|
+
initial.financials.set("IQE", {
|
|
336
|
+
annualStatements: [],
|
|
337
|
+
quarterlyStatements: [],
|
|
338
|
+
priceHistory: [],
|
|
339
|
+
quote: {
|
|
340
|
+
symbol: "IQE.L",
|
|
341
|
+
price: 0.245,
|
|
342
|
+
currency: "GBP",
|
|
343
|
+
change: -0.021,
|
|
344
|
+
changePercent: -7.89,
|
|
345
|
+
lastUpdated: Date.now() - 1000,
|
|
346
|
+
dataSource: "yahoo",
|
|
347
|
+
},
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
const next = appReducer(initial, {
|
|
351
|
+
type: "MERGE_QUOTE",
|
|
352
|
+
symbol: "IQE",
|
|
353
|
+
quote: {
|
|
354
|
+
symbol: "IQE",
|
|
355
|
+
providerId: "gloomberb-cloud",
|
|
356
|
+
price: 24.5,
|
|
357
|
+
currency: "GBP",
|
|
358
|
+
change: -2.1,
|
|
359
|
+
changePercent: -7.89,
|
|
360
|
+
lastUpdated: Date.now(),
|
|
361
|
+
dataSource: "live",
|
|
362
|
+
},
|
|
363
|
+
});
|
|
364
|
+
|
|
365
|
+
expect(next.financials.get("IQE")?.quote?.price).toBe(0.245);
|
|
366
|
+
expect(next.financials.get("IQE")?.quote?.symbol).toBe("IQE.L");
|
|
367
|
+
expect(next.financials.get("IQE")?.quote?.dataSource).toBe("yahoo");
|
|
368
|
+
});
|
|
369
|
+
});
|
|
370
|
+
|
|
371
|
+
describe("layout focus fallback", () => {
|
|
372
|
+
test("focuses the highest remaining floating pane when the focused floating pane closes", () => {
|
|
373
|
+
const config = createDefaultConfig("/tmp/gloomberb-test");
|
|
374
|
+
const backgroundPane = createPaneInstance("chat", {
|
|
375
|
+
instanceId: "chat:background",
|
|
376
|
+
binding: { kind: "none" },
|
|
377
|
+
});
|
|
378
|
+
const topPane = createPaneInstance("help", {
|
|
379
|
+
instanceId: "help:top",
|
|
380
|
+
binding: { kind: "none" },
|
|
381
|
+
});
|
|
382
|
+
const layout = {
|
|
383
|
+
...cloneLayout(config.layout),
|
|
384
|
+
instances: [...config.layout.instances, backgroundPane, topPane],
|
|
385
|
+
floating: [
|
|
386
|
+
{ instanceId: "chat:background", x: 4, y: 2, width: 36, height: 10, zIndex: 70 },
|
|
387
|
+
{ instanceId: "help:top", x: 12, y: 4, width: 36, height: 10, zIndex: 95 },
|
|
388
|
+
],
|
|
389
|
+
};
|
|
390
|
+
const state = createInitialState({
|
|
391
|
+
...config,
|
|
392
|
+
layout,
|
|
393
|
+
layouts: [{ name: "Default", layout: cloneLayout(layout) }],
|
|
394
|
+
});
|
|
395
|
+
state.focusedPaneId = "help:top";
|
|
396
|
+
|
|
397
|
+
const nextLayout = {
|
|
398
|
+
...cloneLayout(layout),
|
|
399
|
+
instances: layout.instances.filter((instance) => instance.instanceId !== "help:top"),
|
|
400
|
+
floating: layout.floating.filter((entry) => entry.instanceId !== "help:top"),
|
|
401
|
+
};
|
|
402
|
+
const next = appReducer(state, { type: "UPDATE_LAYOUT", layout: nextLayout });
|
|
403
|
+
|
|
404
|
+
expect(next.focusedPaneId).toBe("chat:background");
|
|
405
|
+
});
|
|
406
|
+
});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { cloneLayout, createDefaultConfig } from "../types/config";
|
|
3
|
+
import { appReducer, createInitialState } from "./app-context";
|
|
4
|
+
|
|
5
|
+
describe("appReducer command bar state", () => {
|
|
6
|
+
test("opens the command bar with an explicit query", () => {
|
|
7
|
+
const state = createInitialState(createDefaultConfig("/tmp/gloomberb-test"));
|
|
8
|
+
const next = appReducer(state, { type: "SET_COMMAND_BAR", open: true, query: "Sync Broker Account" });
|
|
9
|
+
|
|
10
|
+
expect(next.commandBarOpen).toBe(true);
|
|
11
|
+
expect(next.commandBarQuery).toBe("Sync Broker Account");
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test("clears the command bar query when closing", () => {
|
|
15
|
+
const state = appReducer(
|
|
16
|
+
createInitialState(createDefaultConfig("/tmp/gloomberb-test")),
|
|
17
|
+
{ type: "SET_COMMAND_BAR", open: true, query: "Disconnect Broker Account" },
|
|
18
|
+
);
|
|
19
|
+
const next = appReducer(state, { type: "SET_COMMAND_BAR", open: false });
|
|
20
|
+
|
|
21
|
+
expect(next.commandBarOpen).toBe(false);
|
|
22
|
+
expect(next.commandBarQuery).toBe("");
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
test("toggle opens blank and clears on close", () => {
|
|
26
|
+
const initial = createInitialState(createDefaultConfig("/tmp/gloomberb-test"));
|
|
27
|
+
const opened = appReducer(initial, { type: "TOGGLE_COMMAND_BAR" });
|
|
28
|
+
const closed = appReducer({ ...opened, commandBarQuery: "stale" }, { type: "TOGGLE_COMMAND_BAR" });
|
|
29
|
+
|
|
30
|
+
expect(opened.commandBarOpen).toBe(true);
|
|
31
|
+
expect(opened.commandBarQuery).toBe("");
|
|
32
|
+
expect(closed.commandBarOpen).toBe(false);
|
|
33
|
+
expect(closed.commandBarQuery).toBe("");
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
test("updates the live command bar query without closing the overlay", () => {
|
|
37
|
+
const state = appReducer(
|
|
38
|
+
createInitialState(createDefaultConfig("/tmp/gloomberb-test")),
|
|
39
|
+
{ type: "SET_COMMAND_BAR", open: true, query: "PL " },
|
|
40
|
+
);
|
|
41
|
+
const next = appReducer(state, { type: "SET_COMMAND_BAR_QUERY", query: "PL notes" });
|
|
42
|
+
|
|
43
|
+
expect(next.commandBarOpen).toBe(true);
|
|
44
|
+
expect(next.commandBarQuery).toBe("PL notes");
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
test("re-shows the gridlock tip and refreshes its sequence on every trigger", () => {
|
|
48
|
+
const initial = createInitialState(createDefaultConfig("/tmp/gloomberb-test"));
|
|
49
|
+
|
|
50
|
+
const shown = appReducer(initial, { type: "SHOW_GRIDLOCK_TIP" });
|
|
51
|
+
expect(shown.gridlockTipVisible).toBe(true);
|
|
52
|
+
expect(shown.gridlockTipSequence).toBe(1);
|
|
53
|
+
|
|
54
|
+
const dismissed = appReducer(shown, { type: "DISMISS_GRIDLOCK_TIP" });
|
|
55
|
+
expect(dismissed.gridlockTipVisible).toBe(false);
|
|
56
|
+
expect(dismissed.gridlockTipSequence).toBe(1);
|
|
57
|
+
|
|
58
|
+
const repeated = appReducer(dismissed, { type: "SHOW_GRIDLOCK_TIP" });
|
|
59
|
+
expect(repeated.gridlockTipVisible).toBe(true);
|
|
60
|
+
expect(repeated.gridlockTipSequence).toBe(2);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
test("tracks layout undo and redo history", () => {
|
|
64
|
+
const initial = createInitialState(createDefaultConfig("/tmp/gloomberb-test"));
|
|
65
|
+
const changedLayout = cloneLayout(initial.config.layout);
|
|
66
|
+
if (!changedLayout.dockRoot || changedLayout.dockRoot.kind !== "split") {
|
|
67
|
+
throw new Error("expected split dock root");
|
|
68
|
+
}
|
|
69
|
+
changedLayout.dockRoot.ratio = 0.5;
|
|
70
|
+
|
|
71
|
+
const withHistory = appReducer(initial, { type: "PUSH_LAYOUT_HISTORY" });
|
|
72
|
+
const changed = appReducer(withHistory, { type: "UPDATE_LAYOUT", layout: changedLayout });
|
|
73
|
+
|
|
74
|
+
expect(changed.layoutHistory[0]?.past).toHaveLength(1);
|
|
75
|
+
expect(changed.config.layout.dockRoot && changed.config.layout.dockRoot.kind === "split"
|
|
76
|
+
? changed.config.layout.dockRoot.ratio
|
|
77
|
+
: null).toBe(0.5);
|
|
78
|
+
|
|
79
|
+
const undone = appReducer(changed, { type: "UNDO_LAYOUT" });
|
|
80
|
+
expect(undone.config.layout.dockRoot && undone.config.layout.dockRoot.kind === "split"
|
|
81
|
+
? undone.config.layout.dockRoot.ratio
|
|
82
|
+
: null).toBe(0.4);
|
|
83
|
+
expect(undone.layoutHistory[0]?.future).toHaveLength(1);
|
|
84
|
+
|
|
85
|
+
const redone = appReducer(undone, { type: "REDO_LAYOUT" });
|
|
86
|
+
expect(redone.config.layout.dockRoot && redone.config.layout.dockRoot.kind === "split"
|
|
87
|
+
? redone.config.layout.dockRoot.ratio
|
|
88
|
+
: null).toBe(0.5);
|
|
89
|
+
expect(redone.layoutHistory[0]?.past).toHaveLength(1);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test("keeps layout history isolated per saved layout", () => {
|
|
93
|
+
const initial = createInitialState(createDefaultConfig("/tmp/gloomberb-test"));
|
|
94
|
+
|
|
95
|
+
const firstLayout = cloneLayout(initial.config.layout);
|
|
96
|
+
if (!firstLayout.dockRoot || firstLayout.dockRoot.kind !== "split") {
|
|
97
|
+
throw new Error("expected split dock root");
|
|
98
|
+
}
|
|
99
|
+
firstLayout.dockRoot.ratio = 0.45;
|
|
100
|
+
let state = appReducer(initial, { type: "PUSH_LAYOUT_HISTORY" });
|
|
101
|
+
state = appReducer(state, { type: "UPDATE_LAYOUT", layout: firstLayout });
|
|
102
|
+
state = appReducer(state, { type: "NEW_LAYOUT", name: "Research" });
|
|
103
|
+
|
|
104
|
+
const noUndoOnFreshLayout = appReducer(state, { type: "UNDO_LAYOUT" });
|
|
105
|
+
expect(noUndoOnFreshLayout.config.activeLayoutIndex).toBe(1);
|
|
106
|
+
expect(noUndoOnFreshLayout.config.layout.dockRoot && noUndoOnFreshLayout.config.layout.dockRoot.kind === "split"
|
|
107
|
+
? noUndoOnFreshLayout.config.layout.dockRoot.ratio
|
|
108
|
+
: null).toBe(0.4);
|
|
109
|
+
|
|
110
|
+
const secondLayout = cloneLayout(noUndoOnFreshLayout.config.layout);
|
|
111
|
+
if (!secondLayout.dockRoot || secondLayout.dockRoot.kind !== "split") {
|
|
112
|
+
throw new Error("expected split dock root");
|
|
113
|
+
}
|
|
114
|
+
secondLayout.dockRoot.ratio = 0.55;
|
|
115
|
+
state = appReducer(noUndoOnFreshLayout, { type: "PUSH_LAYOUT_HISTORY" });
|
|
116
|
+
state = appReducer(state, { type: "UPDATE_LAYOUT", layout: secondLayout });
|
|
117
|
+
|
|
118
|
+
const backToFirst = appReducer(state, { type: "SWITCH_LAYOUT", index: 0 });
|
|
119
|
+
const firstUndone = appReducer(backToFirst, { type: "UNDO_LAYOUT" });
|
|
120
|
+
expect(firstUndone.config.activeLayoutIndex).toBe(0);
|
|
121
|
+
expect(firstUndone.config.layout.dockRoot && firstUndone.config.layout.dockRoot.kind === "split"
|
|
122
|
+
? firstUndone.config.layout.dockRoot.ratio
|
|
123
|
+
: null).toBe(0.4);
|
|
124
|
+
|
|
125
|
+
const backToSecond = appReducer(firstUndone, { type: "SWITCH_LAYOUT", index: 1 });
|
|
126
|
+
const secondUndone = appReducer(backToSecond, { type: "UNDO_LAYOUT" });
|
|
127
|
+
expect(secondUndone.config.activeLayoutIndex).toBe(1);
|
|
128
|
+
expect(secondUndone.config.layout.dockRoot && secondUndone.config.layout.dockRoot.kind === "split"
|
|
129
|
+
? secondUndone.config.layout.dockRoot.ratio
|
|
130
|
+
: null).toBe(0.4);
|
|
131
|
+
});
|
|
132
|
+
});
|