Tabs are open documents: Scene, Game and Plugins stay as fixed tabs, every other asset opens in its own tab (double click or Enter in the asset panel, on creation, from the list button), several assets of one kind can be open at once, a tab is labelled with its kind dimmed before the name, cut at 160 px and renamed with its asset, closes with its x or a middle click and goes away when its asset is deleted; a tab always shows its own document instead of following the selection, the picker in the tab head is gone, zoom and scroll are kept per document for the session and dropped on close, a double click on a call node stays in the same tab with breadcrumbs per tab; one editor per kind is switched between documents, the placement rules live in the pure module documents.ts, and the test hook showTab stays as a compatibility path; new e2e module 44 documents (#171)
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4f546c0e08
commit
cc285af10a
33 files changed
+895
-225
No files matched your search
@@ -0,0 +1,65 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { closeDocument, openDocument, replaceDocument } from '../../src/editor/documents';
|
||||
import { tabRowLayout } from '../../src/editor/tabRow';
|
||||
|
||||
const row = (docs: string[], active: string | null) => ({ docs, active });
|
||||
|
||||
describe('open documents', () => {
|
||||
it('puts a new document right of the one showing', () => {
|
||||
expect(openDocument(row(['a', 'b', 'c'], 'a'), 'x')).toEqual(row(['a', 'x', 'b', 'c'], 'x'));
|
||||
});
|
||||
|
||||
it('puts it last while a fixed tab is showing', () => {
|
||||
expect(openDocument(row(['a', 'b'], null), 'x')).toEqual(row(['a', 'b', 'x'], 'x'));
|
||||
expect(openDocument(row([], null), 'x')).toEqual(row(['x'], 'x'));
|
||||
});
|
||||
|
||||
it('only brings an open document up – one tab per document', () => {
|
||||
expect(openDocument(row(['a', 'b', 'c'], 'c'), 'a')).toEqual(row(['a', 'b', 'c'], 'a'));
|
||||
});
|
||||
|
||||
it('shows the left neighbour after the one showing closes', () => {
|
||||
expect(closeDocument(row(['a', 'b', 'c'], 'b'), 'b')).toEqual(row(['a', 'c'], 'a'));
|
||||
});
|
||||
|
||||
it('shows the right one when the first closes, and nothing when the last goes', () => {
|
||||
expect(closeDocument(row(['a', 'b'], 'a'), 'a')).toEqual(row(['b'], 'b'));
|
||||
expect(closeDocument(row(['a'], 'a'), 'a')).toEqual(row([], null));
|
||||
});
|
||||
|
||||
it('keeps what is showing when another tab closes', () => {
|
||||
expect(closeDocument(row(['a', 'b', 'c'], 'c'), 'a')).toEqual(row(['b', 'c'], 'c'));
|
||||
expect(closeDocument(row(['a', 'b'], null), 'b')).toEqual(row(['a'], null));
|
||||
});
|
||||
|
||||
it('ignores a document that is not open', () => {
|
||||
const before = row(['a'], 'a');
|
||||
expect(closeDocument(before, 'x')).toBe(before);
|
||||
});
|
||||
|
||||
it('lets a tab go on to another document in its place', () => {
|
||||
expect(replaceDocument(row(['a', 'b', 'c'], 'b'), 'b', 'x')).toEqual(row(['a', 'x', 'c'], 'x'));
|
||||
});
|
||||
|
||||
it('drops the other tab of a document it goes on to', () => {
|
||||
expect(replaceDocument(row(['a', 'b', 'c'], 'a'), 'a', 'c')).toEqual(row(['c', 'b'], 'c'));
|
||||
});
|
||||
|
||||
it('leaves the row alone for a tab that is not open', () => {
|
||||
const before = row(['a'], 'a');
|
||||
expect(replaceDocument(before, 'x', 'y')).toBe(before);
|
||||
expect(replaceDocument(before, 'a', 'a')).toBe(before);
|
||||
});
|
||||
});
|
||||
|
||||
describe('tab row without an active tab', () => {
|
||||
it('fills the row in order when a kind with no document is showing', () => {
|
||||
const tabs = [
|
||||
{ key: 'a', width: 50 },
|
||||
{ key: 'b', width: 50 },
|
||||
{ key: 'c', width: 50 },
|
||||
];
|
||||
const layout = tabRowLayout({ tabs, available: 132, gap: 2, overflowWidth: 28, active: null });
|
||||
expect(layout).toEqual({ shown: ['a', 'b'], hidden: ['c'] });
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user