Files
adminandClaude Opus 5.5 2aa635f453 Keep an output's name readable beside a long inline value (#306)
An input and an output in the same port row were cut to fit each on
its own. The input text could reach x = 123 and the output label could
start at x = 83, so a long inline value ran under the output's name.
At Animation playing a long animation name covered "progress".

- The output label is placed first and keeps its room. The input text
  is cut with an ellipsis 6 px before it, as decided in the issue.
- The rule is a pure function in src/editor/graph/portRow.ts. A row
  without an output keeps the input's old limit of 108 px.
- The value a run shows beside an output uses the same rule. Its left
  edge can no longer lie right of its right edge.
- New test hook __gm.graph.rowSpans(nodeId) gives each row's input
  and output text as cut and placed, in node units.
- NODE_WIDTH stays as it is, as decided in the issue.

Tests:
- Gate: 230 files, 3520 tests (6 new in port-row.test.ts).
- e2e 6: all passed, 149 checks (148 + 1).
- Counter-check: with the rule switched off, the input text reaches
  x = 121.4 under "progress" at x = 114.1, and the new check fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-03 18:33:06 +02:00

32 lines
1.1 KiB
TypeScript

import { describe, expect, it } from 'vitest';
import { inputTextRoom, ROW_GAP, valueSpan } from '../../src/editor/graph/portRow';
describe('the input text of a port row', () => {
it('keeps its own limit while the output label leaves room for it', () => {
expect(inputTextRoom(15, 108, 140)).toBe(108);
});
it('gives way before the output label, keeping the gap', () => {
expect(inputTextRoom(15, 108, 100)).toBe(100 - ROW_GAP - 15);
});
it('keeps its full limit on a row without an output', () => {
expect(inputTextRoom(15, 108, null)).toBe(108);
});
it('gets no room at all rather than a negative one', () => {
expect(inputTextRoom(15, 108, 10)).toBe(0);
});
});
describe('the value a run shows beside an output', () => {
it('sits between the input text and the output label', () => {
expect(valueSpan(60, 120)).toEqual({ left: 60 + ROW_GAP, right: 120 - ROW_GAP });
});
it('never starts right of where it has to end', () => {
const span = valueSpan(110, 116);
expect(span.left).toBeLessThanOrEqual(span.right);
});
});