import { describe, it, expect } from 'vitest';
import { ActionCategory, BuiltInActionId } from '../core/action-types';
import type { ActionDefinition } from '../core/action-types';

describe('action-types enums', () => {
	describe('ActionCategory', () => {
		it('has all expected categories', () => {
			expect(ActionCategory.None).toBe('none');
			expect(ActionCategory.Selection).toBe('selection');
			expect(ActionCategory.Viewport).toBe('viewport');
			expect(ActionCategory.Node).toBe('node');
			expect(ActionCategory.Layout).toBe('layout');
			expect(ActionCategory.History).toBe('history');
			expect(ActionCategory.Custom).toBe('custom');
		});

		it('has 7 unique values', () => {
			const values = Object.values(ActionCategory);
			expect(new Set(values).size).toBe(7);
		});
	});

	describe('BuiltInActionId', () => {
		it('has unique values', () => {
			const values = Object.values(BuiltInActionId);
			expect(new Set(values).size).toBe(values.length);
		});

		it('includes all selection actions', () => {
			expect(BuiltInActionId.SelectNode).toBe('select-node');
			expect(BuiltInActionId.SelectEdge).toBe('select-edge');
			expect(BuiltInActionId.AddToSelection).toBe('add-to-selection');
			expect(BuiltInActionId.ClearSelection).toBe('clear-selection');
			expect(BuiltInActionId.DeleteSelected).toBe('delete-selected');
		});

		it('includes all viewport actions', () => {
			expect(BuiltInActionId.FitToView).toBe('fit-to-view');
			expect(BuiltInActionId.ResetViewport).toBe('reset-viewport');
		});

		it('includes node operations', () => {
			expect(BuiltInActionId.LockNode).toBe('lock-node');
			expect(BuiltInActionId.SplitNode).toBe('split-node');
			expect(BuiltInActionId.GroupNodes).toBe('group-nodes');
			expect(BuiltInActionId.MergeNodes).toBe('merge-nodes');
		});

		it('includes history actions', () => {
			expect(BuiltInActionId.Undo).toBe('undo');
			expect(BuiltInActionId.Redo).toBe('redo');
		});

		it('has CreateNode', () => {
			expect(BuiltInActionId.CreateNode).toBe('create-node');
		});
	});

	describe('ActionDefinition shape', () => {
		it('accepts a valid action definition', () => {
			const action: ActionDefinition = {
				id: 'test-action',
				label: 'Test',
				description: 'A test action',
				category: ActionCategory.Custom,
				handler: () => {},
			};
			expect(action.id).toBe('test-action');
		});
	});
});
