// The Lucia project.
// Copyright 2026-2026 DSP, inc.  All rights reserved.
// Authors:
//   imacat.yang@dsp.im (imacat), 2026/03/22

import { test, expect } from "@playwright/test";
import { loginWithMSW } from "../helpers";

test.describe("Discover page navigation tabs", () => {
  test.beforeEach(async ({ page, context }) => {
    await loginWithMSW(context);
    await page.goto("/files");
    await expect(page.getByText("sample-process.xes").first()).toBeVisible();
  });

  test("Double-clicking a log file enters the MAP page.", async ({
    page,
  }) => {
    await page
      .locator("td.fileName", { hasText: "sample-process.xes" })
      .dblclick();
    await expect(page).toHaveURL(/map/);
    // MAP tab should exist in the navbar
    await expect(
      page.locator(".nav-item", { hasText: "MAP" }),
    ).toBeVisible();
  });

  test("Clicking CONFORMANCE tab switches active page.", async ({
    page,
  }) => {
    await page
      .locator("td.fileName", { hasText: "sample-process.xes" })
      .dblclick();
    await expect(page).toHaveURL(/map/);
    await page.locator(".nav-item", { hasText: "CONFORMANCE" }).click();
    await expect(page).toHaveURL(/conformance/);
    await expect(
      page.locator(".nav-item", { hasText: "CONFORMANCE" }),
    ).toHaveClass(/active/);
  });

  test("Clicking PERFORMANCE tab switches active page.", async ({
    page,
  }) => {
    await page
      .locator("td.fileName", { hasText: "sample-process.xes" })
      .dblclick();
    await expect(page).toHaveURL(/map/);
    await page.locator(".nav-item", { hasText: "PERFORMANCE" }).click();
    await expect(page).toHaveURL(/performance/);
    await expect(
      page.locator(".nav-item", { hasText: "PERFORMANCE" }),
    ).toHaveClass(/active/);
  });
});
