// 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("Delete an Account", () => {
  test.beforeEach(async ({ page, context }) => {
    await loginWithMSW(context);
    await page.goto("/account-admin");
    await expect(page.getByText("Test Admin").first()).toBeVisible();
  });

  test("Delete button opens confirmation modal and deletes on confirm.", async ({
    page,
  }) => {
    await page.locator("img.delete-account").first().click();
    await expect(
      page.getByText("ARE YOU SURE TO DELETE"),
    ).toBeVisible();
    await page.locator("#sure_to_delete_acct_btn").click();
    await expect(page.getByText("Account deleted")).toBeVisible();
  });

  test("Cancel button closes the delete confirmation modal.", async ({
    page,
  }) => {
    await page.locator("img.delete-account").first().click();
    await expect(
      page.getByText("ARE YOU SURE TO DELETE"),
    ).toBeVisible();
    await page.locator("#calcel_delete_acct_btn").click();
    await expect(
      page.getByText("ARE YOU SURE TO DELETE"),
    ).not.toBeVisible();
  });
});
