import { test, expect } from '@playwright/test';

test('Check usage limits', async ({ page }) => {
  // Check without ID first
  await page.goto('./account');
  await expect(page.locator('div.bg-slate-100.rounded-md').filter({ hasText: 'Usage Limits' })).toBeHidden();

  // Create new ID using seed phrase "island fever beef…"
  await page.goto('./start');
  await page.getByText('You have a seed').click();
  await page.getByPlaceholder('Seed Phrase').fill('island fever beef wine urban aim vacant quit afford total poem flame service calm better adult neither color gaze forum month sister imitate excite');
  await page.getByRole('button', { name: 'Import' }).click();

  // Set name
  await page.getByRole('link', { name: 'Set Your Name' }).click();
  await page.getByPlaceholder('Name').fill('User One');
  await page.getByRole('button', { name: 'Save Changes' }).click();

  // Check DID
  await expect(page.getByRole('code')).toContainText('did:ethr:0x111d15564f824D56C7a07b913aA7aDd03382aA39');

  // Verify that "Usage Limits" section is visible
  await expect(page.locator('#sectionUsageLimits')).toBeVisible();
  await expect(page.getByText('Your claims counter resets')).toBeVisible();
  await expect(page.getByText('Your registration counter resets')).toBeVisible();
  await expect(page.getByText('Your image counter resets')).toBeVisible();
  await expect(page.getByRole('button', { name: 'Recheck Limits' })).toBeVisible();
});