import { TotalsSummarySection } from '@/manager/modules/ui/totals-summary/components/TotalsSummarySection';
import { TotalsSummary } from '@/manager/modules/ui/totals-summary/totals-summary-types';
import { expectSingleLocatorToHaveText } from '@/manager/shared/utils/expect-utils';
import { formatCurrency } from '@/shared/utils/formatters';
import { expect } from '@playwright/test';

export async function verifyTotalsSummarySection(
  section: TotalsSummarySection,
  data: TotalsSummary,
  currency: string
): Promise<void> {
  await expectSingleLocatorToHaveText(section.totalExclVatValue, formatCurrency(data.totalExclVat, currency));

  if (data.totalDiscount) {
    await expectSingleLocatorToHaveText(section.discountValue, `-${formatCurrency(data.totalDiscount, currency)}`);
  } else {
    await expect(section.discountValue).toBeHidden();
  }

  await expectSingleLocatorToHaveText(section.vatValue, formatCurrency(data.totalVat, currency));
  await expectSingleLocatorToHaveText(section.totalInclVatValue, formatCurrency(data.totalInclVat, currency));
}
