mirror of
https://github.com/lWolvesl/antigravity-usage-monitor.git
synced 2026-11-26 17:09:28 +08:00
feat(panel): graduate Modern UI as default, default language to system, and fix 5h quota boundary
This commit is contained in:
@@ -1054,12 +1054,24 @@ test('saving preferences sends the same legacy values normalized by the backend'
|
||||
});
|
||||
|
||||
test('preferences schema defaults match pre-refactor UI, migrate legacy none slots, and support reset & cache rebuild', async () => {
|
||||
// 1. Default schema matches pre-refactor out-of-box UI 100%
|
||||
// 1. Default schema matches v1.5.3 out-of-box UI (language='auto', modernUi=true)
|
||||
const hDefault = backendHarness({});
|
||||
const def = hDefault.loadSettings();
|
||||
assert.equal(def.language, 'zh-CN');
|
||||
assert.equal(def.language, 'auto');
|
||||
assert.equal(def.themeAccent, 'host');
|
||||
assert.equal(def.fontScale, 'md');
|
||||
assert.equal(def.modernUi, true);
|
||||
assert.equal(def.experimentalModernUi, true);
|
||||
|
||||
// Upgrading from v1.5.2 settings.json (with experimentalModernUi: false and no modernUi key) enables modernUi=true
|
||||
const hFrom152 = backendHarness({ settings: { language: 'zh-CN', experimentalModernUi: false } });
|
||||
const loadedFrom152 = hFrom152.loadSettings();
|
||||
assert.equal(loadedFrom152.modernUi, true);
|
||||
assert.equal(loadedFrom152.experimentalModernUi, true);
|
||||
const optOutRes = hFrom152.executeSettingsAction({ modernUi: false });
|
||||
assert.equal(optOutRes.ok, true);
|
||||
assert.equal(optOutRes.updated.modernUi, false);
|
||||
assert.equal(hFrom152.loadSettings().modernUi, false);
|
||||
assert.equal(def.pluginUpdateMode, 'manual');
|
||||
assert.equal(def.windowMountMode, 'dual');
|
||||
assert.equal(def.enableWindowOverlay, true);
|
||||
@@ -1147,7 +1159,8 @@ test('preferences schema defaults match pre-refactor UI, migrate legacy none slo
|
||||
// 6. executeResetSettingsAction restores full defaults cleanly
|
||||
const resetRes = hDefault.executeResetSettingsAction();
|
||||
assert.equal(resetRes.ok, true);
|
||||
assert.equal(resetRes.updated.language, 'zh-CN');
|
||||
assert.equal(resetRes.updated.language, 'auto');
|
||||
assert.equal(resetRes.updated.modernUi, true);
|
||||
assert.equal(resetRes.updated.themeAccent, 'host');
|
||||
assert.equal(resetRes.updated.enableCliStatusLine, true);
|
||||
assert.equal(resetRes.updated.showStepTurnRail, false);
|
||||
|
||||
@@ -1376,3 +1376,119 @@ test('P2 audit fixes: standalone sqlite/proto-wire primitives, structured liveAc
|
||||
globalThis.window = prevWin;
|
||||
}
|
||||
});
|
||||
|
||||
test('5h quota cycle includes cycle-opening compaction CHECKPOINT and cross-boundary steps plus unattributed cold-boot cache entries', async () => {
|
||||
const nowMs = Date.now();
|
||||
const start5hMs = nowMs - 2 * 3600_000;
|
||||
const reset5hIso = new Date(start5hMs + 5 * 3600_000).toISOString();
|
||||
const resetWkIso = new Date(nowMs + 5 * 24 * 3600_000).toISOString();
|
||||
|
||||
// 1. Old step from expired previous cycle (2.5h before start5hMs) -> must be excluded from 5h
|
||||
const oldCycleStep = {
|
||||
type: 'CORTEX_STEP_TYPE_PLANNER_RESPONSE',
|
||||
status: 'CORTEX_STEP_STATUS_DONE',
|
||||
metadata: {
|
||||
sourceTrajectoryStepInfo: { stepIndex: 1 },
|
||||
createdAt: new Date(start5hMs - 2.5 * 3600_000).toISOString(),
|
||||
completedAt: new Date(start5hMs - 2.5 * 3600_000 + 8_000).toISOString(),
|
||||
modelUsage: {
|
||||
model: 'MODEL_PLACEHOLDER_M429',
|
||||
inputTokens: '100000',
|
||||
cacheReadTokens: '0',
|
||||
outputTokens: '5000',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 2. Untimed /compact CHECKPOINT started 70s BEFORE start5hMs that settled & opened the 5h bucket -> must be included!
|
||||
const compactOpeningStep = {
|
||||
type: 'CORTEX_STEP_TYPE_CHECKPOINT',
|
||||
status: 'CORTEX_STEP_STATUS_DONE',
|
||||
metadata: {
|
||||
sourceTrajectoryStepInfo: { stepIndex: 2 },
|
||||
createdAt: new Date(start5hMs - 70_000).toISOString(),
|
||||
modelUsage: {
|
||||
model: 'MODEL_PLACEHOLDER_M429',
|
||||
inputTokens: '300000',
|
||||
cacheReadTokens: '0',
|
||||
outputTokens: '4000',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 3. Normal step after compaction inside 5h window
|
||||
const postCompactStep = {
|
||||
type: 'CORTEX_STEP_TYPE_PLANNER_RESPONSE',
|
||||
status: 'CORTEX_STEP_STATUS_DONE',
|
||||
metadata: {
|
||||
sourceTrajectoryStepInfo: { stepIndex: 3 },
|
||||
createdAt: new Date(start5hMs + 120_000).toISOString(),
|
||||
completedAt: new Date(start5hMs + 135_000).toISOString(),
|
||||
modelUsage: {
|
||||
model: 'MODEL_PLACEHOLDER_M429',
|
||||
inputTokens: '6000',
|
||||
cacheReadTokens: '80000',
|
||||
outputTokens: '2000',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 4. Cold-boot cached conversation initially saved with accountName: '' before email loaded -> included for Alice, while Bob stays excluded
|
||||
const coldBootStep = {
|
||||
type: 'CORTEX_STEP_TYPE_PLANNER_RESPONSE',
|
||||
status: 'CORTEX_STEP_STATUS_DONE',
|
||||
metadata: {
|
||||
sourceTrajectoryStepInfo: { stepIndex: 1 },
|
||||
createdAt: new Date(start5hMs - 40_000).toISOString(),
|
||||
completedAt: new Date(start5hMs + 10_000).toISOString(),
|
||||
modelUsage: {
|
||||
model: 'MODEL_PLACEHOLDER_M429',
|
||||
inputTokens: '10000',
|
||||
cacheReadTokens: '0',
|
||||
outputTokens: '1000',
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
const h = backendHarness({
|
||||
userStatus: { email: 'alice@example.com', userTier: { name: 'Google AI Ultra' } },
|
||||
quotaSummary: {
|
||||
groups: [
|
||||
{
|
||||
displayName: 'Gemini Models',
|
||||
buckets: [
|
||||
{ bucketId: 'gemini-5h', window: '5h', remainingFraction: 0.929, resetTime: reset5hIso },
|
||||
{ bucketId: 'gemini-weekly', window: 'weekly', remainingFraction: 0.395, resetTime: resetWkIso },
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
cache: {
|
||||
'cold-boot-conv': {
|
||||
accountName: '',
|
||||
signature: 'v10-model-identity:cold',
|
||||
steps: extractModelSteps([coldBootStep]),
|
||||
},
|
||||
'bob-conv': {
|
||||
accountName: 'bob@example.com',
|
||||
signature: 'v10-model-identity:bob',
|
||||
steps: extractModelSteps([postCompactStep]),
|
||||
},
|
||||
},
|
||||
summaries: {
|
||||
'main-conv': { stepCount: 3, lastModifiedTime: new Date(nowMs - 10_000).toISOString(), status: 'IDLE' },
|
||||
},
|
||||
trajectories: {
|
||||
'main-conv': { trajectory: { steps: [oldCycleStep, compactOpeningStep, postCompactStep] } },
|
||||
},
|
||||
});
|
||||
|
||||
const payload = await h.buildTelemetryPayloadInternal('main-conv', false, { range: '5h' });
|
||||
const geminiPool = payload.quotas.pools.find((p) => p.poolKey === 'Gemini');
|
||||
// Includes compactOpeningStep (304,000) + postCompactStep (88,000) + coldBootStep (11,000) = 403,000 tokens (3 calls)
|
||||
assert.equal(geminiPool.cycle5h.calls, 3);
|
||||
assert.equal(geminiPool.cycle5h.tokens, 403_000);
|
||||
// Preset 5h account bucket includes Alice's 3 calls (403k) + Bob's 1 call (88k), excluding oldCycleStep (105k)
|
||||
assert.equal(payload.consumption.account.calls, 4);
|
||||
assert.equal(payload.consumption.account.totalTokens, 491_000);
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
DEFAULT_SETTINGS_SCHEMA,
|
||||
normalizeExperimentalModernUi,
|
||||
normalizeFullSettings,
|
||||
normalizeModernUi,
|
||||
} from '../backend/settings-schema.mjs';
|
||||
import {
|
||||
applyAppearanceToRoot,
|
||||
@@ -38,27 +39,44 @@ import { StepsDetailView } from '../src/views/StepsDetailView.js';
|
||||
import { SettingsGeneralTab } from '../src/views/settings/SettingsGeneralTab.js';
|
||||
import { SettingsStructureTab } from '../src/views/settings/SettingsStructureTab.js';
|
||||
|
||||
test('experimentalModernUi schema normalization defaults to false and coerces boolean/string values cleanly', () => {
|
||||
assert.equal(DEFAULT_SETTINGS_SCHEMA.experimentalModernUi, false);
|
||||
test('modernUi schema normalization defaults to true, upgrades 1.5.2 settings without modernUi key to true, and respects explicit false', () => {
|
||||
assert.equal(DEFAULT_SETTINGS_SCHEMA.language, 'auto');
|
||||
assert.equal(DEFAULT_SETTINGS_SCHEMA.modernUi, true);
|
||||
assert.equal(DEFAULT_SETTINGS_SCHEMA.experimentalModernUi, true);
|
||||
assert.equal(normalizeModernUi(undefined), true);
|
||||
assert.equal(normalizeModernUi(false), false);
|
||||
assert.equal(normalizeModernUi('off'), false);
|
||||
assert.equal(normalizeModernUi(true), true);
|
||||
assert.equal(normalizeModernUi('true'), true);
|
||||
assert.equal(normalizeModernUi('on'), true);
|
||||
assert.equal(normalizeExperimentalModernUi(undefined), false);
|
||||
assert.equal(normalizeExperimentalModernUi(false), false);
|
||||
assert.equal(normalizeExperimentalModernUi('off'), false);
|
||||
assert.equal(normalizeExperimentalModernUi(true), true);
|
||||
assert.equal(normalizeExperimentalModernUi('true'), true);
|
||||
assert.equal(normalizeExperimentalModernUi('on'), true);
|
||||
assert.equal(normalizeClientModernUi(undefined), true);
|
||||
assert.equal(normalizeClientModernUi('on'), true);
|
||||
assert.equal(normalizeClientModernUi(false), false);
|
||||
assert.equal(normalizeClientModernUi('off'), false);
|
||||
|
||||
assert.equal(normalizeFullSettings({}).experimentalModernUi, false);
|
||||
assert.equal(normalizeFullSettings({ experimentalModernUi: true }).experimentalModernUi, true);
|
||||
// Fresh 1.5.3 install -> language='auto', modernUi=true
|
||||
assert.equal(normalizeFullSettings({}).language, 'auto');
|
||||
assert.equal(normalizeFullSettings({}).modernUi, true);
|
||||
assert.equal(normalizeFullSettings({}).experimentalModernUi, true);
|
||||
|
||||
// 1.5.2 persisted settings.json (where experimentalModernUi: false was written by default, no modernUi key) -> upgrades to true!
|
||||
const upgradedFrom152 = normalizeFullSettings({ experimentalModernUi: false });
|
||||
assert.equal(upgradedFrom152.modernUi, true);
|
||||
assert.equal(upgradedFrom152.experimentalModernUi, true);
|
||||
|
||||
// Explicit 1.5.3 user opt-out (`modernUi: false`) -> stays false!
|
||||
const explicitOff153 = normalizeFullSettings({ modernUi: false, experimentalModernUi: true });
|
||||
assert.equal(explicitOff153.modernUi, false);
|
||||
assert.equal(explicitOff153.experimentalModernUi, false);
|
||||
|
||||
assert.equal(
|
||||
isEquivalentTelemetry(
|
||||
{ settings: { experimentalModernUi: false } },
|
||||
{ settings: { experimentalModernUi: true } }
|
||||
{ settings: { modernUi: false } },
|
||||
{ settings: { modernUi: true } }
|
||||
),
|
||||
false,
|
||||
'isEquivalentTelemetry must detect experimentalModernUi changes'
|
||||
'isEquivalentTelemetry must detect modernUi changes'
|
||||
);
|
||||
});
|
||||
|
||||
@@ -182,29 +200,41 @@ test('applyAppearanceToRoot and SettingsGeneralTab toggle data-modern-ui + data-
|
||||
assert.equal(document.documentElement.hasAttribute('data-modern-ui'), false);
|
||||
assert.equal(document.documentElement.getAttribute('data-color-scheme'), 'light');
|
||||
|
||||
// 2. SettingsGeneralTab renders '新 UI(实验性)' switch and toggles data-modern-ui immediately
|
||||
// 2. SettingsGeneralTab renders '现代化 UI' (开启 / 关闭) and Language (跟随系统 / 简体中文 / English)
|
||||
tab = SettingsGeneralTab({});
|
||||
document.body.appendChild(tab.el);
|
||||
tab.refs.renderSettings({
|
||||
language: 'zh-CN',
|
||||
language: 'auto',
|
||||
themeAccent: 'host',
|
||||
fontScale: 'md',
|
||||
modernUi: false,
|
||||
experimentalModernUi: false,
|
||||
pluginUpdateMode: 'manual',
|
||||
});
|
||||
|
||||
assert.match(tab.el.textContent, /新 UI(实验性)/);
|
||||
const modernBtns = tab.refs.modernUiSwitch.el.querySelectorAll('.seg-btn');
|
||||
assert.equal(modernBtns.length, 2);
|
||||
assert.equal(modernBtns[0].classList.contains('is-active'), true);
|
||||
assert.match(tab.el.textContent, /现代化 UI/);
|
||||
assert.doesNotMatch(tab.el.textContent, /实验性/);
|
||||
const langSegBtns = tab.refs.languageSwitch.el.querySelectorAll('.seg-btn');
|
||||
assert.deepEqual(
|
||||
langSegBtns.map((b) => b.textContent),
|
||||
['跟随系统', '简体中文', 'English']
|
||||
);
|
||||
assert.equal(langSegBtns[0].classList.contains('is-active'), true);
|
||||
|
||||
// Click '开启' (index 1)
|
||||
modernBtns[1].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
const modernBtns = tab.refs.modernUiSwitch.el.querySelectorAll('.seg-btn');
|
||||
assert.deepEqual(
|
||||
modernBtns.map((b) => b.textContent),
|
||||
['开启', '关闭']
|
||||
);
|
||||
assert.equal(modernBtns[1].classList.contains('is-active'), true);
|
||||
|
||||
// Click '开启' (index 0)
|
||||
modernBtns[0].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 15));
|
||||
|
||||
assert.equal(document.documentElement.getAttribute('data-modern-ui'), 'true');
|
||||
assert.equal(savedPatches.length, 1);
|
||||
assert.equal(savedPatches[0].experimentalModernUi, true);
|
||||
assert.equal(savedPatches[0].modernUi, true);
|
||||
|
||||
// 3. Built styles.css contains modern-ui borderless, sliding glider, and crisp pure-white light-mode rules
|
||||
const builtStyles = fs.readFileSync(new URL('../styles.css', import.meta.url), 'utf8');
|
||||
|
||||
@@ -1234,10 +1234,12 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
capsuleHost.shadowRoot.children.indexOf(capsuleBtn),
|
||||
'Multi-session button sits immediately to the left of telemetry capsule'
|
||||
);
|
||||
assert.equal(capsuleHost.getAttribute('data-modern-ui'), 'true', 'Modern UI enabled out-of-the-box');
|
||||
const readCapVal = (el) => el.getAttribute('data-od-value') ?? el.textContent;
|
||||
assert.equal(multiBtn.querySelector('.svg-icon'), null, 'Multi-session button has zero SVG clutter');
|
||||
assert.equal(multiBtn.classList.contains('is-running'), true);
|
||||
const multiLabelEl = multiBtn.querySelector('.wm-multi-label');
|
||||
assert.equal(multiLabelEl.textContent, '2 运行 · 1 子');
|
||||
assert.equal(readCapVal(multiLabelEl), '2 运行 · 1 子');
|
||||
|
||||
// Verify capsule reactive text (default order: 92.4 t/s without bolt SVG, 0.85s TTFT, 50% context)
|
||||
const defaultCapSlots = capsuleHost.shadowRoot.querySelectorAll('.wm-cap-slot');
|
||||
@@ -1248,9 +1250,9 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
assert.equal(defaultCapSlots[2].getAttribute('data-metric'), 'context');
|
||||
assert.equal(speedSegEl.children.length, 1, 'Speed segment has no lightning bolt SVG');
|
||||
assert.equal(speedSegEl.querySelector('.svg-icon'), null);
|
||||
assert.ok(speedSegEl.children[0].textContent.includes('92.4 t/s'));
|
||||
assert.equal(defaultCapSlots[1].children[0].textContent, '0.85s');
|
||||
assert.equal(ctxPctEl.textContent, '50%');
|
||||
assert.ok(readCapVal(speedSegEl.children[0]).includes('92.4 t/s'));
|
||||
assert.equal(readCapVal(defaultCapSlots[1].children[0]), '0.85s');
|
||||
assert.equal(readCapVal(ctxPctEl), '50%');
|
||||
|
||||
// Verify hovering left multi-session button opens .wm-multi-panel with live tasks, subagents, and recent sessions
|
||||
const multiPanelEl = portalHost.shadowRoot.querySelector('.wm-multi-panel');
|
||||
@@ -1411,22 +1413,28 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
const langBtns = generalSegControls[0].querySelectorAll('.seg-btn');
|
||||
const fontScaleBtns = generalSegControls[1].querySelectorAll('.seg-btn');
|
||||
const modernUiBtns = generalSegControls[2].querySelectorAll('.seg-btn');
|
||||
assert.equal(modernUiBtns.length, 2, 'Experimental Modern UI switch has 关闭 / 开启');
|
||||
assert.equal(modernUiBtns.length, 2, 'Modern UI switch has 开启 / 关闭');
|
||||
assert.equal(modernUiBtns[0].textContent, '开启');
|
||||
assert.equal(modernUiBtns[1].textContent, '关闭');
|
||||
|
||||
modernUiBtns[1].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
assert.equal(mockSettings.modernUi, false);
|
||||
assert.equal(mockSettings.experimentalModernUi, false);
|
||||
assert.equal(portalHost.hasAttribute('data-modern-ui'), false);
|
||||
assert.equal(popoverEl.hasAttribute('data-modern-ui'), false);
|
||||
modernUiBtns[0].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
assert.equal(mockSettings.modernUi, true);
|
||||
assert.equal(mockSettings.experimentalModernUi, true);
|
||||
assert.equal(portalHost.getAttribute('data-modern-ui'), 'true');
|
||||
assert.equal(capsuleHost.getAttribute('data-modern-ui'), 'true');
|
||||
assert.equal(popoverEl.getAttribute('data-modern-ui'), 'true');
|
||||
modernUiBtns[0].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
assert.equal(mockSettings.experimentalModernUi, false);
|
||||
assert.equal(portalHost.hasAttribute('data-modern-ui'), false);
|
||||
assert.equal(popoverEl.hasAttribute('data-modern-ui'), false);
|
||||
assert.equal(langBtns.length, 3, 'Language switch has 简体中文 / English / 跟随宿主');
|
||||
assert.equal(langBtns[0].textContent, '简体中文');
|
||||
assert.equal(langBtns[0].classList.contains('is-active'), true, 'Default language is zh-CN');
|
||||
assert.equal(langBtns.length, 3, 'Language switch has 跟随系统 / 简体中文 / English');
|
||||
assert.equal(langBtns[0].textContent, '跟随系统');
|
||||
assert.equal(langBtns[1].textContent, '简体中文');
|
||||
assert.equal(langBtns[2].textContent, 'English');
|
||||
assert.equal(langBtns[1].classList.contains('is-active'), true, 'mockSettings language zh-CN selects index 1');
|
||||
const generalSelects = generalPane.querySelectorAll('.custom-select');
|
||||
assert.equal(generalSelects.length, 1, 'General tab has Update Mode select');
|
||||
const updateModeSelectEl = generalSelects[0];
|
||||
@@ -1466,8 +1474,8 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
assert.equal(portalHost.getAttribute('data-font-scale'), 'md');
|
||||
assert.equal(popoverEl.getAttribute('data-font-scale'), 'md');
|
||||
|
||||
// Live i18n switch: zh-CN -> en-US -> zh-CN without page reload
|
||||
langBtns[1].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
// Live i18n switch: zh-CN -> en-US (index 2) -> auto (index 0) -> zh-CN (index 1) without page reload
|
||||
langBtns[2].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
assert.equal(mockSettings.language, 'en-US');
|
||||
assert.equal(pillTabs[0].querySelector('.pill-tab-label').textContent, 'Live');
|
||||
@@ -1477,6 +1485,9 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
assert.equal(subNavBtns[2].textContent, 'Other');
|
||||
langBtns[0].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
assert.equal(mockSettings.language, 'auto');
|
||||
langBtns[1].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
assert.equal(mockSettings.language, 'zh-CN');
|
||||
assert.equal(pillTabs[0].querySelector('.pill-tab-label').textContent, '实时监控');
|
||||
assert.equal(subNavBtns[0].textContent, '常规');
|
||||
@@ -1570,10 +1581,15 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
assert.ok(previewCapsuleBar, 'Pane 0 mounts real CapsuleBarWidget preview');
|
||||
assert.equal(previewCapsuleBar.querySelector('.preview-win-controls'), null, 'No redundant 3 window dots after capsule');
|
||||
assert.equal(previewCapsuleSlots.length, 5, 'Preview CapsuleBarWidget mounts real 5 capsule slots');
|
||||
assert.equal(previewCapsuleSlots[0].children[0].textContent, '68.4 t/s', 'Preview slot 0 renders simulated speed');
|
||||
assert.equal(readCapVal(previewCapsuleSlots[0].children[0]), '68.4 t/s', 'Preview slot 0 renders simulated speed');
|
||||
assert.equal(previewCapsuleSlots[0].classList.contains('tone-good'), true, 'Preview capsule 68.4 t/s shares tone-good green with cards');
|
||||
assert.equal(previewCapsuleSlots[1].children[0].textContent, '1.1s', 'Preview slot 1 renders simulated TTFT');
|
||||
assert.equal(previewCapsuleSlots[2].querySelector('.wm-ctx-pct').textContent, '56%', 'Preview slot 2 renders simulated context %');
|
||||
assert.equal(readCapVal(previewCapsuleSlots[1].children[0]), '1.1s', 'Preview slot 1 renders simulated TTFT');
|
||||
assert.equal(readCapVal(previewCapsuleSlots[2].querySelector('.wm-ctx-pct')), '56%', 'Preview slot 2 renders simulated context %');
|
||||
assert.deepEqual(
|
||||
previewCapsuleBar.querySelectorAll('.preview-composer-chip').map((c) => c.textContent.trim()),
|
||||
['Carbon (High)'],
|
||||
'Composer preview bar shows only Carbon (High) chip without Auto'
|
||||
);
|
||||
const mountSelectEl = sec0.querySelectorAll('.custom-select')[0];
|
||||
|
||||
// Toggle windowMountSelect: dual -> composer -> sidebar -> dual (updating both live host & preview bar)
|
||||
@@ -1664,26 +1680,26 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
capRowSelects[0].querySelectorAll('.select-option')[9].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
assert.equal(capSlots[0].getAttribute('data-metric'), 'gemini_5h');
|
||||
assert.equal(capSlots[0].children[0].textContent, '余 44%');
|
||||
assert.equal(readCapVal(capSlots[0].children[0]), '余 44%');
|
||||
assert.equal(previewCapsuleSlots[0].getAttribute('data-metric'), 'gemini_5h', 'Preview slot 0 mirrors gemini_5h');
|
||||
assert.equal(previewCapsuleSlots[0].children[0].textContent, '余 64%', 'Preview slot 0 renders simulated gemini_5h');
|
||||
assert.equal(readCapVal(previewCapsuleSlots[0].children[0]), '余 64%', 'Preview slot 0 renders simulated gemini_5h');
|
||||
assert.equal(capSlots[1].getAttribute('data-metric'), 'ttft');
|
||||
assert.equal(capSlots[1].children[0].textContent, '0.85s');
|
||||
assert.equal(readCapVal(capSlots[1].children[0]), '0.85s');
|
||||
|
||||
capRowSelects[2].querySelector('.select-trigger').dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
capRowSelects[2].querySelectorAll('.select-option')[4].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
assert.equal(capSlots[2].getAttribute('data-metric'), 'cost');
|
||||
assert.equal(capSlots[2].children.length, 1, 'Ring SVG detached cleanly when slot leaves context');
|
||||
assert.equal(capSlots[2].children[0].textContent, '$0.040');
|
||||
assert.equal(readCapVal(capSlots[2].children[0]), '$0.040');
|
||||
assert.deepEqual(mockSettings.topbarCapsuleSlots, ['gemini_5h', 'ttft', 'cost']);
|
||||
|
||||
// Move Row 1 up (left): each row has [up, down, remove], so Row 1 up is index 3
|
||||
capSlotWrap.querySelectorAll('.slot-move-btn')[3].dispatchEvent({ type: 'click', stopPropagation() {} });
|
||||
await new Promise((r) => setTimeout(r, 30));
|
||||
assert.deepEqual(mockSettings.topbarCapsuleSlots, ['ttft', 'gemini_5h', 'cost']);
|
||||
assert.equal(capSlots[0].children[0].textContent, '0.85s');
|
||||
assert.equal(capSlots[1].children[0].textContent, '余 44%');
|
||||
assert.equal(readCapVal(capSlots[0].children[0]), '0.85s');
|
||||
assert.equal(readCapVal(capSlots[1].children[0]), '余 44%');
|
||||
|
||||
// Mouse drag-and-drop reorder: drag Row 0 ('ttft') down below Row 2 ('cost') -> ['gemini_5h', 'cost', 'ttft']
|
||||
const capSlotListEl = capSlotWrap.querySelector('.editable-slot-list');
|
||||
@@ -1755,7 +1771,7 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
assert.equal(capSlots[1].getAttribute('data-metric'), 'ttft');
|
||||
assert.equal(capSlots[2].getAttribute('data-metric'), 'context');
|
||||
assert.equal(capSlots[2].children.length, 2, 'Ring SVG re-attached on Slot 2');
|
||||
assert.equal(capSlots[2].querySelector('.wm-ctx-pct').textContent, '50%');
|
||||
assert.equal(readCapVal(capSlots[2].querySelector('.wm-ctx-pct')), '50%');
|
||||
|
||||
// Pane 1 (3rd-level tab 'hover'): Hover Popup Modules (0..4) + real hover UI preview
|
||||
const sec1 = accordionSections[1];
|
||||
@@ -2644,13 +2660,13 @@ test('Compiled app.js mounts dual Shadow DOM hosts, tracks /c/<uuid> routes, pro
|
||||
assert.equal(delivered, 1);
|
||||
await new Promise((r) => setTimeout(r, 20));
|
||||
assert.equal(
|
||||
defaultCapSlots[2].querySelector('.wm-ctx-pct').textContent,
|
||||
readCapVal(defaultCapSlots[2].querySelector('.wm-ctx-pct')),
|
||||
'25%',
|
||||
'CDP relay delivered live telemetry without HTTP'
|
||||
);
|
||||
assert.equal(defaultCapSlots[0].children[0].textContent, '121 t/s');
|
||||
assert.equal(readCapVal(defaultCapSlots[0].children[0]), '121 t/s');
|
||||
assert.equal(defaultCapSlots[1].hasAttribute('hidden'), false, 'TTFT slot stays pre-reserved even when latestTtftSec is absent');
|
||||
assert.equal(defaultCapSlots[1].children[0].textContent, '--s');
|
||||
assert.equal(readCapVal(defaultCapSlots[1].children[0]), '--s');
|
||||
assert.equal(
|
||||
hoverLegendGrid.children[0],
|
||||
firstLegendSlotBefore,
|
||||
|
||||
Reference in New Issue
Block a user