import { describe, it, expect } from 'vitest';
import { getAction, getAllActions } from '../core/action-registry';
import { BuiltInActionId, ActionCategory } from '../core/settings-types';

// Built-in actions are auto-registered when action-registry is imported.
// We test that the actions from actions-node.ts were registered correctly.

describe('actions-node (registered)', () => {
	describe('selection actions', () => {
		it('SelectNode is registered with correct category', () => {
			const action = getAction(BuiltInActionId.SelectNode);
			expect(action).toBeDefined();
			expect(action!.category).toBe(ActionCategory.Selection);
			expect(action!.requiresNode).toBe(true);
		});

		it('SelectEdge is registered', () => {
			expect(getAction(BuiltInActionId.SelectEdge)).toBeDefined();
		});

		it('AddToSelection is registered', () => {
			expect(getAction(BuiltInActionId.AddToSelection)).toBeDefined();
		});

		it('ClearSelection and DeleteSelected are registered', () => {
			expect(getAction(BuiltInActionId.ClearSelection)).toBeDefined();
			expect(getAction(BuiltInActionId.DeleteSelected)).toBeDefined();
		});
	});

	describe('node actions', () => {
		it('LockNode, UnlockNode, ToggleLock are registered', () => {
			expect(getAction(BuiltInActionId.LockNode)).toBeDefined();
			expect(getAction(BuiltInActionId.UnlockNode)).toBeDefined();
			expect(getAction(BuiltInActionId.ToggleLock)).toBeDefined();
		});

		it('CreateNode is registered with Node category', () => {
			const action = getAction(BuiltInActionId.CreateNode);
			expect(action).toBeDefined();
			expect(action!.category).toBe(ActionCategory.Node);
		});

		it('all node actions are built-in', () => {
			for (const id of [BuiltInActionId.LockNode, BuiltInActionId.UnlockNode, BuiltInActionId.CreateNode]) {
				expect(getAction(id)!.isBuiltIn).toBe(true);
			}
		});

		it('SplitNode, GroupNodes, MergeNodes are registered', () => {
			expect(getAction(BuiltInActionId.SplitNode)).toBeDefined();
			expect(getAction(BuiltInActionId.GroupNodes)).toBeDefined();
			expect(getAction(BuiltInActionId.MergeNodes)).toBeDefined();
		});
	});
});
