Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions e2e/binance-orderbook/specs/control-flows.pw.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,48 @@ test('a precision shortcut selects the exact native orderbook option once', asyn
expect(errors).toEqual([]);
});

test('precision refresh uses the visible latest trades immediately without a sampling wait', async ({ page }) => {
const scenario = createCancelScenario({
ui: { orderbookPrecision: '0.1' },
});
const { errors } = await openUserscriptScenario(page, scenario);
const panel = page.locator(PANEL_SELECTOR);
const refresh = panel.locator('[data-orderbook-precision-refresh]');

await expect(refresh).toBeEnabled({ timeout: 8_000 });
await installInteractionProbe(page, '[data-orderbook-precision-refresh]');
await refresh.click();
await expect(refresh).toBeEnabled();
await expect(panel.locator('[data-orderbook-precision-value="0.01"]'))
.toHaveAttribute('aria-label', '切换价格精度到 0.01,推荐档位');
const probe = await finishInteractionProbe(page);
assertResponsiveInteraction(expect, probe);
expect(await page.evaluate((symbol) => JSON.parse(
localStorage.getItem(`jh_binance_orderbook_precision_samples_v3:${symbol}`)
), scenario.currentSymbol)).toEqual(['0.01', '0.01', '0.01', '0.01', '0.01']);
expect(errors).toEqual([]);
});

test('precision refresh explains when the complete visible trade list still lacks movement', async ({ page }) => {
const scenario = createCancelScenario({
ui: { orderbookPrecision: '0.1' },
});
const { errors } = await openUserscriptScenario(page, scenario);
const panel = page.locator(PANEL_SELECTOR);
await page.locator('.tradew-tradelist .price.emit-price').evaluateAll((nodes) => {
nodes.forEach((node) => { node.textContent = '81.00'; });
});

await panel.locator('[data-orderbook-precision-refresh]').click();
await expect(panel.locator('#jh-binance-ladder-status'))
.toHaveText('近期价格变化不足,请稍后重试');
await expect(panel.locator('[aria-label*="推荐档位"]')).toHaveCount(0);
expect(await page.evaluate((symbol) => JSON.parse(
localStorage.getItem(`jh_binance_orderbook_precision_samples_v3:${symbol}`)
), scenario.currentSymbol)).toEqual([]);
expect(errors).toEqual([]);
});

