import assert from "node:assert/strict";
import { test } from "vitest";
import { handleAutonomousCommand } from "../commands/handlers/autonomous.js";

function makeCtx() {
	const notifications = [];
	return {
		ctx: {
			ui: {
				notify(message, level = "info") {
					notifications.push({ message, level });
				},
			},
		},
		notifications,
	};
}

test("handleAutonomousCommand_when_unsupported_argument_requested_reports_error", async () => {
	const { ctx, notifications } = makeCtx();

	const handled = await handleAutonomousCommand("autonomous --turbo", ctx, {});

	assert.equal(handled, true);
	assert.equal(notifications.length, 1);
	assert.equal(notifications[0].level, "error");
	assert.match(notifications[0].message, /Unsupported \/autonomous argument/);
	assert.match(notifications[0].message, /--turbo/);
});
