import type { Page } from "@playwright/test"

export async function focusLastBlockAtEnd(page: Page) {
  const blockIds = await page.evaluate(() =>
    window.__testUtils__?.getBlockIds(),
  )
  const lastId = blockIds?.[blockIds?.length - 1]
  await page.evaluate(
    (bid: string) => window.__testUtils__?.focusAtEnd(bid),
    lastId,
  )
}
