import assert from "node:assert/strict";
import { describe, test } from 'vitest';

import { parseHeadlessUnitNotification } from "../../../../headless.ts";

describe("headless unit notification parsing", () => {
	test("parses hyphenated unit start notifications", () => {
		assert.deepEqual(
			parseHeadlessUnitNotification("[unit] execute-task M003/S01/T03 starting"),
			{
				kind: "start",
				unitType: "execute-task",
				unitId: "M003/S01/T03",
			},
		);
	});

	test("parses hyphenated unit end notifications", () => {
		assert.deepEqual(
			parseHeadlessUnitNotification(
				"[unit] execute-task M003/S01/T03 ended -> success",
			),
			{
				kind: "end",
				unitType: "execute-task",
				unitId: "M003/S01/T03",
				verdict: "success",
			},
		);
	});

	test("ignores non-unit notifications", () => {
		assert.equal(parseHeadlessUnitNotification("Auto-mode stopped."), null);
	});
});
