import { expect, gotoWorkbench, test } from "../fixtures/test";
import { selectors } from "../fixtures/selectors";

test.use({ viewport: { width: 390, height: 844 } });

test("mobile Workbench exposes visible session management actions", async ({ page }) => {
  await gotoWorkbench(page);
  const create = page.locator(selectors.sessionCreate);
  await expect(create).toBeVisible();
  await expect(page.locator(selectors.sessionCopy)).toBeVisible();
  await expect(page.locator(selectors.sessionDelete)).toBeVisible();
  await expect(page.locator(selectors.sessionCopy)).toBeEnabled();
  await expect(page.locator(selectors.sessionDelete)).toBeEnabled();
  const box = await create.boundingBox();
  expect(box?.width ?? 0).toBeGreaterThan(32);
  expect(box?.height ?? 0).toBeGreaterThan(24);
  await page.locator(selectors.sessionCopy).click();
  await create.click();
  await expect(page.locator('.session-tab[data-active="true"]')).toHaveAttribute("data-session-id", /^ses_/u);
  await page.locator(selectors.sessionDelete).click();
  await expect(page.locator(selectors.sessionTabs)).not.toContainText("没有 session");
});
