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

test('Confirm usage of test API', async ({ page }, testInfo) => {
  // Load account view
  await page.goto('./account');
  await page.getByRole('heading', { name: 'Advanced' }).click();

  const webServer = testInfo.config.webServer;
  const endorserWords = webServer?.command.split(' ');
  const ENDORSER_ENV_NAME = 'VITE_DEFAULT_ENDORSER_API_SERVER';
  const endorserTerm = endorserWords?.find(word => word.startsWith(ENDORSER_ENV_NAME + '='));
  const endorserServer = endorserTerm?.substring(ENDORSER_ENV_NAME.length + 1) || 'https://test-api.endorser.ch';
  await expect(page.getByRole('textbox').nth(1)).toHaveValue(endorserServer);
});