feat: enable Telegram features on binding
This commit is contained in:
+2
-23
@@ -1026,28 +1026,7 @@ function Telegram() {
|
||||
}
|
||||
/>
|
||||
</label>
|
||||
<div className="checks">
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={v.enabled}
|
||||
onChange={(e) => setV({ ...v, enabled: e.target.checked })}
|
||||
/>
|
||||
启用提醒
|
||||
</label>
|
||||
<label>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={v.menuEnabled}
|
||||
onChange={(e) => setV({ ...v, menuEnabled: e.target.checked })}
|
||||
/>
|
||||
启用查询菜单
|
||||
</label>
|
||||
</div>
|
||||
<p className="hint telegram-switch-hint">
|
||||
“启用提醒”只控制自动额度提醒,关闭后仍可发送测试消息;“启用查询菜单”关闭后将停止查询并移除
|
||||
Telegram 键盘。
|
||||
</p>
|
||||
<p className="hint">Bot 绑定后会自动启用额度提醒和查询菜单。</p>
|
||||
<button>验证并保存</button>
|
||||
<div className="actions">
|
||||
<button
|
||||
@@ -1085,7 +1064,7 @@ function Telegram() {
|
||||
onClick={async () => {
|
||||
if (
|
||||
!confirm(
|
||||
"确定要解除 Telegram Bot 绑定吗?这会删除 Bot Token、Chat ID、开关和未使用的绑定码。",
|
||||
"确定要解除 Telegram Bot 绑定吗?这会删除 Bot Token、Chat ID 和未使用的绑定码。",
|
||||
)
|
||||
)
|
||||
return;
|
||||
|
||||
@@ -478,11 +478,6 @@ header p {
|
||||
.checks input {
|
||||
width: auto;
|
||||
}
|
||||
.telegram-switch-hint {
|
||||
margin: -8px 0 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
}
|
||||
.actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
|
||||
@@ -139,7 +139,7 @@ test("shows the GitHub link after login", async ({ page }) => {
|
||||
);
|
||||
});
|
||||
|
||||
test("saves disabled Telegram switches and removes the configuration", async ({
|
||||
test("automatically enables Telegram features and removes the configuration", async ({
|
||||
page,
|
||||
}) => {
|
||||
let savedBody: Record<string, unknown> | undefined;
|
||||
@@ -162,11 +162,14 @@ test("saves disabled Telegram switches and removes the configuration", async ({
|
||||
page.on("dialog", (dialog) => dialog.accept());
|
||||
await page.goto("/settings");
|
||||
await page.getByRole("tab", { name: "Telegram" }).click();
|
||||
await page.getByLabel("启用提醒").uncheck();
|
||||
await page.getByLabel("启用查询菜单").uncheck();
|
||||
await expect(page.getByLabel("启用提醒")).toHaveCount(0);
|
||||
await expect(page.getByLabel("启用查询菜单")).toHaveCount(0);
|
||||
await expect(
|
||||
page.getByText("Bot 绑定后会自动启用额度提醒和查询菜单。"),
|
||||
).toBeVisible();
|
||||
await page.getByRole("button", { name: "验证并保存" }).click();
|
||||
await expect.poll(() => savedBody?.enabled).toBe(false);
|
||||
expect(savedBody?.menuEnabled).toBe(false);
|
||||
await expect.poll(() => savedBody?.enabled).toBe(true);
|
||||
expect(savedBody?.menuEnabled).toBe(true);
|
||||
|
||||
await page.getByRole("button", { name: "解除绑定" }).click();
|
||||
await expect.poll(() => deleted).toBe(true);
|
||||
|
||||
Reference in New Issue
Block a user