/**
 * Agent pane tests — prompt input, send button, message area, status strip.
 */

describe("Agent pane", () => {
  it("should show the prompt input area", async () => {
    const input = await $(".chat-input");
    if (await input.isExisting()) {
      expect(await input.isDisplayed()).toBe(true);
    }
  });

  it("should show the send button", async () => {
    const sendBtn = await $(".send-btn");
    if (await sendBtn.isExisting()) {
      expect(await sendBtn.isDisplayed()).toBe(true);
    }
  });

  it("should show the message area", async () => {
    const msgArea = await $(".agent-messages");
    if (await msgArea.isExisting()) {
      expect(await msgArea.isDisplayed()).toBe(true);
    }
  });

  it("should show the status strip", async () => {
    const statusStrip = await $(".agent-status");
    if (await statusStrip.isExisting()) {
      expect(await statusStrip.isDisplayed()).toBe(true);
    }
  });

  it("should show idle status by default", async () => {
    const statusText = await $(".agent-status .status-text");
    if (await statusText.isExisting()) {
      const text = await statusText.getText();
      expect(text.toLowerCase()).toContain("idle");
    }
  });

  it("should accept text in the prompt input", async () => {
    const input = await $(".chat-input textarea");
    if (!(await input.isExisting())) {
      const altInput = await $(".chat-input input");
      if (await altInput.isExisting()) {
        await altInput.setValue("test prompt");
        const value = await altInput.getValue();
        expect(value).toContain("test");
      }
      return;
    }

    await input.setValue("test prompt");
    const value = await input.getValue();
    expect(value).toContain("test");
  });

  it("should show provider indicator", async () => {
    const provider = await $(".provider-badge");
    if (await provider.isExisting()) {
      const text = await provider.getText();
      expect(text.length).toBeGreaterThan(0);
    }
  });

  it("should show cost display", async () => {
    const cost = await $(".agent-cost");
    if (await cost.isExisting()) {
      expect(await cost.isDisplayed()).toBe(true);
    }
  });

  it("should show model selector or label", async () => {
    const model = await $(".model-label");
    if (await model.isExisting()) {
      expect(await model.isDisplayed()).toBe(true);
    }
  });
});