test('starting a ladder disables every start action and exposes one stop control', async ({ page }) => {
const scenario = createCancelScenario({
ui: { tradeMode: 'OPEN', orderbookPrecision: '0.1' },
Expand Down
23 changes: 23 additions & 0 deletions e2e/binance-orderbook/specs/panel-visual-contract.pw.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,33 @@ async function expectVisualContract(page, name) {
expect(`${JSON.stringify(contract, null, 2)}\n`).toMatchSnapshot(name);
}

async function expectNativeDivider(page) {
const divider = await page.locator(PANEL_SELECTOR).evaluate((panel) => {
const panelRect = panel.getBoundingClientRect();
const ladder = panel.querySelector('[data-panel-group="ladder"]');
const ladderRect = ladder.getBoundingClientRect();
const style = getComputedStyle(ladder);
return {
leftInset: ladderRect.left - panelRect.left,
rightInset: panelRect.right - ladderRect.right,
borderTopWidth: style.borderTopWidth,
borderTopColor: style.borderTopColor,
};
});
expect(divider).toEqual({
leftInset: 1,
rightInset: 1,
borderTopWidth: '1px',
borderTopColor: 'rgb(237, 237, 237)',
});
}

test('open panel matches the fixed visual contract', async ({ page }) => {
await openUserscriptScenario(page, createCancelScenario({
ui: { tradeMode: 'OPEN' },
}));
await expectPrecisionReady(page);
await expectNativeDivider(page);
await expectVisualContract(page, 'open-fixed.visual.json');
});

Expand All @@ -36,5 +58,6 @@ test('close panel matches the disabled-state visual contract', async ({ page })
await expect(panel.getByRole('radio', { name: '平多' })).toBeEnabled();
await expect(panel.getByRole('radio', { name: '平空' })).toBeDisabled();
await expectPrecisionReady(page);
await expectNativeDivider(page);
await expectVisualContract(page, 'close-fixed.visual.json');
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"ladder": {
"rect": {
"top": 135,
"width": 292,
"width": 312,
"height": 263
},
"display": "block",
Expand Down Expand Up @@ -157,7 +157,7 @@
"pressed": null,
"rect": {
"top": 177,
"width": 44.8,
"width": 47.2,
"height": 28
},
"style": {
Expand All @@ -178,7 +178,7 @@
"pressed": null,
"rect": {
"top": 177,
"width": 44.8,
"width": 47.2,
"height": 28
},
"style": {
Expand All @@ -199,7 +199,7 @@
"pressed": null,
"rect": {
"top": 177,
"width": 44.8,
"width": 47.2,
"height": 28
},
"style": {
Expand All @@ -220,7 +220,7 @@
"pressed": null,
"rect": {
"top": 177,
"width": 44.8,
"width": 47.2,
"height": 28
},
"style": {
Expand All @@ -241,7 +241,7 @@
"pressed": null,
"rect": {
"top": 177,
"width": 44.8,
"width": 47.2,
"height": 28
},
"style": {
Expand All @@ -262,7 +262,7 @@
"pressed": null,
"rect": {
"top": 217,
"width": 44.8,
"width": 47.2,
"height": 28
},
"style": {
Expand All @@ -283,7 +283,7 @@
"pressed": null,
"rect": {
"top": 217,
"width": 44.8,
"width": 47.2,
"height": 28
},
"style": {
Expand All @@ -304,7 +304,7 @@
"pressed": null,
"rect": {
"top": 217,
"width": 44.8,
"width": 47.2,
"height": 28
},
"style": {
Expand All @@ -325,7 +325,7 @@
"pressed": null,
"rect": {
"top": 217,
"width": 44.8,
"width": 47.2,
"height": 28
},
"style": {
Expand All @@ -346,7 +346,7 @@
"pressed": null,
"rect": {
"top": 257,
"width": 44.8,
"width": 47.2,
"height": 28
},
"style": {
Expand All @@ -367,7 +367,7 @@
"pressed": null,
"rect": {
"top": 257,
"width": 44.8,
"width": 47.2,
"height": 28
},
"style": {
Expand All @@ -388,7 +388,7 @@
"pressed": null,
"rect": {
"top": 257,
"width": 44.8,
"width": 47.2,
"height": 28
},
"style": {
Expand All @@ -409,7 +409,7 @@
"pressed": null,
"rect": {
"top": 257,
"width": 44.8,
"width": 47.2,
"height": 28
},
"style": {
Expand All @@ -430,7 +430,7 @@
"pressed": null,
"rect": {
"top": 257,
"width": 44.8,
"width": 47.2,
"height": 28
},
"style": {
Expand All @@ -451,7 +451,7 @@
"pressed": "false",
"rect": {
"top": 298,
"width": 44.5,
"width": 51,
"height": 32
},
"style": {
Expand All @@ -472,7 +472,7 @@
"pressed": "false",
"rect": {
"top": 298,
"width": 44.5,
"width": 51,
"height": 32
},
"style": {
Expand All @@ -493,7 +493,7 @@
"pressed": "true",
"rect": {
"top": 298,
"width": 44.5,
"width": 51,
"height": 32
},
"style": {
Expand All @@ -514,7 +514,7 @@
"pressed": "false",
"rect": {
"top": 298,
"width": 44.5,
"width": 51,
"height": 32
},
"style": {
Expand Down Expand Up @@ -594,7 +594,7 @@
"text": {
"mode": "单击订单簿时",
"formula": "0.01 × 1 =0.01",
"precision": "价格精度0.0010.010.11",
"precision": "精度0.0010.010.11",
"status": "空闲"
}
}
Loading
Loading