style(editor): biome 格式化 runnable 模态框代码
biome check --write 修正 import 排序 + 格式化 openRunnableModal 链式调用 (TDD 阶段子代理未跑 make fix,此处补齐以过 make lint)。
This commit is contained in:
parent
01ceef2694
commit
9b4c0ea36e
@ -1,5 +1,5 @@
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import type { Editor } from '@tiptap/core';
|
||||
import { afterEach, describe, expect, it, vi } from 'vitest';
|
||||
import { openRunnableModal } from '../slash-command';
|
||||
|
||||
/**
|
||||
@ -54,10 +54,14 @@ describe('openRunnableModal', () => {
|
||||
timeoutInput.value = '10';
|
||||
timeoutInput.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
// 点插入
|
||||
const insertBtn = document.querySelector<HTMLButtonElement>('.tiptap-runnable-actions .insert')!;
|
||||
const insertBtn = document.querySelector<HTMLButtonElement>(
|
||||
'.tiptap-runnable-actions .insert',
|
||||
)!;
|
||||
insertBtn.click();
|
||||
expect(calls).toHaveLength(1);
|
||||
expect(calls[0].language).toBe('python runnable {"timeout_secs":10,"memory_mb":256,"allow_network":false}');
|
||||
expect(calls[0].language).toBe(
|
||||
'python runnable {"timeout_secs":10,"memory_mb":256,"allow_network":false}',
|
||||
);
|
||||
expect(document.querySelector('.tiptap-runnable-modal')).toBeNull();
|
||||
});
|
||||
|
||||
@ -74,7 +78,9 @@ describe('openRunnableModal', () => {
|
||||
const timeoutInput = document.querySelector<HTMLInputElement>('#runnable-timeout')!;
|
||||
timeoutInput.value = '0';
|
||||
timeoutInput.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
const insertBtn = document.querySelector<HTMLButtonElement>('.tiptap-runnable-actions .insert')!;
|
||||
const insertBtn = document.querySelector<HTMLButtonElement>(
|
||||
'.tiptap-runnable-actions .insert',
|
||||
)!;
|
||||
expect(insertBtn.disabled).toBe(true);
|
||||
// 且点插入(即使强制)不应触发——实际 disabled 按钮不接收 click,这里只验状态
|
||||
insertBtn.click();
|
||||
@ -85,7 +91,9 @@ describe('openRunnableModal', () => {
|
||||
const { editor } = mockEditor();
|
||||
openRunnableModal(editor);
|
||||
const timeoutInput = document.querySelector<HTMLInputElement>('#runnable-timeout')!;
|
||||
const insertBtn = document.querySelector<HTMLButtonElement>('.tiptap-runnable-actions .insert')!;
|
||||
const insertBtn = document.querySelector<HTMLButtonElement>(
|
||||
'.tiptap-runnable-actions .insert',
|
||||
)!;
|
||||
timeoutInput.value = '0';
|
||||
timeoutInput.dispatchEvent(new Event('input', { bubbles: true }));
|
||||
expect(insertBtn.disabled).toBe(true);
|
||||
|
||||
@ -552,11 +552,19 @@ export function openRunnableModal(editor: Editor): void {
|
||||
function updateInsertEnabled(): void {
|
||||
const t = Number(timeoutInput.value);
|
||||
const m = Number(memInput.value);
|
||||
insertBtn.disabled = !(t >= TIMEOUT_RANGE.min && t <= TIMEOUT_RANGE.max && m >= MEMORY_RANGE.min && m <= MEMORY_RANGE.max);
|
||||
insertBtn.disabled = !(
|
||||
t >= TIMEOUT_RANGE.min &&
|
||||
t <= TIMEOUT_RANGE.max &&
|
||||
m >= MEMORY_RANGE.min &&
|
||||
m <= MEMORY_RANGE.max
|
||||
);
|
||||
}
|
||||
|
||||
function insert(): void {
|
||||
editor.chain().setCodeBlock({ language: buildRunnableInfo(state) }).run();
|
||||
editor
|
||||
.chain()
|
||||
.setCodeBlock({ language: buildRunnableInfo(state) })
|
||||
.run();
|
||||
close();
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user