From 02a8367d167a699aad5b27ee76e990b859a022eb Mon Sep 17 00:00:00 2001 From: Gregor Vostrak Date: Fri, 9 May 2025 18:34:23 +0200 Subject: [PATCH] change e2e tests to use organization default values for money formatting --- e2e/organization.spec.ts | 6 ++++-- e2e/project-members.spec.ts | 11 +++-------- e2e/projects.spec.ts | 10 ++-------- e2e/utils/money.ts | 17 +++++++++++++++++ 4 files changed, 26 insertions(+), 18 deletions(-) create mode 100644 e2e/utils/money.ts diff --git a/e2e/organization.spec.ts b/e2e/organization.spec.ts index 67db4220..7454bbcf 100644 --- a/e2e/organization.spec.ts +++ b/e2e/organization.spec.ts @@ -27,9 +27,11 @@ test('test that organization billable rate can be updated with all existing time .getByLabel('Organization Billable Rate') .fill(newBillableRate.toString()); await page - .locator('button') - .filter({ hasText: /^Save$/ }) + .locator('form') + .filter({ hasText: 'Organization Billable' }) + .getByRole('button') .click(); + await Promise.all([ page .getByRole('button', { name: 'Yes, update existing time entries' }) diff --git a/e2e/project-members.spec.ts b/e2e/project-members.spec.ts index b537905b..66434eab 100644 --- a/e2e/project-members.spec.ts +++ b/e2e/project-members.spec.ts @@ -1,8 +1,9 @@ import { expect, Page } from '@playwright/test'; import { PLAYWRIGHT_BASE_URL } from '../playwright/config'; import { test } from '../playwright/fixtures'; -import { formatCents, getOrganizationCurrencySymbol } from '../resources/js/packages/ui/src/utils/money'; +import { formatCentsWithOrganizationDefaults } from './utils/money'; import type { CurrencyFormat } from '../resources/js/packages/ui/src/utils/money'; +import { NumberFormat } from '@/packages/ui/src/utils/number'; async function goToProjectsOverview(page: Page) { await page.goto(PLAYWRIGHT_BASE_URL + '/projects'); @@ -62,12 +63,6 @@ test('test that updating project member billable rate works for existing time en page .getByRole('row') .first() - .getByText(formatCents( - newBillableRate * 100, - 'EUR', - 'symbol-before' as CurrencyFormat, - '€', - 'space-point' - )) + .getByText(formatCentsWithOrganizationDefaults(newBillableRate * 100)) ).toBeVisible(); }); diff --git a/e2e/projects.spec.ts b/e2e/projects.spec.ts index ea855190..156d66e6 100644 --- a/e2e/projects.spec.ts +++ b/e2e/projects.spec.ts @@ -1,7 +1,7 @@ import { expect, Page } from '@playwright/test'; import { PLAYWRIGHT_BASE_URL } from '../playwright/config'; import { test } from '../playwright/fixtures'; -import { formatCents, getOrganizationCurrencySymbol } from '../resources/js/packages/ui/src/utils/money'; +import { formatCentsWithOrganizationDefaults } from './utils/money'; import type { CurrencyFormat } from '../resources/js/packages/ui/src/utils/money'; async function goToProjectsOverview(page: Page) { @@ -132,13 +132,7 @@ test('test that updating billable rate works with existing time entries', async page .getByRole('row') .first() - .getByText(formatCents( - newBillableRate * 100, - 'EUR', - 'symbol-before' as CurrencyFormat, - '€', - 'space-point' - )) + .getByText(formatCentsWithOrganizationDefaults(newBillableRate * 100)) ).toBeVisible(); }); diff --git a/e2e/utils/money.ts b/e2e/utils/money.ts new file mode 100644 index 00000000..34bf83dd --- /dev/null +++ b/e2e/utils/money.ts @@ -0,0 +1,17 @@ +import { formatCents } from '../../resources/js/packages/ui/src/utils/money'; +import type { CurrencyFormat } from '../../resources/js/packages/ui/src/utils/money'; +import { NumberFormat } from '../../resources/js/packages/ui/src/utils/number'; + +export function formatCentsWithOrganizationDefaults( + cents: number, + currencyCode: string = 'EUR', + currencySymbol: string = '€' +): string { + return formatCents( + cents, + currencyCode, + 'iso-code-after-with-space' as CurrencyFormat, + currencySymbol, + 'point-comma' as NumberFormat + ); +} \ No newline at end of file